@webiny/api-composition-aws-ddb-os 0.0.0-unstable.e1999482d0 → 6.6.0-alpha.14

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.
@@ -1 +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-composition-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`), and the OpenSearch core and `DbRegistryFeature` are\n * registered in the root too. Per-request state (the DataLoaders, the OpenSearch field indexes, each\n * request's DbRegistry) is container scoped, so every request still gets its own.\n */\nimport { createWebinyApiHandler as createBaseHandler } from \"@webiny/api-composition-aws\";\nimport { createWebinyStreamApiHandler as createBaseStreamHandler } from \"@webiny/api-composition-aws\";\nimport { storageConfig } from \"./storageConfig.js\";\nimport type { CreateAwsDdbOsApiHandlerConfig } from \"./storageConfig.js\";\n\nexport type { CreateAwsDdbOsApiHandlerConfig };\n\nexport function createAwsDdbOsApiHandler(config: CreateAwsDdbOsApiHandlerConfig) {\n return createBaseHandler(storageConfig(config));\n}\n\n/**\n * Response-streaming counterpart, for the Lambda function whose Function URL uses\n * `InvokeMode: RESPONSE_STREAM`. Identical storage; only the transport differs.\n */\nexport function createAwsDdbOsStreamApiHandler(config: CreateAwsDdbOsApiHandlerConfig) {\n return createBaseStreamHandler(storageConfig(config));\n}\n"],"names":["createAwsDdbOsApiHandler","config","createBaseHandler","storageConfig","createAwsDdbOsStreamApiHandler","createBaseStreamHandler"],"mappings":";;AAgBO,SAASA,yBAAyBC,MAAsC;IAC3E,OAAOC,uBAAkBC,cAAcF;AAC3C;AAMO,SAASG,+BAA+BH,MAAsC;IACjF,OAAOI,6BAAwBF,cAAcF;AACjD"}
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-composition-aws): same DynamoDB storage as the\n * `-ddb` variant for core/audit-logs/ACO/websockets, but CMS uses the DynamoDB+OpenSearch storage\n * (`HeadlessCmsDdbEsStorageFeature`), and the OpenSearch core and `DbRegistryFeature` are registered in\n * the root too. The storage features register in each tenant scope, so every scope gets its own\n * per-request state (the DataLoaders, the OpenSearch field indexes, its DbRegistry).\n */\nimport { createWebinyApiHandler as createBaseHandler } from \"@webiny/api-composition-aws\";\nimport { createWebinyStreamApiHandler as createBaseStreamHandler } from \"@webiny/api-composition-aws\";\nimport { storageConfig } from \"./storageConfig.js\";\nimport type { CreateAwsDdbOsApiHandlerConfig } from \"./storageConfig.js\";\n\nexport type { CreateAwsDdbOsApiHandlerConfig };\n\nexport function createAwsDdbOsApiHandler(config: CreateAwsDdbOsApiHandlerConfig) {\n return createBaseHandler(storageConfig(config));\n}\n\n/**\n * Response-streaming counterpart, for the Lambda function whose Function URL uses\n * `InvokeMode: RESPONSE_STREAM`. Identical storage; only the transport differs.\n */\nexport function createAwsDdbOsStreamApiHandler(config: CreateAwsDdbOsApiHandlerConfig) {\n return createBaseStreamHandler(storageConfig(config));\n}\n"],"names":["createAwsDdbOsApiHandler","config","createBaseHandler","storageConfig","createAwsDdbOsStreamApiHandler","createBaseStreamHandler"],"mappings":";;AAgBO,SAASA,yBAAyBC,MAAsC;IAC3E,OAAOC,uBAAkBC,cAAcF;AAC3C;AAMO,SAASG,+BAA+BH,MAAsC;IACjF,OAAOI,6BAAwBF,cAAcF;AACjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-composition-aws-ddb-os",
3
- "version": "0.0.0-unstable.e1999482d0",
3
+ "version": "6.6.0-alpha.14",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -18,32 +18,45 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@webiny/api-aco-ddb": "0.0.0-unstable.e1999482d0",
22
- "@webiny/api-audit-logs-ddb": "0.0.0-unstable.e1999482d0",
23
- "@webiny/api-composition-aws": "0.0.0-unstable.e1999482d0",
24
- "@webiny/api-core-ddb": "0.0.0-unstable.e1999482d0",
25
- "@webiny/api-headless-cms-ddb-es": "0.0.0-unstable.e1999482d0",
26
- "@webiny/api-opensearch": "0.0.0-unstable.e1999482d0",
27
- "@webiny/api-opensearch-aws": "0.0.0-unstable.e1999482d0",
28
- "@webiny/api-websockets-aws": "0.0.0-unstable.e1999482d0",
29
- "@webiny/aws-sdk": "0.0.0-unstable.e1999482d0",
30
- "@webiny/db": "0.0.0-unstable.e1999482d0",
31
- "@webiny/db-dynamodb": "0.0.0-unstable.e1999482d0"
21
+ "@webiny/api-aco-ddb": "6.6.0-alpha.14",
22
+ "@webiny/api-audit-logs-ddb": "6.6.0-alpha.14",
23
+ "@webiny/api-composition-aws": "6.6.0-alpha.14",
24
+ "@webiny/api-core-ddb": "6.6.0-alpha.14",
25
+ "@webiny/api-headless-cms-ddb-es": "6.6.0-alpha.14",
26
+ "@webiny/api-opensearch": "6.6.0-alpha.14",
27
+ "@webiny/api-opensearch-aws": "6.6.0-alpha.14",
28
+ "@webiny/api-websockets-aws": "6.6.0-alpha.14",
29
+ "@webiny/aws-sdk": "6.6.0-alpha.14",
30
+ "@webiny/db": "6.6.0-alpha.14",
31
+ "@webiny/db-dynamodb": "6.6.0-alpha.14"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@webiny/di": "^2.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@webiny/api-aco": "0.0.0-unstable.e1999482d0",
38
- "@webiny/api-audit-logs": "0.0.0-unstable.e1999482d0",
39
- "@webiny/api-core": "0.0.0-unstable.e1999482d0",
40
- "@webiny/api-headless-cms": "0.0.0-unstable.e1999482d0",
41
- "@webiny/api-websockets": "0.0.0-unstable.e1999482d0",
42
- "@webiny/build-tools": "0.0.0-unstable.e1999482d0",
43
- "@webiny/cognito": "0.0.0-unstable.e1999482d0",
37
+ "@electric-sql/pglite": "0.5.17",
38
+ "@electric-sql/pglite-socket": "0.2.20",
39
+ "@webiny/api-aco": "6.6.0-alpha.14",
40
+ "@webiny/api-aco-pg": "6.6.0-alpha.14",
41
+ "@webiny/api-audit-logs": "6.6.0-alpha.14",
42
+ "@webiny/api-composition-aws-pg": "6.6.0-alpha.14",
43
+ "@webiny/api-composition-core": "6.6.0-alpha.14",
44
+ "@webiny/api-core": "6.6.0-alpha.14",
45
+ "@webiny/api-core-sql": "6.6.0-alpha.14",
46
+ "@webiny/api-graphql": "6.6.0-alpha.14",
47
+ "@webiny/api-headless-cms": "6.6.0-alpha.14",
48
+ "@webiny/api-headless-cms-pg": "6.6.0-alpha.14",
49
+ "@webiny/api-kernel-aws": "6.6.0-alpha.14",
50
+ "@webiny/api-kernel-core": "6.6.0-alpha.14",
51
+ "@webiny/api-storage-pg": "6.6.0-alpha.14",
52
+ "@webiny/api-websockets": "6.6.0-alpha.14",
53
+ "@webiny/build-tools": "6.6.0-alpha.14",
54
+ "@webiny/cognito": "6.6.0-alpha.14",
44
55
  "@webiny/di": "2.0.0",
45
- "@webiny/handler": "0.0.0-unstable.e1999482d0",
56
+ "@webiny/feature": "6.6.0-alpha.14",
57
+ "@webiny/handler": "6.6.0-alpha.14",
46
58
  "jsonwebtoken": "9.0.3",
59
+ "knex": "3.3.0",
47
60
  "rimraf": "6.1.4",
48
61
  "typescript": "7.0.2",
49
62
  "vitest": "5.1.1"
@@ -1,4 +1,4 @@
1
- import type { CreateWebinyApiHandlerConfig as BaseConfig } from "@webiny/api-composition-aws";
1
+ import type { AwsTenantStorages, CreateWebinyApiHandlerConfig as BaseConfig } from "@webiny/api-composition-aws";
2
2
  import { type DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
3
  import { createAwsOpenSearchClient } from "@webiny/api-opensearch-aws";
4
4
  export type CreateAwsDdbOsApiHandlerConfig = Pick<BaseConfig, "extensions"> & {
@@ -12,9 +12,20 @@ export type CreateAwsDdbOsApiHandlerConfig = Pick<BaseConfig, "extensions"> & {
12
12
  * integration tests can point the handler at a local OpenSearch.
13
13
  */
14
14
  openSearchClient?: ReturnType<typeof createAwsOpenSearchClient>;
15
+ /**
16
+ * Extra storages tenants can be placed on, next to DynamoDB, which stays the default storage
17
+ * (root's): `createAwsPgTenantStorages()` from `@webiny/api-composition-aws-pg`, for the
18
+ * storages the deploy declares. Only the tenants whose `settings.storage` names one run on it.
19
+ */
20
+ tenantStorages?: AwsTenantStorages;
15
21
  };
16
22
  /**
17
23
  * The storage half of the composition, shared by the buffered, streaming and web function entry
18
24
  * points so they cannot drift.
25
+ *
26
+ * The root gets what the process shares: the DynamoDB and OpenSearch clients, the OpenSearch core,
27
+ * and the CMS tables and entities. Every storage feature registers in each tenant scope on the
28
+ * default storage (`RequestStorage`), so a scope on another storage gets none of these storages'
29
+ * features, decorators or tasks.
19
30
  */
20
31
  export declare function storageConfig(config: CreateAwsDdbOsApiHandlerConfig): Pick<BaseConfig, "extensions" | "registerRootStorage">;
package/storageConfig.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { getDocumentClient } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
- import { DynamoDBCoreFeature } from "@webiny/db-dynamodb";
2
+ import { DynamoDBClientFeature, DynamoDBCoreFeature } from "@webiny/db-dynamodb";
3
+ import { RequestStorage } from "@webiny/api-core";
4
+ import { TenantStorageBackend, createDefaultTenantStorageBackend } from "@webiny/api-core/exports/api/tenancy.js";
3
5
  import { ApiCoreDdbFeature } from "@webiny/api-core-ddb";
4
- import { HeadlessCmsDdbEsFeature } from "@webiny/api-headless-cms-ddb-es";
6
+ import { HeadlessCmsDdbEsStorageFeature, HeadlessCmsDdbEsTablesFeature } from "@webiny/api-headless-cms-ddb-es";
5
7
  import { AuditLogsDdbFeature } from "@webiny/api-audit-logs-ddb";
6
8
  import { AcoDdbFeature } from "@webiny/api-aco-ddb";
7
9
  import { WebsocketsDdbFeature } from "@webiny/api-websockets-aws/ddb/index.js";
@@ -26,25 +28,36 @@ const openSearchClientFromEnv = ()=>{
26
28
  function storageConfig(config) {
27
29
  return {
28
30
  extensions: config.extensions,
29
- registerRootStorage: (container)=>{
31
+ registerRootStorage: async (container)=>{
30
32
  const documentClient = config.documentClient ?? getDocumentClient();
31
33
  const openSearchClient = config.openSearchClient ?? openSearchClientFromEnv();
32
- DynamoDBCoreFeature.register(container, {
33
- documentClient
34
- });
34
+ DynamoDBClientFeature.register(container, documentClient);
35
35
  OpenSearchClientFeature.register(container, openSearchClient);
36
36
  AwsOpenSearchClientFactoryFeature.register(container);
37
37
  OpenSearchQueryBuilderOperatorFeature.register(container);
38
38
  OpenSearchFieldFeature.register(container);
39
39
  OpenSearchIndexFeature.register(container);
40
40
  DbRegistryFeature.register(container);
41
- ApiCoreDdbFeature.register(container, {
42
- documentClient
41
+ HeadlessCmsDdbEsTablesFeature.register(container);
42
+ container.registerInstance(RequestStorage, {
43
+ register (scope) {
44
+ DynamoDBCoreFeature.register(scope, {
45
+ documentClient
46
+ });
47
+ ApiCoreDdbFeature.register(scope, {
48
+ documentClient
49
+ });
50
+ HeadlessCmsDdbEsStorageFeature.register(scope);
51
+ AuditLogsDdbFeature.register(scope, {});
52
+ AcoDdbFeature.register(scope);
53
+ WebsocketsDdbFeature.register(scope);
54
+ }
43
55
  });
44
- HeadlessCmsDdbEsFeature.register(container);
45
- AuditLogsDdbFeature.register(container, {});
46
- AcoDdbFeature.register(container);
47
- WebsocketsDdbFeature.register(container);
56
+ container.registerInstance(TenantStorageBackend, createDefaultTenantStorageBackend({
57
+ type: "dynamodb-opensearch",
58
+ label: "DynamoDB + OpenSearch"
59
+ }));
60
+ await config.tenantStorages?.register(container);
48
61
  }
49
62
  };
50
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"storageConfig.js","sources":["../src/storageConfig.ts"],"sourcesContent":["import type { CreateWebinyApiHandlerConfig as BaseConfig } from \"@webiny/api-composition-aws\";\nimport { getDocumentClient, type DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { DynamoDBCoreFeature } from \"@webiny/db-dynamodb\";\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-aws/ddb/index.js\";\nimport { DbRegistryFeature } from \"@webiny/db/exports/api/db.js\";\nimport { type OpenSearchClientOptions } from \"@webiny/api-opensearch\";\nimport { createAwsOpenSearchClient } from \"@webiny/api-opensearch-aws\";\nimport { AwsOpenSearchClientFactoryFeature } 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\"> & {\n /**\n * DynamoDB document client. Defaults to the standard AWS client (`getDocumentClient()`).\n * Injectable so integration tests can point the handler at a local (dynalite) DynamoDB.\n */\n documentClient?: DynamoDBDocument;\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\n/**\n * The storage half of the composition, shared by the buffered, streaming and web function entry\n * points so they cannot drift.\n */\nexport function storageConfig(\n config: CreateAwsDdbOsApiHandlerConfig\n): Pick<BaseConfig, \"extensions\" | \"registerRootStorage\"> {\n return {\n extensions: config.extensions,\n registerRootStorage: container => {\n // Built here, in `root`, rather than at factory time: one bundle exports both the buffered\n // and the streaming handler, so eager clients would be created twice per cold start.\n const documentClient = config.documentClient ?? getDocumentClient();\n const openSearchClient = config.openSearchClient ?? openSearchClientFromEnv();\n\n DynamoDBCoreFeature.register(container, { documentClient });\n\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 // DbRegistry holds the DDB entities the DDB+ES CMS storage stages for OpenSearch sync. It is\n // container scoped; the CMS storage adds its entities to every request's registry.\n DbRegistryFeature.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 };\n}\n"],"names":["openSearchClientFromEnv","osUsername","process","osPassword","openSearchClientOptions","createAwsOpenSearchClient","storageConfig","config","container","documentClient","getDocumentClient","openSearchClient","DynamoDBCoreFeature","OpenSearchClientFeature","AwsOpenSearchClientFactoryFeature","OpenSearchQueryBuilderOperatorFeature","OpenSearchFieldFeature","OpenSearchIndexFeature","DbRegistryFeature","ApiCoreDdbFeature","HeadlessCmsDdbEsFeature","AuditLogsDdbFeature","AcoDdbFeature","WebsocketsDdbFeature"],"mappings":";;;;;;;;;;;;;AA8BA,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;AAMO,SAASE,cACZC,MAAsC;IAEtC,OAAO;QACH,YAAYA,OAAO,UAAU;QAC7B,qBAAqBC,CAAAA;YAGjB,MAAMC,iBAAiBF,OAAO,cAAc,IAAIG;YAChD,MAAMC,mBAAmBJ,OAAO,gBAAgB,IAAIP;YAEpDY,oBAAoB,QAAQ,CAACJ,WAAW;gBAAEC;YAAe;YAIzDI,wBAAwB,QAAQ,CAACL,WAAWG;YAC5CG,kCAAkC,QAAQ,CAACN;YAC3CO,sCAAsC,QAAQ,CAACP;YAC/CQ,uBAAuB,QAAQ,CAACR;YAChCS,uBAAuB,QAAQ,CAACT;YAIhCU,kBAAkB,QAAQ,CAACV;YAE3BW,kBAAkB,QAAQ,CAACX,WAAW;gBAAEC;YAAe;YAEvDW,wBAAwB,QAAQ,CAACZ;YACjCa,oBAAoB,QAAQ,CAACb,WAAW,CAAC;YACzCc,cAAc,QAAQ,CAACd;YACvBe,qBAAqB,QAAQ,CAACf;QAClC;IACJ;AACJ"}
1
+ {"version":3,"file":"storageConfig.js","sources":["../src/storageConfig.ts"],"sourcesContent":["import type {\n AwsTenantStorages,\n CreateWebinyApiHandlerConfig as BaseConfig\n} from \"@webiny/api-composition-aws\";\nimport { getDocumentClient, type DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { DynamoDBClientFeature } from \"@webiny/db-dynamodb\";\nimport { DynamoDBCoreFeature } from \"@webiny/db-dynamodb\";\nimport { RequestStorage } from \"@webiny/api-core\";\nimport {\n TenantStorageBackend,\n createDefaultTenantStorageBackend\n} from \"@webiny/api-core/exports/api/tenancy.js\";\nimport { ApiCoreDdbFeature } from \"@webiny/api-core-ddb\";\nimport { HeadlessCmsDdbEsStorageFeature } from \"@webiny/api-headless-cms-ddb-es\";\nimport { HeadlessCmsDdbEsTablesFeature } 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-aws/ddb/index.js\";\nimport { DbRegistryFeature } from \"@webiny/db/exports/api/db.js\";\nimport { type OpenSearchClientOptions } from \"@webiny/api-opensearch\";\nimport { createAwsOpenSearchClient } from \"@webiny/api-opensearch-aws\";\nimport { AwsOpenSearchClientFactoryFeature } 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\"> & {\n /**\n * DynamoDB document client. Defaults to the standard AWS client (`getDocumentClient()`).\n * Injectable so integration tests can point the handler at a local (dynalite) DynamoDB.\n */\n documentClient?: DynamoDBDocument;\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 * Extra storages tenants can be placed on, next to DynamoDB, which stays the default storage\n * (root's): `createAwsPgTenantStorages()` from `@webiny/api-composition-aws-pg`, for the\n * storages the deploy declares. Only the tenants whose `settings.storage` names one run on it.\n */\n tenantStorages?: AwsTenantStorages;\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\n/**\n * The storage half of the composition, shared by the buffered, streaming and web function entry\n * points so they cannot drift.\n *\n * The root gets what the process shares: the DynamoDB and OpenSearch clients, the OpenSearch core,\n * and the CMS tables and entities. Every storage feature registers in each tenant scope on the\n * default storage (`RequestStorage`), so a scope on another storage gets none of these storages'\n * features, decorators or tasks.\n */\nexport function storageConfig(\n config: CreateAwsDdbOsApiHandlerConfig\n): Pick<BaseConfig, \"extensions\" | \"registerRootStorage\"> {\n return {\n extensions: config.extensions,\n registerRootStorage: async container => {\n // Built here, in `root`, rather than at factory time: one bundle exports both the buffered\n // and the streaming handler, so eager clients would be created twice per cold start.\n const documentClient = config.documentClient ?? getDocumentClient();\n const openSearchClient = config.openSearchClient ?? openSearchClientFromEnv();\n\n DynamoDBClientFeature.register(container, documentClient);\n\n // ── OpenSearch core (client + query-builder operators + fields + index registries) ──\n // The DDB+ES CMS storage 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 // DbRegistry holds the DDB entities the DDB+ES CMS storage stages for OpenSearch sync. It is\n // container scoped; the CMS storage adds its entities to the registry of every scope on it.\n DbRegistryFeature.register(container);\n\n HeadlessCmsDdbEsTablesFeature.register(container);\n\n container.registerInstance(RequestStorage, {\n register(scope) {\n DynamoDBCoreFeature.register(scope, { documentClient });\n ApiCoreDdbFeature.register(scope, { documentClient });\n // CMS uses the DynamoDB+OpenSearch storage; the rest stay DynamoDB-only.\n HeadlessCmsDdbEsStorageFeature.register(scope);\n AuditLogsDdbFeature.register(scope, {});\n AcoDdbFeature.register(scope);\n WebsocketsDdbFeature.register(scope);\n }\n });\n\n // The default storage's family, for the storages a tenant can be placed on.\n container.registerInstance(\n TenantStorageBackend,\n createDefaultTenantStorageBackend({\n type: \"dynamodb-opensearch\",\n label: \"DynamoDB + OpenSearch\"\n })\n );\n\n // After the default storage: an extra storage's backend never replaces its parts.\n await config.tenantStorages?.register(container);\n }\n };\n}\n"],"names":["openSearchClientFromEnv","osUsername","process","osPassword","openSearchClientOptions","createAwsOpenSearchClient","storageConfig","config","container","documentClient","getDocumentClient","openSearchClient","DynamoDBClientFeature","OpenSearchClientFeature","AwsOpenSearchClientFactoryFeature","OpenSearchQueryBuilderOperatorFeature","OpenSearchFieldFeature","OpenSearchIndexFeature","DbRegistryFeature","HeadlessCmsDdbEsTablesFeature","RequestStorage","scope","DynamoDBCoreFeature","ApiCoreDdbFeature","HeadlessCmsDdbEsStorageFeature","AuditLogsDdbFeature","AcoDdbFeature","WebsocketsDdbFeature","TenantStorageBackend","createDefaultTenantStorageBackend"],"mappings":";;;;;;;;;;;;;;;AA8CA,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;AAWO,SAASE,cACZC,MAAsC;IAEtC,OAAO;QACH,YAAYA,OAAO,UAAU;QAC7B,qBAAqB,OAAMC;YAGvB,MAAMC,iBAAiBF,OAAO,cAAc,IAAIG;YAChD,MAAMC,mBAAmBJ,OAAO,gBAAgB,IAAIP;YAEpDY,sBAAsB,QAAQ,CAACJ,WAAWC;YAI1CI,wBAAwB,QAAQ,CAACL,WAAWG;YAC5CG,kCAAkC,QAAQ,CAACN;YAC3CO,sCAAsC,QAAQ,CAACP;YAC/CQ,uBAAuB,QAAQ,CAACR;YAChCS,uBAAuB,QAAQ,CAACT;YAIhCU,kBAAkB,QAAQ,CAACV;YAE3BW,8BAA8B,QAAQ,CAACX;YAEvCA,UAAU,gBAAgB,CAACY,gBAAgB;gBACvC,UAASC,KAAK;oBACVC,oBAAoB,QAAQ,CAACD,OAAO;wBAAEZ;oBAAe;oBACrDc,kBAAkB,QAAQ,CAACF,OAAO;wBAAEZ;oBAAe;oBAEnDe,+BAA+B,QAAQ,CAACH;oBACxCI,oBAAoB,QAAQ,CAACJ,OAAO,CAAC;oBACrCK,cAAc,QAAQ,CAACL;oBACvBM,qBAAqB,QAAQ,CAACN;gBAClC;YACJ;YAGAb,UAAU,gBAAgB,CACtBoB,sBACAC,kCAAkC;gBAC9B,MAAM;gBACN,OAAO;YACX;YAIJ,MAAMtB,OAAO,cAAc,EAAE,SAASC;QAC1C;IACJ;AACJ"}