From 012d9601d64c154fc759b54a12f11dc21c1fd925 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:12:03 +0200 Subject: [PATCH 1/3] fix(utils): add barrel file --- packages/data-ingestion/lib/index.ts | 3 +-- packages/jobs/lib/activities.ts | 3 +-- packages/jobs/lib/app.ts | 2 +- packages/jobs/lib/crons/autoIdleDemo.ts | 2 +- packages/jobs/lib/crons/deleteOldActivities.ts | 2 +- packages/jobs/lib/crons/deleteSyncsData.ts | 2 +- packages/jobs/lib/integration.service.ts | 2 +- packages/jobs/lib/runner/local.runner.ts | 2 +- packages/jobs/lib/runner/remote.runner.ts | 2 +- packages/jobs/lib/runner/render.runner.ts | 2 +- packages/jobs/lib/runner/runner.ts | 3 +-- packages/jobs/lib/server.ts | 2 +- packages/jobs/lib/temporal.ts | 3 +-- packages/logs/lib/env.ts | 2 +- packages/logs/lib/utils.ts | 2 +- packages/persist/lib/app.ts | 2 +- packages/persist/lib/server.ts | 2 +- packages/runner/lib/app.ts | 2 +- packages/runner/lib/monitor.ts | 2 +- packages/server/lib/clients/auth.client.ts | 2 +- packages/server/lib/clients/email.client.ts | 2 +- packages/server/lib/clients/publisher.client.ts | 2 +- .../server/lib/controllers/access.middleware.ts | 3 +-- .../server/lib/controllers/account.controller.ts | 2 +- .../server/lib/controllers/auth.controller.ts | 3 +-- .../server/lib/controllers/config.controller.ts | 2 +- .../lib/controllers/environment.controller.ts | 2 +- .../lib/controllers/onboarding.controller.ts | 2 +- .../lib/controllers/ratelimit.middleware.ts | 2 +- .../server/lib/controllers/user.controller.ts | 2 +- packages/server/lib/jobs/index.ts | 2 +- packages/server/lib/server.ts | 3 +-- packages/server/lib/utils/migrate.ts | 2 +- packages/server/lib/utils/utils.ts | 2 +- packages/utils/lib/environment/parse.ts | 1 + packages/utils/lib/errors.ts | 15 +++++++++++++++ packages/utils/lib/index.ts | 5 +++++ packages/utils/package.json | 1 + 38 files changed, 56 insertions(+), 41 deletions(-) create mode 100644 packages/utils/lib/errors.ts create mode 100644 packages/utils/lib/index.ts diff --git a/packages/data-ingestion/lib/index.ts b/packages/data-ingestion/lib/index.ts index ebd51558829..62de05ea5eb 100644 --- a/packages/data-ingestion/lib/index.ts +++ b/packages/data-ingestion/lib/index.ts @@ -1,7 +1,6 @@ import { BigQuery } from '@google-cloud/bigquery'; import type { BigQuery as BigQueryType } from '@google-cloud/bigquery'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; -import { isCloud } from '@nangohq/utils/dist/environment/detection.js'; +import { getLogger, isCloud } from '@nangohq/utils'; const logger = getLogger('BigQueryClient'); diff --git a/packages/jobs/lib/activities.ts b/packages/jobs/lib/activities.ts index 3e19e558071..f78994c0375 100644 --- a/packages/jobs/lib/activities.ts +++ b/packages/jobs/lib/activities.ts @@ -22,9 +22,8 @@ import { getSyncByIdAndName, getLastSyncDate } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger, env } from '@nangohq/utils'; import { BigQueryClient } from '@nangohq/data-ingestion/dist/index.js'; -import { env } from '@nangohq/utils/dist/environment/detection.js'; import integrationService from './integration.service.js'; import type { ContinuousSyncArgs, InitialSyncArgs, ActionArgs, WebhookArgs } from './models/worker'; diff --git a/packages/jobs/lib/app.ts b/packages/jobs/lib/app.ts index 0cad188a1f8..ca217443e0c 100644 --- a/packages/jobs/lib/app.ts +++ b/packages/jobs/lib/app.ts @@ -4,7 +4,7 @@ import { server } from './server.js'; import { cronAutoIdleDemo } from './crons/autoIdleDemo.js'; import { deleteOldActivityLogs } from './crons/deleteOldActivities.js'; import { deleteSyncsData } from './crons/deleteSyncsData.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import { JOBS_PORT } from './constants.js'; const logger = getLogger('Jobs'); diff --git a/packages/jobs/lib/crons/autoIdleDemo.ts b/packages/jobs/lib/crons/autoIdleDemo.ts index aa8f84d379c..67285c7f026 100644 --- a/packages/jobs/lib/crons/autoIdleDemo.ts +++ b/packages/jobs/lib/crons/autoIdleDemo.ts @@ -13,7 +13,7 @@ import { findPausableDemoSyncs, SpanTypes } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import tracer from 'dd-trace'; const logger = getLogger('Jobs'); diff --git a/packages/jobs/lib/crons/deleteOldActivities.ts b/packages/jobs/lib/crons/deleteOldActivities.ts index 34c20debc84..df76c097ce1 100644 --- a/packages/jobs/lib/crons/deleteOldActivities.ts +++ b/packages/jobs/lib/crons/deleteOldActivities.ts @@ -1,6 +1,6 @@ import * as cron from 'node-cron'; import { deleteLog, deleteLogsMessages, errorManager, ErrorSourceEnum, findOldActivities, MetricTypes, telemetry } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import tracer from 'dd-trace'; import { setTimeout } from 'node:timers/promises'; diff --git a/packages/jobs/lib/crons/deleteSyncsData.ts b/packages/jobs/lib/crons/deleteSyncsData.ts index 1d5f8740974..9d15e910959 100644 --- a/packages/jobs/lib/crons/deleteSyncsData.ts +++ b/packages/jobs/lib/crons/deleteSyncsData.ts @@ -10,7 +10,7 @@ import { db, findRecentlyDeletedSync } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import tracer from 'dd-trace'; const logger = getLogger('Jobs'); diff --git a/packages/jobs/lib/integration.service.ts b/packages/jobs/lib/integration.service.ts index 97ca2c3a966..795f65b510b 100644 --- a/packages/jobs/lib/integration.service.ts +++ b/packages/jobs/lib/integration.service.ts @@ -1,6 +1,6 @@ import type { Context } from '@temporalio/activity'; import type { IntegrationServiceInterface, RunScriptOptions, ServiceResponse } from '@nangohq/shared'; -import { integrationFilesAreRemote, isCloud, isProd } from '@nangohq/utils/dist/environment/detection.js'; +import { integrationFilesAreRemote, isCloud, isProd } from '@nangohq/utils'; import { createActivityLogMessage, localFileService, remoteFileService, NangoError, formatScriptError, isOk } from '@nangohq/shared'; import type { Runner } from './runner/runner.js'; import { getOrStartRunner, getRunnerId } from './runner/runner.js'; diff --git a/packages/jobs/lib/runner/local.runner.ts b/packages/jobs/lib/runner/local.runner.ts index bc74d87419a..315b288f3b6 100644 --- a/packages/jobs/lib/runner/local.runner.ts +++ b/packages/jobs/lib/runner/local.runner.ts @@ -3,7 +3,7 @@ import { RunnerType } from './runner.js'; import type { ChildProcess } from 'child_process'; import { execSync, spawn } from 'child_process'; import { getRunnerClient } from '@nangohq/nango-runner'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('Jobs'); diff --git a/packages/jobs/lib/runner/remote.runner.ts b/packages/jobs/lib/runner/remote.runner.ts index 6336c4582ca..0213c33d9ef 100644 --- a/packages/jobs/lib/runner/remote.runner.ts +++ b/packages/jobs/lib/runner/remote.runner.ts @@ -1,4 +1,4 @@ -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import type { Runner } from './runner.js'; import { RunnerType } from './runner.js'; import { getRunnerClient } from '@nangohq/nango-runner'; diff --git a/packages/jobs/lib/runner/render.runner.ts b/packages/jobs/lib/runner/render.runner.ts index 9eb8b99970f..26c0f6aa0e2 100644 --- a/packages/jobs/lib/runner/render.runner.ts +++ b/packages/jobs/lib/runner/render.runner.ts @@ -2,7 +2,7 @@ import type { Runner } from './runner.js'; import { RunnerType } from './runner.js'; import type { ProxyAppRouter } from '@nangohq/nango-runner'; import { getRunnerClient } from '@nangohq/nango-runner'; -import { env } from '@nangohq/utils/dist/environment/detection.js'; +import { env } from '@nangohq/utils'; import { NodeEnv, getPersistAPIUrl } from '@nangohq/shared'; import { RenderAPI } from './render.api.js'; import tracer from 'dd-trace'; diff --git a/packages/jobs/lib/runner/runner.ts b/packages/jobs/lib/runner/runner.ts index aa154368608..3d68516be15 100644 --- a/packages/jobs/lib/runner/runner.ts +++ b/packages/jobs/lib/runner/runner.ts @@ -2,10 +2,9 @@ import type { KVStore } from '@nangohq/shared/lib/utils/kvstore/KVStore.js'; import { LocalRunner } from './local.runner.js'; import { RenderRunner } from './render.runner.js'; import { RemoteRunner } from './remote.runner.js'; -import { isEnterprise, env } from '@nangohq/utils/dist/environment/detection.js'; +import { isEnterprise, env, getLogger } from '@nangohq/utils'; import { getRedisUrl, InMemoryKVStore, RedisKVStore } from '@nangohq/shared'; import type { ProxyAppRouter } from '@nangohq/nango-runner'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; const logger = getLogger('Runner'); diff --git a/packages/jobs/lib/server.ts b/packages/jobs/lib/server.ts index bfec70510fe..c765b3ef1d3 100644 --- a/packages/jobs/lib/server.ts +++ b/packages/jobs/lib/server.ts @@ -3,7 +3,7 @@ import { createHTTPServer } from '@trpc/server/adapters/standalone'; import superjson from 'superjson'; import { z } from 'zod'; import { suspendRunner } from './runner/runner.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('Jobs'); diff --git a/packages/jobs/lib/temporal.ts b/packages/jobs/lib/temporal.ts index af3bc6c7cb8..d805fd4564f 100644 --- a/packages/jobs/lib/temporal.ts +++ b/packages/jobs/lib/temporal.ts @@ -4,8 +4,7 @@ import * as dotenv from 'dotenv'; import { createRequire } from 'module'; import * as activities from './activities.js'; import { SYNC_TASK_QUEUE, WEBHOOK_TASK_QUEUE } from '@nangohq/shared'; -import { isProd, isEnterprise } from '@nangohq/utils/dist/environment/detection.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { isProd, isEnterprise, getLogger } from '@nangohq/utils'; const logger = getLogger('Jobs.Temporal'); diff --git a/packages/logs/lib/env.ts b/packages/logs/lib/env.ts index a229e605135..24b7abdeecc 100644 --- a/packages/logs/lib/env.ts +++ b/packages/logs/lib/env.ts @@ -1,3 +1,3 @@ -import { parseEnvs, ENVS } from '@nangohq/utils/dist/environment/parse.js'; +import { parseEnvs, ENVS } from '@nangohq/utils'; export const envs = parseEnvs(ENVS.required({ NANGO_LOGS_ES_URL: true, NANGO_LOGS_ES_USER: true, NANGO_LOGS_ES_PWD: true })); diff --git a/packages/logs/lib/utils.ts b/packages/logs/lib/utils.ts index 9a670289dd0..6adede93999 100644 --- a/packages/logs/lib/utils.ts +++ b/packages/logs/lib/utils.ts @@ -1,5 +1,5 @@ import { customAlphabet } from 'nanoid'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; export const logger = getLogger('elasticsearch'); diff --git a/packages/persist/lib/app.ts b/packages/persist/lib/app.ts index cc5c7acbc95..714d69e1561 100644 --- a/packages/persist/lib/app.ts +++ b/packages/persist/lib/app.ts @@ -1,5 +1,5 @@ import './tracer.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import { server } from './server.js'; const logger = getLogger('Persist'); diff --git a/packages/persist/lib/server.ts b/packages/persist/lib/server.ts index 71ce5f23758..fe75f982581 100644 --- a/packages/persist/lib/server.ts +++ b/packages/persist/lib/server.ts @@ -2,7 +2,7 @@ import express from 'express'; import type { Request, Response, NextFunction } from 'express'; import { validateRequest } from 'zod-express'; import { z } from 'zod'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import persistController from './controllers/persist.controller.js'; import { logLevelValues } from '@nangohq/shared'; diff --git a/packages/runner/lib/app.ts b/packages/runner/lib/app.ts index 16603a72c75..77dcfb890a1 100644 --- a/packages/runner/lib/app.ts +++ b/packages/runner/lib/app.ts @@ -1,6 +1,6 @@ import './tracer.js'; import { server } from './server.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('Runner'); diff --git a/packages/runner/lib/monitor.ts b/packages/runner/lib/monitor.ts index 8e01718d7e4..9d1406b90f1 100644 --- a/packages/runner/lib/monitor.ts +++ b/packages/runner/lib/monitor.ts @@ -3,7 +3,7 @@ import fs from 'fs'; import { stringifyError, type NangoProps } from '@nangohq/shared'; import * as superjson from 'superjson'; import { fetch } from 'undici'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const MEMORY_WARNING_PERCENTAGE_THRESHOLD = 75; const logger = getLogger('Runner'); diff --git a/packages/server/lib/clients/auth.client.ts b/packages/server/lib/clients/auth.client.ts index 02e1f3b3875..8ef0476d72a 100644 --- a/packages/server/lib/clients/auth.client.ts +++ b/packages/server/lib/clients/auth.client.ts @@ -4,7 +4,7 @@ import { BasicStrategy } from 'passport-http'; import express from 'express'; import session from 'express-session'; import path from 'path'; -import { AUTH_ENABLED, isBasicAuthEnabled } from '@nangohq/utils/dist/environment/detection.js'; +import { AUTH_ENABLED, isBasicAuthEnabled } from '@nangohq/utils'; import { dirname, userService, database } from '@nangohq/shared'; import crypto from 'crypto'; import util from 'util'; diff --git a/packages/server/lib/clients/email.client.ts b/packages/server/lib/clients/email.client.ts index 4587a645b38..f61ccbbe70b 100644 --- a/packages/server/lib/clients/email.client.ts +++ b/packages/server/lib/clients/email.client.ts @@ -1,6 +1,6 @@ import formData from 'form-data'; import Mailgun from 'mailgun.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('Server.EmailClient'); diff --git a/packages/server/lib/clients/publisher.client.ts b/packages/server/lib/clients/publisher.client.ts index 2c221cfec11..71ccc2a6056 100644 --- a/packages/server/lib/clients/publisher.client.ts +++ b/packages/server/lib/clients/publisher.client.ts @@ -2,7 +2,7 @@ import type { WebSocket } from 'ws'; import type { RedisClientType } from 'redis'; import * as uuid from 'uuid'; import { createClient } from 'redis'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import type { WSErr } from '../utils/web-socket-error.js'; import { errorHtml, successHtml } from '../utils/utils.js'; import { getRedisUrl } from '@nangohq/shared'; diff --git a/packages/server/lib/controllers/access.middleware.ts b/packages/server/lib/controllers/access.middleware.ts index 2cec069574a..0e746b5c4fb 100644 --- a/packages/server/lib/controllers/access.middleware.ts +++ b/packages/server/lib/controllers/access.middleware.ts @@ -1,6 +1,5 @@ import type { Request, Response, NextFunction } from 'express'; -import { isCloud, isBasicAuthEnabled } from '@nangohq/utils/dist/environment/detection.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { isCloud, isBasicAuthEnabled, getLogger } from '@nangohq/utils'; import { LogActionEnum, ErrorSourceEnum, diff --git a/packages/server/lib/controllers/account.controller.ts b/packages/server/lib/controllers/account.controller.ts index f0e83840b5d..9123fa3f807 100644 --- a/packages/server/lib/controllers/account.controller.ts +++ b/packages/server/lib/controllers/account.controller.ts @@ -1,6 +1,6 @@ import type { Request, Response, NextFunction } from 'express'; import type { LogLevel } from '@nangohq/shared'; -import { isCloud } from '@nangohq/utils/dist/environment/detection.js'; +import { isCloud } from '@nangohq/utils'; import { accountService, userService, errorManager, LogActionEnum, createActivityLogAndLogMessage } from '@nangohq/shared'; import { getUserAccountAndEnvironmentFromSession } from '../utils/utils.js'; diff --git a/packages/server/lib/controllers/auth.controller.ts b/packages/server/lib/controllers/auth.controller.ts index db874c73a59..13f7753a868 100644 --- a/packages/server/lib/controllers/auth.controller.ts +++ b/packages/server/lib/controllers/auth.controller.ts @@ -6,8 +6,7 @@ import { resetPasswordSecret, getUserAccountAndEnvironmentFromSession } from '.. import jwt from 'jsonwebtoken'; import EmailClient from '../clients/email.client.js'; import type { User, Result } from '@nangohq/shared'; -import { isCloud, baseUrl, basePublicUrl } from '@nangohq/utils/dist/environment/detection.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { isCloud, baseUrl, basePublicUrl, getLogger } from '@nangohq/utils'; import { userService, accountService, diff --git a/packages/server/lib/controllers/config.controller.ts b/packages/server/lib/controllers/config.controller.ts index 759fc0769ff..0cb2a77c069 100644 --- a/packages/server/lib/controllers/config.controller.ts +++ b/packages/server/lib/controllers/config.controller.ts @@ -8,7 +8,7 @@ import type { Integration as ProviderIntegration, Config } from '@nangohq/shared'; -import { isHosted } from '@nangohq/utils/dist/environment/detection.js'; +import { isHosted } from '@nangohq/utils'; import { flowService, getConfigWithEndpointsByProviderConfigKey, diff --git a/packages/server/lib/controllers/environment.controller.ts b/packages/server/lib/controllers/environment.controller.ts index 682a686165d..f6ca1a5f498 100644 --- a/packages/server/lib/controllers/environment.controller.ts +++ b/packages/server/lib/controllers/environment.controller.ts @@ -1,6 +1,6 @@ import type { Request, Response, NextFunction } from 'express'; import type { Environment } from '@nangohq/shared'; -import { isCloud, baseUrl } from '@nangohq/utils/dist/environment/detection.js'; +import { isCloud, baseUrl } from '@nangohq/utils'; import { accountService, hmacService, diff --git a/packages/server/lib/controllers/onboarding.controller.ts b/packages/server/lib/controllers/onboarding.controller.ts index 25023bf6bca..adef63eab0b 100644 --- a/packages/server/lib/controllers/onboarding.controller.ts +++ b/packages/server/lib/controllers/onboarding.controller.ts @@ -30,7 +30,7 @@ import { AnalyticsTypes } from '@nangohq/shared'; import type { CustomerFacingDataRecord, IncomingPreBuiltFlowConfig } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import { getUserAccountAndEnvironmentFromSession } from '../utils/utils.js'; const logger = getLogger('Server.Onboarding'); diff --git a/packages/server/lib/controllers/ratelimit.middleware.ts b/packages/server/lib/controllers/ratelimit.middleware.ts index d56a25b8897..8e800cf0f3c 100644 --- a/packages/server/lib/controllers/ratelimit.middleware.ts +++ b/packages/server/lib/controllers/ratelimit.middleware.ts @@ -3,7 +3,7 @@ import { createClient } from 'redis'; import type { RateLimiterRes } from 'rate-limiter-flexible'; import { RateLimiterRedis, RateLimiterMemory } from 'rate-limiter-flexible'; import { getAccount, getRedisUrl } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('RateLimiter'); diff --git a/packages/server/lib/controllers/user.controller.ts b/packages/server/lib/controllers/user.controller.ts index ee42d51e9e2..d712e18ac39 100644 --- a/packages/server/lib/controllers/user.controller.ts +++ b/packages/server/lib/controllers/user.controller.ts @@ -1,7 +1,7 @@ import { getUserAccountAndEnvironmentFromSession } from '../utils/utils.js'; import type { Request, Response, NextFunction } from 'express'; import EmailClient from '../clients/email.client.js'; -import { isCloud, isEnterprise, basePublicUrl } from '@nangohq/utils/dist/environment/detection.js'; +import { isCloud, isEnterprise, basePublicUrl } from '@nangohq/utils'; import { errorManager, userService } from '@nangohq/shared'; export interface GetUser { diff --git a/packages/server/lib/jobs/index.ts b/packages/server/lib/jobs/index.ts index f5b1f28b232..c90ecd182b6 100644 --- a/packages/server/lib/jobs/index.ts +++ b/packages/server/lib/jobs/index.ts @@ -1,4 +1,4 @@ -import { isCloud } from '@nangohq/utils/dist/environment/detection.js'; +import { isCloud } from '@nangohq/utils'; import { encryptionManager } from '@nangohq/shared'; export async function encryptDataRecords(): Promise { diff --git a/packages/server/lib/server.ts b/packages/server/lib/server.ts index 3cb20285849..6345785db59 100644 --- a/packages/server/lib/server.ts +++ b/packages/server/lib/server.ts @@ -33,8 +33,7 @@ import passport from 'passport'; import environmentController from './controllers/environment.controller.js'; import accountController from './controllers/account.controller.js'; import type { Response, Request } from 'express'; -import { isCloud, isEnterprise, AUTH_ENABLED, MANAGED_AUTH_ENABLED, isBasicAuthEnabled } from '@nangohq/utils/dist/environment/detection.js'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { isCloud, isEnterprise, AUTH_ENABLED, MANAGED_AUTH_ENABLED, isBasicAuthEnabled, getLogger } from '@nangohq/utils'; import { getGlobalOAuthCallbackUrl, environmentService, getPort, errorManager, getWebsocketsPath, packageJsonFile } from '@nangohq/shared'; import oAuthSessionService from './services/oauth-session.service.js'; import migrate from './utils/migrate.js'; diff --git a/packages/server/lib/utils/migrate.ts b/packages/server/lib/utils/migrate.ts index 599f4258e35..bb10a68b4c6 100644 --- a/packages/server/lib/utils/migrate.ts +++ b/packages/server/lib/utils/migrate.ts @@ -1,4 +1,4 @@ -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; const logger = getLogger('Server'); diff --git a/packages/server/lib/utils/utils.ts b/packages/server/lib/utils/utils.ts index c45515e9bd7..bc7a337eaf5 100644 --- a/packages/server/lib/utils/utils.ts +++ b/packages/server/lib/utils/utils.ts @@ -2,7 +2,7 @@ import { fileURLToPath } from 'url'; import path from 'path'; import type { Request } from 'express'; import type { User, Environment, Account, Template as ProviderTemplate, ServiceResponse } from '@nangohq/shared'; -import { getLogger } from '@nangohq/utils/dist/logger.js'; +import { getLogger } from '@nangohq/utils'; import type { WSErr } from './web-socket-error.js'; import { NangoError, userService, environmentService, interpolateString } from '@nangohq/shared'; diff --git a/packages/utils/lib/environment/parse.ts b/packages/utils/lib/environment/parse.ts index 915a0650914..abff8c1dff7 100644 --- a/packages/utils/lib/environment/parse.ts +++ b/packages/utils/lib/environment/parse.ts @@ -37,6 +37,7 @@ export const ENVS = z.object({ RUNNER_OWNER_ID: z.coerce.number().optional(), RUNNER_ID: z.string().optional(), IDLE_MAX_DURATION_MS: z.coerce.number().default(0), + NOTIFY_IDLE_ENDPOINT: z.string().optional(), // Demo DEFAULT_GITHUB_CLIENT_ID: z.string().optional(), diff --git a/packages/utils/lib/errors.ts b/packages/utils/lib/errors.ts new file mode 100644 index 00000000000..68694a54aac --- /dev/null +++ b/packages/utils/lib/errors.ts @@ -0,0 +1,15 @@ +import { serializeError } from 'serialize-error'; + +/** + * Transform any Error or primitive to a json object + */ +export function errorToObject(err: unknown) { + return serializeError(err); +} + +/** + * Transform any Error or primitive to a string + */ +export function stringifyError(err: unknown) { + return JSON.stringify(serializeError(err)); +} diff --git a/packages/utils/lib/index.ts b/packages/utils/lib/index.ts new file mode 100644 index 00000000000..1b46c475dc3 --- /dev/null +++ b/packages/utils/lib/index.ts @@ -0,0 +1,5 @@ +export * from './environment/constants.js'; +export * from './environment/detection.js'; +export * from './environment/parse.js'; +export * from './errors.js'; +export * from './logger.js'; diff --git a/packages/utils/package.json b/packages/utils/package.json index 957fc2c8b8e..3a456b9d04f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -17,6 +17,7 @@ "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", "dependencies": { "winston": "3.8.2", + "serialize-error": "11.0.3", "zod": "3.22.4" }, "devDependencies": { From 9762cc18f34ad9c376a28e19db70de30af340f01 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:15:20 +0200 Subject: [PATCH 2/3] env --- packages/utils/lib/environment/parse.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/utils/lib/environment/parse.ts b/packages/utils/lib/environment/parse.ts index abff8c1dff7..915a0650914 100644 --- a/packages/utils/lib/environment/parse.ts +++ b/packages/utils/lib/environment/parse.ts @@ -37,7 +37,6 @@ export const ENVS = z.object({ RUNNER_OWNER_ID: z.coerce.number().optional(), RUNNER_ID: z.string().optional(), IDLE_MAX_DURATION_MS: z.coerce.number().default(0), - NOTIFY_IDLE_ENDPOINT: z.string().optional(), // Demo DEFAULT_GITHUB_CLIENT_ID: z.string().optional(), From c97fbd9887af37b1b4bdfb2c419b9bb3f85e2761 Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:23:33 +0200 Subject: [PATCH 3/3] lock --- package-lock.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package-lock.json b/package-lock.json index 8933221ff6a..96ebe2d5041 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35549,6 +35549,7 @@ "version": "1.0.0", "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", "dependencies": { + "serialize-error": "11.0.3", "winston": "3.8.2", "zod": "3.22.4" },