|
1 | 1 | import React from "react"; |
| 2 | +import { defineExtension } from "@webiny/project/defineExtension/index.js"; |
2 | 3 | import { OpenSearch as PulumiOpenSearch } from "~/pulumi/extensions/index.js"; |
3 | 4 | import { Infra } from "~/index.js"; |
4 | 5 | import { createPathResolver } from "@webiny/project"; |
5 | 6 | import { ProjectDecorator, DatabaseSetup } from "@webiny/project/extensions/index.js"; |
| 7 | +import { z } from "zod"; |
6 | 8 |
|
7 | 9 | const p = createPathResolver(import.meta.dirname, "OpenSearch"); |
8 | 10 |
|
9 | | -export const OpenSearch = (props: React.ComponentProps<typeof PulumiOpenSearch>) => { |
10 | | - return ( |
11 | | - <> |
12 | | - <PulumiOpenSearch {...props} /> |
13 | | - {props.enabled && ( |
14 | | - <> |
15 | | - {/* Override database setup to indicate OpenSearch is enabled */} |
16 | | - <DatabaseSetup setupName="ddb+os" /> |
17 | | - <ProjectDecorator src={p("InjectDdbEsLambdaFnHandler.js")} /> |
18 | | - <ProjectDecorator src={p("ReplaceApiLambdaFnHandlers.js")} /> |
19 | | - <Infra.Core.BeforeDeploy src={p("EnsureOsServiceRoleBeforeCoreDeploy.js")} /> |
20 | | - <Infra.Core.BeforeDeploy src={p("EnsureOsWasDeployed.js")} /> |
21 | | - </> |
22 | | - )} |
23 | | - </> |
24 | | - ); |
25 | | -}; |
| 11 | +export const OpenSearch = defineExtension({ |
| 12 | + type: "Project/OpenSearch", |
| 13 | + tags: { runtimeContext: "project" }, |
| 14 | + description: "Enable and configure Opensearch integration with project-level setup.", |
| 15 | + paramsSchema: z.object({ |
| 16 | + enabled: z.boolean().describe("Whether to enable OpenSearch.").default(false).optional(), |
| 17 | + domainName: z.string().describe("The name of the Opensearch domain.").optional(), |
| 18 | + indexPrefix: z |
| 19 | + .string() |
| 20 | + .describe("A prefix to be added to all Opensearch indexes.") |
| 21 | + .optional(), |
| 22 | + sharedIndexes: z |
| 23 | + .boolean() |
| 24 | + .describe( |
| 25 | + "Whether to use shared indexes across all environments (true) or separate indexes per environment (false)." |
| 26 | + ) |
| 27 | + .default(false) |
| 28 | + .optional() |
| 29 | + }), |
| 30 | + render: props => { |
| 31 | + return ( |
| 32 | + <> |
| 33 | + <PulumiOpenSearch {...props} /> |
| 34 | + {props.enabled && ( |
| 35 | + <> |
| 36 | + {/* Override database setup to indicate OpenSearch is enabled. */} |
| 37 | + <DatabaseSetup setupName="ddb+os" /> |
| 38 | + <ProjectDecorator src={p("InjectDdbEsLambdaFnHandler.js")} /> |
| 39 | + <ProjectDecorator src={p("ReplaceApiLambdaFnHandlers.js")} /> |
| 40 | + <Infra.Core.BeforeDeploy |
| 41 | + src={p("EnsureOsServiceRoleBeforeCoreDeploy.js")} |
| 42 | + /> |
| 43 | + <Infra.Core.BeforeDeploy src={p("EnsureOsWasDeployed.js")} /> |
| 44 | + </> |
| 45 | + )} |
| 46 | + </> |
| 47 | + ); |
| 48 | + } |
| 49 | +}); |
0 commit comments