Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rebase dev to next #3586

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a65f3b3
fix: file manager listing after first paginated fetch (#3544)
leopuleo Sep 21, 2023
770a185
fix(api-headless-cms): search with special chars in search term (#3557)
brunozoric Sep 28, 2023
115653b
fix(app-aco): add support for `titleFieldId` defined in the content m…
leopuleo Oct 3, 2023
cc9d1a2
fix: assign created block category to `loadedCategory`
adrians5j Sep 25, 2023
f1bd2df
fix: do not show Clone content model if no permissions
adrians5j Sep 26, 2023
acd3e6b
fix: read `id` from `data` object
adrians5j Oct 2, 2023
8ac4546
fix(api-headless-cms): load all models and entries in ref field mappi…
brunozoric Oct 3, 2023
8743fd6
fix(app-headless-cms): ref fields component key (#3571)
brunozoric Oct 3, 2023
6a1281b
fix(api-page-builder): compress page content on publish (#3575)
Pavel910 Oct 4, 2023
88829ab
fix(pulumi): enable config cloning (#3572)
Pavel910 Oct 4, 2023
901560f
fix: add missing IAM permission for ES projects
Pavel910 Oct 10, 2023
949052a
chore: add a script to update CF template file
Pavel910 Oct 10, 2023
6c602e2
feat(api-headless-cms-ddb-es): entry values modifier (#3422)
brunozoric Aug 1, 2023
c70ab6c
chore: remove packages-v6 [skip ci]
Pavel910 Aug 1, 2023
116be60
fix: render blocks when previewing (instead of using preview image) (…
neatbyte-vnobis Aug 7, 2023
2e71bd1
fix(project-utils): add sourceMappingURL to JS files (#3484)
Pavel910 Aug 24, 2023
5213db8
fix(migrations): tests using old get es entry methods
brunozoric Aug 28, 2023
64968fb
feat(app-headless-cms): add support for nested dynamic zones and ref …
Pavel910 Aug 31, 2023
9007275
fix: fix rerenders on element select
neatbyte-vnobis Aug 25, 2023
4000bae
fix: change dependency and add comment
neatbyte-vnobis Aug 29, 2023
e91141a
feat: add column size prop and allow users to resize it (#3502)
leopuleo Sep 11, 2023
0d49dbc
feat: add createdOn column to ACO tables (#3516)
leopuleo Sep 12, 2023
91aae14
feat: add bulk actions to HCMS (#3501)
leopuleo Sep 12, 2023
ae63c7f
feat: upgrade to node 16 (#3504)
brunozoric Sep 13, 2023
cf01783
merge(app-file-manager): update import that was missed by auto-merge
Pavel910 Sep 19, 2023
0fbac3a
test(api-headless-cms): add missing query field
Pavel910 Sep 20, 2023
3ec96fd
fix: address reCaptcha verification and settings update issues (#3542)
neatbyte-vnobis Sep 21, 2023
080f5a3
feat: add bulk actions to page builder (#3530)
leopuleo Sep 22, 2023
0d316ba
test: add test ID
adrians5j Sep 25, 2023
25eecbf
fix: remove `useCallback` usage (#3539)
neatbyte-vnobis Sep 26, 2023
1fe0da0
fix: rerender related pages on form CRUD/publishing actions
neatbyte-vnobis Sep 26, 2023
04dfbd3
fix: make carousel PB element deletable (#3545)
neatbyte-vnobis Sep 26, 2023
9063f8a
test: add PB context
adrians5j Sep 28, 2023
a718eb6
chore: run prettier
adrians5j Sep 28, 2023
c540a93
feat: introduce Multi-step Forms (#3436)
neatbyte-vnobis Sep 29, 2023
af623d1
ci: introduce `geertvdc/setup-hub`
adrians5j Oct 6, 2023
9726608
ci: manually install hub [no ci]
adrians5j Oct 6, 2023
07fce0f
ci: upgrade `/cypress` cmd
adrians5j Oct 6, 2023
cc0535f
ci: remove `CYPRESS_DEPLOYSENTINEL_KEY`
adrians5j Oct 6, 2023
591b0fd
ci: update cypress-related cmds
adrians5j Oct 6, 2023
4dec9ea
ci: update cypress-related cmds [no ci]
adrians5j Oct 7, 2023
cc23c1a
ci: update cypress-related cmds [no ci]
adrians5j Oct 7, 2023
75ffbe9
ci: use e2e folder [no ci]
adrians5j Oct 9, 2023
053c57a
ci: do not remove empty spaces (breaks TS code) [no ci]
adrians5j Oct 9, 2023
8cfcf70
fix: add `template.variables` array
adrians5j Oct 9, 2023
81c4f85
Merge branch 'next' into bruno/rebase-dev-to-next
brunozoric Oct 10, 2023
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
1 change: 1 addition & 0 deletions docs/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Resources:
# https://www.webiny.com/docs/architecture/introduction#different-database-setups
- Effect: Allow
Action:
- iam:GetRole
- iam:CreateServiceLinkedRole
Resource:
- arn:aws:iam::*:role/aws-service-role/es.amazonaws.com/AWSServiceRoleForAmazonElasticsearchService
Expand Down
28 changes: 21 additions & 7 deletions packages/api-elasticsearch/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
*/

const specialCharactersToRemove = [`\\?`];

const specialCharacterToSpace = ["-"];

const specialCharacters = [
"\\\\",
"\\+",
// "\\-",
"\\=",
"\\&\\&",
"\\|\\|",
`\&`,
`\\|`,
">",
"<",
"\\!",
`\!`,
"\\(",
"\\)",
"\\{",
Expand All @@ -25,14 +27,19 @@ const specialCharacters = [
'\\"',
"\\~",
"\\*",
"\\?",
"\\:",
`\:`,
`\/`,
"\\#"
];

export const normalizeValue = (value: string) => {
let result = value || "";
if (!result) {
return result;
}
for (const character of specialCharactersToRemove) {
result = result.replace(new RegExp(character, "g"), "");
}
for (const character of specialCharacterToSpace) {
result = result.replace(new RegExp(character, "g"), " ");
}
Expand All @@ -44,6 +51,13 @@ export const normalizeValue = (value: string) => {
return result || "";
};

const hasSpecialChar = (value: string): boolean | null => {
if (!value) {
return null;
}
return value.match(/^([0-9a-zA-Z]+)$/i) === null;
};

export const normalizeValueWithAsterisk = (initial: string) => {
const value = normalizeValue(initial);
const results = value.split(" ");
Expand All @@ -53,14 +67,14 @@ export const normalizeValueWithAsterisk = (initial: string) => {
* If there is a / in the first word, do not put asterisk in front of it.
*/
const firstWord = results[0];
if (firstWord && firstWord.includes("/") === false) {
if (hasSpecialChar(firstWord) === false) {
result = `*${result}`;
}
/**
* If there is a / in the last word, do not put asterisk at the end of it.
*/
const lastWord = results[results.length - 1];
if (lastWord && lastWord.includes("/") === false) {
if (hasSpecialChar(lastWord) === false) {
result = `${result}*`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ describe("filtering", () => {
fields
});

expect(resultNumber3).toHaveLength(0);

expect(resultNumber3).toMatchObject([]);
expect(resultNumber3).toHaveLength(19);
});

it("should filter by nested options variant colors", async () => {
Expand Down
172 changes: 170 additions & 2 deletions packages/api-headless-cms/__tests__/contentAPI/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { useFruitManageHandler } from "~tests/testHelpers/useFruitManageHandler";
import { setupContentModelGroup, setupContentModels } from "~tests/testHelpers/setup";
import { useCategoryManageHandler } from "~tests/testHelpers/useCategoryManageHandler";
import { toSlug } from "~/utils/toSlug";

describe("search", () => {
const categoryManager = useCategoryManageHandler({
path: "manage/en-US"
});
const fruitManager = useFruitManageHandler({
path: "manage/en-US"
});
Expand All @@ -13,6 +18,7 @@ describe("search", () => {
});

if (response.data.createFruit.error) {
console.log(JSON.stringify(response.data.createFruit.error, null, 2));
throw new Error(response.data.createFruit.error.message);
}
return response.data.createFruit.data;
Expand Down Expand Up @@ -41,11 +47,11 @@ describe("search", () => {

const setupFruits = async (input?: string[]) => {
const group = await setupContentModelGroup(fruitManager);
await setupContentModels(fruitManager, group, ["fruit"]);
await setupContentModels(fruitManager, group, ["fruit", "category"]);
return createFruits(input);
};

it.skip("should find record with dash in the middle of two words", async () => {
it("should find record with dash in the middle of two words", async () => {
await setupFruits();
const [response] = await listFruits({
where: {
Expand Down Expand Up @@ -331,4 +337,166 @@ describe("search", () => {
}
});
});

it("should find a record with special characters in the title", async () => {
await setupFruits();
const categories = {
apple: "A Tasty Fruit: Apple w/ Black Dots?",
banana: "A Not So Tasty Fruit: Banana w/ Yellow Dots",
orange: "Awesome Fruit: Orange w/ Leaves",
grape: "Wine - An Autumn Fruit: Grape w/ Seeds?",
tangerine: "An Autumn Fruit: Tangerine w/ Seeds?",
cleaning: "Clean Building Day | The Ultimate Cleaning Trick Tips!",
car: "2001 CarMaker Car type: SVO Reborn? - Burn Epi. 917"
};
const results: any[] = [];
for (const title of Object.values(categories)) {
const [result] = await categoryManager.createCategory({
data: {
title,
slug: toSlug(title)
}
});
results.push(result?.data?.createCategory?.data);
}
expect(results).toHaveLength(Object.values(categories).length);

const [initialResponse] = await categoryManager.listCategories({
sort: ["createdOn_ASC"]
});
expect(initialResponse).toMatchObject({
data: {
listCategories: {
data: expect.any(Array),
meta: {
totalCount: Object.values(categories).length,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});

const [appleListResponse] = await categoryManager.listCategories({
where: {
title_contains: "tasty fruit: apple w/ black dots"
}
});
expect(appleListResponse).toMatchObject({
data: {
listCategories: {
data: [
{
title: categories.apple
}
],
meta: {
totalCount: 1,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});

const [dotsListResponse] = await categoryManager.listCategories({
where: {
title_contains: "tasty fruit: w/ dots"
}
});
expect(dotsListResponse).toMatchObject({
data: {
listCategories: {
data: [
{
title: categories.banana
},
{
title: categories.apple
}
],
meta: {
totalCount: 2,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});

const [questionMarksListResponse] = await categoryManager.listCategories({
where: {
title_contains: "autumn fruit: seeds?"
}
});
expect(questionMarksListResponse).toMatchObject({
data: {
listCategories: {
data: [
{
title: categories.tangerine
},
{
title: categories.grape
}
],
meta: {
totalCount: 2,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});

const [cleaningListResponse] = await categoryManager.listCategories({
where: {
title_contains: "Clean Building Day | The Ultimate Cleaning Trick Tips!"
}
});
expect(cleaningListResponse).toMatchObject({
data: {
listCategories: {
data: [
{
title: categories.cleaning
}
],
meta: {
totalCount: 1,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});

const [carListResponse] = await categoryManager.listCategories({
where: {
title_contains: "2001 CarMaker Car type: SVO Reborn? - Burn Epi. 917"
}
});
expect(carListResponse).toMatchObject({
data: {
listCategories: {
data: [
{
title: categories.car
}
],
meta: {
totalCount: 1,
hasMoreItems: false,
cursor: null
},
error: null
}
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ const pageFields = `
_templateId
__typename
}
...on ${singularPageApiName}_Content_Author {
author {
id
modelId
}
authors {
id
modelId
}
_templateId
dynamicZone {
__typename
... on ${singularPageApiName}_Content_Objecting_DynamicZone_SuperNestedObject {
authors {
id
modelId
}
}
}
__typename
}
...on ${singularPageApiName}_Content_Author {
author {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,14 @@ async function validateReferencedEntries({
/**
* Load all models and use only those used in the input references.
*/
const models = (await context.cms.listModels()).filter(model => {
const entries = referencesByModel.get(model.modelId);
if (!entries || !entries.length) {
return false;
}
return true;
const models = await context.security.withoutAuthorization(async () => {
return (await context.cms.listModels()).filter(model => {
const entries = referencesByModel.get(model.modelId);
if (!entries?.length) {
return false;
}
return true;
});
});

if (!models.length) {
Expand All @@ -302,8 +304,10 @@ async function validateReferencedEntries({
/**
* Load all the entries by their IDs.
*/
const promises = models.map(model => {
return context.cms.getEntriesByIds(model, referencesByModel.get(model.modelId) || []);
const promises = await context.security.withoutAuthorization(async () => {
return models.map(model => {
return context.cms.getEntriesByIds(model, referencesByModel.get(model.modelId) || []);
});
});

const allEntries = await Promise.all(promises).then(res => res.flat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function importBlock({
if (category) {
loadedCategory = await context.pageBuilder.getBlockCategory(category?.slug);
if (!loadedCategory) {
await context.pageBuilder.createBlockCategory({
loadedCategory = await context.pageBuilder.createBlockCategory({
name: category.name,
slug: category.slug,
icon: category.icon,
Expand Down
8 changes: 4 additions & 4 deletions packages/api-page-builder/src/graphql/crud/pages.crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,10 @@ export const createPageCrud = (params: CreatePageCrudParams): PagesCrud => {
});

const newPublishedPageRaw = await storageOperations.pages.publish({
original,
page,
latestPage,
publishedPage,
original: await compressPage(original),
page: await compressPage(page),
latestPage: await compressPage(latestPage),
publishedPage: publishedPage ? await compressPage(publishedPage) : null,
publishedPathPage
});

Expand Down
Loading
Loading