Skip to main content

getNSupply

@nmi-agro/fdm-source


@nmi-agro/fdm-source / fdm-calculator/src / getNSupply

Variable: getNSupply

const getNSupply: any

Defined in: fdm-calculator/src/mineralization/nsupply.ts:179

DB-backed cached version of requestNSupply.

Uses withCalculationCache from @nmi-agro/fdm-core to persist results in the FDM database. The cache key is derived from a hash of the input (excluding nmiApiKey which is redacted). The cache is automatically invalidated when the request body changes (e.g. soil data updated, different method selected) or when the package version changes.

Signature: (fdm: FdmType, input: NSupplyComputeInput) => Promise<NSupplyResult>

Cache parameters:

  • Function name: "requestNSupply"
  • Version: pkg.calculatorVersion (invalidates on package upgrades)
  • Sensitive keys: ["nmiApiKey"] (redacted from cache key hash)

Example

import { getNSupply } from "@nmi-agro/fdm-calculator"

const result = await getNSupply(fdm, {
b_id: "field_abc",
b_name: "Perceel Noord",
nmiApiKey: env.NMI_API_KEY,
requestBody: buildNSupplyRequest(field, soilData, cultivations, "minip", timeframe),
method: "minip",
completeness,
})