Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/fastify/.eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion packages/fastify/__test__/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */

import configPlugin from "@prefabs.tech/fastify-config";
import Fastify, { FastifyInstance, FastifyReply } from "fastify";
import FastifyPlugin from "fastify-plugin";
Expand Down
14 changes: 14 additions & 0 deletions packages/fastify/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fastifyConfig from "@prefabs.tech/eslint-config/fastify.js";

export default [
...fastifyConfig,
{
ignores: [
"build",
"coverage",
"node_modules",
"fastify.d.ts",
"jest.config.cjs",
],
},
];
78 changes: 37 additions & 41 deletions packages/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,59 @@
"typecheck": "tsc --noEmit -p tsconfig.json --composite false"
},
"dependencies": {
"@graphql-tools/merge": "9.0.19",
"@graphql-tools/merge": "9.1.1",
"@prefabs.tech/postgres-migrations": "5.4.3",
"graphql": "16.10.0",
"graphql": "16.11.0",
"graphql-tag": "2.12.6",
"humps": "2.0.1",
"nanoid": "3.3.8",
"pg": "8.13.3"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/fastify-config": "0.89.2",
"@prefabs.tech/fastify-graphql": "0.89.2",
"@prefabs.tech/fastify-mailer": "0.89.2",
"@prefabs.tech/fastify-s3": "0.89.2",
"@prefabs.tech/fastify-slonik": "0.89.2",
"@prefabs.tech/fastify-user": "0.89.2",
"@prefabs.tech/tsconfig": "0.2.0",
"@fastify/cors": "11.0.1",
"@fastify/formbody": "8.0.2",
"@prefabs.tech/eslint-config": "0.5.0",
"@prefabs.tech/fastify-config": "0.93.5",
"@prefabs.tech/fastify-error-handler": "0.93.5",
"@prefabs.tech/fastify-graphql": "0.93.5",
"@prefabs.tech/fastify-mailer": "0.93.5",
"@prefabs.tech/fastify-s3": "0.93.5",
"@prefabs.tech/fastify-slonik": "0.93.5",
"@prefabs.tech/fastify-user": "0.93.5",
"@prefabs.tech/tsconfig": "0.5.0",
"@types/humps": "2.0.6",
"@types/node": "20.12.2",
"@types/node": "24.10.0",
Comment thread
premsgr marked this conversation as resolved.
"@types/pg": "8.11.10",
"@typescript-eslint/eslint-plugin": "8.14.0",
"@typescript-eslint/parser": "8.14.0",
"@vitest/coverage-istanbul": "3.0.5",
"eslint": "8.57.1",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-n": "14.0.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-promise": "7.1.0",
"eslint-plugin-unicorn": "56.0.1",
"fastify": "5.2.1",
"@vitest/coverage-istanbul": "3.2.4",
"eslint": "9.39.2",
"fastify": "5.6.0",
"fastify-plugin": "5.0.1",
"mercurius": "16.1.0",
"mercurius": "16.2.0",
"mercurius-auth": "6.0.0",
"pg-mem": "3.0.4",
"prettier": "3.3.3",
"slonik": "46.1.0",
"supertokens-node": "14.1.3",
"typescript": "5.5.4",
"vite": "6.1.0",
"vitest": "3.0.5",
"prettier": "3.8.1",
"slonik": "46.8.0",
"supertokens-node": "14.1.4",
"typescript": "5.7.3",
"vite": "6.3.5",
"vitest": "3.2.4",
"zod": "3.23.8"
},
"peerDependencies": {
"@prefabs.tech/fastify-config": ">=0.89.2",
"@prefabs.tech/fastify-graphql": ">=0.89.2",
"@prefabs.tech/fastify-mailer": ">=0.89.2",
"@prefabs.tech/fastify-s3": ">=0.89.2",
"@prefabs.tech/fastify-slonik": ">=0.89.2",
"@prefabs.tech/fastify-user": ">=0.89.2",
"fastify": ">=5.2.1",
"@fastify/cors": ">=11.0.1",
"@fastify/formbody": ">=8.0.2",
"@prefabs.tech/fastify-config": ">=0.93.0",
"@prefabs.tech/fastify-error-handler": ">=0.93.0",
"@prefabs.tech/fastify-graphql": ">=0.93.0",
"@prefabs.tech/fastify-mailer": ">=0.93.0",
"@prefabs.tech/fastify-s3": ">=0.93.0",
"@prefabs.tech/fastify-slonik": ">=0.93.0",
"@prefabs.tech/fastify-user": ">=0.93.0",
"fastify": ">=5.6.0",
"fastify-plugin": ">=5.0.1",
"mercurius": ">=16.1.0",
"slonik": ">=46.1.0",
"supertokens-node": ">=14.1.3",
"mercurius": ">=16.2.0",
"slonik": ">=46.8.0",
"supertokens-node": ">=14.1.4",
"zod": ">=3.23.8"
},
"engines": {
Expand Down
1 change: 0 additions & 1 deletion packages/fastify/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { verifySession } from "supertokens-node/recipe/session/framework/fastify";

import type { SaasConfig, Account } from "./types";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { ApiConfig } from "@prefabs.tech/fastify-config";
import type { Database } from "@prefabs.tech/fastify-slonik";

Expand Down
1 change: 0 additions & 1 deletion packages/fastify/src/model/accountTypes/sqlFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import getSaasConfig from "../../config";
import type { AccountTypeI18nCreateInput } from "../../types";
import type { FilterInput, SortInput } from "@prefabs.tech/fastify-slonik";

/* eslint-disable brace-style */
class AccountTypeSqlFactory extends DefaultSqlFactory {
getAllSql(fields: string[], sort?: SortInput[]): QuerySqlToken {
const identifiers = [];
Expand Down
3 changes: 0 additions & 3 deletions packages/fastify/src/plugins/migratePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const plugin = async (fastify: FastifyInstance) => {
continue;
}

/* eslint-disable-next-line unicorn/consistent-destructuring */
fastify.log.info(`Running migrations for account ${account.name}`);

await runAccountMigrations(
Expand All @@ -48,13 +47,11 @@ const plugin = async (fastify: FastifyInstance) => {

await client.end();
} else {
/* eslint-disable-next-line unicorn/consistent-destructuring */
fastify.log.warn(
`Account migrations path '${migrationsPath}' does not exists.`,
);
}
} catch (error: unknown) {
/* eslint-disable-next-line unicorn/consistent-destructuring */
fastify.log.error("🔴 SaaS: Failed to run account migrations");
throw error;
}
Expand Down
9 changes: 4 additions & 5 deletions packages/fastify/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import type { AccountAwareService as Service } from "./types/service";
import type { ApiConfig } from "@prefabs.tech/fastify-config";
import type { Database } from "@prefabs.tech/fastify-slonik";

/* eslint-disable brace-style */
abstract class AccountAwareBaseService<
T,
C extends Record<string, unknown>,
U extends Record<string, unknown>,
>
T,
C extends Record<string, unknown>,
U extends Record<string, unknown>,
>
extends BaseService<T, C, U>
implements Service<T, C, U>
{
Expand Down
6 changes: 4 additions & 2 deletions packages/fastify/src/sqlFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class AccountAwareSqlFactory extends DefaultSqlFactory {

const allSchema =
this.validationSchema._def.typeName === "ZodObject"
? (this.validationSchema as z.AnyZodObject).pick(fieldsObject)
? (this.validationSchema as unknown as z.AnyZodObject).pick(
fieldsObject,
)
: z.any();

return sql.type(allSchema)`
return sql.type(allSchema as z.ZodTypeAny)`
SELECT ${sql.join(identifiers, sql.fragment`, `)}
FROM ${this.tableFragment} AS ${this.tableIdentifier}
${this.getWhereFragment()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { RecipeInterface } from "supertokens-node/recipe/session/types";

const createNewSession = (
originalImplementation: RecipeInterface,
// eslint-disable-next-line @typescript-eslint/no-unused-vars

fastify: FastifyInstance,
): RecipeInterface["createNewSession"] => {
return async (input) => {
Expand Down
4 changes: 0 additions & 4 deletions packages/react/.eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions packages/react/.eslintrc.cjs

This file was deleted.

11 changes: 11 additions & 0 deletions packages/react/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import reactConfig from "@prefabs.tech/eslint-config/react-app.js";

export default [
{ ignores: ["coverage", "dist", "node_modules"] },
...reactConfig,
{
rules: {
"@typescript-eslint/no-empty-object-type": "off",
},
},
];
57 changes: 25 additions & 32 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@prefabs.tech/saas-react",
"version": "0.28.0",
"description": "Saas plugin for react",
"type": "module",
"exports": {
".": {
"import": "./dist/PrefabsTechSaasReact.es.js",
Expand All @@ -28,49 +29,41 @@
"typecheck": "tsc --noEmit -p tsconfig.vitest.json --composite false"
},
"dependencies": {
"axios": "1.7.9",
"axios": "1.12.0",
"zod": "3.23.8"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/react-config": "0.61.0",
"@prefabs.tech/react-form": "0.61.0",
"@prefabs.tech/react-i18n": "0.61.0",
"@prefabs.tech/react-ui": "0.61.0",
"@types/jsdom": "21.1.6",
"@types/node": "20.14.14",
"@types/react": "18.3.3",
"@typescript-eslint/eslint-plugin": "8.14.0",
"@typescript-eslint/parser": "8.14.0",
"@vitejs/plugin-react": "4.3.4",
"@vitest/coverage-v8": "3.0.6",
"eslint": "8.57.1",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-unicorn": "56.0.1",
"jsdom": "24.0.0",
"prettier": "3.3.3",
"@prefabs.tech/eslint-config": "0.5.0",
"@prefabs.tech/react-config": "0.70.0",
"@prefabs.tech/react-form": "0.70.0",
"@prefabs.tech/react-i18n": "0.70.0",
"@prefabs.tech/react-ui": "0.70.0",
"@types/jsdom": "21.1.7",
"@types/node": "24.10.0",
"@types/react": "18.3.4",
"@vitejs/plugin-react": "4.5.2",
"@vitest/coverage-v8": "3.2.4",
"eslint": "9.39.2",
"jsdom": "25.0.1",
"prettier": "3.8.1",
"primereact": "9.6.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.26.1",
"react-toastify": "10.0.6",
"typescript": "5.4.5",
"vite": "6.1.1",
"vitest": "3.0.6"
"react-router-dom": "6.28.0",
"react-toastify": "10.0.5",
"typescript": "5.7.3",
"vite": "6.3.5",
"vitest": "3.2.4"
},
"peerDependencies": {
"@prefabs.tech/react-config": ">=0.61.0",
"@prefabs.tech/react-form": ">=0.61.0",
"@prefabs.tech/react-i18n": ">=0.61.0",
"@prefabs.tech/react-ui": ">=0.61.0",
"@prefabs.tech/react-config": ">=0.70.0",
"@prefabs.tech/react-form": ">=0.70.0",
"@prefabs.tech/react-i18n": ">=0.70.0",
"@prefabs.tech/react-ui": ">=0.70.0",
"primereact": ">=9.6.1",
"react": ">=18.2",
"react-dom": ">=18.3.1",
"react-router-dom": ">=6.26.1",
"react-router-dom": ">=6.28.0",
"react-toastify": ">=10.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/SaasWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SaasWrapper = ({
.finally(() => {
setLoading(false);
});
}, []);
}, [config.apiBaseUrl]);

const isAdminApp = checkIsAdminApp();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,32 @@ export const useMutation = <MutationResponse = any, MutationData = any>( // esli

const { apiBaseUrl } = useConfig();

const trigger = useCallback((url: string, data?: MutationData) => {
setLoading(true);

const requestObject = {
url,
method,
data,
withCredentials,
};

client(apiBaseUrl)
.request(requestObject)
.then((response) => {
if ("status" in response.data && response.data.status === "ERROR") {
onError && onError(response, requestObject);
} else {
onSuccess &&
onSuccess(response.data as MutationResponse, requestObject);
}
})
.catch((error) => onError && onError(error))
.finally(() => setLoading(false));
}, []);
const trigger = useCallback(
(url: string, data?: MutationData) => {
setLoading(true);

const requestObject = {
url,
method,
data,
withCredentials,
};

client(apiBaseUrl)
.request(requestObject)
.then((response) => {
if ("status" in response.data && response.data.status === "ERROR") {
onError && onError(response, requestObject);
} else {
onSuccess &&
onSuccess(response.data as MutationResponse, requestObject);
}
})
.catch((error) => onError && onError(error))
.finally(() => setLoading(false));
},
[apiBaseUrl, method, withCredentials, onError, onSuccess],
Comment thread
premsgr marked this conversation as resolved.
);

return { loading, trigger };
};
Loading