Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Feb 21, 2023
2 parents e5e63a5 + f30c44a commit f4d4a6a
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 114 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) Webiny Ltd.
Copyright (c) Webiny Inc.

Portions of this software are licensed as follows:

Expand Down
17 changes: 14 additions & 3 deletions packages/api-apw/src/plugins/hooks/initializeContentReviewSteps.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
});
};
14 changes: 13 additions & 1 deletion packages/api-apw/src/scheduler/handlers/executeAction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = Record<string, any>> {
query: string;
variables: T;
Expand All @@ -10,6 +16,8 @@ export interface ApplicationGraphQLBody<T = Record<string, any>> {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
`;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
);
}
};
Expand Down Expand Up @@ -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
}
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const createForm = (params: CreateFormParams) => {
if (cached) {
setFormData(cached);
} else {
// If
if ("then" in getFormDataLoad) {
setLoading(true);
getFormDataLoad.then(formData => {
Expand Down
19 changes: 19 additions & 0 deletions packages/project-utils/packages/createBabelConfigForNode.js
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
37 changes: 4 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f4d4a6a

Please sign in to comment.