Skip to content

Commit

Permalink
v0.27.3 (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Dec 7, 2024
2 parents a10cd83 + 9920212 commit c3b8734
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 43 deletions.
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/api",
"version": "0.27.2",
"version": "0.27.3",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function run() {
const deletedProjectsInEnvironments = await environmentRepository.aggregate([
{
$lookup: {
from: 'project',
from: 'projects',
localField: '_projectId',
foreignField: '_id',
as: 'project',
Expand Down
2 changes: 1 addition & 1 deletion apps/queue-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/queue-manager",
"version": "0.27.2",
"version": "0.27.3",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
12 changes: 6 additions & 6 deletions apps/web/design-system/validation/MinMaxValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,33 @@ export function MinMaxValidation({
control={control}
name={`validations.${index}.min`}
rules={{
validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any).max),
validate: (value, formValues) => validateMinMax(value, (formValues.validations?.[index] as any)?.max),
}}
render={({ field }) => (
<NumberInput
size={size}
min={min}
placeholder={minPlaceholder}
error={(errors?.validations?.[index] as any)?.min?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
<Controller
control={control}
name={`validations.${index}.max`}
rules={{
validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any).min, value),
validate: (value, formValues) => validateMinMax((formValues.validations?.[index] as any)?.min, value),
}}
render={({ field }) => (
<NumberInput
size={size}
max={max}
placeholder={maxPlaceholder}
error={(errors?.validations?.[index] as any)?.max?.message}
value={field.value}
onChange={(value) => (value === '' ? field.onChange(undefined) : field.onChange(value))}
value={field.value ? field.value : undefined}
onChange={(value) => field.onChange(value === '' ? undefined : value)}
/>
)}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/web",
"version": "0.27.2",
"version": "0.27.3",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/widget",
"version": "0.27.2",
"version": "0.27.3",
"author": "implerhq",
"license": "MIT",
"private": true,
Expand Down
10 changes: 5 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:

api:
privileged: true
image: "ghcr.io/implerhq/impler/api:0.27.1"
image: "ghcr.io/implerhq/impler/api:0.27.3"
depends_on:
- mongodb
- rabbitmq
Expand Down Expand Up @@ -53,7 +53,7 @@ services:
- impler

queue-manager:
image: "ghcr.io/implerhq/impler/queue-manager:0.27.2"
image: "ghcr.io/implerhq/impler/queue-manager:0.27.3"
depends_on:
- api
- rabbitmq
Expand All @@ -78,7 +78,7 @@ services:
- impler

widget:
image: "ghcr.io/implerhq/impler/widget:0.27.2"
image: "ghcr.io/implerhq/impler/widget:0.27.3"
depends_on:
- api
container_name: widget
Expand All @@ -95,7 +95,7 @@ services:
embed:
depends_on:
- widget
image: "ghcr.io/implerhq/impler/embed:0.27.2"
image: "ghcr.io/implerhq/impler/embed:0.27.3"
container_name: embed
environment:
WIDGET_URL: ${WIDGET_BASE_URL}
Expand All @@ -107,7 +107,7 @@ services:
web:
depends_on:
- api
image: "ghcr.io/implerhq/impler/web:0.27.2"
image: "ghcr.io/implerhq/impler/web:0.27.3"
container_name: web
environment:
NEXT_PUBLIC_API_BASE_URL: ${API_ROOT_URL}
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"libs/*",
"packages/*"
],
"version": "0.27.2"
"version": "0.27.3"
}
2 changes: 1 addition & 1 deletion libs/dal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/dal",
"version": "0.27.2",
"version": "0.27.3",
"author": "implerhq",
"license": "MIT",
"main": "dist/index.js",
Expand Down
56 changes: 47 additions & 9 deletions libs/dal/src/repositories/base-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,37 @@ export class BaseRepository<T> {
this._model = MongooseModel;
}

private sanitizeQuery(query: FilterQuery<T & Document>): FilterQuery<T & Document> {
if (typeof query !== 'object' || Array.isArray(query)) {
throw new Error('Invalid query format');
}

const sanitizedQuery: Record<string, any> = {};
for (const key of Object.keys(query)) {
const value = query[key];

if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
const hasOperators = Object.keys(value).some((subKey) => subKey.startsWith('$'));
if (hasOperators) {
sanitizedQuery[key] = value;
continue;
}
}

sanitizedQuery[key] = { $eq: value };
}

return sanitizedQuery as FilterQuery<T & Document>;
}

public static createObjectId() {
return new Types.ObjectId().toString();
}

async count(query: FilterQuery<T & Document>): Promise<number> {
return await this.MongooseModel.countDocuments(query);
const sanitizedQuery = this.sanitizeQuery(query);

return await this.MongooseModel.countDocuments(sanitizedQuery);
}

async aggregate(query: any[]): Promise<any> {
Expand All @@ -36,20 +61,24 @@ export class BaseRepository<T> {
}

async findOne(query: FilterQuery<T & Document>, select?: string) {
const data = await this.MongooseModel.findOne(query, select);
const sanitizedQuery = this.sanitizeQuery(query);
const data = await this.MongooseModel.findOne(sanitizedQuery, select);
if (!data) return null;

return this.mapEntity(data.toObject());
}

async delete(query: FilterQuery<T & Document>) {
const data = await this.MongooseModel.findOneAndDelete(query);
const sanitizedQuery = this.sanitizeQuery(query);
const data = await this.MongooseModel.findOneAndDelete(sanitizedQuery); //just return data

return data;
}

async deleteMany(query: FilterQuery<T & Document>): Promise<{ acknowledged: boolean; deletedCount: number }> {
const data = await this.MongooseModel.deleteMany(query);
const sanitizedQuery = this.sanitizeQuery(query);

const data = await this.MongooseModel.deleteMany(sanitizedQuery);

return data;
}
Expand All @@ -59,7 +88,9 @@ export class BaseRepository<T> {
select = '',
options: { limit?: number; sort?: any; skip?: number } = {}
): Promise<T[]> {
const data = await this.MongooseModel.find(query, select, {
const sanitizedQuery = this.sanitizeQuery(query);

const data = await this.MongooseModel.find(sanitizedQuery, select, {
sort: options.sort || null,
})
.skip(options.skip)
Expand All @@ -78,7 +109,9 @@ export class BaseRepository<T> {
data: T[];
total: number;
} | null> {
const data = await this.MongooseModel.find(query, select, {
const sanitizedQuery = this.sanitizeQuery(query);

const data = await this.MongooseModel.find(sanitizedQuery, select, {
sort: options.sort || null,
})
.skip(options.skip)
Expand All @@ -101,8 +134,10 @@ export class BaseRepository<T> {
options: { limit?: number; sort?: any; skip?: number } = {},
batchSize = 500
) {
const sanitizedQuery = this.sanitizeQuery(query);

for await (const doc of this._model
.find(query, select, {
.find(sanitizedQuery, select, {
sort: options.sort || null,
})
.batchSize(batchSize)
Expand All @@ -129,7 +164,8 @@ export class BaseRepository<T> {
matched: number;
modified: number;
}> {
const saved = await this.MongooseModel.updateMany(query, updateBody, {
const sanitizedQuery = this.sanitizeQuery(query);
const saved = await this.MongooseModel.updateMany(sanitizedQuery, updateBody, {
multi: true,
});

Expand All @@ -144,7 +180,9 @@ export class BaseRepository<T> {
updateBody: UpdateQuery<T>,
options: QueryOptions<T> = { new: true } // By default return updated document
): Promise<T> {
return this.MongooseModel.findOneAndUpdate(query, updateBody, options);
const sanitizedQuery = this.sanitizeQuery(query);

return this.MongooseModel.findOneAndUpdate(sanitizedQuery, updateBody, options);
}

protected mapEntity(data: any): T {
Expand Down
2 changes: 1 addition & 1 deletion libs/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/embed",
"version": "0.27.2",
"version": "0.27.3",
"private": true,
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/services/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/services",
"version": "0.27.2",
"version": "0.27.3",
"description": "Reusable services to shared between backend api and queue-manager",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/shared",
"version": "0.27.2",
"version": "0.27.3",
"description": "Reusable types and classes to shared between apps and libraries",
"license": "MIT",
"author": "implerhq",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "impler.io",
"version": "0.27.1",
"version": "0.27.3",
"description": "Open source infrastructure to import data easily",
"packageManager": "[email protected]",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/angular",
"version": "0.27.2",
"version": "0.27.3",
"description": "Angular library to show CSV Excel Importer in angular applications",
"license": "MIT",
"author": "implerhq",
Expand Down Expand Up @@ -52,6 +52,6 @@
"typescript": "^4.4.4"
},
"dependencies": {
"@impler/client": "^0.27.2"
"@impler/client": "^0.27.3"
}
}
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/client",
"version": "0.27.2",
"version": "0.27.3",
"description": "API client to be used in end user environments",
"license": "MIT",
"author": "implerhq",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impler/react",
"version": "0.27.2",
"version": "0.27.3",
"description": "React library to show CSV Excel Importer in react applications",
"license": "MIT",
"author": "implerhq",
Expand Down Expand Up @@ -53,6 +53,6 @@
"typescript": "^4.4.4"
},
"dependencies": {
"@impler/client": "^0.27.2"
"@impler/client": "^0.27.3"
}
}
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3b8734

Please sign in to comment.