@webiny/api-event-handler-aws-ddb-os 0.0.0-unstable.0d717d18dd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-event-handler-aws-ddb-os
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Webiny API handler for AWS Lambda with DynamoDB + OpenSearch storage.
3
+ *
4
+ * Thin variant over the storage-agnostic base (@webiny/api-event-handler-aws): same DynamoDB storage as the
5
+ * `-ddb` variant for core/audit-logs/ACO/websockets, but CMS uses the DynamoDB+OpenSearch storage
6
+ * operations (`HeadlessCmsDdbEsFeature`), the OpenSearch core is registered in the root, and
7
+ * `DbRegistryFeature` is registered per-request before the CMS storage builds (its beforeInit
8
+ * registers the entities the DDB→ES sync stages).
9
+ */
10
+ import { type CreateWebinyApiHandlerConfig as BaseConfig } from "@webiny/api-event-handler-aws";
11
+ import { createAwsOpenSearchClient } from "@webiny/api-opensearch-aws";
12
+ export type CreateAwsDdbOsApiHandlerConfig = Pick<BaseConfig, "extensions" | "documentClient"> & {
13
+ /**
14
+ * OpenSearch client. Defaults to one built from `OPENSEARCH_*` env vars. Injectable so
15
+ * integration tests can point the handler at a local OpenSearch.
16
+ */
17
+ openSearchClient?: ReturnType<typeof createAwsOpenSearchClient>;
18
+ };
19
+ export declare function createAwsDdbOsApiHandler(config: CreateAwsDdbOsApiHandlerConfig): (event: any, context?: import("aws-lambda").Context) => Promise<any>;
@@ -0,0 +1,51 @@
1
+ import { createWebinyApiHandler } from "@webiny/api-event-handler-aws";
2
+ import { ApiCoreDdbFeature } from "@webiny/api-core-ddb";
3
+ import { HeadlessCmsDdbEsFeature } from "@webiny/api-headless-cms-ddb-es";
4
+ import { AuditLogsDdbFeature } from "@webiny/api-audit-logs-ddb";
5
+ import { AcoDdbFeature } from "@webiny/api-aco-ddb";
6
+ import { WebsocketsDdbFeature } from "@webiny/api-websockets-ddb";
7
+ import { DbRegistryFeature } from "@webiny/db/exports/api/db.js";
8
+ import { AwsOpenSearchClientFactoryFeature, createAwsOpenSearchClient } from "@webiny/api-opensearch-aws";
9
+ import { OpenSearchClientFeature } from "@webiny/api-opensearch/features/OpenSearchClient/feature.js";
10
+ import { OpenSearchQueryBuilderOperatorFeature } from "@webiny/api-opensearch/features/OpenSearchQueryBuilderOperator/feature.js";
11
+ import { OpenSearchFieldFeature } from "@webiny/api-opensearch/features/OpenSearchField/feature.js";
12
+ import { OpenSearchIndexFeature } from "@webiny/api-opensearch/features/OpenSearchIndex/feature.js";
13
+ const openSearchClientFromEnv = ()=>{
14
+ const osUsername = process.env.OPENSEARCH_USERNAME;
15
+ const osPassword = process.env.OPENSEARCH_PASSWORD;
16
+ const openSearchClientOptions = {
17
+ endpoint: `https://${process.env.OPENSEARCH_ENDPOINT}`
18
+ };
19
+ if (osUsername && osPassword) openSearchClientOptions.auth = {
20
+ username: osUsername,
21
+ password: osPassword
22
+ };
23
+ return createAwsOpenSearchClient(openSearchClientOptions);
24
+ };
25
+ function createAwsDdbOsApiHandler(config) {
26
+ const openSearchClient = config.openSearchClient ?? openSearchClientFromEnv();
27
+ return createWebinyApiHandler({
28
+ extensions: config.extensions,
29
+ documentClient: config.documentClient,
30
+ registerRootStorage: (container, { documentClient })=>{
31
+ OpenSearchClientFeature.register(container, openSearchClient);
32
+ AwsOpenSearchClientFactoryFeature.register(container);
33
+ OpenSearchQueryBuilderOperatorFeature.register(container);
34
+ OpenSearchFieldFeature.register(container);
35
+ OpenSearchIndexFeature.register(container);
36
+ ApiCoreDdbFeature.register(container, {
37
+ documentClient
38
+ });
39
+ HeadlessCmsDdbEsFeature.register(container);
40
+ AuditLogsDdbFeature.register(container, {});
41
+ AcoDdbFeature.register(container);
42
+ WebsocketsDdbFeature.register(container);
43
+ },
44
+ registerRequestStorage: (container)=>{
45
+ DbRegistryFeature.register(container);
46
+ }
47
+ });
48
+ }
49
+ export { createAwsDdbOsApiHandler };
50
+
51
+ //# sourceMappingURL=createWebinyApiHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createWebinyApiHandler.js","sources":["../src/createWebinyApiHandler.ts"],"sourcesContent":["/**\n * Webiny API handler for AWS Lambda with DynamoDB + OpenSearch storage.\n *\n * Thin variant over the storage-agnostic base (@webiny/api-event-handler-aws): same DynamoDB storage as the\n * `-ddb` variant for core/audit-logs/ACO/websockets, but CMS uses the DynamoDB+OpenSearch storage\n * operations (`HeadlessCmsDdbEsFeature`), the OpenSearch core is registered in the root, and\n * `DbRegistryFeature` is registered per-request before the CMS storage builds (its beforeInit\n * registers the entities the DDB→ES sync stages).\n */\nimport {\n createWebinyApiHandler as createBaseHandler,\n type CreateWebinyApiHandlerConfig as BaseConfig\n} from \"@webiny/api-event-handler-aws\";\nimport { ApiCoreDdbFeature } from \"@webiny/api-core-ddb\";\nimport { HeadlessCmsDdbEsFeature } from \"@webiny/api-headless-cms-ddb-es\";\nimport { AuditLogsDdbFeature } from \"@webiny/api-audit-logs-ddb\";\nimport { AcoDdbFeature } from \"@webiny/api-aco-ddb\";\nimport { WebsocketsDdbFeature } from \"@webiny/api-websockets-ddb\";\nimport { DbRegistryFeature } from \"@webiny/db/exports/api/db.js\";\nimport { type OpenSearchClientOptions } from \"@webiny/api-opensearch\";\nimport {\n createAwsOpenSearchClient,\n AwsOpenSearchClientFactoryFeature\n} from \"@webiny/api-opensearch-aws\";\nimport { OpenSearchClientFeature } from \"@webiny/api-opensearch/features/OpenSearchClient/feature.js\";\nimport { OpenSearchQueryBuilderOperatorFeature } from \"@webiny/api-opensearch/features/OpenSearchQueryBuilderOperator/feature.js\";\nimport { OpenSearchFieldFeature } from \"@webiny/api-opensearch/features/OpenSearchField/feature.js\";\nimport { OpenSearchIndexFeature } from \"@webiny/api-opensearch/features/OpenSearchIndex/feature.js\";\n\nexport type CreateAwsDdbOsApiHandlerConfig = Pick<BaseConfig, \"extensions\" | \"documentClient\"> & {\n /**\n * OpenSearch client. Defaults to one built from `OPENSEARCH_*` env vars. Injectable so\n * integration tests can point the handler at a local OpenSearch.\n */\n openSearchClient?: ReturnType<typeof createAwsOpenSearchClient>;\n};\n\nconst openSearchClientFromEnv = () => {\n const osUsername = process.env.OPENSEARCH_USERNAME;\n const osPassword = process.env.OPENSEARCH_PASSWORD;\n\n const openSearchClientOptions: OpenSearchClientOptions = {\n endpoint: `https://${process.env.OPENSEARCH_ENDPOINT}`\n };\n // Basic auth for local / self-managed OpenSearch; when absent the client falls back to AWS SigV4.\n if (osUsername && osPassword) {\n openSearchClientOptions.auth = {\n username: osUsername,\n password: osPassword\n };\n }\n\n return createAwsOpenSearchClient(openSearchClientOptions);\n};\n\nexport function createAwsDdbOsApiHandler(config: CreateAwsDdbOsApiHandlerConfig) {\n const openSearchClient = config.openSearchClient ?? openSearchClientFromEnv();\n\n return createBaseHandler({\n extensions: config.extensions,\n documentClient: config.documentClient,\n registerRootStorage: (container, { documentClient }) => {\n // ── OpenSearch core (client + query-builder operators + fields + index registries) ──\n // The DDB+ES CMS storage factory resolves all of these.\n OpenSearchClientFeature.register(container, openSearchClient);\n AwsOpenSearchClientFactoryFeature.register(container);\n OpenSearchQueryBuilderOperatorFeature.register(container);\n OpenSearchFieldFeature.register(container);\n OpenSearchIndexFeature.register(container);\n\n ApiCoreDdbFeature.register(container, { documentClient });\n // CMS uses the DynamoDB+OpenSearch storage operations; the rest stay DynamoDB-only.\n HeadlessCmsDdbEsFeature.register(container);\n AuditLogsDdbFeature.register(container, {});\n AcoDdbFeature.register(container);\n WebsocketsDdbFeature.register(container);\n },\n registerRequestStorage: container => {\n // DbRegistry holds the DDB entities the DDB+ES CMS storage stages for OpenSearch sync\n // (its beforeInit registers into it). Must be registered before HeadlessCmsFeature builds.\n DbRegistryFeature.register(container);\n }\n });\n}\n"],"names":["openSearchClientFromEnv","osUsername","process","osPassword","openSearchClientOptions","createAwsOpenSearchClient","createAwsDdbOsApiHandler","config","openSearchClient","createBaseHandler","container","documentClient","OpenSearchClientFeature","AwsOpenSearchClientFactoryFeature","OpenSearchQueryBuilderOperatorFeature","OpenSearchFieldFeature","OpenSearchIndexFeature","ApiCoreDdbFeature","HeadlessCmsDdbEsFeature","AuditLogsDdbFeature","AcoDdbFeature","WebsocketsDdbFeature","DbRegistryFeature"],"mappings":";;;;;;;;;;;;AAqCA,MAAMA,0BAA0B;IAC5B,MAAMC,aAAaC,QAAQ,GAAG,CAAC,mBAAmB;IAClD,MAAMC,aAAaD,QAAQ,GAAG,CAAC,mBAAmB;IAElD,MAAME,0BAAmD;QACrD,UAAU,CAAC,QAAQ,EAAEF,QAAQ,GAAG,CAAC,mBAAmB,EAAE;IAC1D;IAEA,IAAID,cAAcE,YACdC,wBAAwB,IAAI,GAAG;QAC3B,UAAUH;QACV,UAAUE;IACd;IAGJ,OAAOE,0BAA0BD;AACrC;AAEO,SAASE,yBAAyBC,MAAsC;IAC3E,MAAMC,mBAAmBD,OAAO,gBAAgB,IAAIP;IAEpD,OAAOS,uBAAkB;QACrB,YAAYF,OAAO,UAAU;QAC7B,gBAAgBA,OAAO,cAAc;QACrC,qBAAqB,CAACG,WAAW,EAAEC,cAAc,EAAE;YAG/CC,wBAAwB,QAAQ,CAACF,WAAWF;YAC5CK,kCAAkC,QAAQ,CAACH;YAC3CI,sCAAsC,QAAQ,CAACJ;YAC/CK,uBAAuB,QAAQ,CAACL;YAChCM,uBAAuB,QAAQ,CAACN;YAEhCO,kBAAkB,QAAQ,CAACP,WAAW;gBAAEC;YAAe;YAEvDO,wBAAwB,QAAQ,CAACR;YACjCS,oBAAoB,QAAQ,CAACT,WAAW,CAAC;YACzCU,cAAc,QAAQ,CAACV;YACvBW,qBAAqB,QAAQ,CAACX;QAClC;QACA,wBAAwBA,CAAAA;YAGpBY,kBAAkB,QAAQ,CAACZ;QAC/B;IACJ;AACJ"}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createAwsDdbOsApiHandler } from "./createWebinyApiHandler.js";
2
+ export type { CreateAwsDdbOsApiHandlerConfig } from "./createWebinyApiHandler.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createAwsDdbOsApiHandler } from "./createWebinyApiHandler.js";
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@webiny/api-event-handler-aws-ddb-os",
3
+ "version": "0.0.0-unstable.0d717d18dd",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./*": "./*"
9
+ },
10
+ "types": "index.d.ts",
11
+ "description": "Composition layer: Webiny API handler for AWS Lambda with DynamoDB + OpenSearch storage.",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/webiny/webiny-js.git"
15
+ },
16
+ "contributors": [
17
+ "Webiny Team"
18
+ ],
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@webiny/api-aco-ddb": "0.0.0-unstable.0d717d18dd",
22
+ "@webiny/api-audit-logs-ddb": "0.0.0-unstable.0d717d18dd",
23
+ "@webiny/api-core-ddb": "0.0.0-unstable.0d717d18dd",
24
+ "@webiny/api-event-handler-aws": "0.0.0-unstable.0d717d18dd",
25
+ "@webiny/api-headless-cms-ddb-es": "0.0.0-unstable.0d717d18dd",
26
+ "@webiny/api-opensearch": "0.0.0-unstable.0d717d18dd",
27
+ "@webiny/api-opensearch-aws": "0.0.0-unstable.0d717d18dd",
28
+ "@webiny/api-websockets-ddb": "0.0.0-unstable.0d717d18dd",
29
+ "@webiny/db": "0.0.0-unstable.0d717d18dd"
30
+ },
31
+ "peerDependencies": {
32
+ "@webiny/di": ">=0.2.3"
33
+ },
34
+ "devDependencies": {
35
+ "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
36
+ "@webiny/di": "1.0.2",
37
+ "rimraf": "6.1.3",
38
+ "typescript": "7.0.2",
39
+ "vitest": "4.1.10"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "webiny": {
45
+ "publishFrom": "dist"
46
+ }
47
+ }