Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion integrations/arcgis/src/arcgis.mappers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cuenca, Embalse, MetaDatos } from "db-model";
import { Cuenca, Embalse, generateSlug, MetaDatos } from "db-model";
import { ArcGisEntry } from "./api/arcgis-embalse-model.js";

export const mapArgGisEntryToCuenca = (arcGisEntry: ArcGisEntry): Cuenca => ({
Expand All @@ -10,6 +10,7 @@ export const mapArgGisEntryToEmbalse = (arcGisEntry: ArcGisEntry): Embalse => ({
_id: arcGisEntry.embalse_id_1.toString(),
embalse_id: arcGisEntry.EMBALSE_ID,
nombre: arcGisEntry.embalse_nombre,
slug: generateSlug(arcGisEntry.embalse_nombre),
cuenca: mapArgGisEntryToCuenca(arcGisEntry),
provincia: null, // No disponible en ArcGisEntry
capacidad: arcGisEntry.agua_total,
Expand Down
10 changes: 9 additions & 1 deletion packages/db-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts"
".": "./dist/index.js"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "run-p clean type-check build:db-model",
"build:db-model": "tsc",
"clean": "rimraf dist",
"type-check": "tsc --noEmit --preserveWatchOutput"
}
}
1 change: 1 addition & 0 deletions packages/db-model/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Barrel for db-model package

export * from "./model.js";
export * from "./slug.js";
1 change: 1 addition & 0 deletions packages/db-model/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Embalse {
_id: string;
embalse_id: number;
nombre: string;
slug: string;
cuenca: {
_id: string;
nombre: string;
Expand Down
9 changes: 9 additions & 0 deletions packages/db-model/src/slug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const generateSlug = (text: string): string =>
text
.toLowerCase()
.replace(/ñ/g, "n")
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.replace(/[^a-z0-9]+/g, "-")
.replace(/-+/g, "-")
.replace(/^-|-$/g, "");
11 changes: 7 additions & 4 deletions packages/db-model/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"module": "nodenext",
"moduleResolution": "nodenext",
"outDir": "dist",
"skipLibCheck": true,
"isolatedModules": true,
"esModuleInterop": true
"esModuleInterop": true,
"declaration": true
},
"include": ["src"]
"include": ["src/**/*"],
"exclude": ["dist", "node_modules"]
}