diff --git a/assets/jinja/tables/table.jinja b/assets/jinja/tables/table.jinja index a8a97d3d..db9b365d 100644 --- a/assets/jinja/tables/table.jinja +++ b/assets/jinja/tables/table.jinja @@ -10,7 +10,7 @@ AnyPgColumn, geometry, index } from "drizzle-orm/pg-core"; -import { createdAt, updatedAt } from "../common"; +import { createdAt, updatedAt, idReference, idColumn } from "../common"; {% for table in unique_tables %} import { {{ table.dbName }}, {{table.pascalCase}}Keys } from "./{{ table.dbName }}";{% endfor %} import {abbreviation} from "../abbreviation" @@ -24,19 +24,19 @@ import { project } from "../project"; export const {{ table.dbName }} = pgTable( "{{ table.dbName }}", { -id: serial("id").primaryKey(), +id: idColumn(), {% for column in table.columns if not column.isInherited %} -{{ column.camelCase }}: {{ column.dataType }}("{{ column.dbName }}"{% if column.dataType == 'timestamp' %},{mode : "date"}{% +{{ column.camelCase }}:{% if not column.isAbbreviation %}{{ column.dataType }}{% endif %}{% if column.isAbbreviation %}idReference{% endif %} ("{{ column.dbName }}"{% if column.dataType == 'timestamp' %},{mode : "date"}{% endif %}){% if column.isAbbreviation %}.references((): AnyPgColumn => abbreviation.id){% endif %}{% if column.isRequired %}.notNull(){% endif %},{% endfor %} createdAt: createdAt(), updatedAt: updatedAt(), {% if table.parentTableDbName %} -{{ table.parentTableCamelCase }}Id: integer("{{ table.parentTableDbName }}_id") +{{ table.parentTableCamelCase }}Id: idReference("{{ table.parentTableDbName }}_id") .references(() => {{ table.parentTableDbName }}.id, {onDelete : 'cascade'}).notNull(), {% endif %} {% if table.dbName == 'location_details' %} -projectId: integer("project_id").notNull().references((): AnyPgColumn => project.id), +projectId: idReference("project_id").notNull().references((): AnyPgColumn => project.id), geometry: geometry('geometry', { type: 'point', mode: 'xy', srid: 4326 }), {% endif %} diff --git a/package-lock.json b/package-lock.json index 98b7d9d7..b99f5e38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23196,6 +23196,21 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" + }, + "packages/docs/node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.30", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.30.tgz", + "integrity": "sha512-pVZMnFok5qEX4RT59mK2hEVtJX+XFfak+/rjHpyFh7juiT52r177bfFKhnlafm0UOSldhXjj32b+LZIOdswGTg==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/packages/app/src/actions/data/custom-tables/createCustomTable.ts b/packages/app/src/actions/data/custom-tables/createCustomTable.ts index 2e47f2b0..36c532cc 100644 --- a/packages/app/src/actions/data/custom-tables/createCustomTable.ts +++ b/packages/app/src/actions/data/custom-tables/createCustomTable.ts @@ -10,8 +10,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateCustomTableCache } from "@/lib/dal/custom-tables"; export async function createCustomTableAction( - projectId: number, - folderId?: number | null, + projectId: string, + folderId?: string | null, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/custom-tables/deleteCustomTable.ts b/packages/app/src/actions/data/custom-tables/deleteCustomTable.ts index 64ee4ddc..be8aa1c3 100644 --- a/packages/app/src/actions/data/custom-tables/deleteCustomTable.ts +++ b/packages/app/src/actions/data/custom-tables/deleteCustomTable.ts @@ -7,8 +7,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateCustomTableCache } from "@/lib/dal/custom-tables"; export async function deleteCustomTableAction( - projectId: number, - tableId: number, + projectId: string, + tableId: string, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/custom-tables/duplicateCustomTable.ts b/packages/app/src/actions/data/custom-tables/duplicateCustomTable.ts index 67c15364..d2f16b1a 100644 --- a/packages/app/src/actions/data/custom-tables/duplicateCustomTable.ts +++ b/packages/app/src/actions/data/custom-tables/duplicateCustomTable.ts @@ -7,8 +7,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateCustomTableCache } from "@/lib/dal/custom-tables"; export async function duplicateCustomTableAction( - projectId: number, - tableId: number, + projectId: string, + tableId: string, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/custom-tables/moveCustomTable.ts b/packages/app/src/actions/data/custom-tables/moveCustomTable.ts index 6680cd57..b9c89109 100644 --- a/packages/app/src/actions/data/custom-tables/moveCustomTable.ts +++ b/packages/app/src/actions/data/custom-tables/moveCustomTable.ts @@ -6,9 +6,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; export async function moveCustomTableAction( - projectId: number, - customTableId: number, - newFolderId: number | null, + projectId: string, + customTableId: string, + newFolderId: string | null, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/custom-tables/updateCustomTable.ts b/packages/app/src/actions/data/custom-tables/updateCustomTable.ts index 74c1df07..57351bdb 100644 --- a/packages/app/src/actions/data/custom-tables/updateCustomTable.ts +++ b/packages/app/src/actions/data/custom-tables/updateCustomTable.ts @@ -6,8 +6,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateCustomTableCache } from "@/lib/dal/custom-tables"; export async function updateCustomTableAction( - projectId: number, - tableId: number, + projectId: string, + tableId: string, data: { name: string }, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/custom-tables/updateCustomTableDefinition.ts b/packages/app/src/actions/data/custom-tables/updateCustomTableDefinition.ts index 7e4f6454..47f1d606 100644 --- a/packages/app/src/actions/data/custom-tables/updateCustomTableDefinition.ts +++ b/packages/app/src/actions/data/custom-tables/updateCustomTableDefinition.ts @@ -16,9 +16,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { notFound } from "next/navigation"; export async function updateCustomTableDefinitionAction( - id: number, + id: string, definition: CustomTableDefinition, - projectId: number, + projectId: string, ): Promise { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/custom-tables/updateCustomTableZones.ts b/packages/app/src/actions/data/custom-tables/updateCustomTableZones.ts index cf521688..c5f40a1c 100644 --- a/packages/app/src/actions/data/custom-tables/updateCustomTableZones.ts +++ b/packages/app/src/actions/data/custom-tables/updateCustomTableZones.ts @@ -11,9 +11,9 @@ import { } from "@/db/crud/zone"; import { readZones } from "@/db/crud/zone"; export async function updateCustomTableZones( - projectId: number, - tableId: number, - zoneIds: number[], + projectId: string, + tableId: string, + zoneIds: string[], ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); @@ -36,15 +36,15 @@ export async function updateCustomTableZones( !existingCustomTableZones.some((zone) => zone.zoneId === zoneId), ); - const zonesToDelete = existingZones.filter( - (zone) => !zoneIds.includes(zone.id), + const zonesToDelete = existingCustomTableZones.filter( + (zone) => !zoneIds.includes(zone.zoneId), ); await Promise.all([ zonesToCreate.length > 0 ? createCustomTableZones(tableId, zonesToCreate) : Promise.resolve(), - ...zonesToDelete.map((zone) => deleteCustomTableZone(tableId, zone.id)), + ...zonesToDelete.map((zone) => deleteCustomTableZone(tableId, zone.zoneId)), ]); revalidateCustomTableCache(tableId, projectId); diff --git a/packages/app/src/actions/data/folders/createFolder.ts b/packages/app/src/actions/data/folders/createFolder.ts index d9cabfdb..401db2a4 100644 --- a/packages/app/src/actions/data/folders/createFolder.ts +++ b/packages/app/src/actions/data/folders/createFolder.ts @@ -6,8 +6,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; export async function createFolderAction( - projectId: number, - parentFolderId: number | null = null, + projectId: string, + parentFolderId: string | null = null, type: "customTable" | "plot" = "customTable", name?: string, ) { diff --git a/packages/app/src/actions/data/folders/deleteFolder.ts b/packages/app/src/actions/data/folders/deleteFolder.ts index 96003beb..b91b5639 100644 --- a/packages/app/src/actions/data/folders/deleteFolder.ts +++ b/packages/app/src/actions/data/folders/deleteFolder.ts @@ -5,7 +5,7 @@ import { deleteFolder, readFolder } from "@/db/crud/folder"; import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; -export async function deleteFolderAction(projectId: number, folderId: number) { +export async function deleteFolderAction(projectId: string, folderId: string) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/folders/moveFolder.ts b/packages/app/src/actions/data/folders/moveFolder.ts index 14f95a52..41e3957d 100644 --- a/packages/app/src/actions/data/folders/moveFolder.ts +++ b/packages/app/src/actions/data/folders/moveFolder.ts @@ -6,9 +6,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; export async function moveFolderAction( - projectId: number, - folderId: number, - newParentFolderId: number | null, + projectId: string, + folderId: string, + newParentFolderId: string | null, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/folders/updateFolder.ts b/packages/app/src/actions/data/folders/updateFolder.ts index a94a1d73..05bd11f6 100644 --- a/packages/app/src/actions/data/folders/updateFolder.ts +++ b/packages/app/src/actions/data/folders/updateFolder.ts @@ -6,9 +6,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; export async function updateFolderAction( - projectId: number, - folderId: number, - data: { name?: string; parentFolderId?: number | null }, + projectId: string, + folderId: string, + data: { name?: string; parentFolderId?: string | null }, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/plots/createPlot.ts b/packages/app/src/actions/data/plots/createPlot.ts index 3ee709ee..d56a6c70 100644 --- a/packages/app/src/actions/data/plots/createPlot.ts +++ b/packages/app/src/actions/data/plots/createPlot.ts @@ -8,8 +8,8 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { createPlot, generateUniquePlotName } from "@/db/crud/plot"; export async function createPlotAction( - projectId: number, - folderId?: number | null, + projectId: string, + folderId?: string | null, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/plots/deletePlot.ts b/packages/app/src/actions/data/plots/deletePlot.ts index 3c6592de..03b39118 100644 --- a/packages/app/src/actions/data/plots/deletePlot.ts +++ b/packages/app/src/actions/data/plots/deletePlot.ts @@ -6,7 +6,7 @@ import { redirect } from "next/navigation"; import { getProjectForUser } from "@/lib/dal/projects"; import { revalidatePlotCache } from "@/lib/dal/plots"; -export async function deletePlotAction(projectId: number, plotId: number) { +export async function deletePlotAction(projectId: string, plotId: string) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/plots/movePlot.ts b/packages/app/src/actions/data/plots/movePlot.ts index b88c8a83..1ab1e072 100644 --- a/packages/app/src/actions/data/plots/movePlot.ts +++ b/packages/app/src/actions/data/plots/movePlot.ts @@ -6,9 +6,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { revalidateTag } from "next/cache"; export async function movePlotAction( - projectId: number, - plotId: number, - newFolderId: number | null, + projectId: string, + plotId: string, + newFolderId: string | null, ) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/data/plots/updatePlot.ts b/packages/app/src/actions/data/plots/updatePlot.ts index 447b551f..c33fc969 100644 --- a/packages/app/src/actions/data/plots/updatePlot.ts +++ b/packages/app/src/actions/data/plots/updatePlot.ts @@ -7,8 +7,8 @@ import { PlotInsert } from "@common/db/schema/plot"; import { revalidatePlotCache } from "@/lib/dal/plots"; export async function updatePlotAction( - projectId: number, - plotId: number, + projectId: string, + plotId: string, data: Pick, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/plots/updatePlotDefinition.ts b/packages/app/src/actions/data/plots/updatePlotDefinition.ts index 4281c345..d73a7e65 100644 --- a/packages/app/src/actions/data/plots/updatePlotDefinition.ts +++ b/packages/app/src/actions/data/plots/updatePlotDefinition.ts @@ -9,9 +9,9 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { notFound } from "next/navigation"; export async function updatePlotDefinitionAction( - plotId: number, + plotId: string, definition: PlotDefinition, - projectId: number, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/templates/applyTemplate.ts b/packages/app/src/actions/data/templates/applyTemplate.ts index ec0f053e..5fbe1ec8 100644 --- a/packages/app/src/actions/data/templates/applyTemplate.ts +++ b/packages/app/src/actions/data/templates/applyTemplate.ts @@ -13,12 +13,12 @@ import { import { plotDefinitionSchema } from "@common/db/schema/plot"; type ApplyTemplateParams = { - projectId: number; + projectId: string; customTableName: string; customTableDefinition: CustomTableWithoutFilters; plotName?: string; plotDefinition?: PlotDefinitionWithoutSource; - folderId?: number | null; + folderId?: string | null; }; export async function applyTemplateAction({ diff --git a/packages/app/src/actions/data/templates/createTemplate.ts b/packages/app/src/actions/data/templates/createTemplate.ts index 1046296e..ce9a872c 100644 --- a/packages/app/src/actions/data/templates/createTemplate.ts +++ b/packages/app/src/actions/data/templates/createTemplate.ts @@ -16,10 +16,10 @@ interface CreateTemplateParams { name: string; description?: string; scope: "public" | "private"; - customTableId?: number; - plotId?: number; - projectId: number; - tagIds?: number[]; + customTableId?: string; + plotId?: string; + projectId: string; + tagIds?: string[]; } export async function createTemplateAction({ diff --git a/packages/app/src/actions/data/templates/readCustomTableForTemplate.ts b/packages/app/src/actions/data/templates/readCustomTableForTemplate.ts index 8552403e..d14b499c 100644 --- a/packages/app/src/actions/data/templates/readCustomTableForTemplate.ts +++ b/packages/app/src/actions/data/templates/readCustomTableForTemplate.ts @@ -6,8 +6,8 @@ import { getCustomTableForProject } from "@/lib/dal/custom-tables"; import { readTagsWithUsageCountsByUserId } from "@/db/crud/tag"; export async function readCustomTableForTemplateAction( - projectId: number, - customTableId: number, + projectId: string, + customTableId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/templates/readPlotForTemplate.ts b/packages/app/src/actions/data/templates/readPlotForTemplate.ts index 56ca4aa3..11d7676e 100644 --- a/packages/app/src/actions/data/templates/readPlotForTemplate.ts +++ b/packages/app/src/actions/data/templates/readPlotForTemplate.ts @@ -6,8 +6,8 @@ import { getPlotForProject } from "@/lib/dal/plots"; import { readTagsWithUsageCountsByUserId } from "@/db/crud/tag"; export async function readPlotForTemplateAction( - projectId: number, - plotId: number, + projectId: string, + plotId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/data/templates/readTemplate.ts b/packages/app/src/actions/data/templates/readTemplate.ts index 4c901a4e..4853b97b 100644 --- a/packages/app/src/actions/data/templates/readTemplate.ts +++ b/packages/app/src/actions/data/templates/readTemplate.ts @@ -3,7 +3,7 @@ import { getServerUser } from "@/lib/auth"; import { readTemplateWithTags } from "@/db/crud/template"; -export async function readTemplateAction(templateId: number) { +export async function readTemplateAction(templateId: string) { const user = await getServerUser(); const template = await readTemplateWithTags(templateId); diff --git a/packages/app/src/actions/data/templates/readTemplatesWithFilters.ts b/packages/app/src/actions/data/templates/readTemplatesWithFilters.ts index dc5a9391..362b4dcd 100644 --- a/packages/app/src/actions/data/templates/readTemplatesWithFilters.ts +++ b/packages/app/src/actions/data/templates/readTemplatesWithFilters.ts @@ -8,7 +8,7 @@ export type TemplateFilters = { search?: string; type?: "all" | "customTable" | "plot"; scope?: "all" | "public" | "private"; - tagIds?: number[]; + tagIds?: string[]; page?: number; pageSize?: number; }; diff --git a/packages/app/src/actions/imports/ags/autoSaveAgsImport.ts b/packages/app/src/actions/imports/ags/autoSaveAgsImport.ts index f09a134a..5cfda1b5 100644 --- a/packages/app/src/actions/imports/ags/autoSaveAgsImport.ts +++ b/packages/app/src/actions/imports/ags/autoSaveAgsImport.ts @@ -16,8 +16,8 @@ if (!bucketName) { export async function autoSaveAgsImport( fileUpload: AgsFileUpload, - projectId: number, - importId: number, + projectId: string, + importId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/ags/createImport.ts b/packages/app/src/actions/imports/ags/createImport.ts index 0c5ffc09..1d435f02 100644 --- a/packages/app/src/actions/imports/ags/createImport.ts +++ b/packages/app/src/actions/imports/ags/createImport.ts @@ -10,7 +10,7 @@ import { redirect } from "next/navigation"; export async function createImport( blobsData: Omit[], - projectId: number, + projectId: string, agsDictionaryVersion: AgsDictionaryVersion, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/ags/deleteImport.ts b/packages/app/src/actions/imports/ags/deleteImport.ts index a6c6830b..b332989c 100644 --- a/packages/app/src/actions/imports/ags/deleteImport.ts +++ b/packages/app/src/actions/imports/ags/deleteImport.ts @@ -6,8 +6,8 @@ import { getServerUser } from "@/lib/auth"; import { checkImportExistsForProject } from "@/db/crud/import"; import { revalidatePath } from "next/cache"; export async function deleteAgsImportAction( - importId: number, - projectId: number, + importId: string, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/ags/executeImport.ts b/packages/app/src/actions/imports/ags/executeImport.ts index 67e15906..6d7af140 100644 --- a/packages/app/src/actions/imports/ags/executeImport.ts +++ b/packages/app/src/actions/imports/ags/executeImport.ts @@ -9,8 +9,8 @@ import { redirect } from "next/navigation"; import { revalidatePath } from "next/cache"; export async function completeExecuteImport( - importId: number, - projectId: number, + importId: string, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/ags/validateImport.ts b/packages/app/src/actions/imports/ags/validateImport.ts index d4b4e125..4d976432 100644 --- a/packages/app/src/actions/imports/ags/validateImport.ts +++ b/packages/app/src/actions/imports/ags/validateImport.ts @@ -15,8 +15,8 @@ import { validateAgsData } from "@groundup-dev/ags"; import { redirect } from "next/navigation"; export async function completeValidateImport( - projectId: number, - importId: number, + projectId: string, + importId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/csv/autoSaveCsvImport.ts b/packages/app/src/actions/imports/csv/autoSaveCsvImport.ts index 43bf6cb5..5d67965f 100644 --- a/packages/app/src/actions/imports/csv/autoSaveCsvImport.ts +++ b/packages/app/src/actions/imports/csv/autoSaveCsvImport.ts @@ -8,8 +8,8 @@ import { revalidatePath } from "next/cache"; // The extractedData is typed as Record[]> export async function autoSaveCsvImport( - projectId: number, - importId: number, + projectId: string, + importId: string, tableName: TableName, data: Record[], ) { diff --git a/packages/app/src/actions/imports/csv/completeColumnMapping.ts b/packages/app/src/actions/imports/csv/completeColumnMapping.ts index 24247e27..fa817741 100644 --- a/packages/app/src/actions/imports/csv/completeColumnMapping.ts +++ b/packages/app/src/actions/imports/csv/completeColumnMapping.ts @@ -16,8 +16,8 @@ import { read, utils as xlsxUtils } from "xlsx"; import { ColumnConfig, schemaConfig } from "@common/db/schema/common"; export async function completeColumnMappingAction( - importId: number, - projectId: number, + importId: string, + projectId: string, ) { const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/actions/imports/csv/createImport.ts b/packages/app/src/actions/imports/csv/createImport.ts index 7e5052ae..95658e58 100644 --- a/packages/app/src/actions/imports/csv/createImport.ts +++ b/packages/app/src/actions/imports/csv/createImport.ts @@ -21,7 +21,7 @@ export async function createImportCsv( fileSize: number; }[], kind: ExcelImportKind, - projectId: number, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/csv/deleteImport.ts b/packages/app/src/actions/imports/csv/deleteImport.ts index 61c8158c..dc19f78a 100644 --- a/packages/app/src/actions/imports/csv/deleteImport.ts +++ b/packages/app/src/actions/imports/csv/deleteImport.ts @@ -6,8 +6,8 @@ import { getServerUser } from "@/lib/auth"; import { revalidatePath } from "next/cache"; export async function deleteExcelImportAction( - importId: number, - projectId: number, + importId: string, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/csv/executeImport.ts b/packages/app/src/actions/imports/csv/executeImport.ts index 6a5f9c74..5431e86e 100644 --- a/packages/app/src/actions/imports/csv/executeImport.ts +++ b/packages/app/src/actions/imports/csv/executeImport.ts @@ -10,8 +10,8 @@ import { getExcelImportForProject } from "@/lib/dal/imports"; import { updateExcelImport } from "@/db/crud/import"; export async function completeExecuteImportExcel( - importId: number, - projectId: number, + importId: string, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/csv/reparseSheet.ts b/packages/app/src/actions/imports/csv/reparseSheet.ts index ebc8344a..e18ba93e 100644 --- a/packages/app/src/actions/imports/csv/reparseSheet.ts +++ b/packages/app/src/actions/imports/csv/reparseSheet.ts @@ -14,8 +14,8 @@ import { ExcelImportFileMapping } from "@common/db/schema/import"; const sheetToJson = xlsxUtils.sheet_to_json; export async function reparseSheetAction( - importId: number, - projectId: number, + importId: string, + projectId: string, sheetName: string, rowsToSkip: number, ) { @@ -68,8 +68,8 @@ async function reparseExcelSheet( file: any, sheetName: string, rowsToSkip: number, - importId: number, - projectId: number, + importId: string, + projectId: string, ) { // Generate presigned URL to get the file from S3 const { url: blobUrl } = await generatePresignedUrl( @@ -177,8 +177,8 @@ async function reparseCsvSheet( files: any[], sheetName: string, rowsToSkip: number, - importId: number, - projectId: number, + importId: string, + projectId: string, ) { // Find the file that contains the sheet (for CSV, sheet name is the file name) const file = files.find((f) => f.fileName === sheetName); diff --git a/packages/app/src/actions/imports/csv/updateImportFile.ts b/packages/app/src/actions/imports/csv/updateImportFile.ts index 490f98c8..4f175f14 100644 --- a/packages/app/src/actions/imports/csv/updateImportFile.ts +++ b/packages/app/src/actions/imports/csv/updateImportFile.ts @@ -6,12 +6,12 @@ import { updateExcelImportFile } from "@/db/crud/import"; import { revalidatePath } from "next/cache"; export async function updateImportFileAction( - fileId: number, + fileId: string, data: { mapping?: any; - excelImportId: number; + excelImportId: string; }, - projectId: number, + projectId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/imports/csv/validateImport.ts b/packages/app/src/actions/imports/csv/validateImport.ts index 2b4807ce..c4297f73 100644 --- a/packages/app/src/actions/imports/csv/validateImport.ts +++ b/packages/app/src/actions/imports/csv/validateImport.ts @@ -10,8 +10,8 @@ import { generateSummaryExcel } from "@/lib/imports/summary"; import { redirect } from "next/navigation"; export async function completeValidateImportCsv( - projectId: number, - importId: number, + projectId: string, + importId: string, ) { const user = await getServerUser(); diff --git a/packages/app/src/actions/map/getLocation.ts b/packages/app/src/actions/map/getLocation.ts index a1b0a999..23f5cfeb 100644 --- a/packages/app/src/actions/map/getLocation.ts +++ b/packages/app/src/actions/map/getLocation.ts @@ -9,18 +9,14 @@ import { import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; - export async function getLocationAction( - id: number, - projectId: number, + id: string, + projectId: string, ): Promise<(LocationData & { geologyData: LocationGeologyData[] }) | null> { try { const user = await getServerUser(); - const projectIdParsed = parseIntParam(String(projectId)); - - const project = await getProjectForUser(user, projectIdParsed); + const project = await getProjectForUser(user, projectId); const location = await readLocationDataById(id, project.project.id); diff --git a/packages/app/src/actions/map/getZones.ts b/packages/app/src/actions/map/getZones.ts index 96125528..9a457969 100644 --- a/packages/app/src/actions/map/getZones.ts +++ b/packages/app/src/actions/map/getZones.ts @@ -6,7 +6,7 @@ import { getProjectForUser } from "@/lib/dal/projects"; import { notFound } from "next/navigation"; import { revalidatePath } from "next/cache"; -export async function getZonesAction(projectId: number) { +export async function getZonesAction(projectId: string) { const user = await getServerUser(); if (!user) { diff --git a/packages/app/src/actions/projects/addTeamMember.ts b/packages/app/src/actions/projects/addTeamMember.ts index 61d410a9..193cdae3 100644 --- a/packages/app/src/actions/projects/addTeamMember.ts +++ b/packages/app/src/actions/projects/addTeamMember.ts @@ -10,7 +10,7 @@ import { } from "@/lib/dal/projects"; export async function addTeamMemberAction( - projectId: number, + projectId: string, email: string, role: "OWNER" | "CONTRIBUTOR" | "VIEWER", ) { diff --git a/packages/app/src/actions/projects/deleteProject.ts b/packages/app/src/actions/projects/deleteProject.ts index bd90859d..63c14ac2 100644 --- a/packages/app/src/actions/projects/deleteProject.ts +++ b/packages/app/src/actions/projects/deleteProject.ts @@ -6,7 +6,7 @@ import { revalidatePath } from "next/cache"; import { notFound, redirect } from "next/navigation"; import { getProjectForUser } from "@/lib/dal/projects"; -export async function deleteProjectAction(projectId: number) { +export async function deleteProjectAction(projectId: string) { const user = await getServerUser(); const userProject = await getProjectForUser(user, projectId); if (!userProject) { diff --git a/packages/app/src/actions/projects/deleteTeamMember.ts b/packages/app/src/actions/projects/deleteTeamMember.ts index e6b0ade3..00b63634 100644 --- a/packages/app/src/actions/projects/deleteTeamMember.ts +++ b/packages/app/src/actions/projects/deleteTeamMember.ts @@ -7,8 +7,8 @@ import { revalidateUserProjectCache } from "@/lib/dal/projects"; import { readUserById } from "@/db/crud/user"; export async function deleteTeamMemberAction( - projectId: number, - userId: number, + projectId: string, + userId: string, ) { const currentUser = await getServerUser(); diff --git a/packages/app/src/actions/projects/updateTeamMemberRole.ts b/packages/app/src/actions/projects/updateTeamMemberRole.ts index 0f88cecc..ac0d93da 100644 --- a/packages/app/src/actions/projects/updateTeamMemberRole.ts +++ b/packages/app/src/actions/projects/updateTeamMemberRole.ts @@ -7,8 +7,8 @@ import { revalidateUserProjectCache } from "@/lib/dal/projects"; import { readUserById } from "@/db/crud/user"; export async function updateTeamMemberRoleAction( - projectId: number, - userId: number, + projectId: string, + userId: string, newRole: "CONTRIBUTOR" | "VIEWER", ) { const currentUser = await getServerUser(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/activity/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/activity/page.tsx index 54af1453..63a76afa 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/activity/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/activity/page.tsx @@ -1,7 +1,7 @@ import { PageFrame } from "@/components/common/page-frame"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ClipboardList } from "lucide-react"; type Props = { @@ -9,7 +9,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/dashboard/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/dashboard/page.tsx index 9274d0fb..ad043432 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/dashboard/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/dashboard/page.tsx @@ -1,7 +1,7 @@ import { PageFrame } from "@/components/common/page-frame"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { LayoutDashboard } from "lucide-react"; type Props = { @@ -9,7 +9,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/layout.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/layout.tsx index 316f2c80..35f8123d 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/layout.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/layout.tsx @@ -1,7 +1,7 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; import { getProjectData } from "@/lib/dal/data"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { schemaConfig } from "@common/db/schema/common"; import { tableConfigToNodes } from "@/components/data/data-sidebar/table-config"; import { DataWrapper } from "@/components/data/data-wrapper"; @@ -14,7 +14,7 @@ type Props = { }; export default async function Layout({ params, children }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/borehole-log.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/borehole-log.tsx index 7df3eeaf..e2cd69ab 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/borehole-log.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/borehole-log.tsx @@ -57,7 +57,7 @@ export function BoreholeLog({ const containerRef = useRef(null); const geologyCodeMap = useMemo(() => { - return new Map( + return new Map( geologyCodes.map((code, index) => [ code.id, { @@ -78,7 +78,9 @@ export function BoreholeLog({ description: stratum.generalDescriptionOfStratum, formation: stratum.geologicalFormationOrStratumName, geologyCode: stratum.geologyCode, - color: geologyCodeMap.get(stratum.geologyCode)?.color || "#f0f0f0", + color: + geologyCodeMap.get(stratum.geologyCode?.toString() || "")?.color || + "#f0f0f0", })); useEffect(() => { @@ -171,7 +173,7 @@ export function BoreholeLog({ /> ({ - code: geologyCodeMap.get(d.geologyCode)?.code || "", + code: geologyCodeMap.get(d.geologyCode?.toString() || "")?.code || "", color: d.color, }))} /> diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/page.tsx index 4af1c41e..19726021 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/logs/[locationId]/page.tsx @@ -1,5 +1,5 @@ import { notFound } from "next/navigation"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { readDataForLocation, readGeologyCodesForProject, @@ -15,7 +15,7 @@ interface Props { } export default async function LogPage({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const locationId = params.locationId; const user = await getServerUser(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/plots/[plotId]/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/plots/[plotId]/page.tsx index 01ad1698..1484b098 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/plots/[plotId]/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/plots/[plotId]/page.tsx @@ -5,7 +5,7 @@ import { getColumnsForPlot, } from "@/lib/dal/plots"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { getCustomTablesForProject } from "@/lib/dal/custom-tables"; @@ -23,8 +23,8 @@ interface Props { } export default async function PlotPage({ params, searchParams }: Props) { - const projectId = parseIntParam(params.projectId); - const plotId = parseIntParam(params.plotId); + const projectId = parseStringParam(params.projectId); + const plotId = parseStringParam(params.plotId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/tables/[tableName]/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/tables/[tableName]/page.tsx index cf01bebc..f383532e 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/tables/[tableName]/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/tables/[tableName]/page.tsx @@ -1,7 +1,7 @@ import { DataTablePanel } from "@/components/data/data-table-panel"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { TableName } from "@common/db/schema/data"; type Props = { @@ -9,7 +9,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const tableName = params.tableName; const user = await getServerUser(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/data/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/data/page.tsx index b8d4fcb3..d2ae4c66 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/data/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/data/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { redirect } from "next/navigation"; import { Suspense } from "react"; import { CustomTableData } from "@/components/data/custom-table/custom-table-data"; @@ -17,10 +17,10 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); await getProjectForUser(user, projectId); - const customTableId = parseIntParam(params.customTableId); + const customTableId = parseStringParam(params.customTableId); const customTable = await getCustomTableForProject(projectId, customTableId); const definitionConfigured = isDefinitionConfigured(customTable); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/definition/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/definition/page.tsx index f85c3537..afd5d1e2 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/definition/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/definition/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { CustomTableData } from "@/components/data/custom-table/custom-table-data"; import { schemaConfig } from "@common/db/schema/common"; @@ -20,7 +20,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); @@ -28,7 +28,7 @@ export default async function Page({ params }: Props) { notFound(); } - const customTableId = parseIntParam(params.customTableId); + const customTableId = parseStringParam(params.customTableId); const [customTable, tableCounts] = await Promise.all([ getCustomTableForProject(projectId, customTableId), diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/layout.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/layout.tsx index a50e114e..d1e31b5a 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/layout.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/layout.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { CustomTableToggleButton } from "@/components/data/custom-table/custom-table-toggle-button"; @@ -18,10 +18,10 @@ type Props = { }; export default async function Layout({ params, children, modal }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); await getProjectForUser(user, projectId); - const customTableId = parseIntParam(params.customTableId); + const customTableId = parseStringParam(params.customTableId); const customTable = await getCustomTableForProject(projectId, customTableId); if (!customTable) { notFound(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/page.tsx index be13c10e..9a0c7c55 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/data/views/[customTableId]/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound, redirect } from "next/navigation"; import { isDefinitionConfigured } from "@/components/data/custom-table/helpers"; import { getCustomTableForProject } from "@/lib/dal/custom-tables"; @@ -10,10 +10,10 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); await getProjectForUser(user, projectId); - const customTableId = parseIntParam(params.customTableId); + const customTableId = parseStringParam(params.customTableId); const customTable = await getCustomTableForProject(projectId, customTableId); if (!customTable) { notFound(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/detailed/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/detailed/page.tsx index f79cbaf8..e01b8468 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/detailed/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/detailed/page.tsx @@ -2,7 +2,7 @@ import { ChangesNavigation } from "@/components/imports/changes/changes-navigati import { getProjectForUser } from "@/lib/dal/projects"; import { getServerUser } from "@/lib/auth"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { getImportForProject } from "@/lib/dal/imports"; import { ImportSummary } from "@common/db/schema/import"; @@ -29,8 +29,8 @@ function getTableOptions(importData: ImportSummary) { } export default async function DetailedPage({ params, searchParams }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/layout.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/layout.tsx index 580f8eb9..099769c5 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/layout.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/layout.tsx @@ -4,7 +4,7 @@ import { readProjectImport } from "@/db/crud/import"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { ArrowLeft } from "lucide-react"; import Link from "next/link"; @@ -23,8 +23,8 @@ type Props = { }; export default async function ChangesLayout({ children, params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/map/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/map/page.tsx index 8e1e0d5a..c165df35 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/map/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/map/page.tsx @@ -4,7 +4,7 @@ import { Map } from "@/components/imports/changes/map"; import { getImportForProject } from "@/lib/dal/imports"; import { getProjectForUser } from "@/lib/dal/projects"; import { getServerUser } from "@/lib/auth"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportSummary } from "@common/db/schema/import"; import { calculateCentroid } from "@/lib/utils"; import { notFound } from "next/navigation"; @@ -28,8 +28,8 @@ function getInitialViewState(importData: ImportSummary["spatial"]) { } export default async function MapPage({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/page.tsx index 3405acc3..cd19eb2b 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/page.tsx @@ -1,13 +1,13 @@ import { redirect } from "next/navigation"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; type Props = { params: { projectId: string; importId: string }; }; export default function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); redirect(`/projects/${projectId}/imports/ags/${importId}/changes/summary`); } diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/summary/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/summary/page.tsx index 6ab1409e..0580c156 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/summary/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/changes/summary/page.tsx @@ -9,7 +9,7 @@ import { } from "@/components/ui/table"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { getImportForProject } from "@/lib/dal/imports"; import { notFound } from "next/navigation"; import { Button } from "@/components/ui/button"; @@ -53,8 +53,8 @@ async function TableRows({ projectId, importId, }: { - projectId: number; - importId: number; + projectId: string; + importId: string; }) { const importData = await getImportForProject(projectId, importId); if ( @@ -108,8 +108,8 @@ async function TableRows({ export default async function SummaryPage(props: Props) { const params = await props.params; - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/upload/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/upload/page.tsx index bebad624..833ba722 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/upload/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/upload/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportsPageFrame } from "@/components/imports/upload/imports-page-frame"; import UploadImportAgs from "@/components/imports/upload/upload-import-ags"; @@ -15,8 +15,8 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/validate/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/validate/page.tsx index 4fc8ef20..873e2d53 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/validate/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/[importId]/validate/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { readAgsFileUploadsForImport, @@ -14,8 +14,8 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/new/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/new/page.tsx index d044b572..c3ef0850 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/ags/new/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/ags/new/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportsPageFrame } from "@/components/imports/upload/imports-page-frame"; import UploadImportAgs from "@/components/imports/upload/upload-import-ags"; @@ -10,7 +10,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/detailed/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/detailed/page.tsx index 8586442d..7b306435 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/detailed/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/detailed/page.tsx @@ -1,7 +1,7 @@ import { ChangesNavigation } from "@/components/imports/changes/changes-navigation"; import { getProjectForUser } from "@/lib/dal/projects"; import { getServerUser } from "@/lib/auth"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { getExcelImportForProject } from "@/lib/dal/imports"; import { CsvImportSummary } from "@common/db/schema/import"; @@ -28,8 +28,8 @@ function getTableOptions(importData: CsvImportSummary) { } export default async function DetailedPage({ params, searchParams }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/layout.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/layout.tsx index a9568f42..9d1da81f 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/layout.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/layout.tsx @@ -4,7 +4,7 @@ import { buttonVariants } from "@/components/ui/button"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { notFound } from "next/navigation"; import { ArrowLeft } from "lucide-react"; import Link from "next/link"; @@ -23,8 +23,8 @@ type Props = { }; export default async function ChangesLayout({ children, params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/map/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/map/page.tsx index 5913761c..f499311f 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/map/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/map/page.tsx @@ -4,7 +4,7 @@ import { Map } from "@/components/imports/changes/map"; import { getExcelImportForProject } from "@/lib/dal/imports"; import { getProjectForUser } from "@/lib/dal/projects"; import { getServerUser } from "@/lib/auth"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportSummary } from "@common/db/schema/import"; import { calculateCentroid } from "@/lib/utils"; import { notFound } from "next/navigation"; @@ -28,8 +28,8 @@ function getInitialViewState(importData: ImportSummary["spatial"]) { } export default async function MapPage({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/page.tsx index 7ba08a83..cee93891 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/page.tsx @@ -1,13 +1,13 @@ import { redirect } from "next/navigation"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; export default async function ChangesPage({ params, }: { params: { projectId: string; importId: string }; }) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); redirect(`/projects/${projectId}/imports/csv/${importId}/changes/summary`); } diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/summary/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/summary/page.tsx index 1e15b63e..51e78977 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/summary/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/changes/summary/page.tsx @@ -9,7 +9,7 @@ import { } from "@/components/ui/table"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { getExcelImportForProject } from "@/lib/dal/imports"; import { notFound } from "next/navigation"; import { Button } from "@/components/ui/button"; @@ -44,8 +44,8 @@ async function TableRows({ projectId, importId, }: { - projectId: number; - importId: number; + projectId: string; + importId: string; }) { const importData = await getExcelImportForProject(projectId, importId); if (!importData.summary) { @@ -93,8 +93,8 @@ async function TableRows({ export default async function SummaryPage(props: Props) { const params = await props.params; - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/columns/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/columns/page.tsx index 287071aa..146463a8 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/columns/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/columns/page.tsx @@ -35,9 +35,9 @@ type Props = { }; export default async function Page({ params }: Props) { - const importId = parseInt(params.importId); + const importId = params.importId; const user = await getServerUser(); - const { project } = await getProjectForUser(user, parseInt(params.projectId)); + const { project } = await getProjectForUser(user, params.projectId); const importData = await readExcelImportForProject(project.id, importId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/upload/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/upload/page.tsx index 71421356..56693750 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/upload/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/upload/page.tsx @@ -1,7 +1,7 @@ import { StepperNode } from "@/components/common/stepper"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportsPageFrame } from "@/components/imports/upload/imports-page-frame"; import UploadImportCsv from "@/components/imports/upload/upload-import-csv"; import { @@ -17,8 +17,8 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); - const importId = parseIntParam(params.importId); + const projectId = parseStringParam(params.projectId); + const importId = parseStringParam(params.importId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); //above redirects appropiately diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/[tableName]/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/[tableName]/page.tsx index 1822805b..9095b835 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/[tableName]/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/[tableName]/page.tsx @@ -23,10 +23,10 @@ type Props = { export default async function ValidateImportPage({ params }: Props) { const user = await getServerUser(); - const { project } = await getProjectForUser(user, parseInt(params.projectId)); + const { project } = await getProjectForUser(user, params.projectId); const importData = await readExcelImportForProject( project.id, - parseInt(params.importId), + params.importId, ); if (!importData || !importData.extractedData) { @@ -100,7 +100,7 @@ export default async function ValidateImportPage({ params }: Props) { tableConfig={tableConfig} tableData={tableData} projectId={project.id} - importId={parseInt(params.importId)} + importId={params.importId} errors={errorsByTable[params.tableName as TableName]} canContinue={canContinue} /> diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/layout.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/layout.tsx index 3c99d0cf..7baf5dc7 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/layout.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/layout.tsx @@ -14,8 +14,8 @@ type Props = { }; export default async function ValidateImportPage({ params, children }: Props) { - const projectId = parseInt(params.projectId); - const importId = parseInt(params.importId); + const projectId = params.projectId; + const importId = params.importId; const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/page.tsx index cd44151c..5b355bb9 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/[importId]/validate/page.tsx @@ -12,11 +12,11 @@ type Props = { export default async function ValidateImportPage({ params }: Props) { const user = await getServerUser(); - const { project } = await getProjectForUser(user, parseInt(params.projectId)); + const { project } = await getProjectForUser(user, params.projectId); const importData = await readExcelImportForProject( project.id, - parseInt(params.importId), + params.importId, ); if (!importData || !importData.extractedData) { diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/new/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/new/page.tsx index 0a011aad..7e1c828b 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/csv/new/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/csv/new/page.tsx @@ -1,7 +1,7 @@ import { StepperNode } from "@/components/common/stepper"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { ImportsPageFrame } from "@/components/imports/upload/imports-page-frame"; import UploadImportCsv from "@/components/imports/upload/upload-import-csv"; @@ -12,7 +12,7 @@ type Props = { }; export default async function NewCsvImportPage({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); //above redirects appropiately diff --git a/packages/app/src/app/(app)/projects/[projectId]/imports/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/imports/page.tsx index 772c935f..3c137cd0 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/imports/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/imports/page.tsx @@ -1,6 +1,6 @@ import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { PageFrame } from "@/components/common/page-frame"; import { FileSpreadsheet, FileText, List, Plus } from "lucide-react"; import { @@ -26,7 +26,7 @@ type Props = { }; export default async function Page({ params, searchParams }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); // Authentication and authorization - critical path const user = await getServerUser(); diff --git a/packages/app/src/app/(app)/projects/[projectId]/map/@modal/upload/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/map/@modal/upload/page.tsx index 59fa163d..95add26f 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/map/@modal/upload/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/map/@modal/upload/page.tsx @@ -29,7 +29,7 @@ export default function UploadModal({ params }: UploadModalProps) { const [isPending, startTransition] = useTransition(); const [isLoading, setIsLoading] = useState(false); const [file, setFile] = useState(null); - const projectId = parseInt(params.projectId); + const projectId = params.projectId; const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files && e.target.files[0]) { diff --git a/packages/app/src/app/(app)/projects/[projectId]/map/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/map/page.tsx index c0e08de8..7d5131c4 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/map/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/map/page.tsx @@ -1,7 +1,7 @@ import { PageFrame } from "@/components/common/page-frame"; import { getServerUser } from "@/lib/auth"; import { getProjectForUser } from "@/lib/dal/projects"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { Map } from "lucide-react"; import { readZones } from "@/db/crud/zone"; import { @@ -15,7 +15,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const { project } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/settings/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/settings/page.tsx index ac312e93..fed892ea 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/settings/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/settings/page.tsx @@ -1,7 +1,7 @@ import { PageFrame } from "@/components/common/page-frame"; import { EditProjectForm } from "@/components/projects/project-details/edit-project-form"; import { getServerUser } from "@/lib/auth"; -import { parseIntParam } from "@/lib/routing"; +import { parseStringParam } from "@/lib/routing"; import { Settings } from "lucide-react"; import { DeleteProjectForm } from "@/components/projects/delete-project-form"; import { readProjectById, readUserProject } from "@/db/crud/project"; @@ -19,7 +19,7 @@ type Props = { }; export default async function Page({ params }: Props) { - const projectId = parseIntParam(params.projectId); + const projectId = parseStringParam(params.projectId); const user = await getServerUser(); const project = await readProjectById(projectId); diff --git a/packages/app/src/app/(app)/projects/[projectId]/team/page.tsx b/packages/app/src/app/(app)/projects/[projectId]/team/page.tsx index 654469aa..d024cb84 100644 --- a/packages/app/src/app/(app)/projects/[projectId]/team/page.tsx +++ b/packages/app/src/app/(app)/projects/[projectId]/team/page.tsx @@ -17,7 +17,7 @@ type Props = { }; export default async function Page({ params, searchParams }: Props) { - const projectId = parseInt(params.projectId); + const projectId = params.projectId; const user = await getServerUser(); const { project, role } = await getProjectForUser(user, projectId); diff --git a/packages/app/src/app/api/projects/[projectId]/custom-tables/[customTableId]/data/route.ts b/packages/app/src/app/api/projects/[projectId]/custom-tables/[customTableId]/data/route.ts index bb71bd4f..fda6d157 100644 --- a/packages/app/src/app/api/projects/[projectId]/custom-tables/[customTableId]/data/route.ts +++ b/packages/app/src/app/api/projects/[projectId]/custom-tables/[customTableId]/data/route.ts @@ -19,23 +19,8 @@ type RequestArgs = { const LIMIT_MAX = 1000; export async function GET(request: NextRequest, { params }: RequestArgs) { - const projectId = parseInt(params.projectId); - - if (isNaN(projectId)) { - return NextResponse.json( - { message: "Invalid projectId: Must be of type number" }, - { status: 400 }, - ); - } - - const customTableId = parseInt(params.customTableId); - - if (isNaN(customTableId)) { - return NextResponse.json( - { message: "Invalid customTableId: Must be of type number" }, - { status: 400 }, - ); - } + const projectId = params.projectId; + const customTableId = params.customTableId; const searchParams = request.nextUrl.searchParams; diff --git a/packages/app/src/app/api/projects/[projectId]/imports/[importId]/summary/[tableName]/route.ts b/packages/app/src/app/api/projects/[projectId]/imports/[importId]/summary/[tableName]/route.ts index d85dd655..4a9dcea2 100644 --- a/packages/app/src/app/api/projects/[projectId]/imports/[importId]/summary/[tableName]/route.ts +++ b/packages/app/src/app/api/projects/[projectId]/imports/[importId]/summary/[tableName]/route.ts @@ -25,22 +25,8 @@ type RequestArgs = { }; export async function GET(request: NextRequest, { params }: RequestArgs) { - const projectId = parseInt(params.projectId); - if (isNaN(projectId)) { - return NextResponse.json( - { message: "Invalid projectId: Must be of type number" }, - { status: 400 }, - ); - } - - const importId = parseInt(params.importId); - if (isNaN(importId)) { - return NextResponse.json( - { message: "Invalid importId: Must be of type number" }, - { status: 400 }, - ); - } - + const projectId = params.projectId; + const importId = params.importId; const tableName = params.tableName as TableName; const searchParams = request.nextUrl.searchParams; diff --git a/packages/app/src/app/api/projects/[projectId]/imports/[importId]/validate/[tableName]/route.ts b/packages/app/src/app/api/projects/[projectId]/imports/[importId]/validate/[tableName]/route.ts index 29dc5740..054b7204 100644 --- a/packages/app/src/app/api/projects/[projectId]/imports/[importId]/validate/[tableName]/route.ts +++ b/packages/app/src/app/api/projects/[projectId]/imports/[importId]/validate/[tableName]/route.ts @@ -24,22 +24,8 @@ type RequestArgs = { }; export async function GET(request: NextRequest, { params }: RequestArgs) { - const projectId = parseInt(params.projectId); - if (isNaN(projectId)) { - return NextResponse.json( - { message: "Invalid projectId: Must be of type number" }, - { status: 400 }, - ); - } - - const importId = parseInt(params.importId); - if (isNaN(importId)) { - return NextResponse.json( - { message: "Invalid importId: Must be of type number" }, - { status: 400 }, - ); - } - + const projectId = params.projectId; + const importId = params.importId; const tableName = params.tableName as TableName; const searchParams = request.nextUrl.searchParams; diff --git a/packages/app/src/app/api/projects/[projectId]/imports/csv/[importId]/summary/[tableName]/route.ts b/packages/app/src/app/api/projects/[projectId]/imports/csv/[importId]/summary/[tableName]/route.ts index 40f9926b..a476377d 100644 --- a/packages/app/src/app/api/projects/[projectId]/imports/csv/[importId]/summary/[tableName]/route.ts +++ b/packages/app/src/app/api/projects/[projectId]/imports/csv/[importId]/summary/[tableName]/route.ts @@ -22,22 +22,8 @@ type RequestArgs = { }; export async function GET(request: NextRequest, { params }: RequestArgs) { - const projectId = parseInt(params.projectId); - if (isNaN(projectId)) { - return NextResponse.json( - { message: "Invalid projectId: Must be of type number" }, - { status: 400 }, - ); - } - - const importId = parseInt(params.importId); - if (isNaN(importId)) { - return NextResponse.json( - { message: "Invalid importId: Must be of type number" }, - { status: 400 }, - ); - } - + const projectId = params.projectId; + const importId = params.importId; const tableName = params.tableName as TableName; const searchParams = request.nextUrl.searchParams; diff --git a/packages/app/src/app/api/projects/[projectId]/tables/[tableName]/data/route.ts b/packages/app/src/app/api/projects/[projectId]/tables/[tableName]/data/route.ts index b3e8e3a1..b3e92c4c 100644 --- a/packages/app/src/app/api/projects/[projectId]/tables/[tableName]/data/route.ts +++ b/packages/app/src/app/api/projects/[projectId]/tables/[tableName]/data/route.ts @@ -36,7 +36,7 @@ const postBodySchema = z.object({ }), ) .optional(), - zoneIds: z.array(z.number()).optional(), + zoneIds: z.array(z.string()).optional(), }) .optional(), }); @@ -57,14 +57,7 @@ type RequestArgs = { }; export async function POST(request: NextRequest, { params }: RequestArgs) { - const projectId = parseInt(params.projectId); - - if (isNaN(projectId)) { - return NextResponse.json( - { message: "Invalid projectId: Must be of type number" }, - { status: 400 }, - ); - } + const projectId = params.projectId; const searchParams = request.nextUrl.searchParams; diff --git a/packages/app/src/components/data/custom-table/custom-table-data.tsx b/packages/app/src/components/data/custom-table/custom-table-data.tsx index e46f75fe..ac6f6777 100644 --- a/packages/app/src/components/data/custom-table/custom-table-data.tsx +++ b/packages/app/src/components/data/custom-table/custom-table-data.tsx @@ -10,7 +10,7 @@ import { Abbreviation } from "@common/db/schema/abbreviation"; import { Zone } from "@common/db/schema/zone"; type Props = { - projectId: number; + projectId: string; customTable: CustomTable; zones: (Zone & { isSelected: boolean; diff --git a/packages/app/src/components/data/custom-table/custom-table-definition.tsx b/packages/app/src/components/data/custom-table/custom-table-definition.tsx index abf44c66..038e7ad1 100644 --- a/packages/app/src/components/data/custom-table/custom-table-definition.tsx +++ b/packages/app/src/components/data/custom-table/custom-table-definition.tsx @@ -17,7 +17,7 @@ type Props = { schemaConfig: GroupConfig[]; customTable: CustomTable; tableCounts: TableCounts; - projectId: number; + projectId: string; }; export function CustomTableDefinition({ diff --git a/packages/app/src/components/data/custom-table/custom-table-glide.tsx b/packages/app/src/components/data/custom-table/custom-table-glide.tsx index 68c6c713..819918da 100644 --- a/packages/app/src/components/data/custom-table/custom-table-glide.tsx +++ b/packages/app/src/components/data/custom-table/custom-table-glide.tsx @@ -24,7 +24,7 @@ import { MapPin, ExternalLinkIcon } from "lucide-react"; import { Option } from "@/components/ui/multi-select"; import Link from "next/link"; type Props = { - projectId: number; + projectId: string; customTable: CustomTable & { definition: NonNullable; }; diff --git a/packages/app/src/components/data/custom-table/custom-table-save-button.tsx b/packages/app/src/components/data/custom-table/custom-table-save-button.tsx index df3076be..ec070778 100644 --- a/packages/app/src/components/data/custom-table/custom-table-save-button.tsx +++ b/packages/app/src/components/data/custom-table/custom-table-save-button.tsx @@ -6,8 +6,8 @@ import { Save } from "lucide-react"; import { SaveCustomTableTemplateModal } from "@/components/data/templates/save-custom-table-template-modal"; type CustomTableSaveButtonProps = { - projectId: number; - customTableId: number; + projectId: string; + customTableId: string; }; export function CustomTableSaveButton({ diff --git a/packages/app/src/components/data/custom-table/custom-table-toggle-button.tsx b/packages/app/src/components/data/custom-table/custom-table-toggle-button.tsx index b2946526..aeee0e91 100644 --- a/packages/app/src/components/data/custom-table/custom-table-toggle-button.tsx +++ b/packages/app/src/components/data/custom-table/custom-table-toggle-button.tsx @@ -6,8 +6,8 @@ import Link from "next/link"; import { Database, Settings } from "lucide-react"; type Props = { - projectId: number; - customTableId: number; + projectId: string; + customTableId: string; definitionConfigured: boolean; }; diff --git a/packages/app/src/components/data/custom-table/helpers.ts b/packages/app/src/components/data/custom-table/helpers.ts index 7000cf60..756867ef 100644 --- a/packages/app/src/components/data/custom-table/helpers.ts +++ b/packages/app/src/components/data/custom-table/helpers.ts @@ -4,7 +4,7 @@ import { readAbbreviationsForCollectionByColumn } from "@/db/crud/abbreviation"; import { ColumnConfig } from "@common/db/schema/common"; import { TableName } from "@common/db/schema/data"; -export function getTableCounts(projectId: number): Promise<{ +export function getTableCounts(projectId: string): Promise<{ tableCounts: Record; }> { return getTableCounts(projectId); diff --git a/packages/app/src/components/data/data-sidebar/custom-table-list.tsx b/packages/app/src/components/data/data-sidebar/custom-table-list.tsx index 5da0cb67..874cc803 100644 --- a/packages/app/src/components/data/data-sidebar/custom-table-list.tsx +++ b/packages/app/src/components/data/data-sidebar/custom-table-list.tsx @@ -15,18 +15,18 @@ import { RenameDialog } from "./rename-dialog"; import { DataItemList } from "./data-item-list"; type Props = { - projectId: number; + projectId: string; tables: CustomTableItem[]; }; type CustomTableItem = { - id: number; + id: string; label: string; href: string; }; export function CustomTableList({ projectId, tables }: Props) { - const [editingTableId, setEditingTableId] = useState(null); + const [editingTableId, setEditingTableId] = useState(null); const tablesSortedAlphabetically = tables.sort((a, b) => a.label.localeCompare(b.label), diff --git a/packages/app/src/components/data/data-sidebar/custom-table-tab.tsx b/packages/app/src/components/data/data-sidebar/custom-table-tab.tsx index 65b9d27c..9d16836b 100644 --- a/packages/app/src/components/data/data-sidebar/custom-table-tab.tsx +++ b/packages/app/src/components/data/data-sidebar/custom-table-tab.tsx @@ -10,20 +10,20 @@ import { duplicateCustomTableAction } from "@/actions/data/custom-tables/duplica import { FolderTree } from "./folder-tree"; type Props = { - projectId: number; + projectId: string; customTables: CustomTable[]; folders: Folder[]; }; type CustomTableItem = { - id: number; + id: string; label: string; href: string; - folderId?: number | null; + folderId?: string | null; }; export function CustomTableTab({ projectId, customTables, folders }: Props) { - const [currentFolderId, setCurrentFolderId] = useState(null); + const [currentFolderId, setCurrentFolderId] = useState(null); const tableItems: CustomTableItem[] = customTables.map( (table: CustomTable) => { @@ -36,19 +36,19 @@ export function CustomTableTab({ projectId, customTables, folders }: Props) { }, ); - const handleNewItem = async (folderId: number | null) => { + const handleNewItem = async (folderId: string | null) => { await createCustomTableAction(projectId, folderId); }; - const handleRename = async (itemId: number, newName: string) => { + const handleRename = async (itemId: string, newName: string) => { await updateCustomTableAction(projectId, itemId, { name: newName }); }; - const handleDelete = async (itemId: number, _itemName: string) => { + const handleDelete = async (itemId: string, _itemName: string) => { await deleteCustomTableAction(projectId, itemId); }; - const handleDuplicate = async (itemId: number) => { + const handleDuplicate = async (itemId: string) => { await duplicateCustomTableAction(projectId, itemId); }; diff --git a/packages/app/src/components/data/data-sidebar/data-item-list.tsx b/packages/app/src/components/data/data-sidebar/data-item-list.tsx index bf2fe57c..aa80ff61 100644 --- a/packages/app/src/components/data/data-sidebar/data-item-list.tsx +++ b/packages/app/src/components/data/data-sidebar/data-item-list.tsx @@ -18,7 +18,7 @@ import Link from "next/link"; import { MenuActions, MenuItem } from "./menu-actions"; export type DataItem = { - id: number; + id: string; label: string; isActive?: boolean; } & ( @@ -36,7 +36,7 @@ type DataItemListProps = { items: T[]; getMenuItems: (_item: T) => MenuItem[]; isLoading?: { - id: number; + id: string; } | null; }; diff --git a/packages/app/src/components/data/data-sidebar/folder-tree.tsx b/packages/app/src/components/data/data-sidebar/folder-tree.tsx index 2e399047..ef9e66fa 100644 --- a/packages/app/src/components/data/data-sidebar/folder-tree.tsx +++ b/packages/app/src/components/data/data-sidebar/folder-tree.tsx @@ -51,58 +51,58 @@ import Link from "next/link"; import { useRouter } from "next/navigation"; interface FolderTreeProps { - projectId: number; + projectId: string; folders: FolderType[]; - currentFolderId: number | null; - onFolderSelect: (_folderId: number | null) => void; - onNewItem: (_folderId: number | null) => void; + currentFolderId: string | null; + onFolderSelect: (_folderId: string | null) => void; + onNewItem: (_folderId: string | null) => void; items: Array<{ - id: number; + id: string; label: string; href: string; - folderId?: number | null; + folderId?: string | null; }>; itemType: "customTable" | "plot"; - onItemRename?: (_itemId: number, _newName: string) => Promise; - onItemDelete?: (_itemId: number, _itemName: string) => Promise; - onItemDuplicate?: (_itemId: number) => Promise; + onItemRename?: (_itemId: string, _newName: string) => Promise; + onItemDelete?: (_itemId: string, _itemName: string) => Promise; + onItemDuplicate?: (_itemId: string) => Promise; } interface FolderNodeProps { folder: FolderType; level: number; isExpanded: boolean; - onToggle: (_folderId: number) => void; - onSelect: (_folderId: number) => void; - onNewSubfolder: (_parentFolderId: number | null) => void; - onRename: (_folderId: number, _currentName: string) => void; - onDelete: (_folderId: number, _folderName: string) => void; + onToggle: (_folderId: string) => void; + onSelect: (_folderId: string) => void; + onNewSubfolder: (_parentFolderId: string | null) => void; + onRename: (_folderId: string, _currentName: string) => void; + onDelete: (_folderId: string, _folderName: string) => void; isSelected: boolean; items: Array<{ - id: number; + id: string; label: string; href: string; - folderId?: number | null; + folderId?: string | null; }>; itemType: "customTable" | "plot"; - onItemRename?: (_itemId: number, _newName: string) => Promise; - onItemDelete?: (_itemId: number, _itemName: string) => Promise; - onItemDuplicate?: (_itemId: number) => Promise; + onItemRename?: (_itemId: string, _newName: string) => Promise; + onItemDelete?: (_itemId: string, _itemName: string) => Promise; + onItemDuplicate?: (_itemId: string) => Promise; } interface ItemNodeProps { item: { - id: number; + id: string; label: string; href: string; - folderId?: number | null; + folderId?: string | null; }; level: number; itemType: "customTable" | "plot"; - onRename?: (_itemId: number, _newName: string) => Promise; - onDelete?: (_itemId: number, _itemName: string) => Promise; - onDuplicate?: (_itemId: number) => Promise; + onRename?: (_itemId: string, _newName: string) => Promise; + onDelete?: (_itemId: string, _itemName: string) => Promise; + onDuplicate?: (_itemId: string) => Promise; } function RootDroppableArea() { @@ -422,12 +422,12 @@ export function FolderTree({ })), ); - const [expandedFolders, setExpandedFolders] = useState>( + const [expandedFolders, setExpandedFolders] = useState>( new Set(), ); const [draggingItem, setDraggingItem] = useState<{ type: "folder" | "item"; - id: number; + id: string; name: string; } | null>(null); const [isTemplatesModalOpen, setIsTemplatesModalOpen] = useState(false); @@ -441,7 +441,7 @@ export function FolderTree({ }), ); - const toggleExpanded = (folderId: number) => { + const toggleExpanded = (folderId: string) => { const newExpanded = new Set(expandedFolders); if (newExpanded.has(folderId)) { newExpanded.delete(folderId); @@ -451,7 +451,7 @@ export function FolderTree({ setExpandedFolders(newExpanded); }; - const handleNewSubfolder = async (parentFolderId: number | null) => { + const handleNewSubfolder = async (parentFolderId: string | null) => { try { await createFolderAction(projectId, parentFolderId, itemType); @@ -465,11 +465,11 @@ export function FolderTree({ } }; - const handleRename = async (_folderId: number, _currentName: string) => { + const handleRename = async (_folderId: string, _currentName: string) => { // This will be handled by the RenameDialog in the FolderNode }; - const handleDelete = async (folderId: number, folderName: string) => { + const handleDelete = async (folderId: string, folderName: string) => { if ( confirm( `Are you sure you want to delete the folder "${folderName}"? This will also delete all subfolders and move items to the root.`, @@ -486,7 +486,7 @@ export function FolderTree({ setDraggingItem({ type: type as "folder" | "item", - id: parseInt(itemId), + id: itemId, name: decodeURIComponent(name), }); }; @@ -510,8 +510,8 @@ export function FolderTree({ // Only allow dropping on folders if (droppedType !== "folder") return; - const targetFolderId = droppedId === "root" ? null : parseInt(droppedId); - const draggedItemId = parseInt(draggedId); + const targetFolderId = droppedId === "root" ? null : droppedId; + const draggedItemId = draggedId; console.log("Moving item:", { draggedItemId, targetFolderId }); @@ -543,7 +543,7 @@ export function FolderTree({ const buildFolderTree = ( folders: FolderType[], - parentId: number | null = null, + parentId: string | null = null, ): FolderType[] => { const filteredFolders = folders .filter((folder) => { diff --git a/packages/app/src/components/data/data-sidebar/index.tsx b/packages/app/src/components/data/data-sidebar/index.tsx index 3467435e..6dd082ed 100644 --- a/packages/app/src/components/data/data-sidebar/index.tsx +++ b/packages/app/src/components/data/data-sidebar/index.tsx @@ -34,7 +34,7 @@ import { RecentlyVisited } from "./recently-visited"; export const schemaConfig = tableConfig as GroupConfig[]; type Props = { - projectId: number; + projectId: string; nodes: TableNode[]; tableCounts: TableCounts; plots: Plot[]; diff --git a/packages/app/src/components/data/data-sidebar/plot-list.tsx b/packages/app/src/components/data/data-sidebar/plot-list.tsx index ff7eec34..81564ff9 100644 --- a/packages/app/src/components/data/data-sidebar/plot-list.tsx +++ b/packages/app/src/components/data/data-sidebar/plot-list.tsx @@ -13,9 +13,9 @@ import { RenameDialog } from "./rename-dialog"; import { DataItemList, DataItem } from "./data-item-list"; type Props = { - projectId: number; + projectId: string; plots: { - id: number; + id: string; label: string; href: string; }[]; diff --git a/packages/app/src/components/data/data-sidebar/plot-tab.tsx b/packages/app/src/components/data/data-sidebar/plot-tab.tsx index 833469e9..9170f1d6 100644 --- a/packages/app/src/components/data/data-sidebar/plot-tab.tsx +++ b/packages/app/src/components/data/data-sidebar/plot-tab.tsx @@ -10,20 +10,20 @@ import { deletePlotAction } from "@/actions/data/plots/deletePlot"; import { FolderTree } from "./folder-tree"; type Props = { - projectId: number; + projectId: string; plots: Plot[]; folders: Folder[]; }; type PlotItem = { - id: number; + id: string; label: string; href: string; - folderId?: number | null; + folderId?: string | null; }; export function PlotTab({ projectId, plots, folders }: Props) { - const [currentFolderId, setCurrentFolderId] = useState(null); + const [currentFolderId, setCurrentFolderId] = useState(null); const plotItems: PlotItem[] = plots.map((plot: Plot) => { return { @@ -34,19 +34,19 @@ export function PlotTab({ projectId, plots, folders }: Props) { }; }); - const handleNewItem = async (folderId: number | null) => { + const handleNewItem = async (folderId: string | null) => { await createPlotAction(projectId, folderId); }; - const handleRename = async (itemId: number, newName: string) => { + const handleRename = async (itemId: string, newName: string) => { await updatePlotAction(projectId, itemId, { name: newName }); }; - const handleDelete = async (itemId: number, _itemName: string) => { + const handleDelete = async (itemId: string, _itemName: string) => { await deletePlotAction(projectId, itemId); }; - const handleDuplicate = async (_itemId: number) => {}; + const handleDuplicate = async (_itemId: string) => {}; return (
diff --git a/packages/app/src/components/data/data-sidebar/table-explorer.tsx b/packages/app/src/components/data/data-sidebar/table-explorer.tsx index 34b4f359..e64a06b2 100644 --- a/packages/app/src/components/data/data-sidebar/table-explorer.tsx +++ b/packages/app/src/components/data/data-sidebar/table-explorer.tsx @@ -13,7 +13,7 @@ type TableExplorerProps = { nodes: TableNode[]; className?: string; tableCounts: TableCounts; - projectId: number; + projectId: string; }; export function TableExplorer({ diff --git a/packages/app/src/components/data/data-table-panel/config.ts b/packages/app/src/components/data/data-table-panel/config.ts index d84132db..d16ee1d8 100644 --- a/packages/app/src/components/data/data-table-panel/config.ts +++ b/packages/app/src/components/data/data-table-panel/config.ts @@ -1,13 +1,13 @@ import { readDataForProject } from "@/db/crud/data"; import { TableName, tables } from "@common/db/schema/data"; -type TableReadFunction = (_projectId: number) => Promise; +type TableReadFunction = (_projectId: string) => Promise; // Create a map of read functions for each table using the generic readDataForProject export const tableReadFunctionsMap = Object.keys(tables).reduce( (acc, tableName) => ({ ...acc, - [tableName]: (projectId: number) => + [tableName]: (projectId: string) => readDataForProject(projectId, tableName as TableName), }), {} as Record, diff --git a/packages/app/src/components/data/data-table-panel/data-table-glide.tsx b/packages/app/src/components/data/data-table-panel/data-table-glide.tsx index d671ac6d..a37ffb73 100644 --- a/packages/app/src/components/data/data-table-panel/data-table-glide.tsx +++ b/packages/app/src/components/data/data-table-panel/data-table-glide.tsx @@ -21,7 +21,7 @@ import Link from "next/link"; import { ExternalLinkIcon, MapPin } from "lucide-react"; type Props = { - projectId: number; + projectId: string; tableName: TableName; tableConfig: GroupConfig; _abbreviationsColumnMap: Record; diff --git a/packages/app/src/components/data/data-table-panel/index.tsx b/packages/app/src/components/data/data-table-panel/index.tsx index 7223dbff..53f12788 100644 --- a/packages/app/src/components/data/data-table-panel/index.tsx +++ b/packages/app/src/components/data/data-table-panel/index.tsx @@ -11,7 +11,7 @@ import { DataTableGlide } from "./data-table-glide"; const DEFAULT_PAGE_SIZE = 500; type Props = { - projectId: number; + projectId: string; tableName: TableName; }; diff --git a/packages/app/src/components/data/data-wrapper.tsx b/packages/app/src/components/data/data-wrapper.tsx index 24042157..ecb9d8f0 100644 --- a/packages/app/src/components/data/data-wrapper.tsx +++ b/packages/app/src/components/data/data-wrapper.tsx @@ -19,7 +19,7 @@ import { useEffect, createContext } from "react"; import { useLocalStorage } from "@uidotdev/usehooks"; interface DataWrapperProps { - projectId: number; + projectId: string; projectName: string; nodes: TableNode[]; tableCounts: TableCounts; diff --git a/packages/app/src/components/data/helpers.ts b/packages/app/src/components/data/helpers.ts index a51644a0..a57db270 100644 --- a/packages/app/src/components/data/helpers.ts +++ b/packages/app/src/components/data/helpers.ts @@ -4,7 +4,7 @@ import { TableName, tables } from "@common/db/schema/data"; export type TableCounts = Record; -export async function getTableCounts(projectId: number): Promise { +export async function getTableCounts(projectId: string): Promise { const counts: Partial = {}; // Fetch counts for all tables in parallel diff --git a/packages/app/src/components/data/plot/definition/layout.tsx b/packages/app/src/components/data/plot/definition/layout.tsx index 7ef49ed2..569e3766 100644 --- a/packages/app/src/components/data/plot/definition/layout.tsx +++ b/packages/app/src/components/data/plot/definition/layout.tsx @@ -30,7 +30,7 @@ const DEFAULT_DIMENSIONS: PlotDimensions = { interface PlotDefinitionLayoutProps { plotType: "scatter" | "line" | "histogram" | "bar"; - projectId: number; + projectId: string; plot: Plot; customTables: CustomTable[]; data: Record[]; diff --git a/packages/app/src/components/data/plot/definition/sections/general-section.tsx b/packages/app/src/components/data/plot/definition/sections/general-section.tsx index 09d4ca3b..69abb3a1 100644 --- a/packages/app/src/components/data/plot/definition/sections/general-section.tsx +++ b/packages/app/src/components/data/plot/definition/sections/general-section.tsx @@ -37,7 +37,7 @@ interface GeneralSectionProps { type DataSource = | { isCustomTable: true; - customTableId: number; + customTableId: string; } | { isCustomTable: false; @@ -179,7 +179,7 @@ export function GeneralSection({ ( plot.definition?.dataSource as { isCustomTable: true; - customTableId: number; + customTableId: string; } ).customTableId, ) ?? null) diff --git a/packages/app/src/components/data/plot/definition/sections/table-search.tsx b/packages/app/src/components/data/plot/definition/sections/table-search.tsx index 07086198..0cfa8e0b 100644 --- a/packages/app/src/components/data/plot/definition/sections/table-search.tsx +++ b/packages/app/src/components/data/plot/definition/sections/table-search.tsx @@ -26,7 +26,7 @@ import { type SearchItem } from "./general-section"; type Props = { nodes: SearchItem[]; plot: Plot; - projectId: number; + projectId: string; selectedItem: SearchItem | null; }; diff --git a/packages/app/src/components/data/plot/save-plot-button.tsx b/packages/app/src/components/data/plot/save-plot-button.tsx index afabbd2c..7de7107d 100644 --- a/packages/app/src/components/data/plot/save-plot-button.tsx +++ b/packages/app/src/components/data/plot/save-plot-button.tsx @@ -6,8 +6,8 @@ import { Save } from "lucide-react"; import { SavePlotTemplateModal } from "@/components/data/templates/save-plot-template-modal"; type PlotSaveButtonProps = { - projectId: number; - plotId: number; + projectId: string; + plotId: string; }; export function PlotSaveButton({ projectId, plotId }: PlotSaveButtonProps) { diff --git a/packages/app/src/components/data/templates/save-custom-table-template-modal.tsx b/packages/app/src/components/data/templates/save-custom-table-template-modal.tsx index 10ed880c..3b3a88a6 100644 --- a/packages/app/src/components/data/templates/save-custom-table-template-modal.tsx +++ b/packages/app/src/components/data/templates/save-custom-table-template-modal.tsx @@ -14,8 +14,8 @@ import { SaveTemplateForm } from "./save-template-form"; import { useSaveCustomTableTemplate } from "@/hooks/use-save-custom-table-template"; type SaveCustomTableTemplateModalProps = { - projectId: number; - customTableId: number; + projectId: string; + customTableId: string; isOpen: boolean; onClose: () => void; }; diff --git a/packages/app/src/components/data/templates/save-plot-template-modal.tsx b/packages/app/src/components/data/templates/save-plot-template-modal.tsx index 616c7af2..d30cf677 100644 --- a/packages/app/src/components/data/templates/save-plot-template-modal.tsx +++ b/packages/app/src/components/data/templates/save-plot-template-modal.tsx @@ -14,8 +14,8 @@ import { SaveTemplateForm } from "./save-template-form"; import { useSavePlotTemplate } from "@/hooks/use-save-plot-template"; type SavePlotTemplateModalProps = { - projectId: number; - plotId: number; + projectId: string; + plotId: string; isOpen: boolean; onClose: () => void; }; diff --git a/packages/app/src/components/data/templates/save-template-form.tsx b/packages/app/src/components/data/templates/save-template-form.tsx index bcd850c8..9ff2707c 100644 --- a/packages/app/src/components/data/templates/save-template-form.tsx +++ b/packages/app/src/components/data/templates/save-template-form.tsx @@ -33,15 +33,15 @@ const saveTemplateSchema = z.object({ name: z.string().min(1, "Template name is required"), description: z.string().optional(), scope: z.enum(["public", "private"]), - tagIds: z.array(z.number()).default([]), + tagIds: z.array(z.string()).default([]), }); type SaveTemplateFormData = z.infer; type SaveTemplateFormProps = { - projectId: number; - plotId?: number; - customTableId?: number; + projectId: string; + plotId?: string; + customTableId?: string; itemName: string; itemType: "plot" | "customTable"; allTags: (Tag | TagWithUsageCount)[]; diff --git a/packages/app/src/components/data/templates/tag-autocomplete.tsx b/packages/app/src/components/data/templates/tag-autocomplete.tsx index afc0133d..c783db36 100644 --- a/packages/app/src/components/data/templates/tag-autocomplete.tsx +++ b/packages/app/src/components/data/templates/tag-autocomplete.tsx @@ -82,7 +82,7 @@ export function TagAutocomplete({ setOpen(false); }; - const handleRemoveTag = (tagId: number) => { + const handleRemoveTag = (tagId: string) => { onTagsChange(selectedTags.filter((tag) => tag.id !== tagId)); }; diff --git a/packages/app/src/components/data/templates/template-application-modal.tsx b/packages/app/src/components/data/templates/template-application-modal.tsx index c3121757..9fd2b28c 100644 --- a/packages/app/src/components/data/templates/template-application-modal.tsx +++ b/packages/app/src/components/data/templates/template-application-modal.tsx @@ -30,7 +30,7 @@ import { applyTemplateAction } from "@/actions/data/templates/applyTemplate"; type TemplateApplicationModalProps = { template: TemplateWithTags; - projectId: number; + projectId: string; onClose: () => void; onSuccess?: () => void; }; diff --git a/packages/app/src/components/data/templates/templates-modal.tsx b/packages/app/src/components/data/templates/templates-modal.tsx index 474664ec..35d80d0b 100644 --- a/packages/app/src/components/data/templates/templates-modal.tsx +++ b/packages/app/src/components/data/templates/templates-modal.tsx @@ -36,7 +36,7 @@ import { useTemplates } from "@/hooks/use-templates"; import { TemplateWithTags } from "@common/db/schema/template"; type TemplatesModalProps = { - projectId: number; + projectId: string; isOpen: boolean; onClose: () => void; itemType?: "customTable" | "plot"; diff --git a/packages/app/src/components/imports/changes/changes-navigation.tsx b/packages/app/src/components/imports/changes/changes-navigation.tsx index 650de15e..26d0af8b 100644 --- a/packages/app/src/components/imports/changes/changes-navigation.tsx +++ b/packages/app/src/components/imports/changes/changes-navigation.tsx @@ -5,8 +5,8 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; interface ChangesNavigationProps { - projectId: number; - importId: number; + projectId: string; + importId: string; importType?: "ags" | "csv"; } diff --git a/packages/app/src/components/imports/changes/detailed-changes-table.tsx b/packages/app/src/components/imports/changes/detailed-changes-table.tsx index bbb95737..0593c421 100644 --- a/packages/app/src/components/imports/changes/detailed-changes-table.tsx +++ b/packages/app/src/components/imports/changes/detailed-changes-table.tsx @@ -9,8 +9,8 @@ import { SelectDetailedTables } from "@/components/imports/changes/select-detail import { Label } from "@/components/ui/label"; import { Separator } from "@/components/ui/separator"; type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; table: string; tableConfig: GroupConfig; options: { label: string; value: string }[]; diff --git a/packages/app/src/components/imports/changes/execute-import-button.tsx b/packages/app/src/components/imports/changes/execute-import-button.tsx index 80241f79..f69a0555 100644 --- a/packages/app/src/components/imports/changes/execute-import-button.tsx +++ b/packages/app/src/components/imports/changes/execute-import-button.tsx @@ -9,8 +9,8 @@ import { useState } from "react"; import { toast } from "sonner"; type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; importType?: "ags" | "csv"; disabled?: boolean; }; diff --git a/packages/app/src/components/imports/changes/select-detailed-tables.tsx b/packages/app/src/components/imports/changes/select-detailed-tables.tsx index 88c3ee77..7289be24 100644 --- a/packages/app/src/components/imports/changes/select-detailed-tables.tsx +++ b/packages/app/src/components/imports/changes/select-detailed-tables.tsx @@ -6,8 +6,8 @@ import { useRouter } from "next/navigation"; type TableOption = Option; type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; options: TableOption[]; selectedOption: string; importType?: "ags" | "csv"; diff --git a/packages/app/src/components/imports/column-mapping/row-skip-selector.tsx b/packages/app/src/components/imports/column-mapping/row-skip-selector.tsx index 5a4e096f..733f5596 100644 --- a/packages/app/src/components/imports/column-mapping/row-skip-selector.tsx +++ b/packages/app/src/components/imports/column-mapping/row-skip-selector.tsx @@ -11,8 +11,8 @@ interface RowSkipSelectorProps { onValueChange: (_value: number) => Promise; disabled?: boolean; maxRows?: number; - importId: number; - projectId: number; + importId: string; + projectId: string; sheetName: string; } diff --git a/packages/app/src/components/imports/delete-import-button.tsx b/packages/app/src/components/imports/delete-import-button.tsx index fe0c9c13..fb2d2998 100644 --- a/packages/app/src/components/imports/delete-import-button.tsx +++ b/packages/app/src/components/imports/delete-import-button.tsx @@ -24,8 +24,8 @@ export function DeleteImportButton({ isCompleted, kind, }: { - projectId: number; - importId: number; + projectId: string; + importId: string; isCompleted: boolean; kind: "ags" | "excel"; }) { diff --git a/packages/app/src/components/imports/detailed-changes-glide.tsx b/packages/app/src/components/imports/detailed-changes-glide.tsx index bcdb1299..d271bc2b 100644 --- a/packages/app/src/components/imports/detailed-changes-glide.tsx +++ b/packages/app/src/components/imports/detailed-changes-glide.tsx @@ -10,8 +10,8 @@ import { GroupConfig } from "@common/db/schema/common"; import { DataEditorProps } from "@glideapps/glide-data-grid"; type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; tableName: TableName; tableConfig: GroupConfig; diff --git a/packages/app/src/components/imports/imports-table.tsx b/packages/app/src/components/imports/imports-table.tsx index a5e79362..e4f71cc2 100644 --- a/packages/app/src/components/imports/imports-table.tsx +++ b/packages/app/src/components/imports/imports-table.tsx @@ -16,29 +16,29 @@ import { Suspense } from "react"; export type ImportWithFiles = { import: { - id: number; - projectId: number; + id: string; + projectId: string; agsDictionaryVersion: string; completedAt: Date | null; createdAt: Date; kind: "ags" | "excel"; }; files: { - id: number; + id: string; fileName: string; fileSize: number; }[]; }; type ImportsTableProps = { - projectId: number; + projectId: string; importsPromise: Promise<[ImportWithFiles[], number]>; page: number; pageSize: number; }; type ImportsTableContentProps = { - projectId: number; + projectId: string; imports: ImportWithFiles[]; pagination: { total: number; diff --git a/packages/app/src/components/imports/upload/imports-page-frame.tsx b/packages/app/src/components/imports/upload/imports-page-frame.tsx index f27c5b27..9b40f6b9 100644 --- a/packages/app/src/components/imports/upload/imports-page-frame.tsx +++ b/packages/app/src/components/imports/upload/imports-page-frame.tsx @@ -9,7 +9,7 @@ import { Separator } from "@/components/ui/separator"; type Props = { children: React.ReactNode; importData: { - id: number; + id: string; createdAt: Date; } | null; project: Project; diff --git a/packages/app/src/components/imports/upload/upload-import-ags.tsx b/packages/app/src/components/imports/upload/upload-import-ags.tsx index fb6fac6f..95657ec6 100644 --- a/packages/app/src/components/imports/upload/upload-import-ags.tsx +++ b/packages/app/src/components/imports/upload/upload-import-ags.tsx @@ -53,7 +53,7 @@ const MAX_FILE_SIZE_BYTES = 10 * 1000 * 1000; const MAX_FILE_SIZE_HUMAN = humanFileSize(MAX_FILE_SIZE_BYTES, true, 0); type Props = { - projectId: number; + projectId: string; } & ( | { importData: null; diff --git a/packages/app/src/components/imports/upload/upload-import-csv.tsx b/packages/app/src/components/imports/upload/upload-import-csv.tsx index f3561429..1c209cc3 100644 --- a/packages/app/src/components/imports/upload/upload-import-csv.tsx +++ b/packages/app/src/components/imports/upload/upload-import-csv.tsx @@ -54,7 +54,7 @@ const MAX_FILE_SIZE_BYTES = 10 * 1000 * 1000; const MAX_FILE_SIZE_HUMAN = humanFileSize(MAX_FILE_SIZE_BYTES, true, 0); type Props = { - projectId: number; + projectId: string; } & ( | { importData: null; diff --git a/packages/app/src/components/imports/validate/csv-validator.tsx b/packages/app/src/components/imports/validate/csv-validator.tsx index 01aa1507..d7f03061 100644 --- a/packages/app/src/components/imports/validate/csv-validator.tsx +++ b/packages/app/src/components/imports/validate/csv-validator.tsx @@ -25,8 +25,8 @@ import { completeValidateImportCsv } from "@/actions/imports/csv/validateImport" type Props = { tableConfig: GroupConfig; tableData: Record[]; - projectId: number; - importId: number; + projectId: string; + importId: string; errors: CsvError[]; canContinue: boolean; }; diff --git a/packages/app/src/components/imports/validate/editable-csv-table.tsx b/packages/app/src/components/imports/validate/editable-csv-table.tsx index c7d6db7a..67e53cb6 100644 --- a/packages/app/src/components/imports/validate/editable-csv-table.tsx +++ b/packages/app/src/components/imports/validate/editable-csv-table.tsx @@ -30,8 +30,8 @@ import { CsvToolbar } from "./csv-toolbar"; const DEBOUNCE_DELAY = 4000; // 4 seconds type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; tableName: TableName; tableConfig: GroupConfig; setGoToErrorCallback: (_: (_: CsvError) => void) => void; diff --git a/packages/app/src/components/imports/validate/validate-page.tsx b/packages/app/src/components/imports/validate/validate-page.tsx index d9532a7c..a7fda5cf 100644 --- a/packages/app/src/components/imports/validate/validate-page.tsx +++ b/packages/app/src/components/imports/validate/validate-page.tsx @@ -21,8 +21,8 @@ import { CardContent, } from "@/components/ui/card"; type Props = { - projectId: number; - importId: number; + projectId: string; + importId: string; agsDictionaryVersion: AgsDictionaryVersion; fileUploads: AgsFileUpload[]; frozen: boolean; diff --git a/packages/app/src/components/imports/validate/validator/validator.tsx b/packages/app/src/components/imports/validate/validator/validator.tsx index b93fe983..7d36030b 100644 --- a/packages/app/src/components/imports/validate/validator/validator.tsx +++ b/packages/app/src/components/imports/validate/validator/validator.tsx @@ -35,8 +35,8 @@ type Props = { initialData: string; setDataIsValid: (_isValid: boolean) => void; frozen: boolean; - projectId: number; - importId: number; + projectId: string; + importId: string; }; export default function Validator({ diff --git a/packages/app/src/components/map/location-details-panel.tsx b/packages/app/src/components/map/location-details-panel.tsx index ddd87dd6..892a621f 100644 --- a/packages/app/src/components/map/location-details-panel.tsx +++ b/packages/app/src/components/map/location-details-panel.tsx @@ -9,8 +9,8 @@ import { StickLog } from "./stick-log"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; interface LocationDetailsPanelProps { - locationId: number | null; - projectId: number; + locationId: string | null; + projectId: string; isOpen: boolean; onOpenChange: (_open: boolean) => void; } diff --git a/packages/app/src/components/map/map-page-client.tsx b/packages/app/src/components/map/map-page-client.tsx index 76a7b27d..a15fa074 100644 --- a/packages/app/src/components/map/map-page-client.tsx +++ b/packages/app/src/components/map/map-page-client.tsx @@ -24,7 +24,7 @@ import { type MapProps } from "react-map-gl/maplibre"; type MapPageClientProps = { initialViewState: NonNullable; - projectId: number; + projectId: string; zones: Zone[]; locations: LocationDetails[]; @@ -63,7 +63,7 @@ export function MapPageClient({ // When the map finishes drawing a polygon (via double click) const handlePolygonFinish = async ( polygonCoordinates: number[][], - zoneId?: number, + zoneId?: string, ) => { try { if (mode === "edit" && editingZone && zoneId) { @@ -136,7 +136,7 @@ export function MapPageClient({ }; // When a zone is deleted from the sidebar. - const handleDeleteZone = async (zoneId: number) => { + const handleDeleteZone = async (zoneId: string) => { try { await deleteZoneAction({ id: zoneId, projectId }); router.refresh(); diff --git a/packages/app/src/components/map/map-sidebar/map-sidebar.tsx b/packages/app/src/components/map/map-sidebar/map-sidebar.tsx index 853501ef..89b04128 100644 --- a/packages/app/src/components/map/map-sidebar/map-sidebar.tsx +++ b/packages/app/src/components/map/map-sidebar/map-sidebar.tsx @@ -12,11 +12,11 @@ type Props = { x: number; y: number; }; - projectId: number; + projectId: string; onEditZone: (_zone: ZoneDataItem, _editType: "polygon") => void; onRenameZone: (_zone: ZoneDataItem, _newName: string) => void; onCreateZone: () => void; - onDeleteZone: (_zoneId: number) => void; + onDeleteZone: (_zoneId: string) => void; isCollapsed?: boolean; onFlyToZone: (_polygon: number[][][]) => void; }; diff --git a/packages/app/src/components/map/map-sidebar/zone-list.tsx b/packages/app/src/components/map/map-sidebar/zone-list.tsx index 0310f9b5..09db985b 100644 --- a/packages/app/src/components/map/map-sidebar/zone-list.tsx +++ b/packages/app/src/components/map/map-sidebar/zone-list.tsx @@ -11,11 +11,11 @@ import { PencilRuler, MapPinned } from "lucide-react"; import { type ZoneDataItem } from "@/types/zones"; type Props = { - projectId: number; + projectId: string; zones: ZoneDataItem[]; onEditZone: (_zone: ZoneDataItem, _editType: "polygon") => void; onRenameZone: (_zone: ZoneDataItem, _newName: string) => void; - onDeleteZone: (_zoneId: number) => void; + onDeleteZone: (_zoneId: string) => void; onFlyToZone: (_polygon: number[][][]) => void; }; diff --git a/packages/app/src/components/map/map-sidebar/zone-tab.tsx b/packages/app/src/components/map/map-sidebar/zone-tab.tsx index 951dd5a3..fec94c78 100644 --- a/packages/app/src/components/map/map-sidebar/zone-tab.tsx +++ b/packages/app/src/components/map/map-sidebar/zone-tab.tsx @@ -13,12 +13,12 @@ import { import { useRouter } from "next/navigation"; type Props = { - projectId: number; + projectId: string; zones: Zone[]; onEditZone: (_zone: ZoneDataItem, _editType: "polygon") => void; onRenameZone: (_zone: ZoneDataItem, _newName: string) => void; onCreateZone: () => void; - onDeleteZone: (_zoneId: number) => void; + onDeleteZone: (_zoneId: string) => void; onFlyToZone: (_polygon: number[][][]) => void; }; diff --git a/packages/app/src/components/map/map.tsx b/packages/app/src/components/map/map.tsx index 0a4cb546..a7b944d8 100644 --- a/packages/app/src/components/map/map.tsx +++ b/packages/app/src/components/map/map.tsx @@ -42,11 +42,11 @@ const MAP_CONFIG = { export type MapZonesAndLabsProps = { initialViewState: MapProps["initialViewState"]; - projectId: number; + projectId: string; zones: Zone[]; editingZone?: ZoneForEditing | null; mode?: "create" | "edit" | null; - onFinishPolygon?: (_polygonCoordinates: number[][], _zoneId?: number) => void; + onFinishPolygon?: (_polygonCoordinates: number[][], _zoneId?: string) => void; onCancelEdit?: () => void; locations: any[]; @@ -87,7 +87,7 @@ export const MapZonesAndLabs = forwardRef< const [drawControl, setDrawControl] = useState(null); const [isDrawing, setIsDrawing] = useState(false); const [isSettingsOpen, setIsSettingsOpen] = useState(false); - const [selectedLocationId, setSelectedLocationId] = useState( + const [selectedLocationId, setSelectedLocationId] = useState( null, ); const [isLocationPanelOpen, setIsLocationPanelOpen] = useState(false); diff --git a/packages/app/src/components/projects/delete-project-form/index.tsx b/packages/app/src/components/projects/delete-project-form/index.tsx index 4c72f291..3c710115 100644 --- a/packages/app/src/components/projects/delete-project-form/index.tsx +++ b/packages/app/src/components/projects/delete-project-form/index.tsx @@ -26,7 +26,7 @@ import { } from "@/components/ui/form"; interface DeleteProjectFormProps { - projectId: number; + projectId: string; projectName: string; isOwner: boolean; } diff --git a/packages/app/src/components/team/add-team-member-form.tsx b/packages/app/src/components/team/add-team-member-form.tsx index 0eec9677..630a1b84 100644 --- a/packages/app/src/components/team/add-team-member-form.tsx +++ b/packages/app/src/components/team/add-team-member-form.tsx @@ -56,7 +56,7 @@ const formSchema = z.object({ export type FormInputs = z.infer; type Props = { - projectId: number; + projectId: string; open: boolean; onOpenChange: (_open: boolean) => void; teamMembers: TeamMember[]; diff --git a/packages/app/src/components/team/team-table.tsx b/packages/app/src/components/team/team-table.tsx index 588d277a..add83b82 100644 --- a/packages/app/src/components/team/team-table.tsx +++ b/packages/app/src/components/team/team-table.tsx @@ -35,7 +35,7 @@ export type TeamMember = { }; type Props = { - projectId: number; + projectId: string; currentUserRole: "OWNER" | "CONTRIBUTOR" | "VIEWER"; initialTeamMembers: TeamMember[]; searchQuery: string; @@ -73,7 +73,7 @@ export function TeamTable({ const isEditable = currentUserRole === "OWNER"; const handleRoleChange = async ( - userId: number, + userId: string, newRole: "CONTRIBUTOR" | "VIEWER", ) => { try { @@ -91,7 +91,7 @@ export function TeamTable({ return `/projects/${projectId}/team?${params.toString()}`; }; - const handleDeleteMember = async (userId: number) => { + const handleDeleteMember = async (userId: string) => { try { await deleteTeamMemberAction(projectId, userId); toast.success("Team member removed successfully"); diff --git a/packages/app/src/contexts/data-table-query.tsx b/packages/app/src/contexts/data-table-query.tsx index bd2a1842..224cb87e 100644 --- a/packages/app/src/contexts/data-table-query.tsx +++ b/packages/app/src/contexts/data-table-query.tsx @@ -11,7 +11,7 @@ export type DataTableQueryFilter = { export type DataTableQuery = { sort: { columnNameCamelCase: string; order: "asc" | "desc" } | undefined; filters: Record; - zoneIds: number[]; + zoneIds: string[]; }; export const DataTableQueryContext = createContext<{ diff --git a/packages/app/src/db/crud/abbreviation.ts b/packages/app/src/db/crud/abbreviation.ts index d70b791c..397a95bd 100644 --- a/packages/app/src/db/crud/abbreviation.ts +++ b/packages/app/src/db/crud/abbreviation.ts @@ -24,7 +24,7 @@ export async function readAbbreviationByCode( } export async function readAbbreviationCollectionByUnique( - projectId: number, + projectId: string, column: string, table: string, options: QueryOptions = defaultQueryOptions, @@ -45,7 +45,7 @@ export async function readAbbreviationCollectionByUnique( } export async function readAbbreviationsForCollectionByColumn( - projectId: number, + projectId: string, table: string, column: string, ) { @@ -69,7 +69,7 @@ export async function readAbbreviationsForCollectionByColumn( } export async function readAbbreviationsByTable( - projectId: number, + projectId: string, table: string, ) { return await db @@ -91,7 +91,7 @@ export async function readAbbreviationsByTable( } export async function readOrCreateAbbreviationCollection( - projectId: number, + projectId: string, column: string, table: string, options: QueryOptions = defaultQueryOptions, @@ -125,7 +125,7 @@ export async function readOrCreateAbbreviationCollection( export async function readOrCreateAbbreviation( code: string, - collectionId: number, + collectionId: string, options: QueryOptions = defaultQueryOptions, ): Promise { const { dbInstance } = options; diff --git a/packages/app/src/db/crud/custom_table.ts b/packages/app/src/db/crud/custom_table.ts index e6e88c1f..f78b9c1f 100644 --- a/packages/app/src/db/crud/custom_table.ts +++ b/packages/app/src/db/crud/custom_table.ts @@ -6,8 +6,9 @@ import { CustomTable, CustomTableInsert, } from "@common/db/schema/custom_table"; +import { sanitizeDataForInsert } from "@common/db/schema/common"; -export async function readCustomTables(projectId: number) { +export async function readCustomTables(projectId: string) { return await db .select() .from(customTable) @@ -16,8 +17,8 @@ export async function readCustomTables(projectId: number) { } export async function readCustomTablesInFolder( - projectId: number, - folderId: number | null, + projectId: string, + folderId: string | null, ) { const whereCondition = folderId === null @@ -34,7 +35,7 @@ export async function readCustomTablesInFolder( .orderBy(customTable.name); } -export async function readCustomTable(id: number) { +export async function readCustomTable(id: string) { const [selectedCustomTable] = await db .select() .from(customTable) @@ -44,7 +45,7 @@ export async function readCustomTable(id: number) { } export async function generateUniqueTableName( - projectId: number, + projectId: string, baseName: string = "Untitled", ) { const existingTables = await readCustomTables(projectId); @@ -64,19 +65,21 @@ export async function generateUniqueTableName( export async function createCustomTable( insertData: CustomTableInsert, ): Promise { + const sanitizedData = sanitizeDataForInsert(insertData); + const [newCustomTable] = await db .insert(customTable) - .values(insertData) + .values(sanitizedData) .returning(); return newCustomTable; } -export async function deleteCustomTable(id: number): Promise { +export async function deleteCustomTable(id: string): Promise { await db.delete(customTable).where(eq(customTable.id, id)); } -export async function duplicateCustomTable(id: number): Promise { +export async function duplicateCustomTable(id: string): Promise { const [existingTable] = await db .select() .from(customTable) @@ -104,12 +107,14 @@ export async function duplicateCustomTable(id: number): Promise { } export async function updateCustomTable( - id: number, + id: string, data: Partial>, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedTable] = await db .update(customTable) - .set(data) + .set(sanitizedData) .where(eq(customTable.id, id)) .returning(); @@ -117,8 +122,8 @@ export async function updateCustomTable( } export async function readCustomTableForProject( - projectId: number, - customTableId: number, + projectId: string, + customTableId: string, ): Promise { const [selectedCustomTable] = await db .select() diff --git a/packages/app/src/db/crud/data/custom_table.ts b/packages/app/src/db/crud/data/custom_table.ts index c02e9118..029147d6 100644 --- a/packages/app/src/db/crud/data/custom_table.ts +++ b/packages/app/src/db/crud/data/custom_table.ts @@ -14,7 +14,7 @@ import { count, getTableColumns, and, eq, AnyColumn } from "drizzle-orm"; import { tables, AvailableTableName } from "./helpers"; import { location_details } from "@common/db/schema/data/location_details"; export function readDataForCustomTable( - projectId: number, + projectId: string, definition: CustomTableDefinition, paginationOptions?: PaginationOptions, queryOptions?: { @@ -24,7 +24,7 @@ export function readDataForCustomTable( }; filters?: Filters; }, - zoneIds?: number[], + zoneIds?: string[], ) { const queryConfig = getBaseQueryConfig(definition); @@ -137,12 +137,12 @@ export function readDataForCustomTable( } export async function countDataForCustomTable( - projectId: number, + projectId: string, definition: CustomTableDefinition, queryOptions?: { filters?: Filters; }, - zoneIds?: number[], + zoneIds?: string[], ) { const queryConfig = getBaseQueryConfig(definition); let query = buildBaseQuery(queryConfig, { count: count() }, projectId); diff --git a/packages/app/src/db/crud/data/helpers.ts b/packages/app/src/db/crud/data/helpers.ts index cba4b016..a21fa4d7 100644 --- a/packages/app/src/db/crud/data/helpers.ts +++ b/packages/app/src/db/crud/data/helpers.ts @@ -223,7 +223,7 @@ export function generateAbbreviationJoins(tableName: AvailableTableName) { })); } -export function getZoneFilter(zoneIds: number[]) { +export function getZoneFilter(zoneIds: string[]) { return sql`location_details.geometry IS NOT NULL AND ST_Within( ST_SetSRID(location_details.geometry, 4326), @@ -426,7 +426,7 @@ export function getBaseQueryConfig( export function buildBaseQuery( queryConfig: QueryConfig, selection: Record, - projectId: number, + projectId: string, ) { const { table, diff --git a/packages/app/src/db/crud/data/index.ts b/packages/app/src/db/crud/data/index.ts index 0df472d8..38edc402 100644 --- a/packages/app/src/db/crud/data/index.ts +++ b/packages/app/src/db/crud/data/index.ts @@ -104,7 +104,7 @@ function getTableSelection(tableName: TableName) { } export function readDataForProject( - projectId: number, + projectId: string, tableName: TableName, paginationOptions?: PaginationOptions, queryOptions?: { @@ -113,7 +113,7 @@ export function readDataForProject( order: keyof typeof orderFnMap; }; filters?: Filters; - zoneIds?: number[]; + zoneIds?: string[]; }, ): Promise { const config = tableConfig[tableName]; @@ -183,11 +183,11 @@ export function readDataForProject( } export async function countDataForTable( - projectId: number, + projectId: string, tableName: TableName, queryOptions?: { filters?: Filters; - zoneIds?: number[]; + zoneIds?: string[]; }, ) { const config = tableConfig[tableName]; @@ -300,7 +300,7 @@ function processAbbreviations( } export async function readDataRowsByUniqueKeys( - projectId: number, + projectId: string, tableName: TableName, batchUniqueKeys: Record[], ): Promise<(Record | null)[]> { @@ -451,7 +451,7 @@ type AbbrSummaryMapping = Partial< async function getOrCreateAbbreviations( tx: typeof db, abbrSummaryForTable: ImportSummary["abbreviations"], - projectId: number, + projectId: string, ): Promise { const abbrs: AbbrSummaryMapping = {}; for (const abbr of abbrSummaryForTable) { @@ -481,7 +481,7 @@ async function getOrCreateAbbreviations( } export async function executeImport( - projectId: number, + projectId: string, summary: Omit, ) { type RecordMap = { @@ -557,8 +557,8 @@ export async function executeImport( function transformToInsert( table: string, data: Record, - parentId: number | null, - projectId: number, + parentId: string | null, + projectId: string, ): Record { const result: Record = {}; diff --git a/packages/app/src/db/crud/data/log.ts b/packages/app/src/db/crud/data/log.ts index 30246e43..219e6afb 100644 --- a/packages/app/src/db/crud/data/log.ts +++ b/packages/app/src/db/crud/data/log.ts @@ -9,7 +9,7 @@ import { } from "@common/db/schema/abbreviation"; export const readDataForLocation = async ( - projectId: number, + projectId: string, locationId: string, ) => { return await db @@ -29,7 +29,7 @@ export const readDataForLocation = async ( ); }; -export const readGeologyCodesForProject = async (projectId: number) => { +export const readGeologyCodesForProject = async (projectId: string) => { return await db .select({ ...getTableColumns(abbreviation), diff --git a/packages/app/src/db/crud/folder.ts b/packages/app/src/db/crud/folder.ts index 0d7a75a8..98b7252d 100644 --- a/packages/app/src/db/crud/folder.ts +++ b/packages/app/src/db/crud/folder.ts @@ -1,9 +1,9 @@ import { eq, and, isNull } from "drizzle-orm"; import { db } from ".."; import { folder, Folder, FolderInsert } from "@common/db/schema/folder"; - +import { sanitizeDataForInsert } from "@common/db/schema/common"; export async function readFolders( - projectId: number, + projectId: string, type: "customTable" | "plot", ): Promise { return await db @@ -13,7 +13,7 @@ export async function readFolders( .orderBy(folder.name); } -export async function readFolder(id: number): Promise { +export async function readFolder(id: string): Promise { const [selectedFolder] = await db .select() .from(folder) @@ -23,7 +23,7 @@ export async function readFolder(id: number): Promise { } export async function readRootFolders( - projectId: number, + projectId: string, type: "customTable" | "plot", ): Promise { return await db @@ -40,7 +40,7 @@ export async function readRootFolders( } export async function readChildFolders( - parentFolderId: number, + parentFolderId: string, ): Promise { return await db .select() @@ -50,8 +50,8 @@ export async function readChildFolders( } export async function generateUniqueFolderName( - projectId: number, - parentFolderId: number | null = null, + projectId: string, + parentFolderId: string | null = null, type: "customTable" | "plot" = "customTable", baseName: string = "New Folder", ): Promise { @@ -73,22 +73,26 @@ export async function generateUniqueFolderName( } export async function createFolder(insertData: FolderInsert): Promise { - const [newFolder] = await db.insert(folder).values(insertData).returning(); + const sanitizedData = sanitizeDataForInsert(insertData); + + const [newFolder] = await db.insert(folder).values(sanitizedData).returning(); return newFolder; } -export async function deleteFolder(id: number): Promise { +export async function deleteFolder(id: string): Promise { await db.delete(folder).where(eq(folder.id, id)); } export async function updateFolder( - id: number, + id: string, data: Partial>, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedFolder] = await db .update(folder) - .set(data) + .set(sanitizedData) .where(eq(folder.id, id)) .returning(); @@ -96,8 +100,8 @@ export async function updateFolder( } export async function readFolderForProject( - projectId: number, - folderId: number, + projectId: string, + folderId: string, ): Promise { const [selectedFolder] = await db .select() @@ -107,7 +111,7 @@ export async function readFolderForProject( return selectedFolder; } -export async function getFolderPath(folderId: number): Promise { +export async function getFolderPath(folderId: string): Promise { const path: Folder[] = []; let currentFolderId = folderId; @@ -116,7 +120,7 @@ export async function getFolderPath(folderId: number): Promise { if (!currentFolder) break; path.unshift(currentFolder); - currentFolderId = currentFolder.parentFolderId || 0; + currentFolderId = currentFolder.parentFolderId || ""; } return path; diff --git a/packages/app/src/db/crud/import.ts b/packages/app/src/db/crud/import.ts index 3ba99bc5..24396891 100644 --- a/packages/app/src/db/crud/import.ts +++ b/packages/app/src/db/crud/import.ts @@ -17,9 +17,9 @@ import { eq, and, count, getTableColumns, sql } from "drizzle-orm"; import { db } from ".."; import { PaginationOptions } from "./common"; import { TableName } from "@common/db/schema/data"; - +import { sanitizeDataForInsert } from "@common/db/schema/common"; export async function readImportsForProjectWithFiles( - projectId: number, + projectId: string, options?: PaginationOptions, ) { // Calculate pagination @@ -90,7 +90,7 @@ export async function readImportsForProjectWithFiles( return acc; }, {} as Record< - number, + string, { import: Omit< (typeof agsImportsResult)[number]["import"], @@ -126,7 +126,7 @@ export async function readImportsForProjectWithFiles( return acc; }, {} as Record< - number, + string, { import: (typeof excelImportsResult)[number]["import"] & { kind: "excel"; @@ -151,12 +151,12 @@ export async function readImportsForProjectWithFiles( return paginatedImports; } -export async function deleteExcelImport(importId: number) { +export async function deleteExcelImport(importId: string) { await db.delete(excelImport).where(eq(excelImport.id, importId)).execute(); } export async function readImportsCountForProject( - projectId: number, + projectId: string, ): Promise { // Count AGS imports const [agsResult] = await db @@ -177,7 +177,7 @@ export async function readImportsCountForProject( } export async function readImportById( - importId: number, + importId: string, ): Promise { const [selectedImport] = await db .select() @@ -189,8 +189,8 @@ export async function readImportById( } export async function readProjectImport( - projectId: number, - importId: number, + projectId: string, + importId: string, ): Promise { const [selectedImport] = await db .select() @@ -202,8 +202,8 @@ export async function readProjectImport( } export async function readExcelImportForProject( - projectId: number, - importId: number, + projectId: string, + importId: string, ): Promise { const [selectedImport] = await db .select() @@ -216,7 +216,7 @@ export async function readExcelImportForProject( return selectedImport; } export async function readExcelImportFilesForImport( - importId: number, + importId: string, ): Promise { return await db .select() @@ -226,9 +226,9 @@ export async function readExcelImportFilesForImport( } export async function readExcelImportFileForProject( - projectId: number, - importId: number, - fileId: number, + projectId: string, + importId: string, + fileId: string, ): Promise { const [selectedFile] = await db .select() @@ -247,12 +247,14 @@ export async function readExcelImportFileForProject( } export async function updateExcelImportFile( - id: number, + id: string, data: Partial, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedExcelImportFile] = await db .update(excelImportFile) - .set(data) + .set(sanitizedData) .where(eq(excelImportFile.id, id)) .returning() .execute(); @@ -260,8 +262,8 @@ export async function updateExcelImportFile( } export async function readProjectImportWithoutSummary( - projectId: number, - importId: number, + projectId: string, + importId: string, ): Promise | undefined> { const { id, @@ -292,12 +294,14 @@ export async function readProjectImportWithoutSummary( } export async function updateExcelImport( - id: number, + id: string, data: Partial, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedExcelImport] = await db .update(excelImport) - .set(data) + .set(sanitizedData) .where(eq(excelImport.id, id)) .returning() .execute(); @@ -306,8 +310,8 @@ export async function updateExcelImport( } export async function readCsvValidateData( - projectId: number, - importId: number, + projectId: string, + importId: string, tableName: TableName, offset?: number, limit?: number, @@ -331,8 +335,8 @@ export async function readCsvValidateData( } export async function readCsvValidateDataCount( - projectId: number, - importId: number, + projectId: string, + importId: string, tableName: TableName, ) { const result = await db @@ -353,8 +357,8 @@ export async function readCsvValidateDataCount( } export async function readDetailedImportSummary( - projectId: number, - importId: number, + projectId: string, + importId: string, tableName: TableName, changeType: "creates" | "updates", offset: number, @@ -377,8 +381,8 @@ export async function readDetailedImportSummary( } export async function readDetailedImportSummaryCount( - projectId: number, - importId: number, + projectId: string, + importId: string, tableName: TableName, changeType: "creates" | "updates", ) { @@ -398,8 +402,8 @@ export async function readDetailedImportSummaryCount( } // export async function readImportSummaryTableData( -// projectId: number, -// importId: number, +// projectId: string, +// importId: string, // tableName: string, // changeType: "creates" | "updates", // limit: number, @@ -425,8 +429,8 @@ export async function readDetailedImportSummaryCount( // } export async function checkImportExistsForProject( - projectId: number, - importId: number, + projectId: string, + importId: string, ) { const [result] = await db .select({ count: count() }) @@ -440,9 +444,11 @@ export async function checkImportExistsForProject( export async function createAgsImport( data: AgsImportCreate, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [insertedAgsImport] = await db .insert(agsImport) - .values(data) + .values(sanitizedData) .returning() .execute(); @@ -453,10 +459,12 @@ export async function createAgsImportWithUploads( data: AgsImportCreate, uploads: Omit[], ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const result = await db.transaction(async (trx) => { const [insertedAgsImport] = await trx .insert(agsImport) - .values(data) + .values(sanitizedData) .returning() .execute(); @@ -480,17 +488,22 @@ export async function createExcelImportWithUploads( data: ExcelImportInsert, uploads: Omit[], ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const sanitizedUploads = uploads.map((upload) => + sanitizeDataForInsert(upload), + ); + const result = await db.transaction(async (trx) => { const [insertedExcelImport] = await trx .insert(excelImport) - .values(data) + .values(sanitizedData) .returning() .execute(); await trx .insert(excelImportFile) .values( - uploads.map((upload) => ({ + sanitizedUploads.map((upload) => ({ ...upload, excelImportId: insertedExcelImport.id, includeInImport: true, @@ -505,12 +518,14 @@ export async function createExcelImportWithUploads( } export async function updateAgsUpload( - id: number, + id: string, data: Partial, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedAgsUpload] = await db .update(agsFileUpload) - .set(data) + .set(sanitizedData) .where(eq(agsFileUpload.id, id)) .returning() .execute(); @@ -519,7 +534,7 @@ export async function updateAgsUpload( } export async function readAgsFileUploadsForImport( - id: number, + id: string, ): Promise { return await db .select() @@ -529,7 +544,7 @@ export async function readAgsFileUploadsForImport( } export async function readAgsImportById( - id: number, + id: string, ): Promise { const [selectedAgsImport] = await db .select() @@ -541,12 +556,14 @@ export async function readAgsImportById( } export async function updateAgsImport( - id: number, + id: string, data: Partial, ): Promise { + const sanitizedData = sanitizeDataForInsert(data); + const [updatedAgsImport] = await db .update(agsImport) - .set(data) + .set(sanitizedData) .where(eq(agsImport.id, id)) .returning() .execute(); @@ -554,7 +571,7 @@ export async function updateAgsImport( return updatedAgsImport; } -export async function deleteAgsImport(id: number) { +export async function deleteAgsImport(id: string) { await db.transaction(async (trx) => { await trx .delete(agsFileUpload) diff --git a/packages/app/src/db/crud/map.ts b/packages/app/src/db/crud/map.ts index b7627efb..eff2bed0 100644 --- a/packages/app/src/db/crud/map.ts +++ b/packages/app/src/db/crud/map.ts @@ -19,7 +19,7 @@ import { count, countDistinct, eq, sql, and } from "drizzle-orm"; import { field_geological_descriptions } from "@common/db/schema/data/field_geological_descriptions"; import { abbreviation } from "@common/db/schema/abbreviation"; -export async function readProjectCentroidGeoJSON(projectId: number) { +export async function readProjectCentroidGeoJSON(projectId: string) { const locationsSubQuery = db .select({ geometry: location_details.geometry }) .from(location_details) @@ -39,7 +39,7 @@ export async function readProjectCentroidGeoJSON(projectId: number) { } // type LabTestCountByLocation = { -// locationId: number; +// locationId: string; // locationIdentifier: string; // geometry: string; // sampleCount: number; @@ -59,7 +59,7 @@ export async function readProjectCentroidGeoJSON(projectId: number) { // waterMoistureContentTests: number; // }; -export async function readLabTestCountByLocation(projectId: number) { +export async function readLabTestCountByLocation(projectId: string) { const results = await db .select({ locationId: location_details.id, @@ -183,7 +183,7 @@ export async function readLabTestCountByLocation(projectId: number) { return results; } -export async function readLocationsForProject(projectId: number) { +export async function readLocationsForProject(projectId: string) { const locations = await db .select() .from(location_details) @@ -192,15 +192,15 @@ export async function readLocationsForProject(projectId: number) { } export type LocationData = { - id: number; + id: string; locationIdentifier: string | null; groundLevel: number | null; finalDepth: number | null; numSamples: number; }; export async function readLocationDataById( - locationId: number, - projectId: number, + locationId: string, + projectId: string, ): Promise { const [location] = await db .select({ @@ -229,8 +229,8 @@ export async function readLocationDataById( } export async function readGeologyDataForLocation( - locationId: number, - projectId: number, + locationId: string, + projectId: string, ) { const results = await db .select({ diff --git a/packages/app/src/db/crud/plot.ts b/packages/app/src/db/crud/plot.ts index 3cb682f4..b824b41c 100644 --- a/packages/app/src/db/crud/plot.ts +++ b/packages/app/src/db/crud/plot.ts @@ -2,7 +2,7 @@ import { db } from "@/db"; import { plot, type Plot, type PlotInsert } from "@common/db/schema/plot"; import { eq, and, isNull } from "drizzle-orm"; -export async function readPlots(projectId: number): Promise { +export async function readPlots(projectId: string): Promise { return db .select() .from(plot) @@ -11,8 +11,8 @@ export async function readPlots(projectId: number): Promise { } export async function readPlotsInFolder( - projectId: number, - folderId: number | null, + projectId: string, + folderId: string | null, ): Promise { const whereCondition = folderId === null @@ -22,7 +22,7 @@ export async function readPlotsInFolder( return db.select().from(plot).where(whereCondition).orderBy(plot.name); } -export async function readPlot(id: number): Promise { +export async function readPlot(id: string): Promise { const [result] = await db.select().from(plot).where(eq(plot.id, id)); return result; } @@ -33,8 +33,8 @@ export async function createPlot(insertData: PlotInsert): Promise { } export async function readPlotForProject( - projectId: number, - plotId: number, + projectId: string, + plotId: string, ): Promise { const [result] = await db .select() @@ -44,7 +44,7 @@ export async function readPlotForProject( } export async function updatePlot( - id: number, + id: string, data: Partial, ): Promise { const [updatedPlot] = await db @@ -55,12 +55,12 @@ export async function updatePlot( return updatedPlot; } -export async function deletePlot(id: number): Promise { +export async function deletePlot(id: string): Promise { await db.delete(plot).where(eq(plot.id, id)); } export async function generateUniquePlotName( - projectId: number, + projectId: string, baseName: string = "New Plot", ): Promise { const existingPlots = await readPlots(projectId); diff --git a/packages/app/src/db/crud/project.ts b/packages/app/src/db/crud/project.ts index 6ab5ee05..61032d0a 100644 --- a/packages/app/src/db/crud/project.ts +++ b/packages/app/src/db/crud/project.ts @@ -9,7 +9,7 @@ import { userProject, } from "@common/db/schema/project"; -export async function readProjectsByUserId(userId: number) { +export async function readProjectsByUserId(userId: string) { const selectedProjects = await db .select() .from(project) @@ -22,7 +22,7 @@ export async function readProjectsByUserId(userId: number) { } export async function readProjectsWithUsersAndRole( - userId: number, + userId: string, { page = 1, pageSize = 10, @@ -107,7 +107,7 @@ export async function readProjectsWithUsersAndRole( } export async function readProjectById( - projectId: number, + projectId: string, ): Promise { const [selectedProject] = await db .select() @@ -119,8 +119,8 @@ export async function readProjectById( } export async function readUserProject( - projectId: number, - userId: number, + projectId: string, + userId: string, ): Promise { const [selectedUserProject] = await db .select() @@ -134,7 +134,7 @@ export async function readUserProject( } export async function createProject( - userId: number, + userId: string, projectInsert: ProjectInsert, ): Promise { const role = "OWNER"; @@ -163,7 +163,7 @@ export async function createProject( } export async function updateProject( - id: number, + id: string, data: Partial, ): Promise { const [updatedProject] = await db @@ -175,7 +175,7 @@ export async function updateProject( return updatedProject; } -export async function readProjectUsers(projectId: number) { +export async function readProjectUsers(projectId: string) { const selectedUsers = await db .select({ user: user, @@ -190,8 +190,8 @@ export async function readProjectUsers(projectId: number) { } export async function createUserProject(userProjectInsert: { - userId: number; - projectId: number; + userId: string; + projectId: string; role: "OWNER" | "CONTRIBUTOR" | "VIEWER"; }): Promise { const [insertedUserProject] = await db @@ -204,8 +204,8 @@ export async function createUserProject(userProjectInsert: { } export async function updateUserProject( - projectId: number, - userId: number, + projectId: string, + userId: string, role: "CONTRIBUTOR" | "VIEWER", ): Promise { const [updatedUserProject] = await db @@ -224,7 +224,7 @@ export async function updateUserProject( } export async function readProjectTeamMembers( - projectId: number, + projectId: string, options: { search?: string; page?: number; @@ -284,11 +284,11 @@ export async function readProjectTeamMembers( }; } -export async function deleteProject(projectId: number) { +export async function deleteProject(projectId: string) { await db.delete(project).where(eq(project.id, projectId)); } -export async function deleteUserProject(projectId: number, userId: number) { +export async function deleteUserProject(projectId: string, userId: string) { return await db .delete(userProject) .where( diff --git a/packages/app/src/db/crud/tag.ts b/packages/app/src/db/crud/tag.ts index e839fc6b..bea11668 100644 --- a/packages/app/src/db/crud/tag.ts +++ b/packages/app/src/db/crud/tag.ts @@ -8,7 +8,7 @@ import { } from "@common/db/schema/template"; import { unstable_cache } from "next/cache"; -export async function readTagsByUserId(userId: number): Promise { +export async function readTagsByUserId(userId: string): Promise { return unstable_cache( async () => { return db @@ -30,7 +30,7 @@ export type TagWithUsageCount = Omit & { }; export async function readTagsWithUsageCountsByUserId( - userId: number, + userId: string, ): Promise { return unstable_cache( async () => { @@ -60,7 +60,7 @@ export async function readTagsWithUsageCountsByUserId( )(); } -export async function readTag(id: number): Promise { +export async function readTag(id: string): Promise { const [result] = await db.select().from(tag).where(eq(tag.id, id)); return result; } @@ -71,7 +71,7 @@ export async function createTag(insertData: TagInsert): Promise { } export async function updateTag( - id: number, + id: string, data: Partial>, ): Promise { const [updatedTag] = await db @@ -82,13 +82,13 @@ export async function updateTag( return updatedTag; } -export async function deleteTag(id: number): Promise { +export async function deleteTag(id: string): Promise { await db.delete(tag).where(eq(tag.id, id)); } export async function readTagForUser( - userId: number, - tagId: number, + userId: string, + tagId: string, ): Promise { const [result] = await db .select() diff --git a/packages/app/src/db/crud/template.ts b/packages/app/src/db/crud/template.ts index fbf86210..b6521f53 100644 --- a/packages/app/src/db/crud/template.ts +++ b/packages/app/src/db/crud/template.ts @@ -11,7 +11,7 @@ import { } from "@common/db/schema/template"; export async function readTemplatesByUserId( - userId: number, + userId: string, ): Promise { return db .select() @@ -21,12 +21,12 @@ export async function readTemplatesByUserId( } export async function readTemplatesWithSearchAndFilters( - userId: number, + userId: string, options: { search?: string; type?: "all" | "customTable" | "plot"; scope?: "all" | "public" | "private"; - tagIds?: number[]; + tagIds?: string[]; page?: number; pageSize?: number; } = {}, @@ -199,7 +199,7 @@ export async function readTemplatesWithSearchAndFilters( }); return acc; }, - {} as Record, + {} as Record, ); // Combine templates with their tags @@ -219,13 +219,13 @@ export async function readTemplatesWithSearchAndFilters( }; } -export async function readTemplate(id: number): Promise