From 285b88d7d8503de0378476e8b6b39ecaf3304939 Mon Sep 17 00:00:00 2001 From: Kevin Haube Date: Tue, 21 Nov 2023 09:57:08 -0500 Subject: [PATCH 1/4] feat(package actions): Update Enable/Disable RAI Withdraw UI to use ConfirmationModal (#205) * Update to use ConfirmationModal * Deploy fix --- .../{Modal.tsx => ConfirmationModal.tsx} | 7 +- .../ui/src/pages/actions/IssueRai.tsx | 8 +-- .../ui/src/pages/actions/RespondToRai.tsx | 8 +-- .../actions/ToggleRaiResponseWithdraw.tsx | 70 ++++++++++++------- .../ui/src/pages/form/medicaid-form.tsx | 6 +- 5 files changed, 61 insertions(+), 38 deletions(-) rename src/services/ui/src/components/Modal/{Modal.tsx => ConfirmationModal.tsx} (89%) diff --git a/src/services/ui/src/components/Modal/Modal.tsx b/src/services/ui/src/components/Modal/ConfirmationModal.tsx similarity index 89% rename from src/services/ui/src/components/Modal/Modal.tsx rename to src/services/ui/src/components/Modal/ConfirmationModal.tsx index 9d6348e88f..b84ad025a7 100644 --- a/src/services/ui/src/components/Modal/Modal.tsx +++ b/src/services/ui/src/components/Modal/ConfirmationModal.tsx @@ -8,7 +8,7 @@ import { } from "../Dialog"; import { Button } from "../Inputs"; -type Props = { +export type ConfirmationModalProps = { open: boolean; description?: React.ReactNode; body?: React.ReactNode; @@ -21,7 +21,8 @@ type Props = { acceptButtonVisible?: boolean; }; -export function Modal({ +/** A modal with optional Cancel and Accept buttons */ +export function ConfirmationModal({ open, description, title, @@ -32,7 +33,7 @@ export function Modal({ cancelButtonText = "Cancel", acceptButtonVisible = true, cancelButtonVisible = true, -}: Props) { +}: ConfirmationModalProps) { return ( diff --git a/src/services/ui/src/pages/actions/IssueRai.tsx b/src/services/ui/src/pages/actions/IssueRai.tsx index bef9d62b65..b6c8b805b2 100644 --- a/src/services/ui/src/pages/actions/IssueRai.tsx +++ b/src/services/ui/src/pages/actions/IssueRai.tsx @@ -12,7 +12,7 @@ import { LoadingSpinner, BreadCrumbs, } from "@/components"; -import { Modal } from "@/components/Modal/Modal"; +import { ConfirmationModal } from "@/components/Modal/ConfirmationModal"; import { FAQ_TARGET, ROUTES } from "@/routes"; import { Link, useNavigate } from "react-router-dom"; import { Action, RaiIssueTransform } from "shared-types"; @@ -295,7 +295,7 @@ export const IssueRai = () => { > Cancel - { setSuccessModalIsOpen(false); @@ -312,7 +312,7 @@ export const IssueRai = () => { cancelButtonVisible={false} acceptButtonText="Exit to Package Details" /> - { setErrorModalIsOpen(false); @@ -348,7 +348,7 @@ export const IssueRai = () => { cancelButtonText="Return to Form" acceptButtonText="Exit to Package Details" /> - { setCancelModalIsOpen(false); diff --git a/src/services/ui/src/pages/actions/RespondToRai.tsx b/src/services/ui/src/pages/actions/RespondToRai.tsx index ec200ddea3..96c7af7816 100644 --- a/src/services/ui/src/pages/actions/RespondToRai.tsx +++ b/src/services/ui/src/pages/actions/RespondToRai.tsx @@ -12,7 +12,7 @@ import { LoadingSpinner, BreadCrumbs, } from "@/components"; -import { Modal } from "@/components/Modal/Modal"; +import { ConfirmationModal } from "@/components/Modal/ConfirmationModal"; import { FAQ_TARGET, ROUTES } from "@/routes"; import { Link, useNavigate } from "react-router-dom"; import { Action, RaiResponseTransform } from "shared-types"; @@ -294,7 +294,7 @@ export const RespondToRai = () => { > Cancel - { setSuccessModalIsOpen(false); @@ -311,7 +311,7 @@ export const RespondToRai = () => { cancelButtonVisible={false} acceptButtonText="Exit to Package Details" /> - { setErrorModalIsOpen(false); @@ -347,7 +347,7 @@ export const RespondToRai = () => { cancelButtonText="Return to Form" acceptButtonText="Exit to Package Details" /> - { setCancelModalIsOpen(false); diff --git a/src/services/ui/src/pages/actions/ToggleRaiResponseWithdraw.tsx b/src/services/ui/src/pages/actions/ToggleRaiResponseWithdraw.tsx index 3e58e2b539..7f40a0e039 100644 --- a/src/services/ui/src/pages/actions/ToggleRaiResponseWithdraw.tsx +++ b/src/services/ui/src/pages/actions/ToggleRaiResponseWithdraw.tsx @@ -4,10 +4,10 @@ import { ROUTES } from "@/routes"; import { Action, ItemResult } from "shared-types"; import { Button } from "@/components/Inputs"; import { removeUnderscoresAndCapitalize } from "@/utils"; -import { useMemo, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useToggleRaiWithdraw } from "@/api/useToggleRaiWithdraw"; import { PackageActionForm } from "@/pages/actions/PackageActionForm"; -import { useQueryClient } from "@tanstack/react-query"; +import { ConfirmationModal } from "@/components/Modal/ConfirmationModal"; // Keeps aria stuff and classes condensed const SectionTemplate = ({ @@ -59,9 +59,11 @@ const PackageInfo = ({ item }: { item: ItemResult }) => ( const ToggleRaiResponseWithdrawForm = ({ item }: { item?: ItemResult }) => { const navigate = useNavigate(); - const qc = useQueryClient(); const { id, type } = useParams<{ id: string; type: Action }>(); - const [awaitingNav, setAwaitingNav] = useState(false); + + const [successModalOpen, setSuccessModalOpen] = useState(false); + const [cancelModalOpen, setCancelModalOpen] = useState(false); + const { mutate: toggleRaiWithdraw, isLoading: isToggling, @@ -73,28 +75,14 @@ const ToggleRaiResponseWithdrawForm = ({ item }: { item?: ItemResult }) => { [type] ); + useEffect(() => { + if (toggleSucceeded) setSuccessModalOpen(true); + }, [toggleSucceeded]); + if (!item) return ; // Prevents optional chains below - if (isToggling || awaitingNav) return ; - if (toggleSucceeded) { - // Clear actions for package from cache - qc.invalidateQueries(["actions", id]).then(() => { - setAwaitingNav(true); // Triggers LoadingSpinner - // Debounce back nav to give the data pipeline time to update - setTimeout(() => { - // Go back to package details and render success alert - navigate(`/details?id=${id}`, { - state: { - callout: { - heading: `Formal RAI Response Withdraw action has been ${ACTION_WORD.toLowerCase()}d`, - body: `You have successfully ${ACTION_WORD.toLowerCase()}d the Formal RAI Response Withdraw action for the State.`, - }, - }, - }); - }, 2000); - }); - } return ( <> + {isToggling && } {toggleError && ( @@ -105,10 +93,44 @@ const ToggleRaiResponseWithdrawForm = ({ item }: { item?: ItemResult }) => { )}
-
+ {/* Success Modal */} + { + setSuccessModalOpen(false); + navigate(`/details?id=${id}`); + }} + onCancel={() => setSuccessModalOpen(false)} // Should be made optional + title={`Formal RAI Response Withdraw Successfully ${ACTION_WORD}d`} + body={ +

+ Please be aware that it may take up to a minute for changes to show + up on the Dashboard and Details pages. +

+ } + cancelButtonVisible={false} + acceptButtonText="Go to Package Details" + /> + + {/* Cancel Modal */} + { + setCancelModalOpen(false); + navigate(`/details?id=${id}`); + }} + onCancel={() => setCancelModalOpen(false)} + cancelButtonText="Return to Form" + acceptButtonText="Leave Page" + title="Are you sure you want to cancel?" + body={ +

If you leave this page you will lose your progress on this form

+ } + /> ); }; diff --git a/src/services/ui/src/pages/form/medicaid-form.tsx b/src/services/ui/src/pages/form/medicaid-form.tsx index 968f25dae2..5cd4543d19 100644 --- a/src/services/ui/src/pages/form/medicaid-form.tsx +++ b/src/services/ui/src/pages/form/medicaid-form.tsx @@ -14,7 +14,7 @@ import { LoadingSpinner, BreadCrumbs, } from "@/components"; -import { Modal } from "@/components/Modal/Modal"; +import { ConfirmationModal } from "@/components/Modal/ConfirmationModal"; import { FAQ_TARGET, ROUTES } from "@/routes"; import { getUserStateCodes } from "@/utils"; import { NEW_SUBMISSION_CRUMBS } from "@/pages/create/create-breadcrumbs"; @@ -385,7 +385,7 @@ export const MedicaidForm = () => { {/* Success Modal */} - { setSuccessModalIsOpen(false); @@ -404,7 +404,7 @@ export const MedicaidForm = () => { /> {/* Cancel Modal */} - { setCancelModalIsOpen(false); From 7398be6d145cf5c407f60daeeeee72947678b8ee Mon Sep 17 00:00:00 2001 From: Benjamin Paige Date: Tue, 21 Nov 2023 14:00:27 -0700 Subject: [PATCH 2/4] fix(fill: replace type for fill in e2e tests --- src/services/ui/e2e/tests/home/index.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/ui/e2e/tests/home/index.spec.ts b/src/services/ui/e2e/tests/home/index.spec.ts index 12ef20ac1f..e4e7616ff1 100644 --- a/src/services/ui/e2e/tests/home/index.spec.ts +++ b/src/services/ui/e2e/tests/home/index.spec.ts @@ -17,12 +17,15 @@ test("has title", async ({ page }) => { await expect(page).toHaveTitle(/CMS MAKO/); }); -test("see frequently asked questions header when in faq page", async ({ page }) => { +test("see frequently asked questions header when in faq page", async ({ + page, +}) => { await page.goto("/"); const popup = page.waitForEvent("popup"); await page.getByRole("link", { name: "FAQ", exact: true }).click(); const foundFaqHeading = await popup; - await foundFaqHeading.getByRole("heading", { name: "Frequently Asked Questions" }) + await foundFaqHeading + .getByRole("heading", { name: "Frequently Asked Questions" }) .isVisible(); expect(foundFaqHeading).toBeTruthy(); }); @@ -32,8 +35,8 @@ test("see dashboard link when log in", async ({ page }) => { await page.getByRole("button", { name: "Sign In" }).click(); await page .getByRole("textbox", { name: "name@host.com" }) - .type(testUsers.state); - await page.getByRole("textbox", { name: "Password" }).type(password); + .fill(testUsers.state); + await page.getByRole("textbox", { name: "Password" }).fill(password); await page.getByRole("button", { name: "submit" }).click(); await page.getByRole("link", { name: "Dashboard" }).click(); @@ -46,8 +49,8 @@ test("see dashboard link when log in", async ({ page }) => { test("failed incorrect login username", async ({ page }) => { await page.goto("/"); await page.getByRole("button", { name: "Sign In" }).click(); - await page.getByRole("textbox", { name: "name@host.com" }).type("."); - await page.getByRole("textbox", { name: "Password" }).type(password); + await page.getByRole("textbox", { name: "name@host.com" }).fill("."); + await page.getByRole("textbox", { name: "Password" }).fill(password); await page.getByRole("button", { name: "submit" }).click(); await page.locator("#loginErrorMessage").first().isVisible(); }); From 98843144baea647a909530f1b96f3fdf099d24a2 Mon Sep 17 00:00:00 2001 From: Daniel Belcher <47116905+daniel-belcher@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:44:11 -0800 Subject: [PATCH 3/4] fix(ui updates per cms): Dashboard and Forms styling (#217) * style: update search option styling * style: update new submission styling --- .../ui/src/components/Cards/SectionCard.tsx | 23 ++ src/services/ui/src/components/Cards/index.ts | 1 + .../ui/src/components/ExportButton/index.tsx | 40 ++-- .../Opensearch/Filtering/FilterDrawer.tsx | 11 +- .../components/Opensearch/Filtering/index.tsx | 183 ++++++++-------- .../ui/src/components/SearchForm/index.tsx | 8 +- .../ui/src/pages/form/medicaid-form.tsx | 207 +++++++++--------- 7 files changed, 252 insertions(+), 221 deletions(-) create mode 100644 src/services/ui/src/components/Cards/SectionCard.tsx diff --git a/src/services/ui/src/components/Cards/SectionCard.tsx b/src/services/ui/src/components/Cards/SectionCard.tsx new file mode 100644 index 0000000000..0ff07ab86c --- /dev/null +++ b/src/services/ui/src/components/Cards/SectionCard.tsx @@ -0,0 +1,23 @@ +import { FC, ReactNode } from "react"; +import { cn } from "@/lib"; + +interface SectionCardProps { + children: ReactNode; + className?: string; + title: string; +} +export const SectionCard: FC = ({ + title, + children, + className, +}: SectionCardProps) => { + return ( +
+
+

{title}

+
+
{children}
+
+
+ ); +}; diff --git a/src/services/ui/src/components/Cards/index.ts b/src/services/ui/src/components/Cards/index.ts index 51210f108c..bcdb738be4 100644 --- a/src/services/ui/src/components/Cards/index.ts +++ b/src/services/ui/src/components/Cards/index.ts @@ -1 +1,2 @@ export * from "./CardWithTopBorder"; +export * from "./SectionCard"; diff --git a/src/services/ui/src/components/ExportButton/index.tsx b/src/services/ui/src/components/ExportButton/index.tsx index 2811844bc7..83e0b82460 100644 --- a/src/services/ui/src/components/ExportButton/index.tsx +++ b/src/services/ui/src/components/ExportButton/index.tsx @@ -63,26 +63,24 @@ export const ExportButton = >({ }; return ( - <> - - + ); }; diff --git a/src/services/ui/src/components/Opensearch/Filtering/FilterDrawer.tsx b/src/services/ui/src/components/Opensearch/Filtering/FilterDrawer.tsx index 5350444946..3e21f8bd72 100644 --- a/src/services/ui/src/components/Opensearch/Filtering/FilterDrawer.tsx +++ b/src/services/ui/src/components/Opensearch/Filtering/FilterDrawer.tsx @@ -30,11 +30,14 @@ export const OsFilterDrawer = () => { const handleFilterReset = () => resetFilters(params.onSet); return ( - -
+ +
+ Filters +
diff --git a/src/services/ui/src/components/Opensearch/Filtering/index.tsx b/src/services/ui/src/components/Opensearch/Filtering/index.tsx index 5e8ed8eebe..7653c1ae9e 100644 --- a/src/services/ui/src/components/Opensearch/Filtering/index.tsx +++ b/src/services/ui/src/components/Opensearch/Filtering/index.tsx @@ -19,95 +19,102 @@ export const OsFiltering: FC<{ const filters = DEFAULT_FILTERS[params.state.tab]?.filters ?? []; return ( -
- - params.onSet((s) => ({ - ...s, - pagination: { ...s.pagination, number: 0 }, - search, - })) - } - disabled={!!props.disabled} - /> - getAllSearchData([...params.state.filters, ...filters])} - headers={[ - { - name: (() => { - if (params.state.tab === "spas") { - return "SPA ID"; - } else if (params.state.tab === "waivers") { - return "Waiver Number"; - } - return ""; - })(), - transform: (data) => data.id, - }, - { - name: "State", - transform: (data) => data.state ?? BLANK_VALUE, - }, - { - name: "Type", - transform: (data) => data.planType ?? BLANK_VALUE, - }, - { - name: "Action Type", - transform: (data) => { - if (data.actionType === undefined) { - return BLANK_VALUE; - } +
+

+ {"Search by Package ID, CPOC Name, or Submitter Name"} +

+
+ + params.onSet((s) => ({ + ...s, + pagination: { ...s.pagination, number: 0 }, + search, + })) + } + disabled={!!props.disabled} + /> +
+ getAllSearchData([...params.state.filters, ...filters])} + headers={[ + { + name: (() => { + if (params.state.tab === "spas") { + return "SPA ID"; + } else if (params.state.tab === "waivers") { + return "Waiver Number"; + } + return ""; + })(), + transform: (data) => data.id, + }, + { + name: "State", + transform: (data) => data.state ?? BLANK_VALUE, + }, + { + name: "Type", + transform: (data) => data.planType ?? BLANK_VALUE, + }, + { + name: "Action Type", + transform: (data) => { + if (data.actionType === undefined) { + return BLANK_VALUE; + } - return ( - LABELS[data.actionType as keyof typeof LABELS] || - data.actionType - ); - }, - }, - { - name: "Status", - transform(data) { - if (user?.data?.isCms && !user?.data?.user) { - if (data.cmsStatus) { - return data.cmsStatus; - } - return BLANK_VALUE; - } else { - if (data.stateStatus) { - return data.stateStatus; - } - return BLANK_VALUE; - } - }, - }, - { - name: "Initial Submission", - transform: (data) => - data?.submissionDate - ? format(new Date(data.submissionDate), "MM/dd/yyyy") - : BLANK_VALUE, - }, - { - name: "Formal RAI Response", - transform: (data) => { - return data.raiReceivedDate - ? format(new Date(data.raiReceivedDate), "MM/dd/yyyy") - : BLANK_VALUE; - }, - }, - { - name: "CPOC Name", - transform: (data) => data.leadAnalystName ?? BLANK_VALUE, - }, - { - name: "Submitted By", - transform: (data) => data.submitterName ?? BLANK_VALUE, - }, - ]} - /> - + return ( + LABELS[data.actionType as keyof typeof LABELS] || + data.actionType + ); + }, + }, + { + name: "Status", + transform(data) { + if (user?.data?.isCms && !user?.data?.user) { + if (data.cmsStatus) { + return data.cmsStatus; + } + return BLANK_VALUE; + } else { + if (data.stateStatus) { + return data.stateStatus; + } + return BLANK_VALUE; + } + }, + }, + { + name: "Initial Submission", + transform: (data) => + data?.submissionDate + ? format(new Date(data.submissionDate), "MM/dd/yyyy") + : BLANK_VALUE, + }, + { + name: "Formal RAI Response", + transform: (data) => { + return data.raiReceivedDate + ? format(new Date(data.raiReceivedDate), "MM/dd/yyyy") + : BLANK_VALUE; + }, + }, + { + name: "CPOC Name", + transform: (data) => data.leadAnalystName ?? BLANK_VALUE, + }, + { + name: "Submitted By", + transform: (data) => data.submitterName ?? BLANK_VALUE, + }, + ]} + /> + +
+
); }; diff --git a/src/services/ui/src/components/SearchForm/index.tsx b/src/services/ui/src/components/SearchForm/index.tsx index 1fdab0c17a..bf25f0a36a 100644 --- a/src/services/ui/src/components/SearchForm/index.tsx +++ b/src/services/ui/src/components/SearchForm/index.tsx @@ -46,15 +46,15 @@ export const SearchForm: FC<{ {isSearching && ( @@ -63,7 +63,7 @@ export const SearchForm: FC<{ )} {!!searchText && ( { setSearchText(""); handleSearch(""); diff --git a/src/services/ui/src/pages/form/medicaid-form.tsx b/src/services/ui/src/pages/form/medicaid-form.tsx index 5cd4543d19..540f6186e5 100644 --- a/src/services/ui/src/pages/form/medicaid-form.tsx +++ b/src/services/ui/src/pages/form/medicaid-form.tsx @@ -13,6 +13,7 @@ import { Alert, LoadingSpinner, BreadCrumbs, + SectionCard, } from "@/components"; import { ConfirmationModal } from "@/components/Modal/ConfirmationModal"; import { FAQ_TARGET, ROUTES } from "@/routes"; @@ -193,14 +194,10 @@ export const MedicaidForm = () => {
-
-

Medicaid SPA Details

-

- Indicates a required field -

-

+ +

Once you submit this form, a confirmation email is sent to you and to CMS. CMS will use this content to review your package, and you will not be able to edit this form. If CMS needs any additional @@ -210,65 +207,65 @@ export const MedicaidForm = () => { form.

-
- ( - -
- - SPA ID - + ( + +
+ + SPA ID + + + What is my SPA ID? + +
+

+ Must follow the format SS-YY-NNNN or SS-YY-NNNN-XXXX. +

+

+ Reminder - CMS recommends that all SPA numbers start with + the year in which the package is submitted. +

+ + { + if (e.target instanceof HTMLInputElement) { + e.target.value = e.target.value.toUpperCase(); + } + }} + /> + + +
+ )} + /> + ( + + + Proposed Effective Date of Medicaid SPA - - What is my SPA ID? - -
-

- Must follow the format SS-YY-NNNN or SS-YY-NNNN-XXXX. -

-

- Reminder - CMS recommends that all SPA numbers start with the - year in which the package is submitted. -

- - { - if (e.target instanceof HTMLInputElement) { - e.target.value = e.target.value.toUpperCase(); - } - }} - /> - - -
- )} - /> - ( - - - Proposed Effective Date of Medicaid SPA - - - - - - - - )} - /> -
-

Attachments

+ + + + + + )} + /> + +

Maximum file size of 80 MB per attachment.{" "} @@ -288,7 +285,6 @@ export const MedicaidForm = () => { } .

-

We accept the following file formats:{" "} .docx, .jpg, .png, .pdf, .xlsx,{" "} @@ -305,50 +301,53 @@ export const MedicaidForm = () => { } .

-
-

- - At least one attachment is required. -

-
- {attachmentList.map(({ name, label, required }) => ( + {attachmentList.map(({ name, label, required }) => ( + ( + + {label} + { + + {name === "cmsForm179" + ? "One attachment is required" + : ""} + {name === "spaPages" + ? "At least one attachment is required" + : ""} + + } + + + + )} + /> + ))} + + ( - - {label} - {required ? : ""} + + Add anything else you would like to share with CMS, limited + to 4000 characters - - + + + 4,000 characters allowed + )} /> - ))} - ( - -

- Additional Information -

- - Add anything else you would like to share with CMS, limited to - 4000 characters - - - 4,000 characters allowed -
- )} - /> -
+ +
Once you submit this form, a confirmation email is sent to you and to CMS. CMS will use this content to review your package, and you @@ -358,7 +357,7 @@ export const MedicaidForm = () => {
{Object.keys(form.formState.errors).length !== 0 ? ( - + Missing or malformed information. Please see errors above. ) : null} @@ -367,7 +366,7 @@ export const MedicaidForm = () => {
) : null} -
+
Date: Tue, 28 Nov 2023 14:45:25 -0500 Subject: [PATCH 4/4] Fix a logical bug in how we setup indices... dont update mapping if the index exists... will need to reindex in that case (#219) --- src/libs/opensearch-lib.ts | 24 +++++++++++++------- src/services/data/handlers/index.ts | 35 +++++++++++++++-------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/libs/opensearch-lib.ts b/src/libs/opensearch-lib.ts index f5ba0dc66f..4562f425dd 100644 --- a/src/libs/opensearch-lib.ts +++ b/src/libs/opensearch-lib.ts @@ -119,18 +119,14 @@ export async function getItem(host:string, index:string, id:string){ } } -export async function createIndexIfNotExists(host:string, index:string) { +export async function indexExists(host:string, index:string) { client = client || (await getClient(host)); try { const indexExists = await client.indices.exists({ index, }); - if (!indexExists.body) { - const createResponse = await client.indices.create({ - index, - }); - - console.log('Index created:', createResponse); + if (indexExists.body) { + return true; } else { - console.log('Index already exists.'); + return false; } } catch (error) { console.error('Error creating index:', error); @@ -138,6 +134,18 @@ export async function createIndexIfNotExists(host:string, index:string) { } } +export async function createIndex(host:string, index:string) { + client = client || (await getClient(host)); + try { + const createResponse = await client.indices.create({ + index, + }); + } catch (error) { + console.error('Error creating index:', error); + throw error; + } +} + export async function updateFieldMapping(host:string, index:string, properties: object) { client = client || (await getClient(host)); try { diff --git a/src/services/data/handlers/index.ts b/src/services/data/handlers/index.ts index 27f074db24..27253cddc4 100644 --- a/src/services/data/handlers/index.ts +++ b/src/services/data/handlers/index.ts @@ -26,23 +26,24 @@ export const handler: Handler = async (event) => { async function manageIndex() { try { - const createIndexReponse = await os.createIndexIfNotExists( - process.env.osDomain, - "main" - ); - console.log(createIndexReponse); - - const updateFieldMappingResponse = await os.updateFieldMapping( - process.env.osDomain, - "main", - { - rais: { - type: "object", - enabled: false, - }, - } - ); - console.log(updateFieldMappingResponse); + if (!(await os.indexExists(process.env.osDomain, "main"))) { + const createIndexReponse = await os.createIndex( + process.env.osDomain, + "main" + ); + console.log(createIndexReponse); + const updateFieldMappingResponse = await os.updateFieldMapping( + process.env.osDomain, + "main", + { + rais: { + type: "object", + enabled: false, + }, + } + ); + console.log(updateFieldMappingResponse); + } } catch (error) { console.log(error); throw "ERROR: Error occured during index management.";