Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Mar 2, 2025
1 parent 418df70 commit 4a41bc6
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/utils/__tests__/slugify.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { deslugify, slugify } from "@sgcarstrends/utils";
import { describe, expect, it } from "vitest";

describe("slugify", () => {
it("should convert basic string to slug", () => {
Expand Down
8 changes: 4 additions & 4 deletions apps/updater/src/lib/updateCars.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { cars } from "@sgcarstrends/schema";
import { LTA_DATAMALL_BASE_URL } from "@updater/config";
import { RawCar } from "@sgcarstrends/types";
import type { Car } from "@sgcarstrends/types";
import { cleanSpecialChars } from "@sgcarstrends/utils";
import { LTA_DATAMALL_BASE_URL } from "@updater/config";
import { updater } from "./updater";

export const updateCars = () => {
const filename = "Monthly New Registration of Cars by Make.zip";
const url = `${LTA_DATAMALL_BASE_URL}/${filename}`;
const keyFields: Array<keyof RawCar> = [
const keyFields: Array<keyof Car> = [
"month",
"make",
"fuel_type",
"vehicle_type",
];

return updater<RawCar>({
return updater<Car>({
table: cars,
url,
keyFields,
Expand Down
2 changes: 1 addition & 1 deletion apps/updater/src/lib/updater.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "node:path";
import { createUniqueKey } from "@sgcarstrends/utils";
import { AWS_LAMBDA_TEMP_DIR } from "@updater/config";
import { db } from "@updater/db";
import { calculateChecksum } from "@updater/utils/calculateChecksum";
import { createUniqueKey } from "@sgcarstrends/utils";
import { downloadFile } from "@updater/utils/downloadFile";
import {
type CSVTransformOptions,
Expand Down
6 changes: 3 additions & 3 deletions apps/updater/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Re-export types from shared package
export type {
RawCar as Car,
RawCOE as COE,
RawPQP as PQP
Car,
COE,
PQP,
} from "@sgcarstrends/types";
2 changes: 1 addition & 1 deletion apps/updater/src/utils/createUpdateTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const createUpdateTask = (
return schedules.task({
id,
cron,
run: async (payload: any, { ctx }) => {
run: async (payload: unknown, { ctx }) => {
logger.log("Starting updater task", { payload, ctx });

try {
Expand Down
2 changes: 1 addition & 1 deletion apps/updater/src/utils/processCSV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface CSVTransformOptions<T> {
export const processCSV = async <T>(
filePath: string,
options: CSVTransformOptions<T> = {},
): Promise<any[]> => {
): Promise<unknown[]> => {
const fileContent = fs.readFileSync(filePath, "utf-8");

const { fields = {} } = options;
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": [".sst", "coverage", "migrations", "package.json"]
"ignore": [".sst", "coverage", "migrations", "package.json", "*.d.ts"]
},
"formatter": {
"enabled": true,
Expand Down
6 changes: 3 additions & 3 deletions packages/types/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export declare enum VehicleClass {
CategoryE = "Category E"
}
export type Stage = "dev" | "staging" | "prod";
export interface RawCar {
export interface Car {
month: string;
make: string;
importer_type: string;
fuel_type: string;
vehicle_type: string;
number: number;
}
export interface RawCOE {
export interface COE {
month: string;
bidding_no: number;
vehicle_class: string;
Expand All @@ -40,7 +40,7 @@ export interface RawCOE {
bids_received: number;
premium: number;
}
export interface RawPQP {
export interface PQP {
month: string;
vehicle_class: string;
pqp: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export enum VehicleClass {
// Base types
export type Stage = "dev" | "staging" | "prod";

// Common interfaces for raw data (before database insertion)
export interface RawCar {
// Common interfaces for data (before database insertion)
export interface Car {
month: string;
make: string;
importer_type: string;
Expand All @@ -49,7 +49,7 @@ export interface RawCar {
number: number;
}

export interface RawCOE {
export interface COE {
month: string;
bidding_no: number;
vehicle_class: string;
Expand All @@ -59,7 +59,7 @@ export interface RawCOE {
premium: number;
}

export interface RawPQP {
export interface PQP {
month: string;
vehicle_class: string;
pqp: number;
Expand Down
1 change: 1 addition & 0 deletions packages/types/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/utils/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit 4a41bc6

Please sign in to comment.