From 8511b5842a3d887eb3c2baf6e2a59e6c03f4fb8d Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:43:21 +0100 Subject: [PATCH 01/35] Move into separate folder --- fdm-data/src/{fertilizers.test.ts => fertilizers/index.test.ts} | 2 +- fdm-data/src/{fertilizers.ts => fertilizers/index.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename fdm-data/src/{fertilizers.test.ts => fertilizers/index.test.ts} (94%) rename fdm-data/src/{fertilizers.ts => fertilizers/index.ts} (100%) diff --git a/fdm-data/src/fertilizers.test.ts b/fdm-data/src/fertilizers/index.test.ts similarity index 94% rename from fdm-data/src/fertilizers.test.ts rename to fdm-data/src/fertilizers/index.test.ts index f3915e07a..7d6a3e1c2 100644 --- a/fdm-data/src/fertilizers.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, beforeEach } from 'vitest' import { createFdmLocal, migrateFdmLocal, type FdmType } from 'fdm-core' -import { extendFertilizersCatalogue } from './fertilizers' +import { extendFertilizersCatalogue } from '.' describe('Fertilizers Data', () => { let fdm: FdmType diff --git a/fdm-data/src/fertilizers.ts b/fdm-data/src/fertilizers/index.ts similarity index 100% rename from fdm-data/src/fertilizers.ts rename to fdm-data/src/fertilizers/index.ts From e62c51dfc9ba767d9319df3f66f31372bd1026bd Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:37:55 +0100 Subject: [PATCH 02/35] Add srm as dataset --- .changeset/brave-shoes-build.md | 5 + fdm-data/src/fertilizers/datasets/srm.json | 1217 ++++++++++++++++++++ fdm-data/src/fertilizers/datasets/srm.ts | 14 + fdm-data/src/fertilizers/index.ts | 77 +- 4 files changed, 1292 insertions(+), 21 deletions(-) create mode 100644 .changeset/brave-shoes-build.md create mode 100644 fdm-data/src/fertilizers/datasets/srm.json create mode 100644 fdm-data/src/fertilizers/datasets/srm.ts diff --git a/.changeset/brave-shoes-build.md b/.changeset/brave-shoes-build.md new file mode 100644 index 000000000..5dc832926 --- /dev/null +++ b/.changeset/brave-shoes-build.md @@ -0,0 +1,5 @@ +--- +"fdm-data": minor +--- + +Add `srm` as option for `datasetName` at `extendFertilizersCatalogue` diff --git a/fdm-data/src/fertilizers/datasets/srm.json b/fdm-data/src/fertilizers/datasets/srm.json new file mode 100644 index 000000000..8bdd160a2 --- /dev/null +++ b/fdm-data/src/fertilizers/datasets/srm.json @@ -0,0 +1,1217 @@ +[ + { + "p_name_nl": "Agrotop-compost", + "p_dm": 679, + "p_density": 0.8, + "p_om": 231, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 173, + "p_eoc": 86.5, + "p_c_of": 115.5, + "p_c_fr": 0.5, + "p_n_rt": 9, + "p_n_if": 0, + "p_n_of": 9, + "p_n_wc": 0.1, + "p_p_rt": 4.5, + "p_k_rt": 7.6, + "p_mg_rt": 4, + "p_ca_rt": 7.5051, + "p_ne": 0.0687, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": true, + "p_id_catalogue": "0fa8fb5bc763ad9b", + "p_app_method_options": "incorporation||broadcasting", + "p_cn_of": 12.8333 + }, + { + "p_name_nl": "Betacal-carbo", + "p_dm": 680, + "p_density": 1, + "p_om": 90, + "p_a": 0.4959, + "p_hc": 0.1, + "p_eom": 2.8063, + "p_eoc": 1.4031, + "p_c_of": 45, + "p_c_fr": 0.5, + "p_n_rt": 3.3, + "p_n_if": 0.01, + "p_n_of": 3.29, + "p_n_wc": 0.5, + "p_p_rt": 11.5, + "p_k_rt": 1.1, + "p_mg_rt": 8, + "p_ca_rt": 180, + "p_ne": 1.7, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "46bd49cbb67bc7b7", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 13.6778 + }, + { + "p_name_nl": "Betacal-flow", + "p_dm": 470, + "p_density": 1, + "p_om": 60, + "p_a": 0.4959, + "p_hc": 0.1, + "p_eom": 1.8708, + "p_eoc": 0.9354, + "p_c_of": 30, + "p_c_fr": 0.5, + "p_n_rt": 2.3, + "p_n_if": 0.01, + "p_n_of": 2.29, + "p_n_wc": 0.5, + "p_p_rt": 8, + "p_k_rt": 0.8, + "p_mg_rt": 8, + "p_ca_rt": 200, + "p_ne": 2, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "30be8cdc92e64ef2", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 13.1004 + }, + { + "p_name_nl": "Betafer dunne fractie", + "p_dm": 75, + "p_density": 1, + "p_om": 40, + "p_a": 1.118, + "p_hc": 0.25, + "p_eom": 9.8669, + "p_eoc": 4.9335, + "p_c_of": 20, + "p_c_fr": 0.5, + "p_n_rt": 5.5, + "p_n_if": 0.1, + "p_n_of": 5.4, + "p_n_wc": 0.5, + "p_p_rt": 0.7, + "p_k_rt": 3.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0368, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "5e0f486cfce81f85", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 3.7037 + }, + { + "p_name_nl": "Betafert digistaat", + "p_dm": 65, + "p_density": 1, + "p_om": 40, + "p_a": 1.118, + "p_hc": 0.25, + "p_eom": 9.8669, + "p_eoc": 4.9335, + "p_c_of": 20, + "p_c_fr": 0.5, + "p_n_rt": 3.9, + "p_n_if": 0.1, + "p_n_of": 3.8, + "p_n_wc": 0.5, + "p_p_rt": 1.1, + "p_k_rt": 3.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0224, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "9e29a11332476286", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 5.2632 + }, + { + "p_name_nl": "Betafert dikke fractie", + "p_dm": 210, + "p_density": 1, + "p_om": 123, + "p_a": 1.118, + "p_hc": 0.25, + "p_eom": 30.3408, + "p_eoc": 15.1704, + "p_c_of": 61.5, + "p_c_fr": 0.5, + "p_n_rt": 10.6, + "p_n_if": 0.1, + "p_n_of": 10.5, + "p_n_wc": 0.5, + "p_p_rt": 5, + "p_k_rt": 5.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.093, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "898ad56320a5614c", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 5.8571 + }, + { + "p_name_nl": "Betcal-filter", + "p_dm": 580, + "p_density": 1, + "p_om": 80, + "p_a": 0.4959, + "p_hc": 0.1, + "p_eom": 2.4945, + "p_eoc": 1.2472, + "p_c_of": 40, + "p_c_fr": 0.5, + "p_n_rt": 2.8, + "p_n_if": 0.01, + "p_n_of": 2.79, + "p_n_wc": 0.5, + "p_p_rt": 9.8, + "p_k_rt": 0.9, + "p_mg_rt": 9, + "p_ca_rt": 230, + "p_ne": 2.2, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "ff4034f347f9c66e", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 14.3369 + }, + { + "p_name_nl": "Biophosphate", + "p_om": 689, + "p_a": 1.5405, + "p_hc": 0.3905, + "p_eom": 269.1431, + "p_eoc": 134.5715, + "p_c_of": 344.5, + "p_c_fr": 0.5, + "p_n_rt": 24.9, + "p_n_wc": 0.6, + "p_p_rt": 50.6, + "p_k_rt": 12.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "7e4ed7a0abb1c131", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Champost", + "p_dm": 336, + "p_density": 0.55, + "p_om": 211, + "p_a": 2.165, + "p_hc": 0.5, + "p_eom": 115.5149, + "p_eoc": 57.7575, + "p_c_of": 105.5, + "p_c_fr": 0.5, + "p_n_rt": 7.6, + "p_n_if": 0.4, + "p_n_of": 7.2, + "p_n_wc": 0.3, + "p_p_rt": 4.5, + "p_k_rt": 10, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.034, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "6224a5cc4a92865d", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 14.6528 + }, + { + "p_name_nl": "Dolokal", + "p_dm": 995, + "p_density": 1.2, + "p_om": 0, + "p_a": 0.0813, + "p_hc": 0, + "p_eom": 0, + "p_eoc": 0, + "p_c_of": 0, + "p_c_fr": 0.5, + "p_n_rt": 0, + "p_n_if": 0, + "p_n_of": 0, + "p_n_wc": 1, + "p_p_rt": 0, + "p_k_rt": 0, + "p_mg_rt": 50, + "p_ca_rt": 470, + "p_ne": 5.4, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "cb59142efac34dc0", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Fase 3 eind", + "p_om": 249, + "p_a": 0.9782, + "p_hc": 0.1937, + "p_eom": 48.3098, + "p_eoc": 24.1549, + "p_c_of": 124.5, + "p_c_fr": 0.5, + "p_n_rt": 8.3, + "p_n_wc": 0.3, + "p_p_rt": 4.7, + "p_k_rt": 13.9, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "34e762701f91a893", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "GFT compost", + "p_om": 184, + "p_a": 3.6613, + "p_hc": 0.7475, + "p_eom": 137.6952, + "p_eoc": 68.8476, + "p_c_of": 92, + "p_c_fr": 0.5, + "p_n_rt": 7.8, + "p_n_wc": 0.1, + "p_p_rt": 5.2, + "p_k_rt": 8.1, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": true, + "p_id_catalogue": "3efa9129f0eb2e62", + "p_app_method_options": "incorporation||broadcasting" + }, + { + "p_name_nl": "GFT-compost", + "p_dm": 696, + "p_density": 0.8, + "p_om": 242, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 179.5604, + "p_eoc": 80.8022, + "p_c_of": 108.9, + "p_c_fr": 0.45, + "p_n_rt": 12.8, + "p_n_if": 1.2, + "p_n_of": 11.6, + "p_n_wc": 0.1, + "p_p_rt": 6.3, + "p_k_rt": 11.3, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0854, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "76b0d22ed29eb2af", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 9.3879 + }, + { + "p_name_nl": "Groencompost", + "p_om": 135, + "p_a": 3.5013, + "p_hc": 0.7334, + "p_eom": 98.9037, + "p_eoc": 49.4518, + "p_c_of": 67.5, + "p_c_fr": 0.5, + "p_n_rt": 4.5, + "p_n_wc": 0.1, + "p_p_rt": 2.1, + "p_k_rt": 3.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": true, + "p_id_catalogue": "1ae98c5a34997eac", + "p_app_method_options": "incorporation||broadcasting" + }, + { + "p_name_nl": "Haarmeel", + "p_om": 962, + "p_a": 1.1453, + "p_hc": 0.2568, + "p_eom": 246.9526, + "p_eoc": 123.4763, + "p_c_of": 481, + "p_c_fr": 0.5, + "p_n_rt": 145.4, + "p_n_wc": 0.8, + "p_p_rt": 5.1, + "p_k_rt": 1.9, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "83f4f6f067ceecd4", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Humuskal", + "p_dm": 715, + "p_density": 0.8, + "p_om": 266, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 197.37, + "p_eoc": 98.685, + "p_c_of": 133, + "p_c_fr": 0.5, + "p_n_rt": 10, + "p_n_if": 0, + "p_n_of": 10, + "p_n_wc": 0.1, + "p_p_rt": 5.1, + "p_k_rt": 9.3, + "p_mg_rt": 1.9, + "p_ca_rt": 75.0509, + "p_ne": 0.7125, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": true, + "p_id_catalogue": "a9e19e6db97c49aa", + "p_app_method_options": "incorporation||broadcasting", + "p_cn_of": 13.3 + }, + { + "p_name_nl": "Ingekuild gras", + "p_om": 178, + "p_a": 1.2292, + "p_hc": 0.2873, + "p_eom": 51.1729, + "p_eoc": 25.5865, + "p_c_of": 89, + "p_c_fr": 0.5, + "p_n_rt": 3.4, + "p_n_wc": 0.5, + "p_p_rt": 1.5, + "p_k_rt": 4.4, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "8aa0baeaa367dbef", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "KAS", + "p_dm": 995, + "p_density": 0.97, + "p_om": 0, + "p_a": 0.0813, + "p_hc": 0, + "p_eom": 0, + "p_eoc": 0, + "p_c_of": 0, + "p_c_fr": 0.5, + "p_n_rt": 270, + "p_n_if": 270, + "p_n_of": 0, + "p_n_wc": 1, + "p_p_rt": 0, + "p_k_rt": 0, + "p_mg_rt": 0, + "p_ca_rt": 120, + "p_ne": -1.5, + "p_type_manure": false, + "p_type_artificial": true, + "p_type_compost": false, + "p_id_catalogue": "1d2e4f0b600af921", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Kerapro Slow release", + "p_om": 952, + "p_a": 1.2348, + "p_hc": 0.2893, + "p_eom": 275.5277, + "p_eoc": 137.7639, + "p_c_of": 476, + "p_c_fr": 0.5, + "p_n_rt": 136.3, + "p_n_wc": 0.8, + "p_p_rt": 6.4, + "p_k_rt": 1.9, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "56569b23583728e0", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Kerapro Son", + "p_om": 922, + "p_a": 1.1143, + "p_hc": 0.2453, + "p_eom": 226.0711, + "p_eoc": 113.0356, + "p_c_of": 461, + "p_c_fr": 0.5, + "p_n_rt": 134.5, + "p_n_wc": 0.8, + "p_p_rt": 6.3, + "p_k_rt": 1.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "62648ac045e9fff6", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Keratine mengsel", + "p_om": 938, + "p_a": 1.0405, + "p_hc": 0.2175, + "p_eom": 203.945, + "p_eoc": 101.9725, + "p_c_of": 469, + "p_c_fr": 0.5, + "p_n_rt": 143.5, + "p_n_wc": 0.8, + "p_p_rt": 5.7, + "p_k_rt": 3.4, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "1f616af7e94f3ec4", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Kippenmest, strooisel", + "p_dm": 713, + "p_density": 0.6, + "p_om": 359, + "p_a": 1.5752, + "p_hc": 0.36, + "p_eom": 143.9305, + "p_eoc": 71.9652, + "p_c_of": 179.5, + "p_c_fr": 0.5, + "p_n_rt": 28, + "p_n_if": 3.6, + "p_n_of": 24.4, + "p_n_wc": 0.495, + "p_p_rt": 25.6, + "p_k_rt": 20.8, + "p_mg_rt": 7.5, + "p_ca_rt": 18, + "p_ne": 0.058, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "db5cef16b5fd1be4", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 7.3566 + }, + { + "p_name_nl": "Laco-compost", + "p_dm": 759, + "p_density": 0.8, + "p_om": 256, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 189.9482, + "p_eoc": 94.9741, + "p_c_of": 128, + "p_c_fr": 0.5, + "p_n_rt": 8.8, + "p_n_if": 0, + "p_n_of": 8.8, + "p_n_wc": 0.1, + "p_p_rt": 4.5, + "p_k_rt": 8.9, + "p_mg_rt": 1.7, + "p_ca_rt": 75.0509, + "p_ne": 0.7217, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": true, + "p_id_catalogue": "35589ecec6988b94", + "p_app_method_options": "incorporation||broadcasting", + "p_cn_of": 14.5455 + }, + { + "p_name_nl": "Natte kalkslib", + "p_dm": 225, + "p_density": 1, + "p_om": 0, + "p_a": 0.0813, + "p_hc": 0, + "p_eom": 0, + "p_eoc": 0, + "p_c_of": 0, + "p_c_fr": 0.5, + "p_n_rt": 0, + "p_n_if": 0, + "p_n_of": 0, + "p_n_wc": 1, + "p_p_rt": 0, + "p_k_rt": 0, + "p_mg_rt": 1.7, + "p_ca_rt": 105, + "p_ne": 1.0738, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "7fe1088167f5b3b6", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Protamylasse", + "p_dm": 500, + "p_density": 1.3, + "p_om": 360, + "p_a": 0.4959, + "p_hc": 0.1, + "p_eom": 11.225, + "p_eoc": 5.0513, + "p_c_of": 162, + "p_c_fr": 0.45, + "p_n_rt": 30, + "p_n_if": 0, + "p_n_of": 20, + "p_n_wc": 0.5, + "p_p_rt": 13, + "p_k_rt": 90, + "p_mg_rt": 6.6, + "p_ca_rt": 0, + "p_ne": 0.2804, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "9eef309c5a21cac2", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 8.1 + }, + { + "p_name_nl": "Runderdrijfmest", + "p_dm": 85, + "p_density": 1.005, + "p_om": 64, + "p_a": 3.1799, + "p_hc": 0.7, + "p_eom": 44.8643, + "p_eoc": 22.4321, + "p_c_of": 32, + "p_c_fr": 0.5, + "p_n_rt": 4.1, + "p_n_if": 2, + "p_n_of": 2.1, + "p_n_wc": 0.5659, + "p_p_rt": 1.5, + "p_k_rt": 5.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0122, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "9d855a14df2045c2", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 15.2381 + }, + { + "p_name_nl": "Rundvee digestaat dik", + "p_dm": 225, + "p_density": 1, + "p_om": 193, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 143.2031, + "p_eoc": 71.6016, + "p_c_of": 96.5, + "p_c_fr": 0.5, + "p_n_rt": 7.2, + "p_n_if": 3.7, + "p_n_of": 3.5, + "p_n_wc": 0.35, + "p_p_rt": 6.4, + "p_k_rt": 5.3, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0658, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "0eac33098aed5a8c", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 27.5714 + }, + { + "p_name_nl": "Rundvee digestaat dun", + "p_dm": 18, + "p_density": 1, + "p_om": 8, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 5.9359, + "p_eoc": 2.9679, + "p_c_of": 4, + "p_c_fr": 0.5, + "p_n_rt": 3.9, + "p_n_if": 3.2, + "p_n_of": 0.7, + "p_n_wc": 0.8, + "p_p_rt": 0.7, + "p_k_rt": 5.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.007, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "e527c65c26e92c6b", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 5.7143 + }, + { + "p_name_nl": "Rundvee digestaat mc", + "p_dm": 113, + "p_density": 1, + "p_om": 113, + "p_a": 3.5969, + "p_hc": 0.75, + "p_eom": 83.8443, + "p_eoc": 41.9222, + "p_c_of": 56.5, + "p_c_fr": 0.5, + "p_n_rt": 11, + "p_n_if": 10.5, + "p_n_of": 0.5, + "p_n_wc": 0.9, + "p_p_rt": 0.6, + "p_k_rt": 15.7, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0182, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "50a1f75317b0833a", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 113 + }, + { + "p_name_nl": "Rundvee dikke fractie", + "p_dm": 198, + "p_density": 1, + "p_om": 163, + "p_a": 3.1799, + "p_hc": 0.7, + "p_eom": 114.2636, + "p_eoc": 57.1318, + "p_c_of": 81.5, + "p_c_fr": 0.5, + "p_n_rt": 4.5, + "p_n_if": 1.6, + "p_n_of": 2.9, + "p_n_wc": 0.35, + "p_p_rt": 2.3, + "p_k_rt": 5.1, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0236, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "9d3d0b2ecabb8727", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 28.1034 + }, + { + "p_name_nl": "Rundvee dunne fractie", + "p_dm": 48, + "p_density": 1, + "p_om": 31, + "p_a": 3.1799, + "p_hc": 0.7, + "p_eom": 21.7311, + "p_eoc": 10.8656, + "p_c_of": 15.5, + "p_c_fr": 0.5, + "p_n_rt": 2.7, + "p_n_if": 1.4, + "p_n_of": 1.3, + "p_n_wc": 0.8, + "p_p_rt": 1.2, + "p_k_rt": 5.9, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0.0036, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "433104c1442b62c2", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 11.9231 + }, + { + "p_name_nl": "Rundvee gier", + "p_dm": 25, + "p_density": 1.03, + "p_om": 10, + "p_a": 3.1799, + "p_hc": 0.7, + "p_eom": 7.01, + "p_eoc": 3.505, + "p_c_of": 5, + "p_c_fr": 0.5, + "p_n_rt": 4, + "p_n_if": 3.8, + "p_n_of": 0.2, + "p_n_wc": 0.677, + "p_p_rt": 0.2, + "p_k_rt": 8, + "p_mg_rt": 0.2, + "p_ca_rt": 0, + "p_ne": 0.019, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "68af2b5484d8ac21", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 25 + }, + { + "p_name_nl": "Rundvee vaste mest", + "p_dm": 194, + "p_density": 0.9, + "p_om": 153, + "p_a": 3.1799, + "p_hc": 0.7, + "p_eom": 107.2536, + "p_eoc": 53.6268, + "p_c_of": 76.5, + "p_c_fr": 0.5, + "p_n_rt": 5.3, + "p_n_if": 0.9, + "p_n_of": 4.4, + "p_n_wc": 0.3019, + "p_p_rt": 2.8, + "p_k_rt": 6.1, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0276, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "d05ee30018d8b9c5", + "p_app_method_options": "incorporation||broadcasting", + "p_cn_of": 17.3864 + }, + { + "p_name_nl": "TSP", + "p_dm": 995, + "p_density": 1, + "p_om": 0, + "p_a": 0.0813, + "p_hc": 0, + "p_eom": 0, + "p_eoc": 0, + "p_c_of": 0, + "p_c_fr": 0.5, + "p_n_rt": 0, + "p_n_if": 0, + "p_n_of": 0, + "p_n_wc": 1, + "p_p_rt": 450, + "p_k_rt": 0, + "p_mg_rt": 0, + "p_ca_rt": 240, + "p_ne": 0.285, + "p_type_manure": false, + "p_type_artificial": true, + "p_type_compost": false, + "p_id_catalogue": "150a6c681a7c7da0", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Varkens dikke fractie", + "p_dm": 272, + "p_density": 1, + "p_om": 215, + "p_a": 1.4503, + "p_hc": 0.33, + "p_eom": 77.9062, + "p_eoc": 38.9531, + "p_c_of": 107.5, + "p_c_fr": 0.5, + "p_n_rt": 10.6, + "p_n_if": 4, + "p_n_of": 6.6, + "p_n_wc": 0.55, + "p_p_rt": 15.2, + "p_k_rt": 4.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.138, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "bebf7c93d0a5ac01", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 16.2879 + }, + { + "p_name_nl": "Varkens dunne fractie", + "p_dm": 27, + "p_density": 1, + "p_om": 11, + "p_a": 1.4503, + "p_hc": 0.33, + "p_eom": 3.9859, + "p_eoc": 1.9929, + "p_c_of": 5.5, + "p_c_fr": 0.5, + "p_n_rt": 4.2, + "p_n_if": 3.6, + "p_n_of": 0.6, + "p_n_wc": 0.8, + "p_p_rt": 0.7, + "p_k_rt": 4.7, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0166, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "7e0ca9e00a1e04c3", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 9.1667 + }, + { + "p_name_nl": "Varkens gier", + "p_dm": 20, + "p_density": 1.01, + "p_om": 5, + "p_a": 1.4503, + "p_hc": 0.33, + "p_eom": 1.8118, + "p_eoc": 0.9059, + "p_c_of": 2.5, + "p_c_fr": 0.5, + "p_n_rt": 6.5, + "p_n_if": 6.1, + "p_n_of": 0.4, + "p_n_wc": 0.6717, + "p_p_rt": 0.9, + "p_k_rt": 4.5, + "p_mg_rt": 0.2, + "p_ca_rt": 0, + "p_ne": -0.0298, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "82293b5baa991470", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 6.25 + }, + { + "p_name_nl": "Varkens mineralenconcentraat", + "p_dm": 32, + "p_density": 1, + "p_om": 13, + "p_a": 1.4503, + "p_hc": 0.33, + "p_eom": 4.7106, + "p_eoc": 2.3553, + "p_c_of": 6.5, + "p_c_fr": 0.5, + "p_n_rt": 6.7, + "p_n_if": 6, + "p_n_of": 0.7, + "p_n_wc": 0.9, + "p_p_rt": 0.4, + "p_k_rt": 8.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0176, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "982cffd52eb5a270", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 9.2857 + }, + { + "p_name_nl": "Varkensdrijfmest", + "p_dm": 93, + "p_density": 1.04, + "p_om": 43, + "p_a": 1.4503, + "p_hc": 0.33, + "p_eom": 15.5812, + "p_eoc": 7.7906, + "p_c_of": 21.5, + "p_c_fr": 0.5, + "p_n_rt": 7.1, + "p_n_if": 4.6, + "p_n_of": 2.5, + "p_n_wc": 0.8268, + "p_p_rt": 4.6, + "p_k_rt": 5.8, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0546, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "a68418f8d14e112b", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 8.6 + }, + { + "p_name_nl": "Verenmeel", + "p_dm": 925, + "p_density": 1, + "p_om": 740, + "p_a": 0.9106, + "p_hc": 0.2, + "p_eom": 124.2244, + "p_eoc": 62.1122, + "p_c_of": 370, + "p_c_fr": 0.5, + "p_n_rt": 120, + "p_n_if": 3.6, + "p_n_of": 116.4, + "p_n_wc": 0.55, + "p_p_rt": 14, + "p_k_rt": 14, + "p_mg_rt": 2, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "2a6eb018e1ef35b7", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 3.1787 + }, + { + "p_name_nl": "Vinassekali", + "p_dm": 620, + "p_density": 1.35, + "p_om": 410, + "p_a": 0.4959, + "p_hc": 0.1, + "p_eom": 12.7841, + "p_eoc": 5.7528, + "p_c_of": 184.5, + "p_c_fr": 0.45, + "p_n_rt": 30, + "p_n_if": 0, + "p_n_of": 30, + "p_n_wc": 0.75, + "p_p_rt": 15, + "p_k_rt": 100, + "p_mg_rt": 15, + "p_ca_rt": 0, + "p_ne": 0.45, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "7b8dc7437321b2c0", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", + "p_cn_of": 6.15 + }, + { + "p_name_nl": "Vleeskuikens vaste mest", + "p_dm": 626, + "p_density": 0.605, + "p_om": 419, + "p_a": 1.5752, + "p_hc": 0.36, + "p_eom": 167.9857, + "p_eoc": 83.9928, + "p_c_of": 209.5, + "p_c_fr": 0.5, + "p_n_rt": 32.1, + "p_n_if": 8, + "p_n_of": 24.1, + "p_n_wc": 0.6123, + "p_p_rt": 16.8, + "p_k_rt": 20.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.2652, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "8eaafeff8a8bbffa", + "p_app_method_options": "incorporation||broadcasting", + "p_cn_of": 8.6929 + }, + { + "p_name_nl": "Vleesvarkens digestaat dik", + "p_dm": 290, + "p_density": 1, + "p_om": 22, + "p_a": 1.5752, + "p_hc": 0.36, + "p_eom": 8.8203, + "p_eoc": 4.4101, + "p_c_of": 11, + "p_c_fr": 0.5, + "p_n_rt": 11.2, + "p_n_if": 6, + "p_n_of": 5.3, + "p_n_wc": 0.55, + "p_p_rt": 17.3, + "p_k_rt": 5.1, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.1506, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "9386a2ed7eefef8b", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 2.0755 + }, + { + "p_name_nl": "Vleesvarkens digestaat dun", + "p_dm": 12, + "p_density": 1, + "p_om": 3, + "p_a": 1.5752, + "p_hc": 0.36, + "p_eom": 1.2028, + "p_eoc": 0.6014, + "p_c_of": 1.5, + "p_c_fr": 0.5, + "p_n_rt": 3.1, + "p_n_if": 2.9, + "p_n_of": 0.2, + "p_n_wc": 0.8, + "p_p_rt": 0.2, + "p_k_rt": 3.9, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.0084, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "4cbce919da49811c", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 7.5 + }, + { + "p_name_nl": "Vleesvarkens digestaat mc", + "p_dm": 29, + "p_density": 1, + "p_om": 11, + "p_a": 1.5752, + "p_hc": 0.36, + "p_eom": 4.4101, + "p_eoc": 2.2051, + "p_c_of": 5.5, + "p_c_fr": 0.5, + "p_n_rt": 6.4, + "p_n_if": 5.9, + "p_n_of": 0.5, + "p_n_wc": 0.9, + "p_p_rt": 0.5, + "p_k_rt": 8.5, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": -0.015, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "f6bc9a9dac9d5ded", + "p_app_method_options": "slotted coulter||injection||broadcasting", + "p_cn_of": 11 + }, + { + "p_name_nl": "Zaadmeel", + "p_om": 848, + "p_a": 2.1621, + "p_hc": 0.5469, + "p_eom": 463.9594, + "p_eoc": 231.9797, + "p_c_of": 424, + "p_c_fr": 0.5, + "p_n_rt": 46.8, + "p_n_wc": 0.5, + "p_p_rt": 20, + "p_k_rt": 8.2, + "p_mg_rt": 0, + "p_ca_rt": 0, + "p_ne": 0, + "p_type_manure": false, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "c12ca3a82c6c8b68", + "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" + }, + { + "p_name_nl": "Zeugen gier", + "p_dm": 10, + "p_density": 1.02, + "p_om": 10, + "p_a": 1.4919, + "p_hc": 0.34, + "p_eom": 3.7552, + "p_eoc": 1.8776, + "p_c_of": 5, + "p_c_fr": 0.5, + "p_n_rt": 2, + "p_n_if": 1.9, + "p_n_of": 0.1, + "p_n_wc": 0.677, + "p_p_rt": 0.9, + "p_k_rt": 2.5, + "p_mg_rt": 0.2, + "p_ca_rt": 0, + "p_ne": -0.004, + "p_type_manure": true, + "p_type_artificial": false, + "p_type_compost": false, + "p_id_catalogue": "bfbb3200362c312a", + "p_app_method_options": "slotted coulter||injection", + "p_cn_of": 50 + } +] \ No newline at end of file diff --git a/fdm-data/src/fertilizers/datasets/srm.ts b/fdm-data/src/fertilizers/datasets/srm.ts new file mode 100644 index 000000000..bc24be140 --- /dev/null +++ b/fdm-data/src/fertilizers/datasets/srm.ts @@ -0,0 +1,14 @@ +import srm from './srm.json' +import { fdmSchema } from 'fdm-core' + +export function getDatasetSrm(): fdmSchema.fertilizersCatalogueTypeInsert[] { + + const srmDataset = srm.map(product => { + return { + p_source: 'srm', + ...product + } + }) + + return srmDataset +} diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 8145abfcc..13483aa17 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -1,32 +1,67 @@ import { addFertilizerToCatalogue, type FdmType, fdmSchema } from "fdm-core"; +import { getDatasetSrm } from "./datasets/srm"; export async function extendFertilizersCatalogue(fdm: FdmType, datasetName: string): Promise { - + let dataset: fdmSchema.fertilizersCatalogueTypeInsert[] = [] - if (datasetName == 'test') { - dataset = [ - { - p_id_catalogue: '001', - p_source: 'test', - p_name_nl: 'KAS', - p_description: 'A test product for KAS', - p_n_rt: 27 - } - ] + if (datasetName == 'srm') { + dataset = getDatasetSrm() } if (dataset.length === 0) { throw new Error(`Dataset ${datasetName} is not recognized`) - } else { - dataset.map(async product => { - - await addFertilizerToCatalogue({ - fdm: fdm, - p_name_nl: product.p_name_nl, - p_description: product.p_description, - p_n_rt: product.p_n_rt - }) - }) } + // Add fertilizers to catalogue + dataset.map(async product => { + + await addFertilizerToCatalogue({ + fdm: fdm, + p_id_catalogue: product.p_id_catalogue, + p_source: product.p_source, + p_name_nl: product.p_name_nl, + p_name_en: product.p_name_en, + p_description: product.p_description, + properties: { + p_dm: product.p_dm, + p_om: product.p_om, + p_a: product.p_a, + p_hc: product.p_hc, + p_eom: product.p_eom, + p_eoc: product.p_eoc, + p_c_rt: product.p_c_rt, + p_c_of: product.p_c_of, + p_c_if: product.p_c_if, + p_c_fr: product.p_c_fr, + p_cn_of: product.p_cn_of, + p_n_rt: product.p_n_rt, + p_n_if: product.p_n_if, + p_n_of: product.p_n_of, + p_n_wc: product.p_n_wc, + p_p_rt: product.p_p_rt, + p_k_rt: product.p_k_rt, + p_mg_rt: product.p_mg_rt, + p_ca_rt: product.p_ca_rt, + p_ne: product.p_ne, + p_s_rt: product.p_s_rt, + p_s_wc: product.p_s_wc, + p_cu_rt: product.p_cu_rt, + p_zn_rt: product.p_zn_rt, + p_na_rt: product.p_na_rt, + p_si_rt: product.p_si_rt, + p_b_rt: product.p_b_rt, + p_mn_rt: product.p_mn_rt, + p_ni_rt: product.p_ni_rt, + p_fe_rt: product.p_fe_rt, + p_mo_rt: product.p_mo_rt, + p_co_rt: product.p_co_rt, + p_as_rt: product.p_as_rt, + p_cd_rt: product.p_cd_rt, + pr_cr_rt: product.p_cr_rt, + p_cr_vi: product.p_cr_vi, + p_pb_rt: product.p_pb_rt, + p_hg_rt: product.p_hg_rt + } + }) + }) } \ No newline at end of file From 0a9ddb7de2eba7a637928ac9bdcb8317b5ba2d50 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:41:38 +0100 Subject: [PATCH 03/35] Update unit test for srm --- fdm-data/src/fertilizers/index.test.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fdm-data/src/fertilizers/index.test.ts b/fdm-data/src/fertilizers/index.test.ts index 7d6a3e1c2..4f81617b7 100644 --- a/fdm-data/src/fertilizers/index.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -14,13 +14,10 @@ describe('Fertilizers Data', () => { await expect(extendFertilizersCatalogue(fdm, 'not-existing-dataset')).rejects.toThrowError('Dataset not-existing-dataset is not recognized') }) - it('should extend fertilizers catalogue with test dataset', async () => { - await extendFertilizersCatalogue(fdm, 'test') + it('should extend fertilizers catalogue with srm dataset', async () => { + await extendFertilizersCatalogue(fdm, 'srm') const result = await fdm.select().from(fdm.schema.fertilizersCatalogue) - expect(result.length).toBe(1) - expect(result[0].p_name_nl).toBe('KAS') - expect(result[0].p_description).toBe('A test product for KAS') - expect(result[0].p_n_rt).toBe(27) + expect(result.length).toBeGreaterThan(0) }) -}) \ No newline at end of file +}) From b0c497866bc2c8ab3b046667db91ec83a9bf8e7a Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:11:45 +0100 Subject: [PATCH 04/35] Use consistent naming for a set of fertilizer --- .../{datasets => catalogues}/srm.json | 0 fdm-data/src/fertilizers/catalogues/srm.ts | 14 ++ fdm-data/src/fertilizers/datasets/srm.ts | 14 -- fdm-data/src/fertilizers/index.test.ts | 2 +- fdm-data/src/fertilizers/index.ts | 125 ++++++++++-------- 5 files changed, 83 insertions(+), 72 deletions(-) rename fdm-data/src/fertilizers/{datasets => catalogues}/srm.json (100%) create mode 100644 fdm-data/src/fertilizers/catalogues/srm.ts delete mode 100644 fdm-data/src/fertilizers/datasets/srm.ts diff --git a/fdm-data/src/fertilizers/datasets/srm.json b/fdm-data/src/fertilizers/catalogues/srm.json similarity index 100% rename from fdm-data/src/fertilizers/datasets/srm.json rename to fdm-data/src/fertilizers/catalogues/srm.json diff --git a/fdm-data/src/fertilizers/catalogues/srm.ts b/fdm-data/src/fertilizers/catalogues/srm.ts new file mode 100644 index 000000000..53ee5baf3 --- /dev/null +++ b/fdm-data/src/fertilizers/catalogues/srm.ts @@ -0,0 +1,14 @@ +import srm from './srm.json' +import { fdmSchema } from 'fdm-core' + +export function getCatalogueSrm(): fdmSchema.fertilizersCatalogueTypeInsert[] { + + const catalogueSrm = srm.map(fertilizer => { + return { + p_source: 'srm', + ...fertilizer + } + }) + + return catalogueSrm +} diff --git a/fdm-data/src/fertilizers/datasets/srm.ts b/fdm-data/src/fertilizers/datasets/srm.ts deleted file mode 100644 index bc24be140..000000000 --- a/fdm-data/src/fertilizers/datasets/srm.ts +++ /dev/null @@ -1,14 +0,0 @@ -import srm from './srm.json' -import { fdmSchema } from 'fdm-core' - -export function getDatasetSrm(): fdmSchema.fertilizersCatalogueTypeInsert[] { - - const srmDataset = srm.map(product => { - return { - p_source: 'srm', - ...product - } - }) - - return srmDataset -} diff --git a/fdm-data/src/fertilizers/index.test.ts b/fdm-data/src/fertilizers/index.test.ts index 4f81617b7..50456a1ce 100644 --- a/fdm-data/src/fertilizers/index.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -11,7 +11,7 @@ describe('Fertilizers Data', () => { }) it('should throw error if dataset is not recognized', async () => { - await expect(extendFertilizersCatalogue(fdm, 'not-existing-dataset')).rejects.toThrowError('Dataset not-existing-dataset is not recognized') + await expect(extendFertilizersCatalogue(fdm, 'not-existing-dataset')).rejects.toThrowError('catalogue not-existing-dataset is not recognized') }) it('should extend fertilizers catalogue with srm dataset', async () => { diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 13483aa17..3992ff76c 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -1,67 +1,78 @@ -import { addFertilizerToCatalogue, type FdmType, fdmSchema } from "fdm-core"; -import { getDatasetSrm } from "./datasets/srm"; +import { addFertilizerToCatalogue, getFertilizersFromCatalogue, type FdmType, fdmSchema } from "fdm-core"; +import { getCatalogueSrm } from "./catalogues/srm"; -export async function extendFertilizersCatalogue(fdm: FdmType, datasetName: string): Promise { +export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: string): Promise { - let dataset: fdmSchema.fertilizersCatalogueTypeInsert[] = [] - if (datasetName == 'srm') { - dataset = getDatasetSrm() + // Get the specified catalogue + let catalogue: fdmSchema.fertilizersCatalogueTypeInsert[] = [] + if (catalogueName == 'srm') { + catalogue = getCatalogueSrm() } - if (dataset.length === 0) { - throw new Error(`Dataset ${datasetName} is not recognized`) + // Check if specified catalogue exist + if (catalogue.length === 0) { + throw new Error(`catalogue ${catalogueName} is not recognized`) } + // Get list of fertilizers from catalogue + const fertilizersCatalogue = await getFertilizersFromCatalogue(fdm) + // Add fertilizers to catalogue - dataset.map(async product => { + catalogue.map(async fertilizer => { + + // Check if fertilizer is already present in catalogue + const fertilizerInCatalogue = fertilizersCatalogue.find((x: fdmSchema.fertilizersCatalogueTypeSelect): any => x.p_id_catalogue === fertilizer.p_id_catalogue) - await addFertilizerToCatalogue({ - fdm: fdm, - p_id_catalogue: product.p_id_catalogue, - p_source: product.p_source, - p_name_nl: product.p_name_nl, - p_name_en: product.p_name_en, - p_description: product.p_description, - properties: { - p_dm: product.p_dm, - p_om: product.p_om, - p_a: product.p_a, - p_hc: product.p_hc, - p_eom: product.p_eom, - p_eoc: product.p_eoc, - p_c_rt: product.p_c_rt, - p_c_of: product.p_c_of, - p_c_if: product.p_c_if, - p_c_fr: product.p_c_fr, - p_cn_of: product.p_cn_of, - p_n_rt: product.p_n_rt, - p_n_if: product.p_n_if, - p_n_of: product.p_n_of, - p_n_wc: product.p_n_wc, - p_p_rt: product.p_p_rt, - p_k_rt: product.p_k_rt, - p_mg_rt: product.p_mg_rt, - p_ca_rt: product.p_ca_rt, - p_ne: product.p_ne, - p_s_rt: product.p_s_rt, - p_s_wc: product.p_s_wc, - p_cu_rt: product.p_cu_rt, - p_zn_rt: product.p_zn_rt, - p_na_rt: product.p_na_rt, - p_si_rt: product.p_si_rt, - p_b_rt: product.p_b_rt, - p_mn_rt: product.p_mn_rt, - p_ni_rt: product.p_ni_rt, - p_fe_rt: product.p_fe_rt, - p_mo_rt: product.p_mo_rt, - p_co_rt: product.p_co_rt, - p_as_rt: product.p_as_rt, - p_cd_rt: product.p_cd_rt, - pr_cr_rt: product.p_cr_rt, - p_cr_vi: product.p_cr_vi, - p_pb_rt: product.p_pb_rt, - p_hg_rt: product.p_hg_rt - } - }) + // If fertilizer is not present in catalogue, add it to fdm instance + if (fertilizerInCatalogue) { + await addFertilizerToCatalogue({ + fdm: fdm, + p_id_catalogue: fertilizer.p_id_catalogue, + p_source: fertilizer.p_source, + p_name_nl: fertilizer.p_name_nl, + p_name_en: fertilizer.p_name_en, + p_description: fertilizer.p_description, + properties: { + p_dm: fertilizer.p_dm, + p_om: fertilizer.p_om, + p_a: fertilizer.p_a, + p_hc: fertilizer.p_hc, + p_eom: fertilizer.p_eom, + p_eoc: fertilizer.p_eoc, + p_c_rt: fertilizer.p_c_rt, + p_c_of: fertilizer.p_c_of, + p_c_if: fertilizer.p_c_if, + p_c_fr: fertilizer.p_c_fr, + p_cn_of: fertilizer.p_cn_of, + p_n_rt: fertilizer.p_n_rt, + p_n_if: fertilizer.p_n_if, + p_n_of: fertilizer.p_n_of, + p_n_wc: fertilizer.p_n_wc, + p_p_rt: fertilizer.p_p_rt, + p_k_rt: fertilizer.p_k_rt, + p_mg_rt: fertilizer.p_mg_rt, + p_ca_rt: fertilizer.p_ca_rt, + p_ne: fertilizer.p_ne, + p_s_rt: fertilizer.p_s_rt, + p_s_wc: fertilizer.p_s_wc, + p_cu_rt: fertilizer.p_cu_rt, + p_zn_rt: fertilizer.p_zn_rt, + p_na_rt: fertilizer.p_na_rt, + p_si_rt: fertilizer.p_si_rt, + p_b_rt: fertilizer.p_b_rt, + p_mn_rt: fertilizer.p_mn_rt, + p_ni_rt: fertilizer.p_ni_rt, + p_fe_rt: fertilizer.p_fe_rt, + p_mo_rt: fertilizer.p_mo_rt, + p_co_rt: fertilizer.p_co_rt, + p_as_rt: fertilizer.p_as_rt, + p_cd_rt: fertilizer.p_cd_rt, + pr_cr_rt: fertilizer.p_cr_rt, + p_cr_vi: fertilizer.p_cr_vi, + p_pb_rt: fertilizer.p_pb_rt, + p_hg_rt: fertilizer.p_hg_rt + } + }) + } }) } \ No newline at end of file From ebee13204f7b9318714cb57800848ed74c212e8c Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:42:00 +0100 Subject: [PATCH 05/35] Add prerelease workflow for fdm-data --- .github/workflows/prerelease-fdm-data.yml | 65 +++++++++++++++++++++++ fdm-data/package.json | 30 +++++++++-- 2 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/prerelease-fdm-data.yml diff --git a/.github/workflows/prerelease-fdm-data.yml b/.github/workflows/prerelease-fdm-data.yml new file mode 100644 index 000000000..65c50a1e1 --- /dev/null +++ b/.github/workflows/prerelease-fdm-data.yml @@ -0,0 +1,65 @@ +name: Prerelease fdm-data to GitHub Packages + +defaults: + run: + working-directory: ./fdm-data + +on: + pull_request: + paths: + - 'fdm-data/**' + branches: + - main + push: + paths: + - 'fdm-data/**' + branches: + - main + +jobs: + prerelease: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - name: Cache turbo build setup + uses: actions/cache@v4 + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo- + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + registry-url: 'https://npm.pkg.github.com' + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile --filter fdm-data + - name: get-npm-version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + with: + path: fdm-data + - name: Create a prerelease version from PR + if: ${{ github.ref != 'refs/heads/main' }} + run: pnpm version ${{ steps.package-version.outputs.current-version}}-${{ github.head_ref }}.${{ github.sha }} --no-git-tag-version + - name: Create a prerelease version from main + if: ${{ github.ref == 'refs/heads/main' }} + run: pnpm version ${{ steps.package-version.outputs.current-version}}.${{ github.sha }} --no-git-tag-version + # - name: Run tests + # run: pnpm test + - name: Publish the package + run: pnpm publish --tag ${{ github.head_ref }} --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/fdm-data/package.json b/fdm-data/package.json index d1464affb..e8d02a92b 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -1,10 +1,14 @@ { - "name": "fdm-data", - "private": true, + "name": "@svenvw/fdm-data", + "private": false, "version": "0.1.1", "description": "Extend Farm Data Model with catalogue data", "license": "MIT", "homepage": "https://github.com/SvenVw/fdm", + "repository": { + "type": "git", + "url": "git+https://github.com/SvenVw/fdm.git" + }, "bugs": "https://github.com/SvenVw/fdm/issues/new", "author": { "name": "Sven Verweij", @@ -54,5 +58,25 @@ "dependencies": { "fdm-core": "workspace:*" }, - "packageManager": "pnpm@9.12.2" + "packageManager": "pnpm@9.12.2", + "publishConfig": { + "registry": "https://npm.pkg.github.com" + }, + "pnpm": { + "packageExtensions": { + "vite-plugin-dts": { + "dependenciesMeta": { + "@volar/typescript": { + "optional": true + }, + "vue-tsc": { + "optional": true + }, + "@vue/language-core": { + "optional": true + } + } + } + } + } } \ No newline at end of file From 08ac0edb852e50b5ba1579bcd27a564848d81a51 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:47:23 +0100 Subject: [PATCH 06/35] Add to changeset --- .changeset/tidy-ducks-dream.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tidy-ducks-dream.md diff --git a/.changeset/tidy-ducks-dream.md b/.changeset/tidy-ducks-dream.md new file mode 100644 index 000000000..29999e1d5 --- /dev/null +++ b/.changeset/tidy-ducks-dream.md @@ -0,0 +1,5 @@ +--- +"@svenvw/fdm-data": patch +--- + +Add workflow for prereleases From 37ad94a4618b549d3451dff61bf05b657a58e762 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:47:44 +0100 Subject: [PATCH 07/35] Fix that workspace is used --- .github/workflows/prerelease-fdm-data.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prerelease-fdm-data.yml b/.github/workflows/prerelease-fdm-data.yml index 65c50a1e1..2e847c49c 100644 --- a/.github/workflows/prerelease-fdm-data.yml +++ b/.github/workflows/prerelease-fdm-data.yml @@ -1,9 +1,5 @@ name: Prerelease fdm-data to GitHub Packages -defaults: - run: - working-directory: ./fdm-data - on: pull_request: paths: @@ -53,13 +49,13 @@ jobs: path: fdm-data - name: Create a prerelease version from PR if: ${{ github.ref != 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}-${{ github.head_ref }}.${{ github.sha }} --no-git-tag-version + run: pnpm version ${{ steps.package-version.outputs.current-version}}-${{ github.head_ref }}.${{ github.sha }} --no-git-tag-version --workspace=fdm-data - name: Create a prerelease version from main if: ${{ github.ref == 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}.${{ github.sha }} --no-git-tag-version + run: pnpm version ${{ steps.package-version.outputs.current-version}}.${{ github.sha }} --no-git-tag-version --workspace=fdm-data # - name: Run tests # run: pnpm test - name: Publish the package - run: pnpm publish --tag ${{ github.head_ref }} --no-git-checks + run: pnpm publish --tag ${{ github.head_ref }} --no-git-checks --workspace=fdm-data env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 6e6c763b9bf7f736493e784697ed4d2fc862b363 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:49:31 +0100 Subject: [PATCH 08/35] Fix use of pnpm packageExtension --- fdm-core/package.json | 17 ----------------- fdm-data/package.json | 19 +------------------ package.json | 19 ++++++++++++++++++- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/fdm-core/package.json b/fdm-core/package.json index 1d57f965c..5d2357329 100644 --- a/fdm-core/package.json +++ b/fdm-core/package.json @@ -76,22 +76,5 @@ "packageManager": "pnpm@9.12.2", "publishConfig": { "registry": "https://npm.pkg.github.com" - }, - "pnpm": { - "packageExtensions": { - "vite-plugin-dts": { - "dependenciesMeta": { - "@volar/typescript": { - "optional": true - }, - "vue-tsc": { - "optional": true - }, - "@vue/language-core": { - "optional": true - } - } - } - } } } \ No newline at end of file diff --git a/fdm-data/package.json b/fdm-data/package.json index e8d02a92b..0cf9229a8 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -61,22 +61,5 @@ "packageManager": "pnpm@9.12.2", "publishConfig": { "registry": "https://npm.pkg.github.com" - }, - "pnpm": { - "packageExtensions": { - "vite-plugin-dts": { - "dependenciesMeta": { - "@volar/typescript": { - "optional": true - }, - "vue-tsc": { - "optional": true - }, - "@vue/language-core": { - "optional": true - } - } - } - } - } + } } \ No newline at end of file diff --git a/package.json b/package.json index 2bf25dfa0..2f76a2193 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,22 @@ "@changesets/cli": "^2.27.9", "turbo": "^2.2.3" }, - "packageManager": "pnpm@9.12.2" + "packageManager": "pnpm@9.12.2", + "pnpm": { + "packageExtensions": { + "vite-plugin-dts": { + "dependenciesMeta": { + "@volar/typescript": { + "optional": true + }, + "vue-tsc": { + "optional": true + }, + "@vue/language-core": { + "optional": true + } + } + } + } + } } From 9a34dd5210d7c6108359107aa1901a8f4315a9a5 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:57:38 +0100 Subject: [PATCH 09/35] Fixes to use fdm-core in fdm-data --- fdm-data/package.json | 2 +- fdm-data/src/fertilizers/catalogues/srm.ts | 2 +- fdm-data/src/fertilizers/index.test.ts | 2 +- fdm-data/src/fertilizers/index.ts | 2 +- pnpm-lock.yaml | 4 +++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fdm-data/package.json b/fdm-data/package.json index 0cf9229a8..df79a113c 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -56,7 +56,7 @@ "vitest": "^2.0.5" }, "dependencies": { - "fdm-core": "workspace:*" + "@svenvw/fdm-core": "workspace:*" }, "packageManager": "pnpm@9.12.2", "publishConfig": { diff --git a/fdm-data/src/fertilizers/catalogues/srm.ts b/fdm-data/src/fertilizers/catalogues/srm.ts index 53ee5baf3..31a94c9af 100644 --- a/fdm-data/src/fertilizers/catalogues/srm.ts +++ b/fdm-data/src/fertilizers/catalogues/srm.ts @@ -1,5 +1,5 @@ import srm from './srm.json' -import { fdmSchema } from 'fdm-core' +import { fdmSchema } from '@svenvw/fdm-core' export function getCatalogueSrm(): fdmSchema.fertilizersCatalogueTypeInsert[] { diff --git a/fdm-data/src/fertilizers/index.test.ts b/fdm-data/src/fertilizers/index.test.ts index 50456a1ce..d0bb61fc6 100644 --- a/fdm-data/src/fertilizers/index.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, beforeEach } from 'vitest' -import { createFdmLocal, migrateFdmLocal, type FdmType } from 'fdm-core' +import { createFdmLocal, migrateFdmLocal, type FdmType } from '@svenvw/fdm-core' import { extendFertilizersCatalogue } from '.' describe('Fertilizers Data', () => { diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 3992ff76c..0f53b4774 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -1,4 +1,4 @@ -import { addFertilizerToCatalogue, getFertilizersFromCatalogue, type FdmType, fdmSchema } from "fdm-core"; +import { addFertilizerToCatalogue, getFertilizersFromCatalogue, type FdmType, fdmSchema } from "@svenvw/fdm-core"; import { getCatalogueSrm } from "./catalogues/srm"; export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: string): Promise { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dcd97fd81..ce88a2c81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,8 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +packageExtensionsChecksum: 29a6694e1052b064eec0acf6b5bbd138 + importers: .: @@ -103,7 +105,7 @@ importers: fdm-data: dependencies: - fdm-core: + '@svenvw/fdm-core': specifier: workspace:* version: link:../fdm-core devDependencies: From 22b344eff3d85e428ef3a80c69928c5a8685863f Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:17:41 +0100 Subject: [PATCH 10/35] Maybe this works? --- .github/workflows/prerelease-fdm-data.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prerelease-fdm-data.yml b/.github/workflows/prerelease-fdm-data.yml index 2e847c49c..bca6caadb 100644 --- a/.github/workflows/prerelease-fdm-data.yml +++ b/.github/workflows/prerelease-fdm-data.yml @@ -41,7 +41,7 @@ jobs: registry-url: 'https://npm.pkg.github.com' cache: 'pnpm' - name: Install dependencies - run: pnpm install --frozen-lockfile --filter fdm-data + run: pnpm install --frozen-lockfile - name: get-npm-version id: package-version uses: martinbeentjes/npm-get-version-action@v1.3.1 From c722ce21bd82094f5242b7fd61ee26d0d41cd474 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:33:13 +0100 Subject: [PATCH 11/35] Fix name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f76a2193..3b4168830 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "fdm-source", + "name": "@svenvw/fdm-source", "version": "0.0.0", "description": "Monorepo for fdm", "homepage": "https://github.com/SvenVw/fdm", From 4fbd34150d0293ad8afa564e959e99abef0b3335 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:33:35 +0100 Subject: [PATCH 12/35] Link packages through workspace --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..ee96585eb --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +link-workspace-packages=true \ No newline at end of file From e6a4b9ab4d112cdf7fc088d3224af69cf0be223c Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:33:55 +0100 Subject: [PATCH 13/35] Update dependency of fdm-data on fdm-core --- fdm-data/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fdm-data/package.json b/fdm-data/package.json index df79a113c..f4ae8d484 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -50,13 +50,14 @@ }, "devDependencies": { "@dotenvx/dotenvx": "^1.20.0", + "@svenvw/fdm-core": "workspace:../fdm-core", "typescript": "^5.5.3", "vite": "^5.4.8", "vite-plugin-dts": "^4.0.2", "vitest": "^2.0.5" }, - "dependencies": { - "@svenvw/fdm-core": "workspace:*" + "peerDependencies": { + "@svenvw/fdm-core": "workspace:>=0.3.1" }, "packageManager": "pnpm@9.12.2", "publishConfig": { From c36a673531b4a2ab9312cec7a0a2e562b2ad9047 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:34:50 +0100 Subject: [PATCH 14/35] Install only relevant dependencies --- .github/workflows/prerelease-fdm-data.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prerelease-fdm-data.yml b/.github/workflows/prerelease-fdm-data.yml index bca6caadb..2e847c49c 100644 --- a/.github/workflows/prerelease-fdm-data.yml +++ b/.github/workflows/prerelease-fdm-data.yml @@ -41,7 +41,7 @@ jobs: registry-url: 'https://npm.pkg.github.com' cache: 'pnpm' - name: Install dependencies - run: pnpm install --frozen-lockfile + run: pnpm install --frozen-lockfile --filter fdm-data - name: get-npm-version id: package-version uses: martinbeentjes/npm-get-version-action@v1.3.1 From 9550ad66f8866801e7abb28e8f92199068b978a8 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:15:00 +0100 Subject: [PATCH 15/35] Fix depencencies --- fdm-calculator/package.json | 5 +++-- fdm-data/package.json | 2 +- package.json | 3 +++ pnpm-lock.yaml | 24 +++++++++++++++--------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/fdm-calculator/package.json b/fdm-calculator/package.json index d446a84b1..1aad1eff0 100644 --- a/fdm-calculator/package.json +++ b/fdm-calculator/package.json @@ -45,13 +45,14 @@ "lint": "eslint ." }, "devDependencies": { + "@svenvw/fdm-core": "workspace:*", "typescript": "^5.5.3", "vite": "^5.4.8", "vite-plugin-dts": "^4.0.2", "vitest": "^2.0.5" }, - "dependencies": { - "fdm-core": "workspace:*" + "peerDependencies": { + "@svenvw/fdm-core": "workspace:>=0.3.1" }, "packageManager": "pnpm@9.12.2" } \ No newline at end of file diff --git a/fdm-data/package.json b/fdm-data/package.json index f4ae8d484..db8827138 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -50,7 +50,7 @@ }, "devDependencies": { "@dotenvx/dotenvx": "^1.20.0", - "@svenvw/fdm-core": "workspace:../fdm-core", + "@svenvw/fdm-core": "workspace:*", "typescript": "^5.5.3", "vite": "^5.4.8", "vite-plugin-dts": "^4.0.2", diff --git a/package.json b/package.json index 3b4168830..e616956c2 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "bugs": "https://github.com/SvenVw/fdm/issues/new", "type": "module", "private": true, + "workspaces": [ + "fdm-core", "fdm-data", "fdm-docs" + ], "scripts": { "test": "turbo run test", "build": "turbo run build", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce88a2c81..280e1181a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,11 +18,10 @@ importers: version: 2.2.3 fdm-calculator: - dependencies: - fdm-core: + devDependencies: + '@svenvw/fdm-core': specifier: workspace:* version: link:../fdm-core - devDependencies: typescript: specifier: ^5.5.3 version: 5.6.3 @@ -104,14 +103,13 @@ importers: version: 2.1.3(@types/node@22.7.9)(terser@5.36.0) fdm-data: - dependencies: - '@svenvw/fdm-core': - specifier: workspace:* - version: link:../fdm-core devDependencies: '@dotenvx/dotenvx': specifier: ^1.20.0 version: 1.20.0 + '@svenvw/fdm-core': + specifier: workspace:* + version: link:../fdm-core typescript: specifier: ^5.5.3 version: 5.6.3 @@ -806,6 +804,10 @@ packages: resolution: {integrity: sha512-FjoyLe754PMiYsFaN5C94ttGiOmBNYTf6pLr4xXHAT5uctHb092PBszndLDR5XA/jghQvn4n7JMHl7dmTgbm9w==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.26.0': + resolution: {integrity: sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==} + engines: {node: '>=6.9.0'} + '@babel/template@7.25.7': resolution: {integrity: sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==} engines: {node: '>=6.9.0'} @@ -7099,6 +7101,10 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 + '@babel/runtime@7.26.0': + dependencies: + regenerator-runtime: 0.14.1 + '@babel/template@7.25.7': dependencies: '@babel/code-frame': 7.25.7 @@ -8317,14 +8323,14 @@ snapshots: '@manypkg/find-root@1.1.0': dependencies: - '@babel/runtime': 7.25.7 + '@babel/runtime': 7.26.0 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 '@manypkg/get-packages@1.1.3': dependencies: - '@babel/runtime': 7.25.7 + '@babel/runtime': 7.26.0 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 From 909c7e8ec5c2457ddc839c6d6076e77615f8352f Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:47:50 +0100 Subject: [PATCH 16/35] Use single prerelease action --- .github/workflows/prerelease-fdm-core.yml | 65 ----------------------- .github/workflows/prerelease-fdm-data.yml | 61 --------------------- .github/workflows/prerelease.yml | 47 ++++++++++++++++ package.json | 3 +- 4 files changed, 49 insertions(+), 127 deletions(-) delete mode 100644 .github/workflows/prerelease-fdm-core.yml delete mode 100644 .github/workflows/prerelease-fdm-data.yml create mode 100644 .github/workflows/prerelease.yml diff --git a/.github/workflows/prerelease-fdm-core.yml b/.github/workflows/prerelease-fdm-core.yml deleted file mode 100644 index d4f45324d..000000000 --- a/.github/workflows/prerelease-fdm-core.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Prerelease fdm-core to GitHub Packages - -defaults: - run: - working-directory: ./fdm-core - -on: - pull_request: - paths: - - 'fdm-core/**' - branches: - - main - push: - paths: - - 'fdm-core/**' - branches: - - main - -jobs: - prerelease: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20] - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - name: Cache turbo build setup - uses: actions/cache@v4 - with: - path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-turbo- - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://npm.pkg.github.com' - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile --filter fdm-core - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@v1.3.1 - with: - path: fdm-core - - name: Create a prerelease version from PR - if: ${{ github.ref != 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}-${{ github.head_ref }}.${{ github.sha }} --no-git-tag-version - - name: Create a prerelease version from main - if: ${{ github.ref == 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}.${{ github.sha }} --no-git-tag-version - # - name: Run tests - # run: pnpm test - - name: Publish the package - run: pnpm publish --tag ${{ github.head_ref }} --no-git-checks - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/prerelease-fdm-data.yml b/.github/workflows/prerelease-fdm-data.yml deleted file mode 100644 index 2e847c49c..000000000 --- a/.github/workflows/prerelease-fdm-data.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Prerelease fdm-data to GitHub Packages - -on: - pull_request: - paths: - - 'fdm-data/**' - branches: - - main - push: - paths: - - 'fdm-data/**' - branches: - - main - -jobs: - prerelease: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20] - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - name: Cache turbo build setup - uses: actions/cache@v4 - with: - path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-turbo- - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://npm.pkg.github.com' - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile --filter fdm-data - - name: get-npm-version - id: package-version - uses: martinbeentjes/npm-get-version-action@v1.3.1 - with: - path: fdm-data - - name: Create a prerelease version from PR - if: ${{ github.ref != 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}-${{ github.head_ref }}.${{ github.sha }} --no-git-tag-version --workspace=fdm-data - - name: Create a prerelease version from main - if: ${{ github.ref == 'refs/heads/main' }} - run: pnpm version ${{ steps.package-version.outputs.current-version}}.${{ github.sha }} --no-git-tag-version --workspace=fdm-data - # - name: Run tests - # run: pnpm test - - name: Publish the package - run: pnpm publish --tag ${{ github.head_ref }} --no-git-checks --workspace=fdm-data - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 000000000..3578f7144 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,47 @@ +name: Prerelease + +on: + pull_request: + paths: + - 'fdm-core/**' + - 'fdm-data/**' + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + prerelease: + name: Prerelease + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Setup pnpm 9 + uses: pnpm/action-setup@v4 + with: + version: 9.12.2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + registry-url: 'https://npm.pkg.github.com' + cache: 'pnpm' + + - name: Install Dependencies + run: pnpm i + + - name: Create snapshot versions and publish them + id: changesets + uses: changesets/action@v1 + with: + version: changeset version --snapshot ${{ github.head_ref } + publish: pnpm prerelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/package.json b/package.json index e616956c2..50679c121 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "build": "turbo run build", "build-docs": "turbo run build-docs", "watch": "turbo run watch", - "publish-packages": "turbo run build test && changeset version && changeset publish" + "changeset": "changeset", + "prerelease": "turbo build --filter=fdm-core --filter=fdm-data && changeset publish " }, "devDependencies": { "@changesets/cli": "^2.27.9", From de4911ab8da353a310f2d6c45beec2079da7fd25 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:50:06 +0100 Subject: [PATCH 17/35] Fix trigger --- .github/workflows/prerelease.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 3578f7144..2211827ab 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -2,9 +2,9 @@ name: Prerelease on: pull_request: - paths: - - 'fdm-core/**' - - 'fdm-data/**' + # paths: + # - 'fdm-core/**' + # - 'fdm-data/**' branches: - main From 35135268a32de50e757b3cb4247cf09fa6949f30 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:55:39 +0100 Subject: [PATCH 18/35] Switch off concurrency --- .github/workflows/prerelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 2211827ab..2d9b577b1 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -8,7 +8,7 @@ on: branches: - main -concurrency: ${{ github.workflow }}-${{ github.ref }} +# concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: prerelease: From ff47706cd14ebd6986f4549ddad0e63b492e29fc Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:57:02 +0100 Subject: [PATCH 19/35] Fix typo --- .github/workflows/prerelease.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 2d9b577b1..617e73ca3 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -2,13 +2,13 @@ name: Prerelease on: pull_request: - # paths: - # - 'fdm-core/**' - # - 'fdm-data/**' + paths: + - 'fdm-core/**' + - 'fdm-data/**' branches: - main -# concurrency: ${{ github.workflow }}-${{ github.ref }} +concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: prerelease: @@ -40,7 +40,7 @@ jobs: id: changesets uses: changesets/action@v1 with: - version: changeset version --snapshot ${{ github.head_ref } + version: changeset version --snapshot ${{ github.head_ref }} publish: pnpm prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f5d51fcfe0b9570555a38fa16345d07c94858ba0 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:22:04 +0100 Subject: [PATCH 20/35] Fix scopes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50679c121..715c024f5 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "build-docs": "turbo run build-docs", "watch": "turbo run watch", "changeset": "changeset", - "prerelease": "turbo build --filter=fdm-core --filter=fdm-data && changeset publish " + "prerelease": "turbo build --filter=@svenvw/fdm-core --filter=@svenvw/fdm-data && changeset publish " }, "devDependencies": { "@changesets/cli": "^2.27.9", From ac66a44cbd821644230348f35d058e1399857f36 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:22:14 +0100 Subject: [PATCH 21/35] Preserve symlinks --- fdm-data/vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fdm-data/vite.config.ts b/fdm-data/vite.config.ts index b33e20a27..bb8ad4ddc 100644 --- a/fdm-data/vite.config.ts +++ b/fdm-data/vite.config.ts @@ -41,6 +41,9 @@ export default defineConfig({ } }, plugins: [dts()], + resolve: { + preserveSymlinks: true + }, test: { // ... } From 8d9b2b6d804eda131a729449aeeb1471eb17bd0c Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:18:57 +0100 Subject: [PATCH 22/35] Fix permissions --- .github/workflows/prerelease.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 617e73ca3..500ef005b 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -17,6 +17,9 @@ jobs: strategy: matrix: node-version: [20] + permissions: + contents: read + packages: write steps: - name: Checkout Repo uses: actions/checkout@v4 From 7b46f5a8f38dede0dfdaffda9e6f7a6cd02da73d Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:21:17 +0100 Subject: [PATCH 23/35] Add turbo cache --- .github/workflows/prerelease.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 500ef005b..f26024c45 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -24,6 +24,14 @@ jobs: - name: Checkout Repo uses: actions/checkout@v4 + - name: Cache turbo build setup + uses: actions/cache@v4 + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo- + - name: Setup pnpm 9 uses: pnpm/action-setup@v4 with: From 652a21392914dc31848cb6babe02d40fde8970e1 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:26:41 +0100 Subject: [PATCH 24/35] Cancel earlier concurrent build --- .github/workflows/prerelease.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index f26024c45..9ff53c1d6 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -8,7 +8,9 @@ on: branches: - main -concurrency: ${{ github.workflow }}-${{ github.ref }} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: prerelease: From a24344140dae988ff46e840f77ada2fe57e34d70 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:33:43 +0100 Subject: [PATCH 25/35] Set vite log level to error for fdm-data to prevent slowdown of GH Action --- fdm-data/vite.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fdm-data/vite.config.ts b/fdm-data/vite.config.ts index bb8ad4ddc..6047f3874 100644 --- a/fdm-data/vite.config.ts +++ b/fdm-data/vite.config.ts @@ -8,6 +8,7 @@ import { defineConfig } from 'vite'; import dts from 'vite-plugin-dts'; // https://vitejs.dev/guide/build.html#library-mode export default defineConfig({ + logLevel: 'error', build: { lib: { entry: resolve(__dirname, 'src/index.ts'), @@ -41,9 +42,6 @@ export default defineConfig({ } }, plugins: [dts()], - resolve: { - preserveSymlinks: true - }, test: { // ... } From bd48f0e3c2da7e146fa0accbee8d74e0a8c0942c Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:57:45 +0100 Subject: [PATCH 26/35] Replace changeset action with custom steps --- .github/workflows/prerelease.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 9ff53c1d6..013361fc9 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -49,12 +49,13 @@ jobs: - name: Install Dependencies run: pnpm i - - name: Create snapshot versions and publish them - id: changesets - uses: changesets/action@v1 - with: - version: changeset version --snapshot ${{ github.head_ref }} - publish: pnpm prerelease + - name: Bump snapshot + run: pnpm changeset version --snapshot ${{ github.head_ref }} --ignore fdm-docs + + - name: Build packages + run: pnpm build --filter=@svenvw/fdm-core --filter=@svenvw/fdm-data + + - name: Publish snapshot + run: pnpm changeset publish --tag ${{ github.head_ref }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From c333d6b9297d522423411042d9e1696ab28058c7 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:07:34 +0100 Subject: [PATCH 27/35] Fix name change of package --- .changeset/brave-shoes-build.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/brave-shoes-build.md b/.changeset/brave-shoes-build.md index 5dc832926..460151589 100644 --- a/.changeset/brave-shoes-build.md +++ b/.changeset/brave-shoes-build.md @@ -1,5 +1,5 @@ --- -"fdm-data": minor +"@svenvw/fdm-data": minor --- Add `srm` as option for `datasetName` at `extendFertilizersCatalogue` From a2ee85712848e0572a8eea8d4a983338ae8d4d2a Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:16:47 +0100 Subject: [PATCH 28/35] Add to `fertilizers_catalogue` the columns:`p_density`, `p_type_manure`, `p_type_mineral` and `p_type_compost` --- .changeset/twelve-steaks-exercise.md | 5 ++ ...e_jean_grey.sql => 0000_slim_lockheed.sql} | 18 +++---- .../src/db/migrations/meta/0000_snapshot.json | 48 +++++++++++++++---- fdm-core/src/db/migrations/meta/_journal.json | 4 +- fdm-core/src/db/schema.ts | 6 ++- fdm-core/src/fertilizer.test.ts | 16 +++++++ fdm-core/src/fertilizer.ts | 6 ++- 7 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 .changeset/twelve-steaks-exercise.md rename fdm-core/src/db/migrations/{0000_pale_jean_grey.sql => 0000_slim_lockheed.sql} (94%) diff --git a/.changeset/twelve-steaks-exercise.md b/.changeset/twelve-steaks-exercise.md new file mode 100644 index 000000000..98ddbe40a --- /dev/null +++ b/.changeset/twelve-steaks-exercise.md @@ -0,0 +1,5 @@ +--- +"@svenvw/fdm-core": minor +--- + +Add to `fertilizers_catalogue` the columns:`p_density`, `p_type_manure`, `p_type_mineral` and `p_type_compost` diff --git a/fdm-core/src/db/migrations/0000_pale_jean_grey.sql b/fdm-core/src/db/migrations/0000_slim_lockheed.sql similarity index 94% rename from fdm-core/src/db/migrations/0000_pale_jean_grey.sql rename to fdm-core/src/db/migrations/0000_slim_lockheed.sql index 247d5f610..53eb56e3f 100644 --- a/fdm-core/src/db/migrations/0000_pale_jean_grey.sql +++ b/fdm-core/src/db/migrations/0000_slim_lockheed.sql @@ -1,17 +1,7 @@ CREATE SCHEMA "fdm-dev"; --> statement-breakpoint -DO $$ BEGIN - CREATE TYPE "fdm-dev"."b_manage_type" AS ENUM('owner', 'lease'); -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - CREATE TYPE "fdm-dev"."b_sector" AS ENUM('diary', 'arable', 'tree_nursery', 'bulbs'); -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint +CREATE TYPE "fdm-dev"."b_manage_type" AS ENUM('owner', 'lease');--> statement-breakpoint +CREATE TYPE "fdm-dev"."b_sector" AS ENUM('diary', 'arable', 'tree_nursery', 'bulbs');--> statement-breakpoint CREATE TABLE IF NOT EXISTS "fdm-dev"."farm_managing" ( "b_id" text NOT NULL, "b_id_farm" text NOT NULL, @@ -61,6 +51,7 @@ CREATE TABLE IF NOT EXISTS "fdm-dev"."fertilizers_catalogue" ( "p_name_en" text, "p_description" text, "p_dm" numeric, + "p_density" numeric, "p_om" numeric, "p_a" numeric, "p_hc" numeric, @@ -99,6 +90,9 @@ CREATE TABLE IF NOT EXISTS "fdm-dev"."fertilizers_catalogue" ( "p_pb_rt" numeric, "p_hg_rt" numeric, "p_cl_cr" numeric, + "p_type_manure" boolean, + "p_type_mineral" boolean, + "p_type_compost" boolean, "created" timestamp with time zone DEFAULT now() NOT NULL, "updated" timestamp with time zone ); diff --git a/fdm-core/src/db/migrations/meta/0000_snapshot.json b/fdm-core/src/db/migrations/meta/0000_snapshot.json index 06bcd58aa..c1e47cba3 100644 --- a/fdm-core/src/db/migrations/meta/0000_snapshot.json +++ b/fdm-core/src/db/migrations/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "ca7ff342-727b-4512-946e-d4fd95e324a2", + "id": "ba4dd387-e576-411c-8f10-79e84712e7a3", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -115,7 +115,8 @@ ] } }, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.farms": { "name": "farms", @@ -173,7 +174,8 @@ }, "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.fertilizer_aquiring": { "name": "fertilizer_aquiring", @@ -249,7 +251,8 @@ } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.fertilizer_picking": { "name": "fertilizer_picking", @@ -319,7 +322,8 @@ } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.fertilizers": { "name": "fertilizers", @@ -364,7 +368,8 @@ }, "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.fertilizers_catalogue": { "name": "fertilizers_catalogue", @@ -406,6 +411,12 @@ "primaryKey": false, "notNull": false }, + "p_density": { + "name": "p_density", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, "p_om": { "name": "p_om", "type": "numeric", @@ -634,6 +645,24 @@ "primaryKey": false, "notNull": false }, + "p_type_manure": { + "name": "p_type_manure", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "p_type_mineral": { + "name": "p_type_mineral", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "p_type_compost": { + "name": "p_type_compost", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, "created": { "name": "created", "type": "timestamp with time zone", @@ -667,7 +696,8 @@ }, "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} }, "fdm-dev.fields": { "name": "fields", @@ -718,7 +748,8 @@ }, "foreignKeys": {}, "compositePrimaryKeys": {}, - "uniqueConstraints": {} + "uniqueConstraints": {}, + "checkConstraints": {} } }, "enums": { @@ -745,6 +776,7 @@ "fdm-dev": "fdm-dev" }, "sequences": {}, + "views": {}, "_meta": { "columns": {}, "schemas": {}, diff --git a/fdm-core/src/db/migrations/meta/_journal.json b/fdm-core/src/db/migrations/meta/_journal.json index 015f2677f..1630d8c0f 100644 --- a/fdm-core/src/db/migrations/meta/_journal.json +++ b/fdm-core/src/db/migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "7", - "when": 1729004382718, - "tag": "0000_pale_jean_grey", + "when": 1730387776036, + "tag": "0000_slim_lockheed", "breakpoints": true } ] diff --git a/fdm-core/src/db/schema.ts b/fdm-core/src/db/schema.ts index 5eab3637f..bac17aec9 100644 --- a/fdm-core/src/db/schema.ts +++ b/fdm-core/src/db/schema.ts @@ -1,4 +1,4 @@ -import { pgSchema, text, date, timestamp, primaryKey, uniqueIndex} from 'drizzle-orm/pg-core' +import { pgSchema, text, date, timestamp, boolean, primaryKey, uniqueIndex} from 'drizzle-orm/pg-core' import { numericCasted } from './schema-custom-types' // Define postgres schema @@ -95,6 +95,7 @@ export const fertilizersCatalogue = fdmSchema.table('fertilizers_catalogue', { p_name_en: text(), p_description: text(), p_dm: numericCasted(), + p_density: numericCasted(), p_om: numericCasted(), p_a: numericCasted(), p_hc: numericCasted(), @@ -133,6 +134,9 @@ export const fertilizersCatalogue = fdmSchema.table('fertilizers_catalogue', { p_pb_rt: numericCasted(), p_hg_rt: numericCasted(), p_cl_cr: numericCasted(), + p_type_manure: boolean(), + p_type_mineral: boolean(), + p_type_compost: boolean(), created: timestamp({ withTimezone: true }).notNull().defaultNow(), updated: timestamp({ withTimezone: true }) }, (table) => { diff --git a/fdm-core/src/fertilizer.test.ts b/fdm-core/src/fertilizer.test.ts index c049bdba9..b2832ecd3 100644 --- a/fdm-core/src/fertilizer.test.ts +++ b/fdm-core/src/fertilizer.test.ts @@ -45,6 +45,7 @@ describe('Farm Data Model', () => { p_description, { p_dm: 37, + p_density: 20, p_om: 20, p_a: 30, p_hc: 40, @@ -83,6 +84,9 @@ describe('Farm Data Model', () => { p_pb_rt: 370, p_hg_rt: 380, p_cl_rt: 390, + p_type_manure: true, + p_type_mineral: false, + p_type_compost: false } ) expect(p_id_catalogue).toBeDefined() @@ -114,6 +118,7 @@ describe('Farm Data Model', () => { p_description, { p_dm: 37, + p_density: 20, p_om: 20, p_a: 30, p_hc: 40, @@ -152,6 +157,9 @@ describe('Farm Data Model', () => { p_pb_rt: 370, p_hg_rt: 380, p_cl_rt: 390, + p_type_manure: true, + p_type_mineral: false, + p_type_compost: false } ) @@ -183,6 +191,7 @@ describe('Farm Data Model', () => { p_description, { p_dm: 37, + p_density: 20, p_om: 20, p_a: 30, p_hc: 40, @@ -221,6 +230,9 @@ describe('Farm Data Model', () => { p_pb_rt: 370, p_hg_rt: 380, p_cl_rt: 390, + p_type_manure: true, + p_type_mineral: false, + p_type_compost: false } ) @@ -264,6 +276,7 @@ describe('Farm Data Model', () => { p_description, { p_dm: 37, + p_density: 20, p_om: 20, p_a: 30, p_hc: 40, @@ -302,6 +315,9 @@ describe('Farm Data Model', () => { p_pb_rt: 370, p_hg_rt: 380, p_cl_rt: 390, + p_type_manure: true, + p_type_mineral: false, + p_type_compost: false } ) diff --git a/fdm-core/src/fertilizer.ts b/fdm-core/src/fertilizer.ts index 7f6e42dbe..bb1513406 100644 --- a/fdm-core/src/fertilizer.ts +++ b/fdm-core/src/fertilizer.ts @@ -36,6 +36,7 @@ export async function addFertilizerToCatalogue( p_description: schema.fertilizersCatalogueTypeInsert['p_description'], properties: { p_dm: schema.fertilizersCatalogueTypeInsert['p_dm'], + p_density: schema.fertilizersCatalogueTypeInsert['p_density'], p_om: schema.fertilizersCatalogueTypeInsert['p_om'], p_a: schema.fertilizersCatalogueTypeInsert['p_a'], p_hc: schema.fertilizersCatalogueTypeInsert['p_hc'], @@ -73,7 +74,10 @@ export async function addFertilizerToCatalogue( p_cr_vi: schema.fertilizersCatalogueTypeInsert['p_cr_vi'], p_pb_rt: schema.fertilizersCatalogueTypeInsert['p_pb_rt'], p_hg_rt: schema.fertilizersCatalogueTypeInsert['p_hg_rt'], - p_cl_rt: schema.fertilizersCatalogueTypeInsert['p_cl_cr'] + p_cl_rt: schema.fertilizersCatalogueTypeInsert['p_cl_cr'], + p_type_manure: schema.fertilizersCatalogueTypeInsert['p_type_manure'], + p_type_mineral: schema.fertilizersCatalogueTypeInsert['p_type_mineral'], + p_type_compost: schema.fertilizersCatalogueTypeInsert['p_type_compost'] }): Promise { // Generate an ID for the fertilizer catalogue item From 787f33fb5d46408435c94853801acc122cae329a Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:19:19 +0100 Subject: [PATCH 29/35] Add p_density p_type_* of srm to catalogue --- fdm-data/src/fertilizers/catalogues/srm.json | 94 ++++++++++---------- fdm-data/src/fertilizers/index.ts | 6 +- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/fdm-data/src/fertilizers/catalogues/srm.json b/fdm-data/src/fertilizers/catalogues/srm.json index 8bdd160a2..0a9fc86ed 100644 --- a/fdm-data/src/fertilizers/catalogues/srm.json +++ b/fdm-data/src/fertilizers/catalogues/srm.json @@ -20,7 +20,7 @@ "p_ca_rt": 7.5051, "p_ne": 0.0687, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": true, "p_id_catalogue": "0fa8fb5bc763ad9b", "p_app_method_options": "incorporation||broadcasting", @@ -47,7 +47,7 @@ "p_ca_rt": 180, "p_ne": 1.7, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "46bd49cbb67bc7b7", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -74,7 +74,7 @@ "p_ca_rt": 200, "p_ne": 2, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "30be8cdc92e64ef2", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -101,7 +101,7 @@ "p_ca_rt": 0, "p_ne": -0.0368, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "5e0f486cfce81f85", "p_app_method_options": "slotted coulter||injection", @@ -128,7 +128,7 @@ "p_ca_rt": 0, "p_ne": -0.0224, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "9e29a11332476286", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -155,7 +155,7 @@ "p_ca_rt": 0, "p_ne": -0.093, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "898ad56320a5614c", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -182,7 +182,7 @@ "p_ca_rt": 230, "p_ne": 2.2, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "ff4034f347f9c66e", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -205,7 +205,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "7e4ed7a0abb1c131", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -231,7 +231,7 @@ "p_ca_rt": 0, "p_ne": -0.034, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "6224a5cc4a92865d", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -258,7 +258,7 @@ "p_ca_rt": 470, "p_ne": 5.4, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "cb59142efac34dc0", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -280,7 +280,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "34e762701f91a893", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -302,7 +302,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": true, "p_id_catalogue": "3efa9129f0eb2e62", "p_app_method_options": "incorporation||broadcasting" @@ -328,7 +328,7 @@ "p_ca_rt": 0, "p_ne": -0.0854, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "76b0d22ed29eb2af", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -351,7 +351,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": true, "p_id_catalogue": "1ae98c5a34997eac", "p_app_method_options": "incorporation||broadcasting" @@ -373,7 +373,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "83f4f6f067ceecd4", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -399,7 +399,7 @@ "p_ca_rt": 75.0509, "p_ne": 0.7125, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": true, "p_id_catalogue": "a9e19e6db97c49aa", "p_app_method_options": "incorporation||broadcasting", @@ -422,7 +422,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "8aa0baeaa367dbef", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -448,7 +448,7 @@ "p_ca_rt": 120, "p_ne": -1.5, "p_type_manure": false, - "p_type_artificial": true, + "p_type_mineral": true, "p_type_compost": false, "p_id_catalogue": "1d2e4f0b600af921", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -470,7 +470,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "56569b23583728e0", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -492,7 +492,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "62648ac045e9fff6", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -514,7 +514,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "1f616af7e94f3ec4", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -540,7 +540,7 @@ "p_ca_rt": 18, "p_ne": 0.058, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "db5cef16b5fd1be4", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -567,7 +567,7 @@ "p_ca_rt": 75.0509, "p_ne": 0.7217, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": true, "p_id_catalogue": "35589ecec6988b94", "p_app_method_options": "incorporation||broadcasting", @@ -594,7 +594,7 @@ "p_ca_rt": 105, "p_ne": 1.0738, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "7fe1088167f5b3b6", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -620,7 +620,7 @@ "p_ca_rt": 0, "p_ne": 0.2804, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "9eef309c5a21cac2", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -647,7 +647,7 @@ "p_ca_rt": 0, "p_ne": -0.0122, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "9d855a14df2045c2", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -674,7 +674,7 @@ "p_ca_rt": 0, "p_ne": -0.0658, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "0eac33098aed5a8c", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -701,7 +701,7 @@ "p_ca_rt": 0, "p_ne": -0.007, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "e527c65c26e92c6b", "p_app_method_options": "slotted coulter||injection", @@ -728,7 +728,7 @@ "p_ca_rt": 0, "p_ne": -0.0182, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "50a1f75317b0833a", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -755,7 +755,7 @@ "p_ca_rt": 0, "p_ne": -0.0236, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "9d3d0b2ecabb8727", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -782,7 +782,7 @@ "p_ca_rt": 0, "p_ne": 0.0036, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "433104c1442b62c2", "p_app_method_options": "slotted coulter||injection", @@ -809,7 +809,7 @@ "p_ca_rt": 0, "p_ne": 0.019, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "68af2b5484d8ac21", "p_app_method_options": "slotted coulter||injection", @@ -836,7 +836,7 @@ "p_ca_rt": 0, "p_ne": -0.0276, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "d05ee30018d8b9c5", "p_app_method_options": "incorporation||broadcasting", @@ -863,7 +863,7 @@ "p_ca_rt": 240, "p_ne": 0.285, "p_type_manure": false, - "p_type_artificial": true, + "p_type_mineral": true, "p_type_compost": false, "p_id_catalogue": "150a6c681a7c7da0", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -889,7 +889,7 @@ "p_ca_rt": 0, "p_ne": -0.138, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "bebf7c93d0a5ac01", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -916,7 +916,7 @@ "p_ca_rt": 0, "p_ne": -0.0166, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "7e0ca9e00a1e04c3", "p_app_method_options": "slotted coulter||injection", @@ -943,7 +943,7 @@ "p_ca_rt": 0, "p_ne": -0.0298, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "82293b5baa991470", "p_app_method_options": "slotted coulter||injection", @@ -970,7 +970,7 @@ "p_ca_rt": 0, "p_ne": -0.0176, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "982cffd52eb5a270", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -997,7 +997,7 @@ "p_ca_rt": 0, "p_ne": -0.0546, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "a68418f8d14e112b", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -1024,7 +1024,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "2a6eb018e1ef35b7", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -1051,7 +1051,7 @@ "p_ca_rt": 0, "p_ne": 0.45, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "7b8dc7437321b2c0", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement", @@ -1078,7 +1078,7 @@ "p_ca_rt": 0, "p_ne": -0.2652, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "8eaafeff8a8bbffa", "p_app_method_options": "incorporation||broadcasting", @@ -1105,7 +1105,7 @@ "p_ca_rt": 0, "p_ne": -0.1506, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "9386a2ed7eefef8b", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -1132,7 +1132,7 @@ "p_ca_rt": 0, "p_ne": -0.0084, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "4cbce919da49811c", "p_app_method_options": "slotted coulter||injection", @@ -1159,7 +1159,7 @@ "p_ca_rt": 0, "p_ne": -0.015, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "f6bc9a9dac9d5ded", "p_app_method_options": "slotted coulter||injection||broadcasting", @@ -1182,7 +1182,7 @@ "p_ca_rt": 0, "p_ne": 0, "p_type_manure": false, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "c12ca3a82c6c8b68", "p_app_method_options": "spraying||broadcasting||spoke wheel||pocket placement" @@ -1208,7 +1208,7 @@ "p_ca_rt": 0, "p_ne": -0.004, "p_type_manure": true, - "p_type_artificial": false, + "p_type_mineral": false, "p_type_compost": false, "p_id_catalogue": "bfbb3200362c312a", "p_app_method_options": "slotted coulter||injection", diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 0f53b4774..96a84074a 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -34,6 +34,7 @@ export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: st p_description: fertilizer.p_description, properties: { p_dm: fertilizer.p_dm, + p_density: fertilizer.p_density, p_om: fertilizer.p_om, p_a: fertilizer.p_a, p_hc: fertilizer.p_hc, @@ -70,7 +71,10 @@ export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: st pr_cr_rt: fertilizer.p_cr_rt, p_cr_vi: fertilizer.p_cr_vi, p_pb_rt: fertilizer.p_pb_rt, - p_hg_rt: fertilizer.p_hg_rt + p_hg_rt: fertilizer.p_hg_rt, + p_type_manure: fertilizer.p_type_manure, + p_type_mineral: fertilizer.p_type_mineral, + p_type_compost: fertilizer.p_type_compost } }) } From b2803dbda5d53150bfb7730bc692898b586264eb Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:18:25 +0100 Subject: [PATCH 30/35] Fix fdm-calculator config --- fdm-calculator/.gitignore | 1 + fdm-calculator/package.json | 1 + pnpm-workspace.yaml | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fdm-calculator/.gitignore b/fdm-calculator/.gitignore index a547bf36d..1cac5597e 100644 --- a/fdm-calculator/.gitignore +++ b/fdm-calculator/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +.env \ No newline at end of file diff --git a/fdm-calculator/package.json b/fdm-calculator/package.json index 1aad1eff0..443b6aede 100644 --- a/fdm-calculator/package.json +++ b/fdm-calculator/package.json @@ -45,6 +45,7 @@ "lint": "eslint ." }, "devDependencies": { + "@dotenvx/dotenvx": "^1.20.0", "@svenvw/fdm-core": "workspace:*", "typescript": "^5.5.3", "vite": "^5.4.8", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 88c5c7bac..35d1e6ae1 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,5 @@ packages: - 'fdm-core' - 'fdm-data' - - 'fdm-calculator' + # - 'fdm-calculator' - 'fdm-docs' \ No newline at end of file From 412e5d55f5c64e461b6231e0e002a8dfbfa3c720 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:19:11 +0100 Subject: [PATCH 31/35] Fix drizzle-rom version across packages --- fdm-core/package.json | 2 +- pnpm-lock.yaml | 29 ++++++++++------------------- pnpm-workspace.yaml | 5 ++++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/fdm-core/package.json b/fdm-core/package.json index 5d2357329..d81f888bd 100644 --- a/fdm-core/package.json +++ b/fdm-core/package.json @@ -68,7 +68,7 @@ "dependencies": { "@electric-sql/pglite": "^0.2.12", "drizzle-graphql": "^0.8.5", - "drizzle-orm": "^0.35.3", + "drizzle-orm": "catalog:", "graphql": "^16.9.0", "nanoid": "^5.0.7", "postgres": "^3.4.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 280e1181a..2addb5c9a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,12 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + drizzle-orm: + specifier: ^0.35.3 + version: 0.35.3 + packageExtensionsChecksum: 29a6694e1052b064eec0acf6b5bbd138 importers: @@ -17,24 +23,6 @@ importers: specifier: ^2.2.3 version: 2.2.3 - fdm-calculator: - devDependencies: - '@svenvw/fdm-core': - specifier: workspace:* - version: link:../fdm-core - typescript: - specifier: ^5.5.3 - version: 5.6.3 - vite: - specifier: ^5.4.8 - version: 5.4.9(@types/node@22.7.9)(terser@5.36.0) - vite-plugin-dts: - specifier: ^4.0.2 - version: 4.2.4(@types/node@22.7.9)(rollup@4.24.0)(typescript@5.6.3)(vite@5.4.9(@types/node@22.7.9)(terser@5.36.0)) - vitest: - specifier: ^2.0.5 - version: 2.1.3(@types/node@22.7.9)(terser@5.36.0) - fdm-core: dependencies: '@electric-sql/pglite': @@ -44,7 +32,7 @@ importers: specifier: ^0.8.5 version: 0.8.5(drizzle-orm@0.35.3(@electric-sql/pglite@0.2.12)(@libsql/client-wasm@0.14.0)(@types/react@18.3.11)(postgres@3.4.4)(react@18.3.1))(graphql@16.9.0) drizzle-orm: - specifier: ^0.35.3 + specifier: 'catalog:' version: 0.35.3(@electric-sql/pglite@0.2.12)(@libsql/client-wasm@0.14.0)(@types/react@18.3.11)(postgres@3.4.4)(react@18.3.1) graphql: specifier: ^16.9.0 @@ -110,6 +98,9 @@ importers: '@svenvw/fdm-core': specifier: workspace:* version: link:../fdm-core + drizzle-orm: + specifier: 'catalog:' + version: 0.35.3(@electric-sql/pglite@0.2.12)(@libsql/client-wasm@0.14.0)(@types/react@18.3.11)(postgres@3.4.4)(react@18.3.1) typescript: specifier: ^5.5.3 version: 5.6.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 35d1e6ae1..b31362909 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,4 +2,7 @@ packages: - 'fdm-core' - 'fdm-data' # - 'fdm-calculator' - - 'fdm-docs' \ No newline at end of file + - 'fdm-docs' + +catalog: + drizzle-orm: ^0.35.3 \ No newline at end of file From b08d78b6c56a5b4dda7ba90bf95f045d0e836fe3 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:19:32 +0100 Subject: [PATCH 32/35] Add workaround for fdm-data test to connect to fdm --- fdm-data/package.json | 1 + fdm-data/src/fertilizers/index.test.ts | 43 +++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/fdm-data/package.json b/fdm-data/package.json index db8827138..354ebb6d2 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -51,6 +51,7 @@ "devDependencies": { "@dotenvx/dotenvx": "^1.20.0", "@svenvw/fdm-core": "workspace:*", + "drizzle-orm": "catalog:", "typescript": "^5.5.3", "vite": "^5.4.8", "vite-plugin-dts": "^4.0.2", diff --git a/fdm-data/src/fertilizers/index.test.ts b/fdm-data/src/fertilizers/index.test.ts index d0bb61fc6..33a25b6fd 100644 --- a/fdm-data/src/fertilizers/index.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -1,13 +1,48 @@ import { describe, expect, it, beforeEach } from 'vitest' -import { createFdmLocal, migrateFdmLocal, type FdmType } from '@svenvw/fdm-core' +import { fdmSchema as schema, type FdmType } from '@svenvw/fdm-core' import { extendFertilizersCatalogue } from '.' -describe('Fertilizers Data', () => { +import { drizzle } from 'drizzle-orm/postgres-js' +import { migrate } from 'drizzle-orm/postgres-js/migrator' + +describe('Fertilizers Data [server]', () => { let fdm: FdmType beforeEach(async () => { - fdm = await createFdmLocal('memory://') - await migrateFdmLocal(fdm) + + const host = process.env.POSTGRES_HOST + const port = Number(process.env.POSTGRES_PORT) + const user = process.env.POSTGRES_USER + const password = process.env.POSTGRES_PASSWORD + const database = process.env.POSTGRES_DB + const migrationsFolderPath = 'node_modules/@svenvw/fdm-core/dist/db/migrations' + + // Does not work yet :( + // const fdm = await createFdmServer( + // host, + // port, + // user, + // password, + // database + // ) + // await migrateFdmServer(fdm) + + // Workaround + fdm = drizzle({ + connection : { + user : user, + password : password, + host : host, + port : port, + database : database + }, + logger: false, + schema: schema + }) + + // Run migration + await migrate(fdm, { migrationsFolder: migrationsFolderPath, migrationsSchema: 'fdm-migrations' }) + }) it('should throw error if dataset is not recognized', async () => { From ca8107ee9861b006cbd7cc58880a0416708f4410 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:58:56 +0100 Subject: [PATCH 33/35] Fix that fertilizer is added to catalogue --- fdm-data/src/fertilizers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 96a84074a..9c0e15f8a 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -24,7 +24,7 @@ export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: st const fertilizerInCatalogue = fertilizersCatalogue.find((x: fdmSchema.fertilizersCatalogueTypeSelect): any => x.p_id_catalogue === fertilizer.p_id_catalogue) // If fertilizer is not present in catalogue, add it to fdm instance - if (fertilizerInCatalogue) { + if (! fertilizerInCatalogue) { await addFertilizerToCatalogue({ fdm: fdm, p_id_catalogue: fertilizer.p_id_catalogue, From cb90c93b05a61bb168c1d0f2a4ec3d5857691eec Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:35:34 +0100 Subject: [PATCH 34/35] Improve adding fertilzers from catalogue --- fdm-core/src/fertilizer.test.ts | 234 +++---------------------- fdm-core/src/fertilizer.ts | 27 +-- fdm-data/src/fertilizers/index.test.ts | 4 +- fdm-data/src/fertilizers/index.ts | 26 +-- 4 files changed, 51 insertions(+), 240 deletions(-) diff --git a/fdm-core/src/fertilizer.test.ts b/fdm-core/src/fertilizer.test.ts index b2832ecd3..833e35d9f 100644 --- a/fdm-core/src/fertilizer.test.ts +++ b/fdm-core/src/fertilizer.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it, beforeEach } from 'vitest' import { createFdmServer, migrateFdmServer } from './fdm-server' import { type FdmServerType } from './fdm-server.d' +import { addFertilizerToCatalogue, getFertilizersFromCatalogue, addFertilizer, removeFertilizer, getFertilizer, getFertilizers } from './fertilizer' import { addFarm } from './farm' -import { addFertilizerToCatalogue, getFertilizersFromCatalogue, addFertilizer, removeFertilizer, getFertilizer } from './fertilizer' -describe('Farm Data Model', () => { +describe('Fertilizer Data Model', () => { let fdm: FdmServerType beforeEach(async () => { @@ -26,24 +26,26 @@ describe('Farm Data Model', () => { await migrateFdmServer(fdm, migrationsFolderPath) }) - describe('Fertilizers CRUD', () => { + describe('Fertilizer CRUD', () => { it('should get fertilizers from catalogue', async () => { const fertilizers = await getFertilizersFromCatalogue(fdm) expect(fertilizers).toBeDefined() }) - it('should add a new fertilizer to the catalogue', async () => { + const p_source = 'custom' const p_name_nl = 'Test Fertilizer' const p_name_en = 'Test Fertilizer (EN)' const p_description = 'This is a test fertilizer' - const p_id_catalogue = await addFertilizerToCatalogue( + const p_id_catalogue = 'test-fertilizer-id' // Use a predefined ID for testing + await addFertilizerToCatalogue( fdm, - 'custom', - p_name_nl, - p_name_en, - p_description, { + p_id_catalogue, + p_source, + p_name_nl, + p_name_en, + p_description, p_dm: 37, p_density: 20, p_om: 20, @@ -89,7 +91,6 @@ describe('Farm Data Model', () => { p_type_compost: false } ) - expect(p_id_catalogue).toBeDefined() const fertilizers = await getFertilizersFromCatalogue(fdm) expect(fertilizers.length).toBeGreaterThanOrEqual(1) @@ -97,72 +98,18 @@ describe('Farm Data Model', () => { (f) => f.p_id_catalogue === p_id_catalogue ) expect(fertilizer).toBeDefined() + expect(fertilizer?.p_source).toBe(p_source) expect(fertilizer?.p_name_nl).toBe(p_name_nl) expect(fertilizer?.p_name_en).toBe(p_name_en) expect(fertilizer?.p_description).toBe(p_description) }) - + it('should add a new fertilizer', async () => { const farmName = 'Test Farm' const farmSector = 'diary' const b_id_farm = await addFarm(fdm, farmName, farmSector) - const p_name_nl = 'Test Fertilizer' - const p_name_en = 'Test Fertilizer (EN)' - const p_description = 'This is a test fertilizer' - const p_id_catalogue = await addFertilizerToCatalogue( - fdm, - 'custom', - p_name_nl, - p_name_en, - p_description, - { - p_dm: 37, - p_density: 20, - p_om: 20, - p_a: 30, - p_hc: 40, - p_eom: 50, - p_eoc: 60, - p_c_rt: 70, - p_c_of: 80, - p_c_if: 90, - p_c_fr: 100, - p_cn_of: 110, - p_n_rt: 120, - p_n_if: 130, - p_n_of: 140, - p_n_wc: 150, - p_p_rt: 160, - p_k_rt: 170, - p_mg_rt: 180, - p_ca_rt: 190, - p_ne: 200, - p_s_rt: 210, - p_s_wc: 220, - p_cu_rt: 230, - p_zn_rt: 240, - p_na_rt: 250, - p_si_rt: 260, - p_b_rt: 270, - p_mn_rt: 280, - p_ni_rt: 290, - p_fe_rt: 300, - p_mo_rt: 310, - p_co_rt: 320, - p_as_rt: 330, - p_cd_rt: 340, - pr_cr_rt: 350, - p_cr_vi: 360, - p_pb_rt: 370, - p_hg_rt: 380, - p_cl_rt: 390, - p_type_manure: true, - p_type_mineral: false, - p_type_compost: false - } - ) - + const p_id_catalogue = 'test-fertilizer-id' // Use a predefined ID for testing const p_amount = 1000 const p_date_acquiring = new Date() const p_id = await addFertilizer( @@ -173,154 +120,34 @@ describe('Farm Data Model', () => { p_date_acquiring ) expect(p_id).toBeDefined() + + const fertilizer = await getFertilizer(fdm, p_id) + expect(fertilizer.p_id).toBeDefined() }) - it('should remove a fertilizer', async () => { + it('should get fertilizers by farm ID', async () => { const farmName = 'Test Farm' const farmSector = 'diary' const b_id_farm = await addFarm(fdm, farmName, farmSector) - const p_name_nl = 'Test Fertilizer' - const p_name_en = 'Test Fertilizer (EN)' - const p_description = 'This is a test fertilizer' - const p_id_catalogue = await addFertilizerToCatalogue( - fdm, - 'custom', - p_name_nl, - p_name_en, - p_description, - { - p_dm: 37, - p_density: 20, - p_om: 20, - p_a: 30, - p_hc: 40, - p_eom: 50, - p_eoc: 60, - p_c_rt: 70, - p_c_of: 80, - p_c_if: 90, - p_c_fr: 100, - p_cn_of: 110, - p_n_rt: 120, - p_n_if: 130, - p_n_of: 140, - p_n_wc: 150, - p_p_rt: 160, - p_k_rt: 170, - p_mg_rt: 180, - p_ca_rt: 190, - p_ne: 200, - p_s_rt: 210, - p_s_wc: 220, - p_cu_rt: 230, - p_zn_rt: 240, - p_na_rt: 250, - p_si_rt: 260, - p_b_rt: 270, - p_mn_rt: 280, - p_ni_rt: 290, - p_fe_rt: 300, - p_mo_rt: 310, - p_co_rt: 320, - p_as_rt: 330, - p_cd_rt: 340, - pr_cr_rt: 350, - p_cr_vi: 360, - p_pb_rt: 370, - p_hg_rt: 380, - p_cl_rt: 390, - p_type_manure: true, - p_type_mineral: false, - p_type_compost: false - } - ) - + const p_id_catalogue = 'test-fertilizer-id' const p_amount = 1000 const p_date_acquiring = new Date() - const p_id = await addFertilizer( - fdm, - p_id_catalogue, - b_id_farm, - p_amount, - p_date_acquiring - ) - expect(p_id).toBeDefined() - await removeFertilizer(fdm, p_id) + // Add two fertilizers to the farm + await addFertilizer(fdm, p_id_catalogue, b_id_farm, p_amount, p_date_acquiring) + await addFertilizer(fdm, p_id_catalogue, b_id_farm, 1500, p_date_acquiring) - const fertilizers = await getFertilizersFromCatalogue(fdm) - expect(fertilizers.length).toBeGreaterThanOrEqual(1) - const fertilizer = fertilizers.find( - (f) => f.p_id_catalogue === p_id_catalogue - ) - expect(fertilizer).toBeDefined() - expect(fertilizer?.p_name_nl).toBe(p_name_nl) - expect(fertilizer?.p_name_en).toBe(p_name_en) - expect(fertilizer?.p_description).toBe(p_description) + const fertilizers = await getFertilizers(fdm, b_id_farm) + expect(fertilizers.length).toBe(2) }) - it('should get a fertilizer by ID', async () => { + it('should remove a fertilizer', async () => { const farmName = 'Test Farm' const farmSector = 'diary' const b_id_farm = await addFarm(fdm, farmName, farmSector) - const p_name_nl = 'Test Fertilizer' - const p_name_en = 'Test Fertilizer (EN)' - const p_description = 'This is a test fertilizer' - const p_id_catalogue = await addFertilizerToCatalogue( - fdm, - 'custom', - p_name_nl, - p_name_en, - p_description, - { - p_dm: 37, - p_density: 20, - p_om: 20, - p_a: 30, - p_hc: 40, - p_eom: 50, - p_eoc: 60, - p_c_rt: 70, - p_c_of: 80, - p_c_if: 90, - p_c_fr: 100, - p_cn_of: 110, - p_n_rt: 120, - p_n_if: 130, - p_n_of: 140, - p_n_wc: 150, - p_p_rt: 160, - p_k_rt: 170, - p_mg_rt: 180, - p_ca_rt: 190, - p_ne: 200, - p_s_rt: 210, - p_s_wc: 220, - p_cu_rt: 230, - p_zn_rt: 240, - p_na_rt: 250, - p_si_rt: 260, - p_b_rt: 270, - p_mn_rt: 280, - p_ni_rt: 290, - p_fe_rt: 300, - p_mo_rt: 310, - p_co_rt: 320, - p_as_rt: 330, - p_cd_rt: 340, - pr_cr_rt: 350, - p_cr_vi: 360, - p_pb_rt: 370, - p_hg_rt: 380, - p_cl_rt: 390, - p_type_manure: true, - p_type_mineral: false, - p_type_compost: false - } - ) - + const p_id_catalogue = 'test-fertilizer-id' const p_amount = 1000 const p_date_acquiring = new Date() const p_id = await addFertilizer( @@ -332,13 +159,10 @@ describe('Farm Data Model', () => { ) expect(p_id).toBeDefined() + await removeFertilizer(fdm, p_id) + const fertilizer = await getFertilizer(fdm, p_id) - expect(fertilizer).toBeDefined() - expect(fertilizer.p_name_nl).toBe(p_name_nl) - expect(fertilizer.p_name_en).toBe(p_name_en) - expect(fertilizer.p_description).toBe(p_description) - expect(fertilizer.p_amount).toBe(p_amount) - expect(fertilizer.p_date_acquiring).toEqual(p_date_acquiring) + expect(fertilizer.p_id).toBeUndefined() }) }) }) diff --git a/fdm-core/src/fertilizer.ts b/fdm-core/src/fertilizer.ts index bb1513406..4ded110f0 100644 --- a/fdm-core/src/fertilizer.ts +++ b/fdm-core/src/fertilizer.ts @@ -30,11 +30,12 @@ export async function getFertilizersFromCatalogue(fdm: FdmType): Promise { - - // Generate an ID for the fertilizer catalogue item - const p_id_catalogue = nanoid() + }): Promise { // Insert the farm in the db - const fertilizerData = { - p_id_catalogue: p_id_catalogue, - p_source: p_source, - p_name_nl: p_name_nl, - p_name_en: p_name_en, - p_description: p_description, - ...properties - } - await fdm .insert(schema.fertilizersCatalogue) - .values(fertilizerData) - - return p_id_catalogue + .values(properties) } diff --git a/fdm-data/src/fertilizers/index.test.ts b/fdm-data/src/fertilizers/index.test.ts index 33a25b6fd..49fc546b0 100644 --- a/fdm-data/src/fertilizers/index.test.ts +++ b/fdm-data/src/fertilizers/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, beforeEach } from 'vitest' -import { fdmSchema as schema, type FdmType } from '@svenvw/fdm-core' +import { getFertilizersFromCatalogue, fdmSchema as schema, type FdmType } from '@svenvw/fdm-core' import { extendFertilizersCatalogue } from '.' import { drizzle } from 'drizzle-orm/postgres-js' @@ -52,7 +52,7 @@ describe('Fertilizers Data [server]', () => { it('should extend fertilizers catalogue with srm dataset', async () => { await extendFertilizersCatalogue(fdm, 'srm') - const result = await fdm.select().from(fdm.schema.fertilizersCatalogue) + const result = await getFertilizersFromCatalogue(fdm) expect(result.length).toBeGreaterThan(0) }) }) diff --git a/fdm-data/src/fertilizers/index.ts b/fdm-data/src/fertilizers/index.ts index 9c0e15f8a..09c32166d 100644 --- a/fdm-data/src/fertilizers/index.ts +++ b/fdm-data/src/fertilizers/index.ts @@ -18,21 +18,21 @@ export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: st const fertilizersCatalogue = await getFertilizersFromCatalogue(fdm) // Add fertilizers to catalogue - catalogue.map(async fertilizer => { + await Promise.all(catalogue.map(async fertilizer => { // Check if fertilizer is already present in catalogue const fertilizerInCatalogue = fertilizersCatalogue.find((x: fdmSchema.fertilizersCatalogueTypeSelect): any => x.p_id_catalogue === fertilizer.p_id_catalogue) // If fertilizer is not present in catalogue, add it to fdm instance - if (! fertilizerInCatalogue) { - await addFertilizerToCatalogue({ - fdm: fdm, - p_id_catalogue: fertilizer.p_id_catalogue, - p_source: fertilizer.p_source, - p_name_nl: fertilizer.p_name_nl, - p_name_en: fertilizer.p_name_en, - p_description: fertilizer.p_description, - properties: { + if (!fertilizerInCatalogue) { + await addFertilizerToCatalogue( + fdm, + { + p_id_catalogue: fertilizer.p_id_catalogue, + p_source: fertilizer.p_source, + p_name_nl: fertilizer.p_name_nl, + p_name_en: fertilizer.p_name_en, + p_description: fertilizer.p_description, p_dm: fertilizer.p_dm, p_density: fertilizer.p_density, p_om: fertilizer.p_om, @@ -76,7 +76,7 @@ export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: st p_type_mineral: fertilizer.p_type_mineral, p_type_compost: fertilizer.p_type_compost } - }) - } - }) + ) + } + })) } \ No newline at end of file From 829776554c23ff032b60ed36110a2032629210b9 Mon Sep 17 00:00:00 2001 From: Sven Verweij <37927107+SvenVw@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:56:15 +0100 Subject: [PATCH 35/35] Bump version numbers and update changelog --- .changeset/brave-shoes-build.md | 5 ----- .changeset/tidy-ducks-dream.md | 5 ----- .changeset/twelve-steaks-exercise.md | 5 ----- fdm-core/CHANGELOG.md | 7 +++++++ fdm-core/package.json | 2 +- fdm-data/CHANGELOG.md | 12 ++++++++++++ fdm-data/package.json | 6 +++--- 7 files changed, 23 insertions(+), 19 deletions(-) delete mode 100644 .changeset/brave-shoes-build.md delete mode 100644 .changeset/tidy-ducks-dream.md delete mode 100644 .changeset/twelve-steaks-exercise.md diff --git a/.changeset/brave-shoes-build.md b/.changeset/brave-shoes-build.md deleted file mode 100644 index 460151589..000000000 --- a/.changeset/brave-shoes-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@svenvw/fdm-data": minor ---- - -Add `srm` as option for `datasetName` at `extendFertilizersCatalogue` diff --git a/.changeset/tidy-ducks-dream.md b/.changeset/tidy-ducks-dream.md deleted file mode 100644 index 29999e1d5..000000000 --- a/.changeset/tidy-ducks-dream.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@svenvw/fdm-data": patch ---- - -Add workflow for prereleases diff --git a/.changeset/twelve-steaks-exercise.md b/.changeset/twelve-steaks-exercise.md deleted file mode 100644 index 98ddbe40a..000000000 --- a/.changeset/twelve-steaks-exercise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@svenvw/fdm-core": minor ---- - -Add to `fertilizers_catalogue` the columns:`p_density`, `p_type_manure`, `p_type_mineral` and `p_type_compost` diff --git a/fdm-core/CHANGELOG.md b/fdm-core/CHANGELOG.md index 669787753..2b05d459a 100644 --- a/fdm-core/CHANGELOG.md +++ b/fdm-core/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog fdm-core +## 0.4.0 + +### Minor Changes + +- For `addFertilizersToCatalogue` include all parameters in `properties` +- a2ee857: Add to `fertilizers_catalogue` the columns:`p_density`, `p_type_manure`, `p_type_mineral` and `p_type_compost` + ## 0.3.1 ### Patch Changes diff --git a/fdm-core/package.json b/fdm-core/package.json index d81f888bd..07d31de77 100644 --- a/fdm-core/package.json +++ b/fdm-core/package.json @@ -1,7 +1,7 @@ { "name": "@svenvw/fdm-core", "private": false, - "version": "0.3.1", + "version": "0.4.0", "description": "Interface for the Farm Data Model", "license": "MIT", "homepage": "https://svenvw.github.io/fdm/", diff --git a/fdm-data/CHANGELOG.md b/fdm-data/CHANGELOG.md index f1b188350..6f421b46c 100644 --- a/fdm-data/CHANGELOG.md +++ b/fdm-data/CHANGELOG.md @@ -1,5 +1,17 @@ # fdm-data +## 0.2.0 +### Minor Changes + +- e62c51d: Add `srm` as option for `datasetName` at `extendFertilizersCatalogue` + +### Patch Changes + +- 08ac0ed: Add workflow for prereleases +- Updated dependencies +- Updated dependencies [a2ee857] + - @svenvw/fdm-core@0.4.0 + ## 0.1.1 ### Patch Changes diff --git a/fdm-data/package.json b/fdm-data/package.json index 354ebb6d2..f99fe70be 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -1,7 +1,7 @@ { "name": "@svenvw/fdm-data", "private": false, - "version": "0.1.1", + "version": "0.2.0", "description": "Extend Farm Data Model with catalogue data", "license": "MIT", "homepage": "https://github.com/SvenVw/fdm", @@ -58,10 +58,10 @@ "vitest": "^2.0.5" }, "peerDependencies": { - "@svenvw/fdm-core": "workspace:>=0.3.1" + "@svenvw/fdm-core": "workspace:>=0.4.0" }, "packageManager": "pnpm@9.12.2", "publishConfig": { "registry": "https://npm.pkg.github.com" - } + } } \ No newline at end of file