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: strict typescript #2235

Merged
merged 60 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9c3a452
feat: strict null checks handler
brunozoric Feb 14, 2022
c1c36b4
feat: sort out types in ui package
brunozoric Feb 14, 2022
e8e1cd7
feat: stricted types in cli packages
brunozoric Feb 14, 2022
a460212
feat: app admin wip
brunozoric Feb 14, 2022
1c72ffd
feat: app admin done
brunozoric Feb 15, 2022
bc45792
feat: api security strict null checks
brunozoric Feb 15, 2022
b499e97
feat: app admin security
brunozoric Feb 15, 2022
1023e84
feat: app page builder wip
brunozoric Feb 15, 2022
c6834ff
fix(ui): override rmwc/base package
Pavel910 Feb 15, 2022
f6b00a1
fix(ui): override rmwc/base package
Pavel910 Feb 16, 2022
3a830f8
feat: app page builder done
brunozoric Feb 16, 2022
f44eb89
feat: app theme manager strict null checks
brunozoric Feb 16, 2022
6112932
feat: app headless cms strict done
brunozoric Feb 17, 2022
813be34
feat: app form builder strict done
brunozoric Feb 18, 2022
9d5e6eb
feat: api file manager strict done
brunozoric Feb 18, 2022
d30ac6a
feat: api headless cms strict done
brunozoric Feb 18, 2022
3e73e68
feat: api page builder strict done
brunozoric Feb 18, 2022
616d9c5
feat: api apw strict is done
brunozoric Feb 18, 2022
606cb67
chore: eslint and prettier fix
brunozoric Feb 18, 2022
cb26342
chore: adio and check ts configs
brunozoric Feb 18, 2022
4adf740
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Feb 18, 2022
7dabd4f
fix: api headless cms ddb tests
brunozoric Feb 19, 2022
f832aa0
fix: api page builder get category
brunozoric Feb 19, 2022
ff6bffc
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Feb 19, 2022
476f4a0
fix: ts errors
brunozoric Feb 20, 2022
578d04c
fix: user project files
brunozoric Feb 21, 2022
0100030
refactor: remove all Params interfaces or types
brunozoric Feb 22, 2022
aab543b
style: eslint and prettier fix
brunozoric Feb 22, 2022
49f98a1
style: form builder fields
brunozoric Feb 22, 2022
4d565ee
fix: app headless cms dynamic fields
brunozoric Feb 23, 2022
4b6cb5c
fix: page builder breadcrumbs
brunozoric Feb 23, 2022
7272bf0
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Feb 23, 2022
3522f9b
fix: validators tab display
brunozoric Feb 23, 2022
8d19d65
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Feb 24, 2022
2d1406d
fix: render url params
brunozoric Feb 24, 2022
01c82d7
fix: render elements
brunozoric Feb 24, 2022
c5d47d7
fix: render layout
brunozoric Feb 24, 2022
7291b89
fix: app page builder back button
brunozoric Feb 24, 2022
bf8fbaa
feat: add strictFunctionTypes
brunozoric Mar 1, 2022
0b7cb50
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Mar 1, 2022
ab50af2
feat: add strict mode
brunozoric Mar 1, 2022
bac3126
feat: typescript to 4.2.2
brunozoric Mar 1, 2022
d345061
feat: typescript to 4.3.2
brunozoric Mar 1, 2022
28feea8
fix: typescript to 4.3.2
brunozoric Mar 1, 2022
a61ccd8
feat: typescript to 4.4.4
brunozoric Mar 1, 2022
7fe606f
feat: typescript to 4.5.5
brunozoric Mar 2, 2022
b115299
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Mar 2, 2022
dd60eac
fix: after next merge
brunozoric Mar 2, 2022
fe397ef
feat: comments about any types
brunozoric Mar 2, 2022
f9b576e
feat: typescript to 4.6.2
brunozoric Mar 2, 2022
15c026f
fix: api-admin-users-cognito tests
brunozoric Mar 3, 2022
9c35065
fix: api-apw tests
brunozoric Mar 3, 2022
e9f141c
feat: typescript to 4.5.5 due to eslint not supporting latest version
brunozoric Mar 3, 2022
8dc68c2
fix: ts errors in api-elasticsearch tests
brunozoric Mar 3, 2022
ebfee47
fix: ts errors in api-file-manager tests
brunozoric Mar 3, 2022
50a85fa
fix: ts errors in api-form-builder tests
brunozoric Mar 3, 2022
476b463
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Mar 3, 2022
2c5841b
fix: after merge
brunozoric Mar 3, 2022
97dbb10
fix: api-headless-cms tests ts errors
brunozoric Mar 4, 2022
62cc54e
Merge branch 'next' into feat/ts/strict-null-checks
brunozoric Mar 4, 2022
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
Prev Previous commit
Next Next commit
fix: user project files
  • Loading branch information
brunozoric committed Feb 21, 2022
commit 578d04cc7dabaf0a2d102fa96048a0b6530c0dcd
2 changes: 1 addition & 1 deletion apps/admin/code/src/okta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const oktaFactory: OktaFactory = ({ clientId }) => {
redirectUri,
scopes,
pkce: true,
restoreOriginalUri: null,
restoreOriginalUri: undefined,
devMode: false
});

Expand Down
9 changes: 7 additions & 2 deletions apps/theme/formBuilder/layouts/DefaultFormLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { BindComponentRenderProp, Form, BindComponent, FormOnSubmit } from "@webiny/form";
import { BindComponentRenderProp, Form, BindComponent } from "@webiny/form";
import {
FbFormModelField,
FormLayoutComponent,
Expand All @@ -14,6 +14,7 @@ import Radio from "./fields/Radio";
import Checkbox from "./fields/Checkbox";
import Textarea from "./fields/Textarea";
import HelperMessage from "./components/HelperMessage";
import { FormRenderPropParamsSubmit } from "@webiny/form";

/**
* This is the default form layout component, in which we render all the form fields. We also render terms of service
Expand Down Expand Up @@ -236,7 +237,11 @@ const DefaultFormLayout: FormLayoutComponent = ({
/**
* Renders the form submit button. We disable the button if the form is in the loading state.
*/
const renderSubmitButton = (submit: FormOnSubmit, loading: boolean, buttonLabel: string) => {
const renderSubmitButton = (
submit: FormRenderPropParamsSubmit,
loading: boolean,
buttonLabel: string
) => {
return (
<div className="webiny-fb-form-submit-button">
<button
Expand Down
2 changes: 1 addition & 1 deletion apps/theme/formBuilder/layouts/fields/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Checkbox: React.FC<CheckboxProps> = props => {
{props.field.label}
</label>
<div className="webiny-fb-form-field__checkbox-group">
{props.field.options.map(option => (
{(props.field.options || []).map(option => (
endymion1818 marked this conversation as resolved.
Show resolved Hide resolved
<div className="webiny-fb-form-field__checkbox" key={option.value}>
<input
name={fieldId}
Expand Down
2 changes: 1 addition & 1 deletion apps/theme/formBuilder/layouts/fields/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Radio: React.FC<RadioProps> = props => {
{props.field.label}
</label>
<div className="webiny-fb-form-field__radio-group">
{props.field.options.map(option => {
{(props.field.options || []).map(option => {
return (
<div className="webiny-fb-form-field__radio" key={option.value}>
<input
Expand Down
2 changes: 1 addition & 1 deletion apps/theme/formBuilder/layouts/fields/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Select: React.FC<SelectProps> = props => {
<option disabled value={""}>
{props.field.placeholderText}
</option>
{props.field.options.map(option => (
{(props.field.options || []).map(option => (
<option key={option.value} value={option.value}>
{option.label}
</option>
Expand Down
7 changes: 6 additions & 1 deletion apps/website/code/src/components/Page/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useMemo, createElement } from "react";
import { plugins } from "@webiny/plugins";
import { PbPageLayoutPlugin, PbPageData } from "@webiny/app-page-builder/types";
import { SettingsQueryResponseData } from "./graphql";
import lodashGet from "lodash/get";

interface LayoutProps {
page: PbPageData;
Expand All @@ -13,7 +14,11 @@ const Layout: React.FC<LayoutProps> = ({ page, settings, children }) => {
return layoutPlugins.map(pl => pl.layout);
}, []);

const themeLayout = layouts.find(l => l.name === page.settings.general.layout);
const layout = lodashGet(page, "page.settings.general.layout", null);
if (!layout) {
return children as React.ReactElement;
endymion1818 marked this conversation as resolved.
Show resolved Hide resolved
}
const themeLayout = layouts.find(l => l.name === layout);

if (!themeLayout) {
return children as React.ReactElement;
Expand Down
24 changes: 15 additions & 9 deletions apps/website/code/src/components/Page/Render.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from "react";
import { Helmet } from "react-helmet";
import { PbErrorResponse, PbPageData } from "@webiny/app-page-builder/types";
import {
PbErrorResponse,
PbPageData,
PbPageDataSettingsSeo,
PbPageDataSettingsSocial
} from "@webiny/app-page-builder/types";
import Layout from "./Layout";
import Element from "@webiny/app-page-builder/render/components/Element";
import useResponsiveClassName from "@webiny/app-page-builder/hooks/useResponsiveClassName";
Expand All @@ -13,16 +18,16 @@ interface Head {
src: string;
};
title: string;
seo: PbPageData["settings"]["seo"];
social: PbPageData["settings"]["social"];
seo: PbPageDataSettingsSeo;
social: PbPageDataSettingsSocial;
}

/**
* This component will render the page, including the page content, its layout, and also meta tags.
*/
interface RenderProps {
page: PbPageData;
error: PbErrorResponse;
page: PbPageData | null;
error: PbErrorResponse | null;
settings: SettingsQueryResponseData;
}
const Render: React.FC<RenderProps> = ({ page, error, settings }) => {
Expand All @@ -40,19 +45,20 @@ const Render: React.FC<RenderProps> = ({ page, error, settings }) => {
}

const head: Head = {
favicon: settings?.favicon,
title: page.title || settings?.name,
favicon: settings.favicon,
title: page.title || settings.name,
seo: {
title: "",
description: "",
meta: [],
...page?.settings?.seo
...(page.settings?.seo || {})
},
social: {
title: "",
description: "",
image: null,
...page?.settings?.social
meta: [],
...(page.settings?.social || {})
}
};

Expand Down
4 changes: 2 additions & 2 deletions apps/website/code/src/components/Page/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface PublishedPageQueryResponse {
};
}
export interface PublishedPageQueryVariables {
id: string;
path: string;
id: string | null;
path: string | null;
returnNotFoundPage: boolean;
returnErrorPage: boolean;
preview: boolean;
Expand Down
12 changes: 8 additions & 4 deletions apps/website/code/src/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare global {
// Make sure the final path looks like `/xyz`. We don't want to run into situations where the prerendering engine is
// visiting `/xyz`, but delivery URL is forcing `/xyz/`. This ensures the path is standardized, and the GraphQL
// queries are the same on both sides.
const trimPath = (value: string) => {
const trimPath = (value: string): string | null => {
if (typeof value === "string") {
return "/" + trim(value, "/");
}
Expand All @@ -35,13 +35,16 @@ const isNotFoundPage = window.__PS_NOT_FOUND_PAGE__;
// allow navigating to other pages, in the `getPath` function below.
const notFoundInitialPath = trimPath(location.pathname);

const getPath = (): string => {
let path = location.pathname;
const getPath = (): string | null => {
let path: string | null = location.pathname;
if (typeof path !== "string") {
return null;
}

path = trimPath(path);
if (path === null) {
return null;
}

// Let's check if the not-found page was just served to the user. If so, let's just return page content for the
// "/not-found" path, which is already present in the initially served HTML and ready to be used by Apollo Cache.
Expand Down Expand Up @@ -79,7 +82,8 @@ const Page: React.FC = () => {
// Here we get all site data like website name, favicon image, social links etc.
const getSettingsQuery = useQuery<SettingsQueryResponse>(GET_SETTINGS);

const { data: page, error } = getPublishedPageQuery.data?.pageBuilder?.getPublishedPage || {};
const { data: page = null, error = null } =
getPublishedPageQuery.data?.pageBuilder?.getPublishedPage || {};
const settings =
getSettingsQuery.data?.pageBuilder?.getSettings?.data || ({} as SettingsQueryResponseData);

Expand Down
45 changes: 27 additions & 18 deletions packages/app-page-builder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,32 @@ export interface PbErrorResponse {
data: Record<string, any>;
code: string;
}

export interface PbPageDataSettingsGeneral {
layout?: string;
}
export interface PbPageDataSettingsSeo {
title: string;
description: string;
meta: {
name: string;
content: string;
}[];
}
export interface PbPageDataSettingsSocial {
title: string;
description: string;
meta: {
property: string;
content: string;
}[];
image?: { src: string } | null;
}
export interface PbPageDataSettings {
general?: PbPageDataSettingsGeneral;
seo?: PbPageDataSettingsSeo;
social?: PbPageDataSettingsSocial;
}
export interface PbPageData {
id: string;
pid: string;
Expand All @@ -226,24 +252,7 @@ export interface PbPageData {
version?: number;
category: PbCategory;
status: string | "draft" | "published" | "unpublished";
settings?: {
general?: {
layout?: string;
};
seo?: {
title: string;
description: string;
meta: { name: string; content: string }[];
};
social?: {
title: string;
description: string;
meta: { property: string; content: string }[];
image: {
src: string;
};
};
};
settings?: PbPageDataSettings;
createdOn: string;
savedOn: string;
publishedOn: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"@webiny/api-file-manager": "latest",
"@webiny/cli": "latest",
"@webiny/handler-aws": "latest",
"@webiny/project-utils": "^5.3.0"
"@webiny/project-utils": "latest"
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useState } from "react";
import { BindComponentRenderProp, Form, BindComponent, FormOnSubmit } from "@webiny/form";
import { BindComponentRenderProp, Form, BindComponent } from "@webiny/form";
import {
FbFormModelField,
FormLayoutComponent,
FormRenderFbFormModelField
} from "@webiny/app-form-builder/types";
import { validation } from "@webiny/validation";
import { RichTextRenderer } from "@webiny/react-rich-text-renderer";
import { FormRenderPropParamsSubmit } from "@webiny/form";

import Input from "./fields/Input";
import Select from "./fields/Select";
Expand Down Expand Up @@ -236,7 +237,11 @@ const DefaultFormLayout: FormLayoutComponent = ({
/**
* Renders the form submit button. We disable the button if the form is in the loading state.
*/
const renderSubmitButton = (submit: FormOnSubmit, loading: boolean, buttonLabel: string) => {
const renderSubmitButton = (
submit: FormRenderPropParamsSubmit,
loading: boolean,
buttonLabel: string
) => {
return (
<div className="webiny-fb-form-submit-button">
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Checkbox: React.FC<CheckboxProps> = props => {
{props.field.label}
</label>
<div className="webiny-fb-form-field__checkbox-group">
{props.field.options.map(option => (
{(props.field.options || []).map(option => (
<div className="webiny-fb-form-field__checkbox" key={option.value}>
<input
name={fieldId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Radio: React.FC<RadioProps> = props => {
{props.field.label}
</label>
<div className="webiny-fb-form-field__radio-group">
{props.field.options.map(option => {
{(props.field.options || []).map(option => {
return (
<div className="webiny-fb-form-field__radio" key={option.value}>
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Select: React.FC<SelectProps> = props => {
<option disabled value={""}>
{props.field.placeholderText}
</option>
{props.field.options.map(option => (
{(props.field.options || []).map(option => (
<option key={option.value} value={option.value}>
{option.label}
</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"dependencies": {
"@apollo/react-components": "^3.1.5",
"@apollo/react-hooks": "^3.1.5",
"@webiny/app-form-builder": "^5.3.0",
"@webiny/app-page-builder": "^5.3.0",
"@webiny/form": "^5.3.0",
"@webiny/react-router": "^5.3.0",
"@webiny/react-rich-text-renderer": "^5.3.0",
"@webiny/validation": "^5.3.0",
"@webiny/app-form-builder": "latest",
"@webiny/app-page-builder": "latest",
"@webiny/form": "latest",
"@webiny/react-router": "latest",
"@webiny/react-rich-text-renderer": "latest",
"@webiny/validation": "latest",
"classnames": "^2.2.6",
"emotion": "^10.0.17",
"graphql": "^15.7.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"@apollo/react-components": "^3.1.5",
"@apollo/react-hooks": "^3.1.5",
"@types/react": "^16.14.0",
"@webiny/app": "^5.0.0",
"@webiny/app-form-builder": "^5.0.0",
"@webiny/app-page-builder": "^5.0.0",
"@webiny/cli": "^5.0.0",
"@webiny/cli-plugin-deploy-pulumi": "^5.0.0",
"@webiny/plugins": "^5.0.0",
"@webiny/project-utils": "^5.0.0",
"@webiny/react-router": "^5.0.0",
"@webiny/app": "latest",
"@webiny/app-form-builder": "latest",
"@webiny/app-page-builder": "latest",
"@webiny/cli": "latest",
"@webiny/cli-plugin-deploy-pulumi": "latest",
"@webiny/plugins": "latest",
"@webiny/project-utils": "latest",
"@webiny/react-router": "latest",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-batch-http": "^1.2.14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useMemo, createElement } from "react";
import { plugins } from "@webiny/plugins";
import { PbPageLayoutPlugin, PbPageData } from "@webiny/app-page-builder/types";
import { SettingsQueryResponseData } from "./graphql";
import lodashGet from "lodash/get";

interface LayoutProps {
page: PbPageData;
Expand All @@ -13,7 +14,11 @@ const Layout: React.FC<LayoutProps> = ({ page, settings, children }) => {
return layoutPlugins.map(pl => pl.layout);
}, []);

const themeLayout = layouts.find(l => l.name === page.settings.general.layout);
const layout = lodashGet(page, "page.settings.general.layout", null);
if (!layout) {
return children as React.ReactElement;
}
const themeLayout = layouts.find(l => l.name === layout);

if (!themeLayout) {
return children as React.ReactElement;
Expand Down
Loading