@agencebio/rosetta-cultures
Advanced tools
Comparing version 1.8.5 to 2.0.0
/** | ||
* Built with `npm run build` | ||
* | ||
* @type {Object.<String, Cepage>} | ||
* @module cepages | ||
* @deprecated | ||
*/ | ||
import cepages from './data/cepages.json' assert { type: 'json' } | ||
/** | ||
* @typedef Cepage | ||
* @property {String} code | ||
* @property {String} libelle | ||
* @property {CepageCouleur} couleur | ||
* @property {String=} code_cpf | ||
* @property {Boolean} is_selectable | ||
*/ | ||
export const CepageCouleur = { | ||
BLANC: 'Blanc', | ||
INDETERMINÉ: 'Indéterminé', | ||
NOIR: 'Noir', | ||
ROUGE: 'Rouge', | ||
ROSÉ: 'Rose' | ||
} | ||
export const CepageCatégorie = { | ||
Cuve: '01.21.12', | ||
Multiplication: '01.21.1', | ||
Table: '01.21.11', | ||
Mixte: '01.21.1', | ||
Interdit: '01.21.1' | ||
} | ||
export function cepageCategorieCpf (categorie) { | ||
return CepageCatégorie[String(categorie)] ?? null | ||
} | ||
export function fromCepageCode (code) { | ||
return cepages[String(code)] ?? null | ||
} | ||
export { fromCepageCode } from './src/converters.js' | ||
export * from './src/cepages.js' |
import { describe, it } from 'node:test' | ||
import { ok, deepEqual } from 'node:assert/strict' | ||
import { deepEqual } from 'node:assert/strict' | ||
import { CepageCouleur, fromCepageCode } from './cepages.js' | ||
import cepages from './data/cepages.json' assert { type: 'json' } | ||
@@ -7,0 +6,0 @@ describe('fromCepageCode()', () => { |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fromCepageCode = exports.cepageCategorieCpf = exports.CepageCatégorie = exports.CepageCouleur = void 0; | ||
/** | ||
* Built with `npm run build` | ||
* | ||
* @type {Object.<String, Cepage>} | ||
* @module cepages | ||
* @deprecated | ||
*/ | ||
var cepages_json_1 = __importDefault(require("./data/cepages.json")); | ||
/** | ||
* @typedef Cepage | ||
* @property {String} code | ||
* @property {String} libelle | ||
* @property {CepageCouleur} couleur | ||
* @property {String=} code_cpf | ||
* @property {Boolean} is_selectable | ||
*/ | ||
exports.CepageCouleur = { | ||
BLANC: 'Blanc', | ||
INDETERMINÉ: 'Indéterminé', | ||
NOIR: 'Noir', | ||
ROUGE: 'Rouge', | ||
ROSÉ: 'Rose' | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
exports.CepageCatégorie = { | ||
Cuve: '01.21.12', | ||
Multiplication: '01.21.1', | ||
Table: '01.21.11', | ||
Mixte: '01.21.1', | ||
Interdit: '01.21.1' | ||
}; | ||
function cepageCategorieCpf(categorie) { | ||
var _a; | ||
return (_a = exports.CepageCatégorie[String(categorie)]) !== null && _a !== void 0 ? _a : null; | ||
} | ||
exports.cepageCategorieCpf = cepageCategorieCpf; | ||
function fromCepageCode(code) { | ||
var _a; | ||
return (_a = cepages_json_1.default[String(code)]) !== null && _a !== void 0 ? _a : null; | ||
} | ||
exports.fromCepageCode = fromCepageCode; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fromCepageCode = void 0; | ||
var converters_js_1 = require("./src/converters.js"); | ||
Object.defineProperty(exports, "fromCepageCode", { enumerable: true, get: function () { return converters_js_1.fromCepageCode; } }); | ||
__exportStar(require("./src/cepages.js"), exports); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createCpfResolver = exports.toBoolean = exports.isOrganicProductionCode = exports.fromCodeGeofolia = exports.fromCodeCpf = exports.fromCodePacAll = exports.fromCodePacFirst = exports.fromCodePacStrict = exports.fromCodePac = void 0; | ||
__exportStar(require("./src/converters.js"), exports); | ||
__exportStar(require("./src/resolvers.js"), exports); | ||
__exportStar(require("./src/cepages.js"), exports); | ||
/** | ||
* Built with `npm run build` | ||
* | ||
* @type {Array.<UnifiedCulture>} | ||
*/ | ||
var cpf_json_1 = __importDefault(require("./data/cpf.json")); | ||
/** | ||
* @typedef UnifiedCulture | ||
@@ -26,2 +33,7 @@ * @property {String} code_cpf | ||
/** | ||
* @typedef {Omit<UnifiedCulture, 'cultures_pac'> & { | ||
* cultures_pac: Array<Array<string>> | ||
* }} CPFCulture | ||
*/ | ||
/** | ||
* @typedef PacCulture | ||
@@ -34,172 +46,8 @@ * @property {String} code | ||
/** | ||
* @deprecated since version 1.4.0 | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
* @typedef Cepage | ||
* @property {String} code | ||
* @property {String} libelle | ||
* @property {import('./src/cepages.js').CepageCouleur} couleur | ||
* @property {String=} code_cpf | ||
* @property {Boolean} is_selectable | ||
*/ | ||
function fromCodePac(code, precision) { | ||
console.warn("fromCodePac is deprecated, use fromCodePacFirst instead"); | ||
return fromCodePacFirst(code, precision); | ||
} | ||
exports.fromCodePac = fromCodePac; | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
function fromCodePacStrict(code, precision) { | ||
var _a; | ||
var allMatchs = fromCodePacAll(code, precision); | ||
var codes = allMatchs.map(function (_a) { | ||
var code_cpf = _a.code_cpf; | ||
return code_cpf; | ||
}); | ||
var commonPrefix = codes.reduce(function (acc, code) { | ||
var i = 0; | ||
while (code[i] === acc[i] && i < acc.length) { | ||
i++; | ||
} | ||
return code.slice(0, i); | ||
}, (_a = codes[0]) !== null && _a !== void 0 ? _a : '').replace(/\.$/, "").split("."); | ||
if (commonPrefix.length < 2) { | ||
return null; | ||
} | ||
var commonPrefixString = commonPrefix.join("."); | ||
return cpf_json_1.default.find(function (_a) { | ||
var code_cpf = _a.code_cpf; | ||
return code_cpf === commonPrefixString; | ||
}); | ||
} | ||
exports.fromCodePacStrict = fromCodePacStrict; | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
function fromCodePacFirst(code, precision) { | ||
return fromCodePacAll(code, precision)[0] || null; | ||
} | ||
exports.fromCodePacFirst = fromCodePacFirst; | ||
/** | ||
* Return all CPF codes associated to a given PAC code | ||
* | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {UnifiedCulture[]} | ||
*/ | ||
function fromCodePacAll(code, precision) { | ||
if (precision === void 0) { precision = null; } | ||
if (precision) { | ||
var cleanedPrecision_1 = String(precision).padStart(3, '0'); | ||
var results = cpf_json_1.default.filter(function (_a) { | ||
var cultures_pac = _a.cultures_pac; | ||
return cultures_pac.some(function (culture) { | ||
return culture.code === code && culture.precision === cleanedPrecision_1; | ||
}); | ||
}); | ||
if (results.length) { | ||
return results; | ||
} | ||
} | ||
// otherwise, and in any case, we lookup results without precision | ||
return cpf_json_1.default.filter(function (_a) { | ||
var cultures_pac = _a.cultures_pac; | ||
return cultures_pac.some(function (culture) { | ||
return culture.code === code && culture.precision === ''; | ||
}); | ||
}); | ||
} | ||
exports.fromCodePacAll = fromCodePacAll; | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture} | ||
*/ | ||
function fromCodeCpf(code) { | ||
return cpf_json_1.default.find(function (_a) { | ||
var code_cpf = _a.code_cpf; | ||
return code_cpf === code; | ||
}); | ||
} | ||
exports.fromCodeCpf = fromCodeCpf; | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture|null} | ||
*/ | ||
function fromCodeGeofolia(code) { | ||
var _a; | ||
if (typeof code !== 'string') { | ||
return null; | ||
} | ||
var cleanCode = code.trim().replace(/\s+/g, ' '); | ||
return (_a = cpf_json_1.default.find(function (_a) { | ||
var codes_geofolia = _a.codes_geofolia; | ||
return codes_geofolia.includes(cleanCode); | ||
})) !== null && _a !== void 0 ? _a : null; | ||
} | ||
exports.fromCodeGeofolia = fromCodeGeofolia; | ||
/** | ||
* @see https://mattermost.incubateur.net/betagouv/pl/nn6psexgw3bedq16yisrpj777h | ||
* > Oui 01 et 02 en enlevant les productions animales | ||
* > En enlevant 01.4, 01.5 et 01.6 | ||
* > En ajoutant `08.93.1` (équivalent PAC de `MRS`/Marais salant) | ||
*/ | ||
var CPF_ORGANIC_PRODUCTION_RE = /^(01(?!.[456][1-9]?(.\d{1,3})*).+|02(.\d{1,3})+|08.93.1)$/; | ||
/** | ||
* | ||
* @param {String} code | ||
* @returns {Boolean} | ||
*/ | ||
function isOrganicProductionCode(code) { | ||
return CPF_ORGANIC_PRODUCTION_RE.test(code); | ||
} | ||
exports.isOrganicProductionCode = isOrganicProductionCode; | ||
/** | ||
* Returns a JavaScript boolean from an Excel string value of '0' or '1' | ||
* | ||
* @param {String} excelLikeBoolean | ||
* @returns {Boolean} | ||
*/ | ||
function toBoolean(excelLikeBoolean) { | ||
return Boolean(parseInt(excelLikeBoolean, 10)); | ||
} | ||
exports.toBoolean = toBoolean; | ||
/** | ||
* | ||
* @param {UnifiedCulture[]} cultures | ||
* @returns {function(String):UnifiedCulture[]} | ||
*/ | ||
function createCpfResolver(cultures) { | ||
var HAS_MANY_RE = /,/g; | ||
var HAS_GLOB_RE = /\*/g; | ||
var filterByValues = function (parts) { return function (code_cpf) { return parts.includes(code_cpf); }; }; | ||
var filterByGlob = function (parts) { return function (code_cpf) { return parts.some(function (part) { | ||
if (part.search(HAS_GLOB_RE) !== -1) { | ||
return code_cpf.startsWith(part.split(HAS_GLOB_RE).at(0)); | ||
} | ||
else { | ||
return code_cpf === part; | ||
} | ||
}); }; }; | ||
/** | ||
* We have multiple resolution strategies | ||
* 1. one-to-one (xx.yy.zz) | ||
* 2. one-to-explicit-many (xx.yy.z1, xx.yy.z2) | ||
* 3. one-to-range-of-many (xx.yy.*) - correspondance_cartobio = 0 | ||
* 4. lists of all of the above (xx.yy.z1, xx.aa.*, zz.*) | ||
* | ||
* @param {String} selector | ||
* @param {String=} precision | ||
* @returns {UnifiedCulture[]} | ||
*/ | ||
return function cpfResolver(selector, precision) { | ||
if (precision === void 0) { precision = null; } | ||
var parts = selector.split(HAS_MANY_RE).map(function (maybeSelector) { return maybeSelector.trim(); }); | ||
var hasGlob = selector.search(HAS_GLOB_RE) !== -1; | ||
var strategyFn = hasGlob ? filterByGlob(parts) : filterByValues(parts); | ||
return cultures.filter(function (_a) { | ||
var code_cpf = _a.code_cpf; | ||
return strategyFn(code_cpf); | ||
}); | ||
}; | ||
} | ||
exports.createCpfResolver = createCpfResolver; |
@@ -1,76 +0,4 @@ | ||
/** | ||
* @typedef UnifiedCulture | ||
* @property {String} code_cpf | ||
* @property {String} libelle_code_cpf | ||
* @property {String} code_cpf_alias | ||
* @property {String=} code_bureau_veritas | ||
* @property {String[]} codes_geofolia | ||
* @property {Boolean} is_selectable | ||
* @property {String} groupe | ||
* @property {String} sous_groupe | ||
* @property {Array.<PacCulture>} cultures_pac | ||
*/ | ||
/** | ||
* @typedef PacCulture | ||
* @property {String} code | ||
* @property {String} precision | ||
* @property {String} libelle | ||
* @property {Boolean} requires_precision | ||
*/ | ||
/** | ||
* @deprecated since version 1.4.0 | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
export function fromCodePac(code: string, precision?: string | undefined): UnifiedCulture | null; | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
export function fromCodePacStrict(code: string, precision?: string | undefined): UnifiedCulture | null; | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
export function fromCodePacFirst(code: string, precision?: string | undefined): UnifiedCulture | null; | ||
/** | ||
* Return all CPF codes associated to a given PAC code | ||
* | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {UnifiedCulture[]} | ||
*/ | ||
export function fromCodePacAll(code: string, precision?: string | undefined): UnifiedCulture[]; | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture} | ||
*/ | ||
export function fromCodeCpf(code: string): UnifiedCulture; | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture|null} | ||
*/ | ||
export function fromCodeGeofolia(code: string): UnifiedCulture | null; | ||
/** | ||
* | ||
* @param {String} code | ||
* @returns {Boolean} | ||
*/ | ||
export function isOrganicProductionCode(code: string): boolean; | ||
/** | ||
* Returns a JavaScript boolean from an Excel string value of '0' or '1' | ||
* | ||
* @param {String} excelLikeBoolean | ||
* @returns {Boolean} | ||
*/ | ||
export function toBoolean(excelLikeBoolean: string): boolean; | ||
/** | ||
* | ||
* @param {UnifiedCulture[]} cultures | ||
* @returns {function(String):UnifiedCulture[]} | ||
*/ | ||
export function createCpfResolver(cultures: UnifiedCulture[]): (arg0: string) => UnifiedCulture[]; | ||
export * from "./src/converters.js"; | ||
export * from "./src/resolvers.js"; | ||
export * from "./src/cepages.js"; | ||
export type UnifiedCulture = { | ||
@@ -87,2 +15,5 @@ code_cpf: string; | ||
}; | ||
export type CPFCulture = Omit<UnifiedCulture, 'cultures_pac'> & { | ||
cultures_pac: Array<Array<string>>; | ||
}; | ||
export type PacCulture = { | ||
@@ -94,1 +25,8 @@ code: string; | ||
}; | ||
export type Cepage = { | ||
code: string; | ||
libelle: string; | ||
couleur: any; | ||
code_cpf?: string | undefined; | ||
is_selectable: boolean; | ||
}; |
180
index.js
@@ -1,7 +0,4 @@ | ||
/** | ||
* Built with `npm run build` | ||
* | ||
* @type {Array.<UnifiedCulture>} | ||
*/ | ||
import cpf from './data/cpf.json' assert { type: 'json' } | ||
export * from './src/converters.js' | ||
export * from './src/resolvers.js' | ||
export * from './src/cepages.js' | ||
@@ -22,2 +19,8 @@ /** | ||
/** | ||
* @typedef {Omit<UnifiedCulture, 'cultures_pac'> & { | ||
* cultures_pac: Array<Array<string>> | ||
* }} CPFCulture | ||
*/ | ||
/** | ||
* @typedef PacCulture | ||
@@ -31,162 +34,9 @@ * @property {String} code | ||
/** | ||
* @deprecated since version 1.4.0 | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
* @typedef Cepage | ||
* @property {String} code | ||
* @property {String} libelle | ||
* @property {import('./src/cepages.js').CepageCouleur} couleur | ||
* @property {String=} code_cpf | ||
* @property {Boolean} is_selectable | ||
*/ | ||
export function fromCodePac (code, precision) { | ||
console.warn("fromCodePac is deprecated, use fromCodePacFirst instead") | ||
return fromCodePacFirst(code, precision) | ||
} | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
export function fromCodePacStrict (code, precision) { | ||
let allMatchs = fromCodePacAll(code, precision) | ||
let codes = allMatchs.map(({ code_cpf }) => code_cpf) | ||
let commonPrefix = codes.reduce((acc, code) => { | ||
let i = 0 | ||
while (code[i] === acc[i] && i < acc.length) { | ||
i++ | ||
} | ||
return code.slice(0, i) | ||
}, codes[0] ?? '').replace(/\.$/, "").split(".") | ||
if (commonPrefix.length < 2) { | ||
return null; | ||
} | ||
let commonPrefixString = commonPrefix.join(".") | ||
return cpf.find(({ code_cpf }) => code_cpf === commonPrefixString) | ||
} | ||
/** | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {?UnifiedCulture} | ||
*/ | ||
export function fromCodePacFirst (code, precision) { | ||
return fromCodePacAll(code, precision)[0] || null | ||
} | ||
/** | ||
* Return all CPF codes associated to a given PAC code | ||
* | ||
* @param {String} code | ||
* @param {String=} precision | ||
* @returns {UnifiedCulture[]} | ||
*/ | ||
export function fromCodePacAll (code, precision = null) { | ||
if (precision) { | ||
const cleanedPrecision = String(precision).padStart(3, '0') | ||
const results = cpf.filter(({ cultures_pac }) => { | ||
return cultures_pac.some(culture => { | ||
return culture.code === code && culture.precision === cleanedPrecision | ||
}) | ||
}) | ||
if (results.length) { | ||
return results | ||
} | ||
} | ||
// otherwise, and in any case, we lookup results without precision | ||
return cpf.filter(({ cultures_pac }) => { | ||
return cultures_pac.some(culture => { | ||
return culture.code === code && culture.precision === '' | ||
}) | ||
}) | ||
} | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture} | ||
*/ | ||
export function fromCodeCpf (code) { | ||
return cpf.find(({ code_cpf }) => code_cpf === code) | ||
} | ||
/** | ||
* @param {String} code | ||
* @returns {UnifiedCulture|null} | ||
*/ | ||
export function fromCodeGeofolia (code) { | ||
if (typeof code !== 'string') { | ||
return null | ||
} | ||
const cleanCode = code.trim().replace(/\s+/g, ' ') | ||
return cpf.find(({ codes_geofolia }) => codes_geofolia.includes(cleanCode)) ?? null | ||
} | ||
/** | ||
* @see https://mattermost.incubateur.net/betagouv/pl/nn6psexgw3bedq16yisrpj777h | ||
* > Oui 01 et 02 en enlevant les productions animales | ||
* > En enlevant 01.4, 01.5 et 01.6 | ||
* > En ajoutant `08.93.1` (équivalent PAC de `MRS`/Marais salant) | ||
*/ | ||
const CPF_ORGANIC_PRODUCTION_RE = /^(01(?!.[456][1-9]?(.\d{1,3})*).+|02(.\d{1,3})+|08.93.1)$/ | ||
/** | ||
* | ||
* @param {String} code | ||
* @returns {Boolean} | ||
*/ | ||
export function isOrganicProductionCode (code) { | ||
return CPF_ORGANIC_PRODUCTION_RE.test(code) | ||
} | ||
/** | ||
* Returns a JavaScript boolean from an Excel string value of '0' or '1' | ||
* | ||
* @param {String} excelLikeBoolean | ||
* @returns {Boolean} | ||
*/ | ||
export function toBoolean (excelLikeBoolean) { | ||
return Boolean(parseInt(excelLikeBoolean, 10)) | ||
} | ||
/** | ||
* | ||
* @param {UnifiedCulture[]} cultures | ||
* @returns {function(String):UnifiedCulture[]} | ||
*/ | ||
export function createCpfResolver (cultures) { | ||
const HAS_MANY_RE = /,/g | ||
const HAS_GLOB_RE = /\*/g | ||
const filterByValues = (parts) => (code_cpf) => parts.includes(code_cpf) | ||
const filterByGlob = (parts) => (code_cpf) => parts.some(part => { | ||
if (part.search(HAS_GLOB_RE) !== -1) { | ||
return code_cpf.startsWith(part.split(HAS_GLOB_RE).at(0)) | ||
} | ||
else { | ||
return code_cpf === part | ||
} | ||
}) | ||
/** | ||
* We have multiple resolution strategies | ||
* 1. one-to-one (xx.yy.zz) | ||
* 2. one-to-explicit-many (xx.yy.z1, xx.yy.z2) | ||
* 3. one-to-range-of-many (xx.yy.*) - correspondance_cartobio = 0 | ||
* 4. lists of all of the above (xx.yy.z1, xx.aa.*, zz.*) | ||
* | ||
* @param {String} selector | ||
* @param {String=} precision | ||
* @returns {UnifiedCulture[]} | ||
*/ | ||
return function cpfResolver (selector, precision = null) { | ||
const parts = selector.split(HAS_MANY_RE).map(maybeSelector => maybeSelector.trim()) | ||
const hasGlob = selector.search(HAS_GLOB_RE) !== -1 | ||
const strategyFn = hasGlob ? filterByGlob(parts) : filterByValues(parts) | ||
return cultures.filter(({ code_cpf }) => strategyFn(code_cpf)) | ||
} | ||
} |
@@ -10,5 +10,5 @@ import { describe, it } from 'node:test' | ||
isOrganicProductionCode, | ||
fromCodePacAll | ||
fromCodePacAll, attachPAC | ||
} from './index.js' | ||
import cultures from './data/cpf.json' assert { type: 'json' }; | ||
import data from './data/cpf.json' with { type: 'json' }; | ||
@@ -35,2 +35,4 @@ /** | ||
const cultures = data.CPF.map(attachPAC) | ||
describe('isOrganicProductionCode', () => { | ||
@@ -110,2 +112,6 @@ it('this is an organic production code', () => { | ||
it('works with non existent precision code', () => { | ||
deepEqual(fromCodePacStrict('MCR').code_cpf, "01.11.49.31") // Mélanges Céréaliers (sans légumineuses) | ||
deepEqual(fromCodePacStrict('MCR', '001').code_cpf, "01.11.49.31") // Mélanges Céréaliers (sans légumineuses) | ||
}) | ||
@@ -112,0 +118,0 @@ it('returns nothing for codes with no match', () => { |
{ | ||
"name": "@agencebio/rosetta-cultures", | ||
"version": "1.8.5", | ||
"version": "2.0.0", | ||
"description": "Traduction des codes cultures de la CPF vers la PAC vers des nomenclatures d'organismes de certification, et vice-versa.", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"build:json": "node bin/assemble.js", | ||
"build:types": "tsc --declaration --emitDeclarationOnly", | ||
"build:types": "tsc --declaration --emitDeclarationOnly ", | ||
"build:cjs": "tsc --esModuleInterop --CheckJs false --module commonjs --outDir dist/cjs", | ||
@@ -36,0 +36,0 @@ "prepublish": "npm run build", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
1538632
73768