Skip to content

Commit

Permalink
Merge pull request #5 from wizbii/feat/transform_null_to_boolean
Browse files Browse the repository at this point in the history
feat(index): transform null to boolean for some fields
  • Loading branch information
squelix committed Apr 30, 2024
2 parents c333128 + c2714b0 commit 71565bf
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 82 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,19 @@


## [1.7.0-1](https://github.com/wizbii/strapi-algolia/compare/v1.7.0-0...v1.7.0-1) (2024-04-30)


### Bug Fixes

- [transformToBoolean] - handle array

## [1.7.0-0](https://github.com/wizbii/strapi-algolia/compare/v1.6.1...v1.7.0-0) (2024-04-30)


### Features

- [index] - transform null to boolean for some fields

## [1.6.1](https://github.com/wizbii/strapi-algolia/compare/v1.6.0...v1.6.1) (2024-04-25)

## [1.6.0](https://github.com/wizbii/strapi-algolia/compare/v1.6.0-0...v1.6.0) (2024-04-22)
Expand Down
22 changes: 12 additions & 10 deletions README.md
Expand Up @@ -79,16 +79,18 @@ export default ({ env }) => ({

#### All configurations options

| Property | Description | Type | Default value |
| --------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------- |
| applicationId | Algolia application ID | string **(required)** | |
| apiKey | Algolia API Key | string **(required)** | |
| indexPrefix | Prefix for the Algolia index | string | `` `${strapi.config.environment}_` `` |
| contentTypes | Array of content types needed to be indexed | Array\<object\> **(required)** | |
| contentTypes.name | Name of the content type | string **(required)** | |
| contentTypes.index | Algolia index for the current content type | string | |
| contentTypes.idPrefix | Prefix for the item id | string | |
| contentTypes.populate | Which fields needed to be indexed on Algolia, by default all the properties are indexed | [object](https://docs.strapi.io/dev-docs/api/entity-service/populate) | `'*'` = All fields |
| Property | Description | Type | Default value |
| ------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------- |
| applicationId | Algolia application ID | string **(required)** | |
| apiKey | Algolia API Key | string **(required)** | |
| indexPrefix | Prefix for the Algolia index | string | `` `${strapi.config.environment}_` `` |
| contentTypes | Array of content types needed to be indexed | Array\<object\> **(required)** | |
| contentTypes.name | Name of the content type | string **(required)** | |
| contentTypes.index | Algolia index for the current content type | string | |
| contentTypes.idPrefix | Prefix for the item id | string | |
| contentTypes.populate | Which fields needed to be indexed on Algolia, by default all the properties are indexed | [object](https://docs.strapi.io/dev-docs/api/entity-service/populate) | `'*'` = All fields |
| contentTypes.hideFields | Which fields needed to be hidden on Algolia, by default all the properties are indexed | Array\<string\> | [] |
| contentTypes.transformToBooleanFields | Which fields needed to be transform from null to boolean on Algolia | Array\<string\> | [] |

## UI

Expand Down
125 changes: 70 additions & 55 deletions package-lock.json

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

9 changes: 5 additions & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-strapi-algolia",
"version": "1.6.1",
"version": "1.7.0-1",
"description": "Index articles configured to Algolia",
"keywords": [
"strapi",
Expand Down Expand Up @@ -49,6 +49,7 @@
"@strapi/strapi": "^4.24.0",
"@strapi/utils": "^4.24.0",
"algoliasearch": "4.23.3",
"deep-reduce": "^1.0.5",
"prop-types": "^15.8.1"
},
"devDependencies": {
Expand All @@ -60,8 +61,8 @@
"@types/react-dom": "^18.0.28",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.34",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"commitlint": "^19.3.0",
"eslint": "^8.57.0",
"eslint-config": "^0.3.0",
Expand All @@ -71,7 +72,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.3.4",
"release-it": "^17.2.0",
"release-it": "^17.2.1",
"styled-components": "^5.3.6",
"ts-jest": "^29.1.2",
"typescript": "5.4.5"
Expand Down
4 changes: 3 additions & 1 deletion server/controllers/index-all.ts
Expand Up @@ -56,6 +56,7 @@ export default ({ strapi }: { strapi: Strapi }) => ({
idPrefix = '',
populate = '*',
hideFields = [],
transformToBooleanFields = [],
} = contentType;

const indexName = `${indexPrefix}${index ?? name}`;
Expand Down Expand Up @@ -85,7 +86,8 @@ export default ({ strapi }: { strapi: Strapi }) => ({
await strapiService.afterUpdateAndCreateAlreadyPopulate(
articles,
idPrefix,
algoliaIndex
algoliaIndex,
transformToBooleanFields
);

return ctx.send({
Expand Down

0 comments on commit 71565bf

Please sign in to comment.