Added filterable languages on multiple indexes

This commit is contained in:
DrMint 2023-06-11 15:21:04 +02:00
parent b7eef516fd
commit c3897ef5e0
6 changed files with 100 additions and 85 deletions

147
package-lock.json generated
View File

@ -7,11 +7,11 @@
"name": "search.accords-library.com",
"dependencies": {
"@digitak/esrun": "3.2.24",
"dotenv": "^16.1.3",
"dotenv": "^16.1.4",
"html-to-text": "^9.0.5",
"isomorphic-dompurify": "^1.6.0",
"marked": "^5.0.4",
"meilisearch": "^0.32.3"
"meilisearch": "^0.33.0"
},
"devDependencies": {
"@graphql-codegen/cli": "^3.3.1",
@ -20,9 +20,9 @@
"@graphql-codegen/typescript-operations": "^3.0.4",
"@types/html-to-text": "^9.0.1",
"@types/marked": "^5.0.0",
"@types/node": "^18.14.6",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@types/node": "^20.2.5",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"graphql": "^16.6.0",
"graphql-request": "5.1.0"
@ -2844,9 +2844,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "18.14.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.6.tgz",
"integrity": "sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==",
"version": "20.2.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz",
"integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==",
"dev": true
},
"node_modules/@types/parse-json": {
@ -2876,15 +2876,15 @@
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz",
"integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz",
"integrity": "sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.59.8",
"@typescript-eslint/type-utils": "5.59.8",
"@typescript-eslint/utils": "5.59.8",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/type-utils": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
@ -2925,14 +2925,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz",
"integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.9.tgz",
"integrity": "sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.59.8",
"@typescript-eslint/types": "5.59.8",
"@typescript-eslint/typescript-estree": "5.59.8",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"debug": "^4.3.4"
},
"engines": {
@ -2952,13 +2952,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz",
"integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz",
"integrity": "sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.59.8",
"@typescript-eslint/visitor-keys": "5.59.8"
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -2969,13 +2969,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz",
"integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz",
"integrity": "sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "5.59.8",
"@typescript-eslint/utils": "5.59.8",
"@typescript-eslint/typescript-estree": "5.59.9",
"@typescript-eslint/utils": "5.59.9",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@ -2996,9 +2996,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz",
"integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.9.tgz",
"integrity": "sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -3009,13 +3009,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz",
"integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz",
"integrity": "sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.59.8",
"@typescript-eslint/visitor-keys": "5.59.8",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/visitor-keys": "5.59.9",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -3051,17 +3051,17 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz",
"integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz",
"integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.59.8",
"@typescript-eslint/types": "5.59.8",
"@typescript-eslint/typescript-estree": "5.59.8",
"@typescript-eslint/scope-manager": "5.59.9",
"@typescript-eslint/types": "5.59.9",
"@typescript-eslint/typescript-estree": "5.59.9",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
},
@ -3092,12 +3092,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.59.8",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz",
"integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==",
"version": "5.59.9",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz",
"integrity": "sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.59.8",
"@typescript-eslint/types": "5.59.9",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@ -3109,9 +3109,9 @@
}
},
"node_modules/@whatwg-node/events": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.0.2.tgz",
"integrity": "sha512-WKj/lI4QjnLuPrim0cfO7i+HsDSXHxNv1y0CrJhdntuO3hxWZmnXCwNDnwOvry11OjRin6cgWNF+j/9Pn8TN4w==",
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.0.3.tgz",
"integrity": "sha512-IqnKIDWfXBJkvy/k6tzskWTc2NK3LcqHlb+KHGCrjOCH4jfQckRX0NAiIcC/vIqQkzLYw2r2CTSwAxcrtcD6lA==",
"dev": true
},
"node_modules/@whatwg-node/fetch": {
@ -3131,19 +3131,16 @@
}
},
"node_modules/@whatwg-node/node-fetch": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.3.1.tgz",
"integrity": "sha512-/U4onp5eBkRHfFe/VL+ppyupqj7z6iBtjcuPSosQNH2/y+LxRn5lyFb7Vqhb5DokjrDMjssLcqiVYnx+UABFsw==",
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.3.6.tgz",
"integrity": "sha512-w9wKgDO4C95qnXZRwZTfCmLWqyRnooGjcIwG0wADWjw9/HN0p7dtvtgSvItZtUyNteEvgTrd8QojNEqV6DAGTA==",
"dev": true,
"dependencies": {
"@whatwg-node/events": "^0.0.2",
"@whatwg-node/events": "^0.0.3",
"busboy": "^1.6.0",
"fast-querystring": "^1.1.1",
"fast-url-parser": "^1.1.3",
"tslib": "^2.3.1"
},
"peerDependencies": {
"@types/node": "^18.0.6"
}
},
"node_modules/abab": {
@ -3831,11 +3828,11 @@
}
},
"node_modules/cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.6.tgz",
"integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==",
"dependencies": {
"node-fetch": "2.6.7"
"node-fetch": "^2.6.11"
}
},
"node_modules/cross-spawn": {
@ -4111,9 +4108,9 @@
}
},
"node_modules/dotenv": {
"version": "16.1.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.3.tgz",
"integrity": "sha512-FYssxsmCTtKL72fGBSvb1K9dRz0/VZeWqFme/vSb7r7323x4CRaHu4LvQ5JG3+s6yt2YPbBrkpiEODktfyjI9A==",
"version": "16.1.4",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.4.tgz",
"integrity": "sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==",
"engines": {
"node": ">=12"
},
@ -4581,9 +4578,9 @@
"dev": true
},
"node_modules/fast-querystring": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.1.tgz",
"integrity": "sha512-qR2r+e3HvhEFmpdHMv//U8FnFlnYjaC6QKDuaXALDkw2kvHO8WDjxH+f/rHGR4Me4pnk8p9JAkRNTjYHAKRn2Q==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz",
"integrity": "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==",
"dev": true,
"dependencies": {
"fast-decode-uri-component": "^1.0.1"
@ -5904,11 +5901,11 @@
}
},
"node_modules/meilisearch": {
"version": "0.32.3",
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.32.3.tgz",
"integrity": "sha512-EOgfBuRE5SiIPIpEDYe2HO0D7a4z5bexIgaAdJFma/dH5hx1kwO+u/qb2g3qKyjG+iA3l8MlmTj/Xd72uahaAw==",
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.33.0.tgz",
"integrity": "sha512-bYPb9WyITnJfzf92e7QFK8Rc50DmshFWxypXCs3ILlpNh8pT15A7KSu9Xgnnk/K3G/4vb3wkxxtFS4sxNkWB8w==",
"dependencies": {
"cross-fetch": "^3.1.5"
"cross-fetch": "^3.1.6"
}
},
"node_modules/merge2": {
@ -6049,9 +6046,9 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dependencies": {
"whatwg-url": "^5.0.0"
},

View File

@ -11,11 +11,11 @@
},
"dependencies": {
"@digitak/esrun": "3.2.24",
"dotenv": "^16.1.3",
"dotenv": "^16.1.4",
"html-to-text": "^9.0.5",
"isomorphic-dompurify": "^1.6.0",
"marked": "^5.0.4",
"meilisearch": "^0.32.3"
"meilisearch": "^0.33.0"
},
"devDependencies": {
"@graphql-codegen/cli": "^3.3.1",
@ -24,9 +24,9 @@
"@graphql-codegen/typescript-operations": "^3.0.4",
"@types/html-to-text": "^9.0.1",
"@types/marked": "^5.0.0",
"@types/node": "^18.14.6",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@types/node": "^20.2.5",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"graphql": "^16.6.0",
"graphql-request": "5.1.0"

View File

@ -33,6 +33,7 @@ export interface MeiliContent
displayable_description?: string | null;
})[];
sortable_updated_date: number;
filterable_languages: string[];
}
export interface MeiliVideo extends VideoAttributesFragment {
@ -50,6 +51,7 @@ export interface MeiliPost extends Omit<PostAttributesFragment, "translations">
> & {
displayable_description?: string | null;
})[];
filterable_languages: string[];
}
export interface MeiliWikiPage extends Omit<WikiPageAttributesFragment, "translations"> {
@ -60,6 +62,7 @@ export interface MeiliWikiPage extends Omit<WikiPageAttributesFragment, "transla
> & {
displayable_description?: string | null;
})[];
filterable_languages: string[];
}
type WeaponAttributesTranslation = NonNullable<
@ -79,6 +82,7 @@ export interface MeiliWeapon extends Omit<WeaponAttributesFragment, "name" | "st
description: string;
language: WeaponAttributesTranslation["language"];
}[];
filterable_languages: string[];
}
export enum MeiliIndices {

View File

@ -56,6 +56,9 @@ const transformContent: TransformFunction<MeiliIndices.CONTENT> = (data) => {
};
}
),
filterable_languages: filterHasAttributes(translations, [
"language.data.attributes.code",
] as const).map(({ language }) => language.data.attributes.code),
sortable_updated_date: updatedAt,
};
};
@ -105,6 +108,9 @@ const transformPost: TransformFunction<MeiliIndices.POST> = (data) => {
displayable_description,
};
}),
filterable_languages: filterHasAttributes(translations, [
"language.data.attributes.code",
] as const).map(({ language }) => language.data.attributes.code),
...otherAttributes,
};
};
@ -142,6 +148,9 @@ const transformWikiPage: TransformFunction<MeiliIndices.WIKI_PAGE> = (data) => {
displayable_description,
};
}),
filterable_languages: filterHasAttributes(translations, [
"language.data.attributes.code",
] as const).map(({ language }) => language.data.attributes.code),
...otherAttributes,
};
};
@ -192,6 +201,7 @@ const transformWeapon: TransformFunction<MeiliIndices.WEAPON> = (data) => {
...otherAttributes,
categories: [...categories.values()],
translations: [...translations.values()],
filterable_languages: [...translations.keys()],
};
return result;
};

View File

@ -40,7 +40,8 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
"translations.subtitle",
"translations.displayable_description",
],
["slug", "sortable_updated_date"]
["slug", "sortable_updated_date"],
["filterable_languages"]
);
// [ VIDEOS ]
@ -62,7 +63,7 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
posts.posts?.data.map((item) => strapiToMeiliTransformFunctions.post(item)),
["translations.title", "translations.displayable_description"],
["sortable_date"],
["hidden"]
["hidden", "filterable_languages"]
);
// [ WIKI PAGES ]
@ -76,7 +77,9 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
"translations.summary",
"translations.displayable_description",
"definitions",
]
],
undefined,
["filterable_languages"]
);
// [ WEAPONS ]
@ -86,7 +89,8 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
MeiliIndices.WEAPON,
weapons.weaponStories?.data.map((item) => strapiToMeiliTransformFunctions.weapon(item)),
["translations.names", "translations.description"],
["slug"]
["slug"],
["filterable_languages"]
);
};

File diff suppressed because one or more lines are too long