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.yml b/.github/workflows/prerelease.yml new file mode 100644 index 000000000..013361fc9 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,61 @@ +name: Prerelease + +on: + pull_request: + paths: + - 'fdm-core/**' + - 'fdm-data/**' + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + prerelease: + name: Prerelease + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20] + permissions: + contents: read + packages: write + steps: + - 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: + 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: 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: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file 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 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 d446a84b1..443b6aede 100644 --- a/fdm-calculator/package.json +++ b/fdm-calculator/package.json @@ -45,13 +45,15 @@ "lint": "eslint ." }, "devDependencies": { + "@dotenvx/dotenvx": "^1.20.0", + "@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-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 1d57f965c..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/", @@ -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" @@ -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-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..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,25 +26,28 @@ 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, p_a: 30, p_hc: 40, @@ -83,9 +86,11 @@ 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() const fertilizers = await getFertilizersFromCatalogue(fdm) expect(fertilizers.length).toBeGreaterThanOrEqual(1) @@ -93,68 +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_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, - } - ) - + 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( @@ -165,146 +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_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, - } - ) - + 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_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, - } - ) - + const p_id_catalogue = 'test-fertilizer-id' const p_amount = 1000 const p_date_acquiring = new Date() const p_id = await addFertilizer( @@ -316,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 7f6e42dbe..4ded110f0 100644 --- a/fdm-core/src/fertilizer.ts +++ b/fdm-core/src/fertilizer.ts @@ -30,12 +30,14 @@ export async function getFertilizersFromCatalogue(fdm: FdmType): Promise { - - // Generate an ID for the fertilizer catalogue item - const p_id_catalogue = nanoid() + 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 { // 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/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 d1464affb..f99fe70be 100644 --- a/fdm-data/package.json +++ b/fdm-data/package.json @@ -1,10 +1,14 @@ { - "name": "fdm-data", - "private": true, - "version": "0.1.1", + "name": "@svenvw/fdm-data", + "private": false, + "version": "0.2.0", "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", @@ -46,13 +50,18 @@ }, "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", "vitest": "^2.0.5" }, - "dependencies": { - "fdm-core": "workspace:*" + "peerDependencies": { + "@svenvw/fdm-core": "workspace:>=0.4.0" }, - "packageManager": "pnpm@9.12.2" + "packageManager": "pnpm@9.12.2", + "publishConfig": { + "registry": "https://npm.pkg.github.com" + } } \ No newline at end of file diff --git a/fdm-data/src/fertilizers.test.ts b/fdm-data/src/fertilizers.test.ts deleted file mode 100644 index f3915e07a..000000000 --- a/fdm-data/src/fertilizers.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { describe, expect, it, beforeEach } from 'vitest' -import { createFdmLocal, migrateFdmLocal, type FdmType } from 'fdm-core' -import { extendFertilizersCatalogue } from './fertilizers' - -describe('Fertilizers Data', () => { - let fdm: FdmType - - beforeEach(async () => { - fdm = await createFdmLocal('memory://') - await migrateFdmLocal(fdm) - }) - - 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') - }) - - it('should extend fertilizers catalogue with test dataset', async () => { - await extendFertilizersCatalogue(fdm, 'test') - - 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) - }) -}) \ No newline at end of file diff --git a/fdm-data/src/fertilizers.ts b/fdm-data/src/fertilizers.ts deleted file mode 100644 index 8145abfcc..000000000 --- a/fdm-data/src/fertilizers.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { addFertilizerToCatalogue, type FdmType, fdmSchema } from "fdm-core"; - -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 (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 - }) - }) - } - -} \ No newline at end of file diff --git a/fdm-data/src/fertilizers/catalogues/srm.json b/fdm-data/src/fertilizers/catalogues/srm.json new file mode 100644 index 000000000..0a9fc86ed --- /dev/null +++ b/fdm-data/src/fertilizers/catalogues/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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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_mineral": 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/catalogues/srm.ts b/fdm-data/src/fertilizers/catalogues/srm.ts new file mode 100644 index 000000000..31a94c9af --- /dev/null +++ b/fdm-data/src/fertilizers/catalogues/srm.ts @@ -0,0 +1,14 @@ +import srm from './srm.json' +import { fdmSchema } from '@svenvw/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/index.test.ts b/fdm-data/src/fertilizers/index.test.ts new file mode 100644 index 000000000..49fc546b0 --- /dev/null +++ b/fdm-data/src/fertilizers/index.test.ts @@ -0,0 +1,58 @@ +import { describe, expect, it, beforeEach } from 'vitest' +import { getFertilizersFromCatalogue, fdmSchema as schema, type FdmType } from '@svenvw/fdm-core' +import { extendFertilizersCatalogue } from '.' + +import { drizzle } from 'drizzle-orm/postgres-js' +import { migrate } from 'drizzle-orm/postgres-js/migrator' + +describe('Fertilizers Data [server]', () => { + let fdm: FdmType + + beforeEach(async () => { + + 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 () => { + 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 () => { + await extendFertilizersCatalogue(fdm, 'srm') + + 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 new file mode 100644 index 000000000..09c32166d --- /dev/null +++ b/fdm-data/src/fertilizers/index.ts @@ -0,0 +1,82 @@ +import { addFertilizerToCatalogue, getFertilizersFromCatalogue, type FdmType, fdmSchema } from "@svenvw/fdm-core"; +import { getCatalogueSrm } from "./catalogues/srm"; + +export async function extendFertilizersCatalogue(fdm: FdmType, catalogueName: string): Promise { + + // Get the specified catalogue + let catalogue: fdmSchema.fertilizersCatalogueTypeInsert[] = [] + if (catalogueName == 'srm') { + catalogue = getCatalogueSrm() + } + + // 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 + 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, + { + 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, + 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, + p_type_manure: fertilizer.p_type_manure, + p_type_mineral: fertilizer.p_type_mineral, + p_type_compost: fertilizer.p_type_compost + } + ) + } + })) +} \ No newline at end of file diff --git a/fdm-data/vite.config.ts b/fdm-data/vite.config.ts index b33e20a27..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'), diff --git a/package.json b/package.json index 2bf25dfa0..715c024f5 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,42 @@ { - "name": "fdm-source", + "name": "@svenvw/fdm-source", "version": "0.0.0", "description": "Monorepo for fdm", "homepage": "https://github.com/SvenVw/fdm", "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", "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=@svenvw/fdm-core --filter=@svenvw/fdm-data && changeset publish " }, "devDependencies": { "@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 + } + } + } + } + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dcd97fd81..2addb5c9a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,14 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + drizzle-orm: + specifier: ^0.35.3 + version: 0.35.3 + +packageExtensionsChecksum: 29a6694e1052b064eec0acf6b5bbd138 + importers: .: @@ -15,25 +23,6 @@ importers: specifier: ^2.2.3 version: 2.2.3 - fdm-calculator: - dependencies: - fdm-core: - specifier: workspace:* - version: link:../fdm-core - devDependencies: - 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': @@ -43,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 @@ -102,14 +91,16 @@ importers: version: 2.1.3(@types/node@22.7.9)(terser@5.36.0) fdm-data: - dependencies: - 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 + 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 @@ -804,6 +795,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'} @@ -7097,6 +7092,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 @@ -8315,14 +8314,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 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 88c5c7bac..b31362909 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,8 @@ packages: - 'fdm-core' - 'fdm-data' - - 'fdm-calculator' - - 'fdm-docs' \ No newline at end of file + # - 'fdm-calculator' + - 'fdm-docs' + +catalog: + drizzle-orm: ^0.35.3 \ No newline at end of file