diff --git a/apps/scandic-web/package.json b/apps/scandic-web/package.json index 066c97d85..e9f24a8e9 100644 --- a/apps/scandic-web/package.json +++ b/apps/scandic-web/package.json @@ -73,7 +73,6 @@ "input-otp": "^1.4.2", "json-stable-stringify-without-jsonify": "^1.0.1", "jsonwebtoken": "^9.0.2", - "lodash-es": "^4.17.21", "md5": "^2.3.0", "motion": "^12.10.0", "nanoid": "^5.1.5", @@ -108,7 +107,6 @@ "@types/adm-zip": "^0.5.7", "@types/json-stable-stringify-without-jsonify": "^1.0.2", "@types/jsonwebtoken": "^9", - "@types/lodash-es": "^4", "@types/node": "^20", "@types/react": "19.1.0", "@types/react-dom": "19.1.0", diff --git a/packages/booking-flow/package.json b/packages/booking-flow/package.json index d611656e4..44505aa41 100644 --- a/packages/booking-flow/package.json +++ b/packages/booking-flow/package.json @@ -82,7 +82,6 @@ "@eslint/js": "^9.26.0", "@scandic-hotels/typescript-config": "workspace:*", "@t3-oss/env-nextjs": "^0.13.4", - "@types/lodash-es": "^4", "@types/react": "19.1.0", "@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/parser": "^8.32.0", diff --git a/packages/common/package.json b/packages/common/package.json index c9654b894..d8ea5afb2 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -73,7 +73,6 @@ "deepmerge": "^4.3.1", "flat": "^6.0.1", "libphonenumber-js": "^1.12.7", - "lodash-es": "^4.17.21", "nanoid": "^5.1.5", "zod": "^3.24.4", "zustand": "^4.5.2" @@ -86,7 +85,6 @@ "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.26.0", "@scandic-hotels/typescript-config": "workspace:*", - "@types/lodash-es": "^4", "@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/parser": "^8.32.0", "dotenv": "^16.5.0", diff --git a/packages/common/telemetry/index.ts b/packages/common/telemetry/index.ts index e1333227d..bfce226b1 100644 --- a/packages/common/telemetry/index.ts +++ b/packages/common/telemetry/index.ts @@ -8,20 +8,6 @@ import { } from "@opentelemetry/api" import deepmerge from "deepmerge" import { flatten } from "flat" -import { - every, - isArray, - isBoolean, - isFunction, - isNull, - isNumber, - isObject, - isPlainObject, - isString, - isUndefined, - keys, - mapValues, -} from "lodash-es" import { logger } from "../logger" @@ -32,10 +18,10 @@ type AttributesInput = Record function isAttributesInput(value: unknown): value is AttributesInput { return ( isObject(value) && - !isArray(value) && + !Array.isArray(value) && !isNull(value) && - keys(value).length > 0 && - every(keys(value), isString) + Object.keys(value).length > 0 && + Object.keys(value).every(isString) ) } @@ -51,9 +37,8 @@ export function isValidAttributeValue(value: unknown): value is AttributeValue { if (isString(value) || isNumber(value) || isBoolean(value)) { return true } - if (isArray(value)) { - return every( - value, + if (Array.isArray(value)) { + return value.every( (item) => isNull(item) || isUndefined(item) || @@ -309,3 +294,31 @@ export function createCounter(meterName: string, counterName: string) { }, } } + +const isBoolean = (v: unknown): v is boolean => typeof v === "boolean" +const isFunction = (v: unknown): v is Function => typeof v === "function" +const isNull = (v: unknown): v is null => v === null +const isNumber = (v: unknown): v is number => + typeof v === "number" && Number.isFinite(v as number) +const isObject = (v: unknown): v is Record => + typeof v === "object" && v !== null +const isString = (v: unknown): v is string => typeof v === "string" +const isUndefined = (v: unknown): v is undefined => typeof v === "undefined" +const isPlainObject = (v: unknown): v is Record => { + if (!isObject(v)) return false + const proto = Object.getPrototypeOf(v) + return proto === Object.prototype || proto === null +} + +const mapValues = , R>( + obj: T, + iteratee: (value: T[keyof T], key: keyof T) => R +): Record => { + const out: Partial> = {} + for (const k in obj) { + if (Object.prototype.hasOwnProperty.call(obj, k)) { + out[k] = iteratee(obj[k], k) + } + } + return out as Record +} diff --git a/packages/tracking/package.json b/packages/tracking/package.json index c7cd002ba..437b4e285 100644 --- a/packages/tracking/package.json +++ b/packages/tracking/package.json @@ -27,7 +27,6 @@ "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.26.0", "@scandic-hotels/typescript-config": "workspace:*", - "@types/lodash-es": "^4", "@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/parser": "^8.32.0", "dotenv": "^16.5.0", diff --git a/packages/trpc/package.json b/packages/trpc/package.json index a44dd4b2a..585eea93e 100644 --- a/packages/trpc/package.json +++ b/packages/trpc/package.json @@ -77,7 +77,6 @@ "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.26.0", "@scandic-hotels/typescript-config": "workspace:*", - "@types/lodash-es": "^4", "@types/react": "19.1.0", "@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/parser": "^8.32.0", diff --git a/yarn.lock b/yarn.lock index f4601d9b6..a28e2098e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5878,7 +5878,6 @@ __metadata: "@scandic-hotels/typescript-config": "workspace:*" "@t3-oss/env-nextjs": "npm:^0.13.4" "@trpc/client": "npm:^11.1.2" - "@types/lodash-es": "npm:^4" "@types/react": "npm:19.1.0" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" @@ -5930,7 +5929,6 @@ __metadata: "@scandic-hotels/typescript-config": "workspace:*" "@sentry/nextjs": "npm:^10.11.0" "@t3-oss/env-nextjs": "npm:^0.13.4" - "@types/lodash-es": "npm:^4" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" deepmerge: "npm:^4.3.1" @@ -5940,7 +5938,6 @@ __metadata: eslint-plugin-simple-import-sort: "npm:^12.1.1" flat: "npm:^6.0.1" libphonenumber-js: "npm:^1.12.7" - lodash-es: "npm:^4.17.21" nanoid: "npm:^5.1.5" typescript: "npm:5.8.3" vitest: "npm:^3.2.4" @@ -6152,7 +6149,6 @@ __metadata: "@types/geojson": "npm:^7946.0.16" "@types/json-stable-stringify-without-jsonify": "npm:^1.0.2" "@types/jsonwebtoken": "npm:^9" - "@types/lodash-es": "npm:^4" "@types/node": "npm:^20" "@types/react": "npm:19.1.0" "@types/react-dom": "npm:19.1.0" @@ -6190,7 +6186,6 @@ __metadata: json-stable-stringify-without-jsonify: "npm:^1.0.1" jsonwebtoken: "npm:^9.0.2" lint-staged: "npm:^15.5.2" - lodash-es: "npm:^4.17.21" md5: "npm:^2.3.0" motion: "npm:^12.10.0" nanoid: "npm:^5.1.5" @@ -6232,7 +6227,6 @@ __metadata: "@scandic-hotels/common": "workspace:*" "@scandic-hotels/trpc": "workspace:*" "@scandic-hotels/typescript-config": "workspace:*" - "@types/lodash-es": "npm:^4" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" dotenv: "npm:^16.5.0" @@ -6259,7 +6253,6 @@ __metadata: "@trpc/client": "npm:^11.1.2" "@trpc/react-query": "npm:^11.1.2" "@trpc/server": "npm:^11.1.2" - "@types/lodash-es": "npm:^4" "@types/react": "npm:19.1.0" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" @@ -7902,22 +7895,6 @@ __metadata: languageName: node linkType: hard -"@types/lodash-es@npm:^4": - version: 4.17.12 - resolution: "@types/lodash-es@npm:4.17.12" - dependencies: - "@types/lodash": "npm:*" - checksum: 10c0/5d12d2cede07f07ab067541371ed1b838a33edb3c35cb81b73284e93c6fd0c4bbeaefee984e69294bffb53f62d7272c5d679fdba8e595ff71e11d00f2601dde0 - languageName: node - linkType: hard - -"@types/lodash@npm:*": - version: 4.17.16 - resolution: "@types/lodash@npm:4.17.16" - checksum: 10c0/cf017901b8ab1d7aabc86d5189d9288f4f99f19a75caf020c0e2c77b8d4cead4db0d0b842d009b029339f92399f49f34377dd7c2721053388f251778b4c23534 - languageName: node - linkType: hard - "@types/mdx@npm:^2.0.0": version: 2.0.13 resolution: "@types/mdx@npm:2.0.13"