Skip to content

Commit

Permalink
Do not remove special characters in Drop search query and drop_image …
Browse files Browse the repository at this point in the history
…possibly null (#133)

* testing do not remove special chars

* Remove removeSepecialCharacters

* Bump version

* handle drop_image null
  • Loading branch information
nacho9900 authored Jul 17, 2024
1 parent ce32449 commit 68a1aa5
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 52 deletions.
6 changes: 3 additions & 3 deletions packages/drops/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/drops",
"version": "0.5.4",
"version": "0.5.5",
"description": "Drops module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand Down Expand Up @@ -29,7 +29,7 @@
"node": ">=18"
},
"dependencies": {
"@poap-xyz/providers": "0.5.4",
"@poap-xyz/utils": "0.5.4"
"@poap-xyz/providers": "0.5.5",
"@poap-xyz/utils": "0.5.5"
}
}
15 changes: 7 additions & 8 deletions packages/drops/src/DropsClient.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { CompassProvider, DropApiProvider } from '@poap-xyz/providers';
import {
PaginatedResult,
nextCursor,
createBetweenFilter,
createInFilter,
Order,
isNumeric,
removeSpecialCharacters,
createOrderBy,
createBoolFilter,
createInFilter,
createLikeFilter,
createOrderBy,
isNumeric,
nextCursor,
Order,
PaginatedResult,
toPOAPDate,
} from '@poap-xyz/utils';
import { Drop } from './domain/Drop';
Expand Down Expand Up @@ -116,7 +115,7 @@ export class DropsClient {
offset,
...(isNumeric(search) && { orderBy: { id: Order.ASC } }),
args: {
search: removeSpecialCharacters(search),
search,
},
};

Expand Down
32 changes: 21 additions & 11 deletions packages/drops/src/domain/Drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ export class Drop {
emailReservationCount: number;

public static fromCompass(response: DropResponse): Drop {
const images: { crop: string; original: string } =
response.drop_image.gateways.reduce(
(images, gateway) => ({
...images,
[gateway.type.toLowerCase()]: gateway.url,
}),
{
crop: response.image_url,
original: response.image_url,
},
);
const images = Drop.getDropImageFromCompass(response);

return new Drop({
id: Number(response.id),
Expand Down Expand Up @@ -70,6 +60,26 @@ export class Drop {
});
}

private static getDropImageFromCompass(response: DropResponse): {
crop: string;
original: string;
} {
const defaultImage = {
crop: response.image_url,
original: response.image_url,
};

return (
response.drop_image?.gateways.reduce(
(images, gateway) => ({
...images,
[gateway.type.toLowerCase()]: gateway.url,
}),
defaultImage,
) || defaultImage
);
}

public static fromProvider(response: ProviderDropResponse): Drop {
return new Drop({
id: response.id,
Expand Down
2 changes: 1 addition & 1 deletion packages/drops/src/types/DropResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export interface DropResponse {
type: 'CROP' | 'ORIGINAL';
url: string;
}>;
};
} | null;
}
6 changes: 3 additions & 3 deletions packages/moments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/moments",
"version": "0.5.4",
"version": "0.5.5",
"description": "Moments module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand All @@ -26,8 +26,8 @@
"build": "rollup -c --bundleConfigAsCjs"
},
"dependencies": {
"@poap-xyz/providers": "0.5.4",
"@poap-xyz/utils": "0.5.4",
"@poap-xyz/providers": "0.5.5",
"@poap-xyz/utils": "0.5.5",
"uuid": "^9.0.0"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/poaps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/poaps",
"version": "0.5.4",
"version": "0.5.5",
"description": "Poaps module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand All @@ -26,8 +26,8 @@
"build": "rollup -c --bundleConfigAsCjs"
},
"dependencies": {
"@poap-xyz/providers": "0.5.4",
"@poap-xyz/utils": "0.5.4"
"@poap-xyz/providers": "0.5.5",
"@poap-xyz/utils": "0.5.5"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 2 additions & 2 deletions packages/providers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/providers",
"version": "0.5.4",
"version": "0.5.5",
"description": "Providers module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand All @@ -26,7 +26,7 @@
"build": "rollup -c --bundleConfigAsCjs"
},
"dependencies": {
"@poap-xyz/utils": "0.5.4",
"@poap-xyz/utils": "0.5.5",
"axios": "^1.6.8",
"lodash.chunk": "^4.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/utils",
"version": "0.5.4",
"version": "0.5.5",
"description": "Utils module for the poap.js library",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/format/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './removeSpecialCharacters';
export * from './toPOAPDate';
10 changes: 0 additions & 10 deletions packages/utils/src/format/removeSpecialCharacters.ts

This file was deleted.

18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@poap-xyz/drops@workspace:packages/drops"
dependencies:
"@poap-xyz/providers": 0.5.4
"@poap-xyz/utils": 0.5.4
"@poap-xyz/providers": 0.5.5
"@poap-xyz/utils": 0.5.5
languageName: unknown
linkType: soft

Expand All @@ -901,8 +901,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@poap-xyz/moments@workspace:packages/moments"
dependencies:
"@poap-xyz/providers": 0.5.4
"@poap-xyz/utils": 0.5.4
"@poap-xyz/providers": 0.5.5
"@poap-xyz/utils": 0.5.5
"@types/uuid": ^9.0.2
uuid: ^9.0.0
languageName: unknown
Expand All @@ -912,24 +912,24 @@ __metadata:
version: 0.0.0-use.local
resolution: "@poap-xyz/poaps@workspace:packages/poaps"
dependencies:
"@poap-xyz/providers": 0.5.4
"@poap-xyz/utils": 0.5.4
"@poap-xyz/providers": 0.5.5
"@poap-xyz/utils": 0.5.5
languageName: unknown
linkType: soft

"@poap-xyz/[email protected].4, @poap-xyz/providers@workspace:packages/providers":
"@poap-xyz/[email protected].5, @poap-xyz/providers@workspace:packages/providers":
version: 0.0.0-use.local
resolution: "@poap-xyz/providers@workspace:packages/providers"
dependencies:
"@poap-xyz/utils": 0.5.4
"@poap-xyz/utils": 0.5.5
axios: ^1.6.8
axios-mock-adapter: ^1.21.4
jest-fetch-mock: ^3.0.3
lodash.chunk: ^4.2.0
languageName: unknown
linkType: soft

"@poap-xyz/[email protected].4, @poap-xyz/utils@workspace:packages/utils":
"@poap-xyz/[email protected].5, @poap-xyz/utils@workspace:packages/utils":
version: 0.0.0-use.local
resolution: "@poap-xyz/utils@workspace:packages/utils"
languageName: unknown
Expand Down

0 comments on commit 68a1aa5

Please sign in to comment.