@brightchain/node-express-suite 0.25.0

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.
Files changed (127) hide show
  1. package/MIGRATION.md +131 -0
  2. package/README.md +11 -0
  3. package/package.json +18 -0
  4. package/src/index.d.ts +46 -0
  5. package/src/index.d.ts.map +1 -0
  6. package/src/index.js +73 -0
  7. package/src/index.js.map +1 -0
  8. package/src/lib/application.d.ts +35 -0
  9. package/src/lib/application.d.ts.map +1 -0
  10. package/src/lib/application.js +38 -0
  11. package/src/lib/application.js.map +1 -0
  12. package/src/lib/bright-db-model-registry.d.ts +56 -0
  13. package/src/lib/bright-db-model-registry.d.ts.map +1 -0
  14. package/src/lib/bright-db-model-registry.js +71 -0
  15. package/src/lib/bright-db-model-registry.js.map +1 -0
  16. package/src/lib/brightchain-lib.d.ts +7 -0
  17. package/src/lib/brightchain-lib.d.ts.map +1 -0
  18. package/src/lib/brightchain-lib.js +12 -0
  19. package/src/lib/brightchain-lib.js.map +1 -0
  20. package/src/lib/brightdb.d.ts +7 -0
  21. package/src/lib/brightdb.d.ts.map +1 -0
  22. package/src/lib/brightdb.js +11 -0
  23. package/src/lib/brightdb.js.map +1 -0
  24. package/src/lib/constants.d.ts +6 -0
  25. package/src/lib/constants.d.ts.map +1 -0
  26. package/src/lib/constants.js +12 -0
  27. package/src/lib/constants.js.map +1 -0
  28. package/src/lib/create-test-app.d.ts +22 -0
  29. package/src/lib/create-test-app.d.ts.map +1 -0
  30. package/src/lib/create-test-app.js +49 -0
  31. package/src/lib/create-test-app.js.map +1 -0
  32. package/src/lib/databaseInit.d.ts +53 -0
  33. package/src/lib/databaseInit.d.ts.map +1 -0
  34. package/src/lib/databaseInit.js +114 -0
  35. package/src/lib/databaseInit.js.map +1 -0
  36. package/src/lib/datastore/block-document-store-factory.d.ts +31 -0
  37. package/src/lib/datastore/block-document-store-factory.d.ts.map +1 -0
  38. package/src/lib/datastore/block-document-store-factory.js +35 -0
  39. package/src/lib/datastore/block-document-store-factory.js.map +1 -0
  40. package/src/lib/datastore/block-document-store.d.ts +201 -0
  41. package/src/lib/datastore/block-document-store.d.ts.map +1 -0
  42. package/src/lib/datastore/block-document-store.js +649 -0
  43. package/src/lib/datastore/block-document-store.js.map +1 -0
  44. package/src/lib/datastore/document-store.d.ts +83 -0
  45. package/src/lib/datastore/document-store.d.ts.map +1 -0
  46. package/src/lib/datastore/document-store.js +3 -0
  47. package/src/lib/datastore/document-store.js.map +1 -0
  48. package/src/lib/datastore/index.d.ts +6 -0
  49. package/src/lib/datastore/index.d.ts.map +1 -0
  50. package/src/lib/datastore/index.js +11 -0
  51. package/src/lib/datastore/index.js.map +1 -0
  52. package/src/lib/datastore/memory-document-store.d.ts +9 -0
  53. package/src/lib/datastore/memory-document-store.d.ts.map +1 -0
  54. package/src/lib/datastore/memory-document-store.js +218 -0
  55. package/src/lib/datastore/memory-document-store.js.map +1 -0
  56. package/src/lib/environment.d.ts +64 -0
  57. package/src/lib/environment.d.ts.map +1 -0
  58. package/src/lib/environment.js +165 -0
  59. package/src/lib/environment.js.map +1 -0
  60. package/src/lib/factories/blockStoreFactory.d.ts +10 -0
  61. package/src/lib/factories/blockStoreFactory.d.ts.map +1 -0
  62. package/src/lib/factories/blockStoreFactory.js +14 -0
  63. package/src/lib/factories/blockStoreFactory.js.map +1 -0
  64. package/src/lib/interfaces/bright-db-application.d.ts +34 -0
  65. package/src/lib/interfaces/bright-db-application.d.ts.map +1 -0
  66. package/src/lib/interfaces/bright-db-application.js +13 -0
  67. package/src/lib/interfaces/bright-db-application.js.map +1 -0
  68. package/src/lib/interfaces/environment.d.ts +34 -0
  69. package/src/lib/interfaces/environment.d.ts.map +1 -0
  70. package/src/lib/interfaces/environment.js +11 -0
  71. package/src/lib/interfaces/environment.js.map +1 -0
  72. package/src/lib/middleware/index.d.ts +2 -0
  73. package/src/lib/middleware/index.d.ts.map +1 -0
  74. package/src/lib/middleware/index.js +6 -0
  75. package/src/lib/middleware/index.js.map +1 -0
  76. package/src/lib/middleware/validateBody.d.ts +13 -0
  77. package/src/lib/middleware/validateBody.d.ts.map +1 -0
  78. package/src/lib/middleware/validateBody.js +35 -0
  79. package/src/lib/middleware/validateBody.js.map +1 -0
  80. package/src/lib/middlewares.d.ts +9 -0
  81. package/src/lib/middlewares.d.ts.map +1 -0
  82. package/src/lib/middlewares.js +21 -0
  83. package/src/lib/middlewares.js.map +1 -0
  84. package/src/lib/plugins/bright-db-database-plugin.d.ts +95 -0
  85. package/src/lib/plugins/bright-db-database-plugin.d.ts.map +1 -0
  86. package/src/lib/plugins/bright-db-database-plugin.js +143 -0
  87. package/src/lib/plugins/bright-db-database-plugin.js.map +1 -0
  88. package/src/lib/plugins/configure-bright-db-app.d.ts +25 -0
  89. package/src/lib/plugins/configure-bright-db-app.d.ts.map +1 -0
  90. package/src/lib/plugins/configure-bright-db-app.js +31 -0
  91. package/src/lib/plugins/configure-bright-db-app.js.map +1 -0
  92. package/src/lib/services/bright-db-authentication-provider.d.ts +31 -0
  93. package/src/lib/services/bright-db-authentication-provider.d.ts.map +1 -0
  94. package/src/lib/services/bright-db-authentication-provider.js +91 -0
  95. package/src/lib/services/bright-db-authentication-provider.js.map +1 -0
  96. package/src/lib/services/bright-db-base-service.d.ts +26 -0
  97. package/src/lib/services/bright-db-base-service.d.ts.map +1 -0
  98. package/src/lib/services/bright-db-base-service.js +30 -0
  99. package/src/lib/services/bright-db-base-service.js.map +1 -0
  100. package/src/lib/services/bright-db-collection.d.ts +50 -0
  101. package/src/lib/services/bright-db-collection.d.ts.map +1 -0
  102. package/src/lib/services/bright-db-collection.js +116 -0
  103. package/src/lib/services/bright-db-collection.js.map +1 -0
  104. package/src/lib/services/sessionAdapter.d.ts +62 -0
  105. package/src/lib/services/sessionAdapter.d.ts.map +1 -0
  106. package/src/lib/services/sessionAdapter.js +106 -0
  107. package/src/lib/services/sessionAdapter.js.map +1 -0
  108. package/src/lib/shared-types.d.ts +41 -0
  109. package/src/lib/shared-types.d.ts.map +1 -0
  110. package/src/lib/shared-types.js +3 -0
  111. package/src/lib/shared-types.js.map +1 -0
  112. package/src/lib/transactions/bright-db-transaction-manager.d.ts +46 -0
  113. package/src/lib/transactions/bright-db-transaction-manager.d.ts.map +1 -0
  114. package/src/lib/transactions/bright-db-transaction-manager.js +81 -0
  115. package/src/lib/transactions/bright-db-transaction-manager.js.map +1 -0
  116. package/src/lib/types/backend-id.d.ts +3 -0
  117. package/src/lib/types/backend-id.d.ts.map +1 -0
  118. package/src/lib/types/backend-id.js +3 -0
  119. package/src/lib/types/backend-id.js.map +1 -0
  120. package/src/lib/upstream.d.ts +8 -0
  121. package/src/lib/upstream.d.ts.map +1 -0
  122. package/src/lib/upstream.js +13 -0
  123. package/src/lib/upstream.js.map +1 -0
  124. package/src/lib/validation/userValidation.d.ts +44 -0
  125. package/src/lib/validation/userValidation.d.ts.map +1 -0
  126. package/src/lib/validation/userValidation.js +147 -0
  127. package/src/lib/validation/userValidation.js.map +1 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview BrightDB-specific application interface.
3
+ * Extends the base IApplication with BrightDB-specific capabilities.
4
+ * Parallel to upstream's IMongoApplication.
5
+ *
6
+ * Use this interface in controllers, services, and middlewares that require
7
+ * direct access to the BrightDB document store or BrightDB configuration.
8
+ *
9
+ * @module interfaces/bright-db-application
10
+ */
11
+ import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
12
+ import type { IApplication } from '@digitaldefiance/node-express-suite';
13
+ import type { DocumentStore, DocumentCollection, DocumentRecord } from '../datastore/document-store';
14
+ import type { BrightDbEnvironment } from '../environment';
15
+ /**
16
+ * BrightDB-specific application interface.
17
+ * Extends IApplication with the BrightDB document store and collection access.
18
+ *
19
+ * Use this interface when your code needs:
20
+ * - `application.db` (the BrightDB-backed document store)
21
+ * - `application.getModel<T>(name)` (BrightDB collection lookup)
22
+ * - `application.environment` typed as BrightDbEnvironment
23
+ *
24
+ * Non-BrightDB applications should use the base IApplication.
25
+ */
26
+ export interface IBrightDbApplication<TID extends PlatformID = Buffer> extends IApplication<TID> {
27
+ /** The BrightDB-backed document store */
28
+ readonly db: DocumentStore;
29
+ /** Retrieve a BrightDB collection by name */
30
+ getModel<U extends DocumentRecord>(modelName: string): DocumentCollection<U>;
31
+ /** The BrightDB environment */
32
+ readonly environment: BrightDbEnvironment<TID>;
33
+ }
34
+ //# sourceMappingURL=bright-db-application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bright-db-application.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/interfaces/bright-db-application.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,oBAAoB,CACnC,GAAG,SAAS,UAAU,GAAG,MAAM,CAC/B,SAAQ,YAAY,CAAC,GAAG,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC7E,+BAA+B;IAC/B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;CAChD"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview BrightDB-specific application interface.
4
+ * Extends the base IApplication with BrightDB-specific capabilities.
5
+ * Parallel to upstream's IMongoApplication.
6
+ *
7
+ * Use this interface in controllers, services, and middlewares that require
8
+ * direct access to the BrightDB document store or BrightDB configuration.
9
+ *
10
+ * @module interfaces/bright-db-application
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=bright-db-application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bright-db-application.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/interfaces/bright-db-application.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview BrightDB-specific cloud block store configuration interfaces.
3
+ *
4
+ * Extracted from brightchain-api-lib so that BrightDbEnvironment can reference
5
+ * them without depending on api-lib.
6
+ *
7
+ * @module interfaces/environment
8
+ */
9
+ import { ICloudBlockStoreConfig } from '@brightchain/brightchain-lib';
10
+ /**
11
+ * Azure-specific cloud block store configuration fields.
12
+ * Extends ICloudBlockStoreConfig with Azure Blob Storage auth options.
13
+ * Defined here (not in brightchain-azure-store) so consumers
14
+ * stay free of static cloud SDK dependencies.
15
+ */
16
+ export interface IAzureEnvironmentConfig extends ICloudBlockStoreConfig {
17
+ connectionString?: string;
18
+ accountName?: string;
19
+ accountKey?: string;
20
+ useManagedIdentity?: boolean;
21
+ }
22
+ /**
23
+ * S3-specific cloud block store configuration fields.
24
+ * Extends ICloudBlockStoreConfig with S3 auth options.
25
+ * Defined here (not in brightchain-s3-store) so consumers
26
+ * stay free of static cloud SDK dependencies.
27
+ */
28
+ export interface IS3EnvironmentConfig extends ICloudBlockStoreConfig {
29
+ accessKeyId?: string;
30
+ secretAccessKey?: string;
31
+ useIamRole?: boolean;
32
+ endpoint?: string;
33
+ }
34
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/interfaces/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview BrightDB-specific cloud block store configuration interfaces.
4
+ *
5
+ * Extracted from brightchain-api-lib so that BrightDbEnvironment can reference
6
+ * them without depending on api-lib.
7
+ *
8
+ * @module interfaces/environment
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/interfaces/environment.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
@@ -0,0 +1,2 @@
1
+ export { validateBody } from './validateBody';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateBody = void 0;
4
+ var validateBody_1 = require("./validateBody");
5
+ Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return validateBody_1.validateBody; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/middleware/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,13 @@
1
+ import { BrandedInterfaceDefinition } from '@digitaldefiance/branded-interface';
2
+ import type { NextFunction, Request, Response } from 'express';
3
+ /**
4
+ * Express middleware factory that validates the request body against a
5
+ * BrandedInterfaceDefinition using safeParseInterface().
6
+ *
7
+ * On success: attaches the branded instance to `req.brandedBody` and calls `next()`.
8
+ * On failure: responds with HTTP 400 and a JSON error body.
9
+ *
10
+ * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
11
+ */
12
+ export declare function validateBody<T extends Record<string, unknown>>(definition: BrandedInterfaceDefinition<T>): (req: Request, res: Response, next: NextFunction) => void;
13
+ //# sourceMappingURL=validateBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateBody.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/middleware/validateBody.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,UAAU,EAAE,0BAA0B,CAAC,CAAC,CAAC,IAEjC,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IAAI,CAmB/D"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateBody = validateBody;
4
+ const branded_interface_1 = require("@digitaldefiance/branded-interface");
5
+ /**
6
+ * Express middleware factory that validates the request body against a
7
+ * BrandedInterfaceDefinition using safeParseInterface().
8
+ *
9
+ * On success: attaches the branded instance to `req.brandedBody` and calls `next()`.
10
+ * On failure: responds with HTTP 400 and a JSON error body.
11
+ *
12
+ * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
13
+ */
14
+ function validateBody(definition) {
15
+ return (req, res, next) => {
16
+ if (!req.body || typeof req.body !== 'object' || Array.isArray(req.body)) {
17
+ res
18
+ .status(400)
19
+ .json({ error: 'Request body is missing or not an object' });
20
+ return;
21
+ }
22
+ const result = (0, branded_interface_1.safeParseInterface)(req.body, definition);
23
+ if (!result.success) {
24
+ res.status(400).json({
25
+ error: result.error.message,
26
+ code: result.error.code,
27
+ fieldErrors: result.error.fieldErrors ?? [],
28
+ });
29
+ return;
30
+ }
31
+ req.brandedBody = result.value;
32
+ next();
33
+ };
34
+ }
35
+ //# sourceMappingURL=validateBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateBody.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/middleware/validateBody.ts"],"names":[],"mappings":";;AAeA,oCAsBC;AArCD,0EAG4C;AAG5C;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAC1B,UAAyC;IAEzC,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzE,GAAG;iBACA,MAAM,CAAC,GAAG,CAAC;iBACX,IAAI,CAAC,EAAE,KAAK,EAAE,0CAA0C,EAAE,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;gBAC3B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI;gBACvB,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE;aAC5C,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACA,GAA0C,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;QACvE,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Application } from 'express';
2
+ /**
3
+ * Generic BrightDB middleware initialization.
4
+ * Provides standard Express security middleware without domain-specific CSP.
5
+ */
6
+ export declare class BrightDbMiddlewares {
7
+ static init(app: Application): void;
8
+ }
9
+ //# sourceMappingURL=middlewares.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/middlewares.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAoB,MAAM,SAAS,CAAC;AAGxD;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAMpC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrightDbMiddlewares = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cors_1 = tslib_1.__importDefault(require("cors"));
6
+ const express_1 = require("express");
7
+ const helmet_1 = tslib_1.__importDefault(require("helmet"));
8
+ /**
9
+ * Generic BrightDB middleware initialization.
10
+ * Provides standard Express security middleware without domain-specific CSP.
11
+ */
12
+ class BrightDbMiddlewares {
13
+ static init(app) {
14
+ app.use((0, helmet_1.default)());
15
+ app.use((0, cors_1.default)());
16
+ app.use((0, express_1.json)());
17
+ app.use((0, express_1.urlencoded)({ extended: true }));
18
+ }
19
+ }
20
+ exports.BrightDbMiddlewares = BrightDbMiddlewares;
21
+ //# sourceMappingURL=middlewares.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/middlewares.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,qCAAwD;AACxD,4DAA4B;AAE5B;;;GAGG;AACH,MAAa,mBAAmB;IAC9B,MAAM,CAAC,IAAI,CAAC,GAAgB;QAC1B,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,GAAE,CAAC,CAAC;QAClB,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;QAChB,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;QAChB,GAAG,CAAC,GAAG,CAAC,IAAA,oBAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;CACF;AAPD,kDAOC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @fileoverview Generic BrightDB database plugin for the express-suite plugin architecture.
3
+ *
4
+ * Implements IDatabasePlugin<TID> to encapsulate the generic BrightDB database
5
+ * lifecycle: block stores, BrightDb connection/disconnection, and typed accessors.
6
+ * Domain-specific stores (MemberStore, EnergyAccountStore, etc.) are added by
7
+ * subclasses in consuming libraries.
8
+ *
9
+ * @module plugins/bright-db-database-plugin
10
+ */
11
+ import type { IBlockStore } from '@brightchain/brightchain-lib';
12
+ import type { BrightDb } from '@brightchain/db';
13
+ import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
14
+ import type { IApplication, IAuthenticationProvider, IDatabasePlugin } from '@digitaldefiance/node-express-suite';
15
+ import type { IDatabase } from '@digitaldefiance/suite-core-lib';
16
+ import type { BrightDbEnvironment } from '../environment';
17
+ export interface IBrightDbDatabasePluginOptions {
18
+ skipAutoSeed?: boolean;
19
+ }
20
+ export declare class BrightDbDatabasePlugin<TID extends PlatformID> implements IDatabasePlugin<TID> {
21
+ readonly name: string;
22
+ readonly version: string;
23
+ protected readonly _environment: BrightDbEnvironment<TID>;
24
+ protected readonly _skipAutoSeed: boolean;
25
+ protected _connected: boolean;
26
+ protected _blockStore: IBlockStore | null;
27
+ protected _brightDb: BrightDb | null;
28
+ protected _authProvider: IAuthenticationProvider<TID> | null;
29
+ constructor(environment: BrightDbEnvironment<TID>, options?: IBrightDbDatabasePluginOptions);
30
+ /**
31
+ * The IDatabase instance this plugin manages.
32
+ * BrightDb implements IDatabase directly, so no adapter is needed.
33
+ * @throws Error if the plugin is not connected.
34
+ */
35
+ get database(): IDatabase;
36
+ /**
37
+ * Authentication provider created during init().
38
+ * Returns undefined before init() is called.
39
+ */
40
+ get authenticationProvider(): IAuthenticationProvider<TID> | undefined;
41
+ /**
42
+ * Connect the BrightDB database stack.
43
+ *
44
+ * Calls brightchainDatabaseInit(environment) and stores the resulting
45
+ * backend references (blockStore, BrightDb).
46
+ *
47
+ * @param _uri - Ignored; BrightDB uses environment-based configuration.
48
+ * @throws Error if brightchainDatabaseInit() returns a failure result.
49
+ */
50
+ connect(_uri?: string): Promise<void>;
51
+ /**
52
+ * Disconnect and release all backend references.
53
+ * Idempotent — calling when already disconnected completes without error.
54
+ */
55
+ disconnect(): Promise<void>;
56
+ /**
57
+ * Whether the database is currently connected.
58
+ */
59
+ isConnected(): boolean;
60
+ /**
61
+ * Initialize the plugin after connection.
62
+ * Subclasses override to create domain-specific auth providers.
63
+ */
64
+ init(_app: IApplication<TID>): Promise<void>;
65
+ /**
66
+ * Stop the plugin. Delegates to disconnect() for cleanup.
67
+ */
68
+ stop(): Promise<void>;
69
+ /**
70
+ * Provision an ephemeral dev/test block store.
71
+ * BrightChain doesn't use connection URIs — returns empty string.
72
+ */
73
+ setupDevStore(): Promise<string>;
74
+ /**
75
+ * Tear down the ephemeral dev/test block store.
76
+ * disconnect() handles all cleanup — nothing extra needed.
77
+ */
78
+ teardownDevStore(): Promise<void>;
79
+ /**
80
+ * Seed the dev database after connection.
81
+ * Subclasses override with domain-specific seeding.
82
+ */
83
+ initializeDevStore(): Promise<unknown>;
84
+ /**
85
+ * The block store backing the BrightDB database.
86
+ * @throws Error if the plugin is not connected.
87
+ */
88
+ get blockStore(): IBlockStore;
89
+ /**
90
+ * The BrightDb instance (implements IDatabase).
91
+ * @throws Error if the plugin is not connected.
92
+ */
93
+ get brightDb(): BrightDb;
94
+ }
95
+ //# sourceMappingURL=bright-db-database-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bright-db-database-plugin.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/plugins/bright-db-database-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,8BAA8B;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,qBAAa,sBAAsB,CAAC,GAAG,SAAS,UAAU,CACxD,YAAW,eAAe,CAAC,GAAG,CAAC;IAE/B,SAAgB,IAAI,EAAE,MAAM,CAAc;IAC1C,SAAgB,OAAO,EAAE,MAAM,CAAW;IAE1C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC1D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAC1C,SAAS,CAAC,UAAU,UAAS;IAC7B,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAQ;IACjD,SAAS,CAAC,SAAS,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAC5C,SAAS,CAAC,aAAa,EAAE,uBAAuB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;gBAGlE,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,EACrC,OAAO,GAAE,8BAAmC;IAQ9C;;;;OAIG;IACH,IAAI,QAAQ,IAAI,SAAS,CAOxB;IAED;;;OAGG;IACH,IAAI,sBAAsB,IAAI,uBAAuB,CAAC,GAAG,CAAC,GAAG,SAAS,CAErE;IAED;;;;;;;;OAQG;IACG,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQjC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAO5C;;;OAGG;IACH,IAAI,UAAU,IAAI,WAAW,CAO5B;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAOvB;CACF"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Generic BrightDB database plugin for the express-suite plugin architecture.
4
+ *
5
+ * Implements IDatabasePlugin<TID> to encapsulate the generic BrightDB database
6
+ * lifecycle: block stores, BrightDb connection/disconnection, and typed accessors.
7
+ * Domain-specific stores (MemberStore, EnergyAccountStore, etc.) are added by
8
+ * subclasses in consuming libraries.
9
+ *
10
+ * @module plugins/bright-db-database-plugin
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.BrightDbDatabasePlugin = void 0;
14
+ const databaseInit_1 = require("../databaseInit");
15
+ class BrightDbDatabasePlugin {
16
+ name = 'brightdb';
17
+ version = '1.0.0';
18
+ _environment;
19
+ _skipAutoSeed;
20
+ _connected = false;
21
+ _blockStore = null;
22
+ _brightDb = null;
23
+ _authProvider = null;
24
+ constructor(environment, options = {}) {
25
+ this._environment = environment;
26
+ this._skipAutoSeed = options.skipAutoSeed ?? false;
27
+ }
28
+ // ── IDatabasePlugin contract ──────────────────────────────────────
29
+ /**
30
+ * The IDatabase instance this plugin manages.
31
+ * BrightDb implements IDatabase directly, so no adapter is needed.
32
+ * @throws Error if the plugin is not connected.
33
+ */
34
+ get database() {
35
+ if (!this._brightDb) {
36
+ throw new Error('BrightDbDatabasePlugin: cannot access "database" — plugin is not connected. Call connect() first.');
37
+ }
38
+ return this._brightDb;
39
+ }
40
+ /**
41
+ * Authentication provider created during init().
42
+ * Returns undefined before init() is called.
43
+ */
44
+ get authenticationProvider() {
45
+ return this._authProvider ?? undefined;
46
+ }
47
+ /**
48
+ * Connect the BrightDB database stack.
49
+ *
50
+ * Calls brightchainDatabaseInit(environment) and stores the resulting
51
+ * backend references (blockStore, BrightDb).
52
+ *
53
+ * @param _uri - Ignored; BrightDB uses environment-based configuration.
54
+ * @throws Error if brightchainDatabaseInit() returns a failure result.
55
+ */
56
+ async connect(_uri) {
57
+ const initResult = await (0, databaseInit_1.brightchainDatabaseInit)(this._environment);
58
+ if (!initResult.success || !initResult.backend) {
59
+ throw new Error(`BrightDB database initialization failed: ${initResult.error ?? 'unknown error'}`);
60
+ }
61
+ this._blockStore = initResult.backend.blockStore;
62
+ this._brightDb = initResult.backend.db;
63
+ this._connected = true;
64
+ }
65
+ /**
66
+ * Disconnect and release all backend references.
67
+ * Idempotent — calling when already disconnected completes without error.
68
+ */
69
+ async disconnect() {
70
+ if (!this._connected)
71
+ return;
72
+ this._blockStore = null;
73
+ this._brightDb = null;
74
+ this._authProvider = null;
75
+ this._connected = false;
76
+ }
77
+ /**
78
+ * Whether the database is currently connected.
79
+ */
80
+ isConnected() {
81
+ return this._connected;
82
+ }
83
+ /**
84
+ * Initialize the plugin after connection.
85
+ * Subclasses override to create domain-specific auth providers.
86
+ */
87
+ async init(_app) {
88
+ // Subclasses override to create domain-specific auth providers
89
+ }
90
+ /**
91
+ * Stop the plugin. Delegates to disconnect() for cleanup.
92
+ */
93
+ async stop() {
94
+ await this.disconnect();
95
+ }
96
+ // ── Dev store lifecycle hooks ─────────────────────────────────────
97
+ /**
98
+ * Provision an ephemeral dev/test block store.
99
+ * BrightChain doesn't use connection URIs — returns empty string.
100
+ */
101
+ async setupDevStore() {
102
+ console.log('[BrightDB] Dev database mode — using ephemeral MemoryBlockStore.');
103
+ return '';
104
+ }
105
+ /**
106
+ * Tear down the ephemeral dev/test block store.
107
+ * disconnect() handles all cleanup — nothing extra needed.
108
+ */
109
+ async teardownDevStore() {
110
+ // disconnect() handles cleanup
111
+ }
112
+ /**
113
+ * Seed the dev database after connection.
114
+ * Subclasses override with domain-specific seeding.
115
+ */
116
+ async initializeDevStore() {
117
+ // Subclasses override with domain-specific seeding
118
+ return {};
119
+ }
120
+ // ── Typed accessors ───────────────────────────────────────────────
121
+ /**
122
+ * The block store backing the BrightDB database.
123
+ * @throws Error if the plugin is not connected.
124
+ */
125
+ get blockStore() {
126
+ if (!this._blockStore) {
127
+ throw new Error('BrightDbDatabasePlugin: cannot access "blockStore" — plugin is not connected. Call connect() first.');
128
+ }
129
+ return this._blockStore;
130
+ }
131
+ /**
132
+ * The BrightDb instance (implements IDatabase).
133
+ * @throws Error if the plugin is not connected.
134
+ */
135
+ get brightDb() {
136
+ if (!this._brightDb) {
137
+ throw new Error('BrightDbDatabasePlugin: cannot access "brightDb" — plugin is not connected. Call connect() first.');
138
+ }
139
+ return this._brightDb;
140
+ }
141
+ }
142
+ exports.BrightDbDatabasePlugin = BrightDbDatabasePlugin;
143
+ //# sourceMappingURL=bright-db-database-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bright-db-database-plugin.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/plugins/bright-db-database-plugin.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @fileoverview Generic BrightDB application configuration helper.
3
+ *
4
+ * Creates a BrightDbDatabasePlugin and registers it on the application.
5
+ * Domain-specific setup (GUID provider, constants, initializeBrightChain)
6
+ * is handled by the consuming library's configureBrightChainApp.
7
+ *
8
+ * @module plugins/configure-bright-db-app
9
+ */
10
+ import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
11
+ import type { IApplication } from '@digitaldefiance/node-express-suite';
12
+ import { BrightDbDatabasePlugin, type IBrightDbDatabasePluginOptions } from './bright-db-database-plugin';
13
+ import type { BrightDbEnvironment } from '../environment';
14
+ export interface ConfigureBrightDbAppResult<TID extends PlatformID> {
15
+ plugin: BrightDbDatabasePlugin<TID>;
16
+ }
17
+ /**
18
+ * Configure a generic BrightDB application with the database plugin.
19
+ *
20
+ * Creates a BrightDbDatabasePlugin and registers it on the application.
21
+ * Domain-specific setup (GUID provider, constants, initializeBrightChain)
22
+ * is handled by the consuming library's configureBrightChainApp.
23
+ */
24
+ export declare function configureBrightDbApp<TID extends PlatformID>(app: IApplication<TID>, environment: BrightDbEnvironment<TID>, pluginOptions?: IBrightDbDatabasePluginOptions): ConfigureBrightDbAppResult<TID>;
25
+ //# sourceMappingURL=configure-bright-db-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure-bright-db-app.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/plugins/configure-bright-db-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC1G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,0BAA0B,CAAC,GAAG,SAAS,UAAU;IAChE,MAAM,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,SAAS,UAAU,EACzD,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,EACtB,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,EACrC,aAAa,GAAE,8BAAmC,GACjD,0BAA0B,CAAC,GAAG,CAAC,CAUjC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Generic BrightDB application configuration helper.
4
+ *
5
+ * Creates a BrightDbDatabasePlugin and registers it on the application.
6
+ * Domain-specific setup (GUID provider, constants, initializeBrightChain)
7
+ * is handled by the consuming library's configureBrightChainApp.
8
+ *
9
+ * @module plugins/configure-bright-db-app
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.configureBrightDbApp = configureBrightDbApp;
13
+ const bright_db_database_plugin_1 = require("./bright-db-database-plugin");
14
+ /**
15
+ * Configure a generic BrightDB application with the database plugin.
16
+ *
17
+ * Creates a BrightDbDatabasePlugin and registers it on the application.
18
+ * Domain-specific setup (GUID provider, constants, initializeBrightChain)
19
+ * is handled by the consuming library's configureBrightChainApp.
20
+ */
21
+ function configureBrightDbApp(app, environment, pluginOptions = {}) {
22
+ const plugin = new bright_db_database_plugin_1.BrightDbDatabasePlugin(environment, pluginOptions);
23
+ if ('useDatabasePlugin' in app && typeof app.useDatabasePlugin === 'function') {
24
+ app.useDatabasePlugin(plugin);
25
+ }
26
+ else {
27
+ app.plugins.register(plugin);
28
+ }
29
+ return { plugin };
30
+ }
31
+ //# sourceMappingURL=configure-bright-db-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure-bright-db-app.js","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/plugins/configure-bright-db-app.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAkBH,oDAcC;AA5BD,2EAA0G;AAO1G;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,GAAsB,EACtB,WAAqC,EACrC,gBAAgD,EAAE;IAElD,MAAM,MAAM,GAAG,IAAI,kDAAsB,CAAM,WAAW,EAAE,aAAa,CAAC,CAAC;IAE3E,IAAI,mBAAmB,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC9E,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { BrightDb } from '@brightchain/db';
2
+ import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
3
+ import type { IAuthenticatedUser, IAuthenticationProvider } from '@digitaldefiance/node-express-suite';
4
+ import type { IRequestUserDTO, ITokenUser } from '@digitaldefiance/suite-core-lib';
5
+ /**
6
+ * Generic BrightDB-backed authentication provider.
7
+ *
8
+ * Provides basic user lookup from BrightDB `users` collection and JWT
9
+ * token verification. Domain-specific auth (MemberStore, mnemonic auth,
10
+ * password auth) is added by subclasses.
11
+ */
12
+ export declare class BrightDbAuthenticationProvider<TID extends PlatformID = Buffer, TLanguage extends string = string> implements IAuthenticationProvider<TID, TLanguage> {
13
+ protected readonly db: BrightDb;
14
+ protected readonly jwtSecret: string;
15
+ constructor(db: BrightDb, jwtSecret: string);
16
+ /**
17
+ * Find a user by ID from the `users` collection.
18
+ * Subclasses override to try MemberStore first.
19
+ */
20
+ findUserById(userId: string): Promise<IAuthenticatedUser<TLanguage> | null>;
21
+ /**
22
+ * Build a request user DTO from the `users` collection.
23
+ * Subclasses override to try MemberStore first.
24
+ */
25
+ buildRequestUserDTO(userId: string): Promise<IRequestUserDTO | null>;
26
+ /**
27
+ * Verify a JWT token and return the decoded user.
28
+ */
29
+ verifyToken<TTokenUser extends ITokenUser = ITokenUser>(token: string): Promise<TTokenUser | null>;
30
+ }
31
+ //# sourceMappingURL=bright-db-authentication-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bright-db-authentication-provider.d.ts","sourceRoot":"","sources":["../../../../../brightchain-node-express-suite/src/lib/services/bright-db-authentication-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACX,MAAM,iCAAiC,CAAC;AAGzC;;;;;;GAMG;AACH,qBAAa,8BAA8B,CACzC,GAAG,SAAS,UAAU,GAAG,MAAM,EAC/B,SAAS,SAAS,MAAM,GAAG,MAAM,CACjC,YAAW,uBAAuB,CAAC,GAAG,EAAE,SAAS,CAAC;IAGhD,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ;IAC/B,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM;gBADjB,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM;IAGtC;;;OAGG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IA2BhD;;;OAGG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA0C1E;;OAEG;IACG,WAAW,CAAC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1D,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAW9B"}