diff --git a/LICENSE b/LICENSE index 91dbd9d28f9..33735690de2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) Webiny Ltd. +Copyright (c) Webiny Inc. Portions of this software are licensed as follows: diff --git a/packages/api-apw/src/plugins/hooks/initializeContentReviewSteps.ts b/packages/api-apw/src/plugins/hooks/initializeContentReviewSteps.ts index 398a273f3cb..fdc726746a1 100644 --- a/packages/api-apw/src/plugins/hooks/initializeContentReviewSteps.ts +++ b/packages/api-apw/src/plugins/hooks/initializeContentReviewSteps.ts @@ -1,5 +1,10 @@ import lodashSet from "lodash/set"; -import { ApwContentReviewStepStatus, ApwContext } from "~/types"; +import { + ApwContentReviewStatus, + ApwContentReviewStepStatus, + ApwContext, + ApwWorkflowStepTypes +} from "~/types"; import { getContentReviewStepInitialStatus } from "~/plugins/utils"; import { NotFoundError } from "@webiny/handler-graphql"; import { getContentApwSettingsPlugin } from "~/utils/contentApwSettingsPlugin"; @@ -57,9 +62,15 @@ export const initializeContentReviewSteps = ({ apw, plugins }: ApwContext) => { }; }); /** - * TODO Figure our what does this actually do? - * There is no steps property on CreateApwContentReviewParams + * If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED. */ + const isNonMandatory = updatedSteps.every(step => { + return step.type === ApwWorkflowStepTypes.NON_MANDATORY; + }); + if (isNonMandatory) { + input.reviewStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED; + } + input = lodashSet(input, "steps", updatedSteps); }); }; diff --git a/packages/api-apw/src/scheduler/handlers/executeAction/index.ts b/packages/api-apw/src/scheduler/handlers/executeAction/index.ts index 38af75d2e12..91c886942b7 100644 --- a/packages/api-apw/src/scheduler/handlers/executeAction/index.ts +++ b/packages/api-apw/src/scheduler/handlers/executeAction/index.ts @@ -113,6 +113,18 @@ const createExecuteActionLambda = (params: Configuration) => { continue; } + const url = plugin.getUrl({ + locale, + tenant + }); + if (!url) { + console.error( + `There is no url defined, in the Plugin, for type "${item.data.type}".` + ); + console.log(JSON.stringify(item)); + continue; + } + const body = plugin.getGraphQLBody(item.data); if (!body) { @@ -128,7 +140,7 @@ const createExecuteActionLambda = (params: Configuration) => { name, payload: { httpMethod: "POST", - path: `/cms/manage/${locale}`, + path: url, headers: { ["content-type"]: "application/json", Authorization: encodeToken({ diff --git a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.ts b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.ts index 0924ff73dab..2b06fd4d59b 100644 --- a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.ts +++ b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.ts @@ -2,6 +2,12 @@ import { Plugin } from "@webiny/plugins/Plugin"; import { ApwScheduleActionData } from "~/scheduler/types"; import { ApwSettings } from "~/scheduler/handlers/utils"; +export { ApwScheduleActionData, ApwSettings }; + +export interface ApplicationGraphQLGetUrlParams { + tenant: string; + locale: string; +} export interface ApplicationGraphQLBody> { query: string; variables: T; @@ -10,6 +16,8 @@ export interface ApplicationGraphQLBody> { export abstract class ApplicationGraphQL extends Plugin { public static override readonly type: string = "apw.scheduler.applicationGraphQL"; + public abstract getUrl(params: ApplicationGraphQLGetUrlParams): string; + public abstract canUse(data: ApwScheduleActionData): boolean; public abstract getArn(settings: ApwSettings): string; diff --git a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.ts b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.ts index 39b85160c2f..3f34c6b056f 100644 --- a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.ts +++ b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.ts @@ -1,6 +1,11 @@ -import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL"; -import { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from "~/scheduler/types"; -import { ApwSettings } from "~/scheduler/handlers/utils"; +import { + ApplicationGraphQL, + ApplicationGraphQLBody, + ApwSettings, + ApplicationGraphQLGetUrlParams, + ApwScheduleActionData +} from "./ApplicationGraphQL"; +import { ApwContentTypes, ApwScheduleActionTypes } from "~/scheduler/types"; import WebinyError from "@webiny/error"; import upperFirst from "lodash/upperFirst"; @@ -59,12 +64,16 @@ interface ApplicationGraphQLBodyVariables { } export class HeadlessCMSGraphQL extends ApplicationGraphQL { - public override name = "apw.scheduler.applicationGraphQL.pageBuilder"; + public override name = "apw.scheduler.applicationGraphQL.headlessCms"; public override canUse(data: ApwScheduleActionData): boolean { return data.type === ApwContentTypes.CMS_ENTRY; } + public override getUrl({ locale }: ApplicationGraphQLGetUrlParams): string { + return `/cms/manage/${locale}`; + } + public override getArn(settings: ApwSettings): string { return settings.cmsGraphqlFunctionArn; } diff --git a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.ts b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.ts index a2e2ba86b22..3bdd90744d2 100644 --- a/packages/api-apw/src/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.ts +++ b/packages/api-apw/src/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.ts @@ -1,69 +1,14 @@ -import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL"; -import { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from "~/scheduler/types"; +import { + ApplicationGraphQL, + ApplicationGraphQLBody, + ApwScheduleActionData +} from "./ApplicationGraphQL"; +import { ApwContentTypes, ApwScheduleActionTypes } from "~/scheduler/types"; import { ApwSettings } from "~/scheduler/handlers/utils"; const PB_PAGE_DATA_FIELD = /* GraphQL */ ` { id - pid - editor - category { - slug - } - version - title - path - url - content - savedOn - status - locked - publishedOn - locked - revisions { - id - status - locked - version - } - settings { - general { - snippet - tags - layout - image { - id - src - } - } - social { - meta { - property - content - } - title - description - image { - id - src - } - } - seo { - title - description - meta { - name - content - } - } - } - createdFrom - createdOn - createdBy { - id - displayName - type - } } `; @@ -108,6 +53,10 @@ export class PageBuilderGraphQL extends ApplicationGraphQL { return data.type === ApwContentTypes.PAGE; } + public override getUrl(): string { + return `/graphql`; + } + public override getArn(settings: ApwSettings): string { return settings.mainGraphqlFunctionArn; } diff --git a/packages/api-headless-cms/src/crud/contentEntry/markLockedFields.ts b/packages/api-headless-cms/src/crud/contentEntry/markLockedFields.ts index 5197cb203ef..dcc060074af 100644 --- a/packages/api-headless-cms/src/crud/contentEntry/markLockedFields.ts +++ b/packages/api-headless-cms/src/crud/contentEntry/markLockedFields.ts @@ -72,7 +72,11 @@ export const markLockedFields = async (params: MarkLockedFieldsParams): Promise< throw new WebinyError( `Could not update model "${model.modelId}" with new locked fields.`, "MODEL_LOCKED_FIELDS_UPDATE_FAILED", - ex + { + message: ex.message, + code: ex.code, + data: ex.data + } ); } }; @@ -104,7 +108,11 @@ export const markUnlockedFields = async (params: MarkFieldsUnlockedParams) => { throw new WebinyError( `Could not update model "${model.modelId}" with unlocked fields.`, "MODEL_UNLOCKED_FIELDS_UPDATE_FAILED", - ex + { + message: ex.message, + code: ex.code, + data: ex.data + } ); } }; diff --git a/packages/app-form-builder/src/page-builder/admin/plugins/components/PeFormElement.tsx b/packages/app-form-builder/src/page-builder/admin/plugins/components/PeFormElement.tsx index 64f9a965b9d..3bc1cd9a697 100644 --- a/packages/app-form-builder/src/page-builder/admin/plugins/components/PeFormElement.tsx +++ b/packages/app-form-builder/src/page-builder/admin/plugins/components/PeFormElement.tsx @@ -39,13 +39,13 @@ const PeForm: FormRenderer = props => { }, submitForm: ({ variables }) => { return apolloClient - .query({ query: gql(CREATE_FORM_SUBMISSION), variables }) - .then(({ data }) => data.formBuilder.createFormSubmission.data); + .mutate({ mutation: gql(CREATE_FORM_SUBMISSION), variables }) + .then(({ data }) => data.formBuilder.createFormSubmission); }, logFormView: ({ variables }) => { return apolloClient - .query({ query: gql(LOG_FORM_VIEW), variables }) - .then(({ data }) => data.formBuilder.createFormSubmission.data); + .mutate({ mutation: gql(LOG_FORM_VIEW), variables }) + .then(({ data }) => data.formBuilder.saveFormView); } }, formLayoutComponents: () => { diff --git a/packages/app-form-builder/src/page-builder/render/plugins/PeFormElement.tsx b/packages/app-form-builder/src/page-builder/render/plugins/PeFormElement.tsx index 491ac7471c7..11c72a61212 100644 --- a/packages/app-form-builder/src/page-builder/render/plugins/PeFormElement.tsx +++ b/packages/app-form-builder/src/page-builder/render/plugins/PeFormElement.tsx @@ -39,13 +39,13 @@ const PeForm: FormRenderer = props => { }, submitForm: ({ variables }) => { return apolloClient - .query({ query: gql(CREATE_FORM_SUBMISSION), variables }) - .then(({ data }) => data.formBuilder.createFormSubmission.data); + .mutate({ mutation: gql(CREATE_FORM_SUBMISSION), variables }) + .then(({ data }) => data.formBuilder.createFormSubmission); }, logFormView: ({ variables }) => { return apolloClient - .query({ query: gql(LOG_FORM_VIEW), variables }) - .then(({ data }) => data.formBuilder.createFormSubmission.data); + .mutate({ mutation: gql(LOG_FORM_VIEW), variables }) + .then(({ data }) => data.formBuilder.saveFormView); } }, formLayoutComponents: () => { diff --git a/packages/app-page-builder-elements/src/renderers/form/index.tsx b/packages/app-page-builder-elements/src/renderers/form/index.tsx index 01fc9f7fd7c..b94b0489a2e 100644 --- a/packages/app-page-builder-elements/src/renderers/form/index.tsx +++ b/packages/app-page-builder-elements/src/renderers/form/index.tsx @@ -68,7 +68,6 @@ export const createForm = (params: CreateFormParams) => { if (cached) { setFormData(cached); } else { - // If if ("then" in getFormDataLoad) { setLoading(true); getFormDataLoad.then(formData => { diff --git a/packages/project-utils/packages/createBabelConfigForNode.js b/packages/project-utils/packages/createBabelConfigForNode.js index 8dfa48b1484..c0af0b7d0a3 100644 --- a/packages/project-utils/packages/createBabelConfigForNode.js +++ b/packages/project-utils/packages/createBabelConfigForNode.js @@ -1,3 +1,22 @@ +/** + * This is override for https://github.com/lodash/babel-plugin-lodash/issues/259. + * babel-plugin-lodash is using deprecated babel API, which causes generation of many + * console.trace calls. + */ +const consoleTrace = console.trace.bind(console); +console.trace = (message, ...optionalParams) => { + if ( + typeof message === "string" && + message.startsWith("`isModuleDeclaration` has been deprecated") + ) { + return undefined; // noop + } + + return consoleTrace(message, ...optionalParams); +}; +/** + * + */ module.exports = ({ path, esm }) => { return { presets: [ diff --git a/yarn.lock b/yarn.lock index 8921dcf75fe..22905a40855 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2015,13 +2015,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-string-parser@npm:^7.18.10": - version: 7.18.10 - resolution: "@babel/helper-string-parser@npm:7.18.10" - checksum: d554a4393365b624916b5c00a4cc21c990c6617e7f3fe30be7d9731f107f12c33229a7a3db9d829bfa110d2eb9f04790745d421640e3bd245bb412dc0ea123c1 - languageName: node - linkType: hard - "@babel/helper-string-parser@npm:^7.19.4": version: 7.19.4 resolution: "@babel/helper-string-parser@npm:7.19.4" @@ -3693,36 +3686,14 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.0.0-beta.49, @babel/types@npm:^7.18.10, @babel/types@npm:^7.18.4, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.19.3, @babel/types@npm:^7.2.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.7.0, @babel/types@npm:^7.8.3": - version: 7.19.3 - resolution: "@babel/types@npm:7.19.3" - dependencies: - "@babel/helper-string-parser": ^7.18.10 - "@babel/helper-validator-identifier": ^7.19.1 - to-fast-properties: ^2.0.0 - checksum: 34a5b3db3b99a1a80ec2a784c2bb0e48769a38f1526dc377a5753a3ac5e5704663c405a393117ecc7a9df9da07b01625be7c4c3fee43ae46aba23b0c40928d77 - languageName: node - linkType: hard - -"@babel/types@npm:^7.19.4": - version: 7.19.4 - resolution: "@babel/types@npm:7.19.4" - dependencies: - "@babel/helper-string-parser": ^7.19.4 - "@babel/helper-validator-identifier": ^7.19.1 - to-fast-properties: ^2.0.0 - checksum: 4032f6407093f80dd4f4764be676f7527d2a5c0381586967cd79683cf8af01cdc16745a381b9cef045f702f0c9b0dffd880d84ee55dad59ba01bd23d5d52a8e0 - languageName: node - linkType: hard - -"@babel/types@npm:^7.20.2, @babel/types@npm:^7.20.7": - version: 7.20.7 - resolution: "@babel/types@npm:7.20.7" +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.0.0-beta.49, @babel/types@npm:^7.18.10, @babel/types@npm:^7.18.4, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.19.3, @babel/types@npm:^7.19.4, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.2, @babel/types@npm:^7.20.7, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.7.0, @babel/types@npm:^7.8.3": + version: 7.21.0 + resolution: "@babel/types@npm:7.21.0" dependencies: "@babel/helper-string-parser": ^7.19.4 "@babel/helper-validator-identifier": ^7.19.1 to-fast-properties: ^2.0.0 - checksum: b39af241f0b72bba67fd6d0d23914f6faec8c0eba8015c181cbd5ea92e59fc91a52a1ab490d3520c7dbd19ddb9ebb76c476308f6388764f16d8201e37fae6811 + checksum: dbcdda202b3a2bfd59e4de880ce38652f1f8957893a9751be069ac86e47ad751222070fe6cd92220214d77973f1474e4e1111c16dc48199dfca1489c0ee8c0c5 languageName: node linkType: hard