remove sdk/types package and move it to main sdk package

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-28 11:09:51 +01:00
parent a898cfb14a
commit 43b2fbe7e4
28 changed files with 48 additions and 393 deletions

View File

@@ -29,7 +29,7 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@mixan/sdk": "workspace:*",
"@types/ramda": "^0.29.6",
"@types/ua-parser-js": "^0.7.39",
"@types/uuid": "^9.0.8",

View File

@@ -11,7 +11,7 @@ import type { IServiceCreateEventPayload } from '@mixan/db';
import { createBotEvent, createEvent, getEvents, getSalts } from '@mixan/db';
import type { JobsOptions } from '@mixan/queue';
import { eventsQueue, findJobByPrefix } from '@mixan/queue';
import type { PostEventPayload } from '@mixan/types';
import type { PostEventPayload } from '@mixan/sdk';
const SESSION_TIMEOUT = 1000 * 60 * 30;
const SESSION_END_TIMEOUT = SESSION_TIMEOUT + 1000;

View File

@@ -4,10 +4,7 @@ import type { FastifyReply, FastifyRequest } from 'fastify';
import { assocPath, pathOr } from 'ramda';
import { getProfileById, upsertProfile } from '@mixan/db';
import type {
IncrementProfilePayload,
UpdateProfilePayload,
} from '@mixan/types';
import type { IncrementProfilePayload, UpdateProfilePayload } from '@mixan/sdk';
export async function updateProfile(
request: FastifyRequest<{

View File

@@ -6,12 +6,7 @@
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: false,
transpilePackages: [
'@mixan/types',
'@mixan/sdk',
'@mixan/web-sdk',
'@mixan/next',
],
transpilePackages: ['@mixan/sdk', '@mixan/web-sdk', '@mixan/next'],
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
/**

View File

@@ -20,7 +20,6 @@
"@mixan/constants": "workspace:^",
"@mixan/db": "workspace:^",
"@mixan/queue": "workspace:^",
"@mixan/types": "workspace:*",
"@mixan/validation": "workspace:^",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",

View File

@@ -1,57 +0,0 @@
import type { NextApiResponse } from 'next';
import type { MixanErrorResponse, MixanIssue } from '@mixan/types';
export class HttpError extends Error {
public status: number;
public message: string;
public issues: MixanIssue[];
constructor(status: number, message: string | Error, issues?: MixanIssue[]) {
super(message instanceof Error ? message.message : message);
this.status = status;
this.message = message instanceof Error ? message.message : message;
this.issues = issues ?? [];
}
toJson(): MixanErrorResponse {
return {
code: this.status,
status: 'error',
message: this.message,
issues: this.issues.length ? this.issues : undefined,
stack: process.env.NODE_ENV !== 'production' ? this.stack : undefined,
};
}
}
export function createIssues(arr: MixanIssue[]) {
throw new HttpError(400, 'Issues', arr);
}
export function createError(status = 500, error: unknown) {
if (error instanceof Error || typeof error === 'string') {
return new HttpError(status, error);
}
return new HttpError(500, 'Unexpected error occured');
}
export function handleError(res: NextApiResponse, error: unknown) {
console.log('-----------------');
console.log('ERROR');
console.log(error);
console.log('-----------------');
if (error instanceof HttpError) {
return res.status(error.status).json(error.toJson());
}
if (error instanceof Error) {
const httpError = createError(500, error);
return res.status(httpError.status).json(httpError.toJson());
}
const httpError = createError(500, error);
return res.status(httpError.status).json(httpError.toJson());
}

View File

@@ -25,7 +25,6 @@
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@mixan/types": "workspace:*",
"@types/express": "^4.17.21",
"@types/ramda": "^0.29.6",
"eslint": "^8.48.0",