@ambiten/core 1.0.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.
- package/LICENSE +21 -0
- package/README.md +247 -0
- package/bin/bootstrap.js +26 -0
- package/dist/ambiten-cache/ambitenCache.d.ts +64 -0
- package/dist/ambiten-cache/ambitenCache.d.ts.map +1 -0
- package/dist/ambiten-cache/ambitenCache.js +127 -0
- package/dist/ambiten-cache/index.d.ts +2 -0
- package/dist/ambiten-cache/index.d.ts.map +1 -0
- package/dist/ambiten-cache/index.js +4 -0
- package/dist/browser.d.ts +32 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +37 -0
- package/dist/cli/ambiten-core-cli.d.ts +4 -0
- package/dist/cli/ambiten-core-cli.d.ts.map +1 -0
- package/dist/cli/ambiten-core-cli.js +41 -0
- package/dist/cli/buildInteractiveConfig.d.ts +4 -0
- package/dist/cli/buildInteractiveConfig.d.ts.map +1 -0
- package/dist/cli/buildInteractiveConfig.js +198 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/prompt.d.ts +10 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +48 -0
- package/dist/cli/types.d.ts +11 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/config/ambiten.config.schema.json +278 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/loadAmbitenConfig.d.ts +3 -0
- package/dist/config/loadAmbitenConfig.d.ts.map +1 -0
- package/dist/config/loadAmbitenConfig.js +131 -0
- package/dist/context/ambitenContext.d.ts +35 -0
- package/dist/context/ambitenContext.d.ts.map +1 -0
- package/dist/context/ambitenContext.js +147 -0
- package/dist/context/helpers/runManualTransaction.d.ts +3 -0
- package/dist/context/helpers/runManualTransaction.d.ts.map +1 -0
- package/dist/context/helpers/runManualTransaction.js +22 -0
- package/dist/context/helpers/transactionSession.d.ts +9 -0
- package/dist/context/helpers/transactionSession.d.ts.map +1 -0
- package/dist/context/helpers/transactionSession.js +8 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +6 -0
- package/dist/debug/debugLog.d.ts +2 -0
- package/dist/debug/debugLog.d.ts.map +1 -0
- package/dist/debug/debugLog.js +23 -0
- package/dist/debug/index.d.ts +2 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +4 -0
- package/dist/gc/ambitenGC.d.ts +49 -0
- package/dist/gc/ambitenGC.d.ts.map +1 -0
- package/dist/gc/ambitenGC.js +138 -0
- package/dist/gc/gcCron.browser.d.ts +2 -0
- package/dist/gc/gcCron.browser.d.ts.map +1 -0
- package/dist/gc/gcCron.browser.js +9 -0
- package/dist/gc/gcCron.node.d.ts +19 -0
- package/dist/gc/gcCron.node.d.ts.map +1 -0
- package/dist/gc/gcCron.node.js +47 -0
- package/dist/gc/gcManager.d.ts +37 -0
- package/dist/gc/gcManager.d.ts.map +1 -0
- package/dist/gc/gcManager.js +62 -0
- package/dist/gc/index.d.ts +5 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/gc/index.js +7 -0
- package/dist/graphql/ambitenGraphQL.d.ts +24 -0
- package/dist/graphql/ambitenGraphQL.d.ts.map +1 -0
- package/dist/graphql/ambitenGraphQL.js +215 -0
- package/dist/graphql/index.d.ts +2 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +4 -0
- package/dist/index-browser.js +25 -0
- package/dist/index-browser.js.map +1 -0
- package/dist/index-cli.js +26 -0
- package/dist/index-cli.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/init-cli/generate.project.d.ts +9 -0
- package/dist/init-cli/generate.project.d.ts.map +1 -0
- package/dist/init-cli/generate.project.js +38 -0
- package/dist/instrumentation/index.d.ts +3 -0
- package/dist/instrumentation/index.d.ts.map +1 -0
- package/dist/instrumentation/index.js +5 -0
- package/dist/instrumentation/measureQuery.browser.d.ts +3 -0
- package/dist/instrumentation/measureQuery.browser.d.ts.map +1 -0
- package/dist/instrumentation/measureQuery.browser.js +6 -0
- package/dist/instrumentation/measureQueryWithErrors.d.ts +11 -0
- package/dist/instrumentation/measureQueryWithErrors.d.ts.map +1 -0
- package/dist/instrumentation/measureQueryWithErrors.js +90 -0
- package/dist/lib-core/ambitenClient.d.ts +115 -0
- package/dist/lib-core/ambitenClient.d.ts.map +1 -0
- package/dist/lib-core/ambitenClient.js +537 -0
- package/dist/lib-core/ambitenModelFactory.d.ts +979 -0
- package/dist/lib-core/ambitenModelFactory.d.ts.map +1 -0
- package/dist/lib-core/ambitenModelFactory.js +3984 -0
- package/dist/lib-core/ambitenSchema.d.ts +126 -0
- package/dist/lib-core/ambitenSchema.d.ts.map +1 -0
- package/dist/lib-core/ambitenSchema.js +247 -0
- package/dist/lib-core/bootstrap/ambitenBootstrap.d.ts +38 -0
- package/dist/lib-core/bootstrap/ambitenBootstrap.d.ts.map +1 -0
- package/dist/lib-core/bootstrap/ambitenBootstrap.js +381 -0
- package/dist/lib-core/bootstrap/index.d.ts +2 -0
- package/dist/lib-core/bootstrap/index.d.ts.map +1 -0
- package/dist/lib-core/bootstrap/index.js +4 -0
- package/dist/lib-core/index.d.ts +5 -0
- package/dist/lib-core/index.d.ts.map +1 -0
- package/dist/lib-core/index.js +7 -0
- package/dist/middleware/authorization/auth.d.ts +22 -0
- package/dist/middleware/authorization/auth.d.ts.map +1 -0
- package/dist/middleware/authorization/auth.js +37 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +6 -0
- package/dist/middleware/rbac/rbacMiddleware.d.ts +103 -0
- package/dist/middleware/rbac/rbacMiddleware.d.ts.map +1 -0
- package/dist/middleware/rbac/rbacMiddleware.js +246 -0
- package/dist/middleware/rbac/rbacTypes.d.ts +4 -0
- package/dist/middleware/rbac/rbacTypes.d.ts.map +1 -0
- package/dist/middleware/rbac/rbacTypes.js +8 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/softDelete/applySoftDelete.d.ts +5 -0
- package/dist/plugins/softDelete/applySoftDelete.d.ts.map +1 -0
- package/dist/plugins/softDelete/applySoftDelete.js +139 -0
- package/dist/plugins/softDelete/types.d.ts +14 -0
- package/dist/plugins/softDelete/types.d.ts.map +1 -0
- package/dist/plugins/softDelete/types.js +2 -0
- package/dist/redis-manager/index.d.ts +2 -0
- package/dist/redis-manager/index.d.ts.map +1 -0
- package/dist/redis-manager/index.js +4 -0
- package/dist/redis-manager/redisClient.d.ts +32 -0
- package/dist/redis-manager/redisClient.d.ts.map +1 -0
- package/dist/redis-manager/redisClient.js +146 -0
- package/dist/tanancy/MultiTenantManager.d.ts +98 -0
- package/dist/tanancy/MultiTenantManager.d.ts.map +1 -0
- package/dist/tanancy/MultiTenantManager.js +190 -0
- package/dist/tanancy/TenantContext.d.ts +31 -0
- package/dist/tanancy/TenantContext.d.ts.map +1 -0
- package/dist/tanancy/TenantContext.js +59 -0
- package/dist/tanancy/TenantModelResolver.d.ts +10 -0
- package/dist/tanancy/TenantModelResolver.d.ts.map +1 -0
- package/dist/tanancy/TenantModelResolver.js +114 -0
- package/dist/tanancy/index.d.ts +5 -0
- package/dist/tanancy/index.d.ts.map +1 -0
- package/dist/tanancy/index.js +7 -0
- package/dist/tanancy/init/initMultiTenancy.d.ts +29 -0
- package/dist/tanancy/init/initMultiTenancy.d.ts.map +1 -0
- package/dist/tanancy/init/initMultiTenancy.js +62 -0
- package/dist/templates/generateDefaultConfigContent.d.ts +10 -0
- package/dist/templates/generateDefaultConfigContent.d.ts.map +1 -0
- package/dist/templates/generateDefaultConfigContent.js +108 -0
- package/dist/templates/generateGCManagerFile.d.ts +2 -0
- package/dist/templates/generateGCManagerFile.d.ts.map +1 -0
- package/dist/templates/generateGCManagerFile.js +39 -0
- package/dist/templates/generateGCRunnerFile.d.ts +2 -0
- package/dist/templates/generateGCRunnerFile.d.ts.map +1 -0
- package/dist/templates/generateGCRunnerFile.js +25 -0
- package/dist/templates/generateMainEntry.d.ts +3 -0
- package/dist/templates/generateMainEntry.d.ts.map +1 -0
- package/dist/templates/generateMainEntry.js +24 -0
- package/dist/templates/index.d.ts +6 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +8 -0
- package/dist/templates/scaffold/structureGenerator.d.ts +4 -0
- package/dist/templates/scaffold/structureGenerator.d.ts.map +1 -0
- package/dist/templates/scaffold/structureGenerator.js +193 -0
- package/dist/types/GCConfig.d.ts +7 -0
- package/dist/types/GCConfig.d.ts.map +1 -0
- package/dist/types/GCConfig.js +2 -0
- package/dist/types/ambiten-runtime-type.d.ts +24 -0
- package/dist/types/ambiten-runtime-type.d.ts.map +1 -0
- package/dist/types/ambiten-runtime-type.js +2 -0
- package/dist/types/ambiten.client.type.d.ts +136 -0
- package/dist/types/ambiten.client.type.d.ts.map +1 -0
- package/dist/types/ambiten.client.type.js +3 -0
- package/dist/types/ambiten.model.type.d.ts +135 -0
- package/dist/types/ambiten.model.type.d.ts.map +1 -0
- package/dist/types/ambiten.model.type.js +4 -0
- package/dist/types/ambitenConfig.d.ts +103 -0
- package/dist/types/ambitenConfig.d.ts.map +1 -0
- package/dist/types/ambitenConfig.js +3 -0
- package/dist/types/bootstrapClient.type.d.ts +11 -0
- package/dist/types/bootstrapClient.type.d.ts.map +1 -0
- package/dist/types/bootstrapClient.type.js +2 -0
- package/dist/types/db.provider.d.ts +66 -0
- package/dist/types/db.provider.d.ts.map +1 -0
- package/dist/types/db.provider.js +2 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/document.d.ts.map +1 -0
- package/dist/types/document.js +2 -0
- package/dist/types/event.type.d.ts +6 -0
- package/dist/types/event.type.d.ts.map +1 -0
- package/dist/types/event.type.js +27 -0
- package/dist/types/graphql.type.d.ts +22 -0
- package/dist/types/graphql.type.d.ts.map +1 -0
- package/dist/types/graphql.type.js +2 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/logger.types.d.ts +15 -0
- package/dist/types/logger.types.d.ts.map +1 -0
- package/dist/types/logger.types.js +3 -0
- package/dist/types/middleware/types.d.ts +28 -0
- package/dist/types/middleware/types.d.ts.map +1 -0
- package/dist/types/middleware/types.js +2 -0
- package/dist/types/result.utils.types.d.ts +7 -0
- package/dist/types/result.utils.types.d.ts.map +1 -0
- package/dist/types/result.utils.types.js +2 -0
- package/dist/types/schema.type.d.ts +23 -0
- package/dist/types/schema.type.d.ts.map +1 -0
- package/dist/types/schema.type.js +10 -0
- package/dist/types/user.type.d.ts +11 -0
- package/dist/types/user.type.d.ts.map +1 -0
- package/dist/types/user.type.js +2 -0
- package/dist/utils/AuthUtils.d.ts +15 -0
- package/dist/utils/AuthUtils.d.ts.map +1 -0
- package/dist/utils/AuthUtils.js +26 -0
- package/dist/utils/ModelRegistry.d.ts +15 -0
- package/dist/utils/ModelRegistry.d.ts.map +1 -0
- package/dist/utils/ModelRegistry.js +35 -0
- package/dist/utils/banner.d.ts +2 -0
- package/dist/utils/banner.d.ts.map +1 -0
- package/dist/utils/banner.js +20 -0
- package/dist/utils/builders/createModel.d.ts +37 -0
- package/dist/utils/builders/createModel.d.ts.map +1 -0
- package/dist/utils/builders/createModel.js +38 -0
- package/dist/utils/builders/getTenantDb.d.ts +12 -0
- package/dist/utils/builders/getTenantDb.d.ts.map +1 -0
- package/dist/utils/builders/getTenantDb.js +25 -0
- package/dist/utils/builders/index.d.ts +4 -0
- package/dist/utils/builders/index.d.ts.map +1 -0
- package/dist/utils/builders/index.js +6 -0
- package/dist/utils/builders/schema.d.ts +22 -0
- package/dist/utils/builders/schema.d.ts.map +1 -0
- package/dist/utils/builders/schema.js +26 -0
- package/dist/utils/cacheWithRedis.d.ts +27 -0
- package/dist/utils/cacheWithRedis.d.ts.map +1 -0
- package/dist/utils/cacheWithRedis.js +22 -0
- package/dist/utils/castId.d.ts +5 -0
- package/dist/utils/castId.d.ts.map +1 -0
- package/dist/utils/castId.js +52 -0
- package/dist/utils/color-palatte.d.ts +4 -0
- package/dist/utils/color-palatte.d.ts.map +1 -0
- package/dist/utils/color-palatte.js +24 -0
- package/dist/utils/configureAmbitenContext.d.ts +13 -0
- package/dist/utils/configureAmbitenContext.d.ts.map +1 -0
- package/dist/utils/configureAmbitenContext.js +35 -0
- package/dist/utils/detect-package-manager.d.ts +5 -0
- package/dist/utils/detect-package-manager.d.ts.map +1 -0
- package/dist/utils/detect-package-manager.js +59 -0
- package/dist/utils/ensureModelNameSafe.d.ts +12 -0
- package/dist/utils/ensureModelNameSafe.d.ts.map +1 -0
- package/dist/utils/ensureModelNameSafe.js +28 -0
- package/dist/utils/ensureRedis.d.ts +7 -0
- package/dist/utils/ensureRedis.d.ts.map +1 -0
- package/dist/utils/ensureRedis.js +40 -0
- package/dist/utils/error/ambitenError-handler.d.ts +24 -0
- package/dist/utils/error/ambitenError-handler.d.ts.map +1 -0
- package/dist/utils/error/ambitenError-handler.js +39 -0
- package/dist/utils/error/errorTypes.d.ts +27 -0
- package/dist/utils/error/errorTypes.d.ts.map +1 -0
- package/dist/utils/error/errorTypes.js +30 -0
- package/dist/utils/error/index.d.ts +3 -0
- package/dist/utils/error/index.d.ts.map +1 -0
- package/dist/utils/error/index.js +5 -0
- package/dist/utils/eventOptions.d.ts +38 -0
- package/dist/utils/eventOptions.d.ts.map +1 -0
- package/dist/utils/eventOptions.js +130 -0
- package/dist/utils/events.d.ts +5 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +7 -0
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +25 -0
- package/dist/utils/invalidateTenantCache.d.ts +18 -0
- package/dist/utils/invalidateTenantCache.d.ts.map +1 -0
- package/dist/utils/invalidateTenantCache.js +27 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +27 -0
- package/dist/utils/modelLoader.d.ts +3 -0
- package/dist/utils/modelLoader.d.ts.map +1 -0
- package/dist/utils/modelLoader.js +41 -0
- package/dist/utils/resolveAmbitenOption.d.ts +2 -0
- package/dist/utils/resolveAmbitenOption.d.ts.map +1 -0
- package/dist/utils/resolveAmbitenOption.js +10 -0
- package/dist/utils/resolveRuntimeConfig.d.ts +22 -0
- package/dist/utils/resolveRuntimeConfig.d.ts.map +1 -0
- package/dist/utils/resolveRuntimeConfig.js +33 -0
- package/dist/utils/scaffoldLoger.d.ts +11 -0
- package/dist/utils/scaffoldLoger.d.ts.map +1 -0
- package/dist/utils/scaffoldLoger.js +68 -0
- package/dist/utils/symbols.d.ts +4 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/dist/utils/symbols.js +6 -0
- package/dist/utils/time.d.ts +5 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +39 -0
- package/package.json +180 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ambiten
|
|
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,247 @@
|
|
|
1
|
+
<div style="display: flex; align-items: center;">
|
|
2
|
+
<p >
|
|
3
|
+
<img
|
|
4
|
+
src="https://raw.githubusercontent.com/AmbitenHQ/ambiten/main/assets/ambiten-mark-192x192.png"
|
|
5
|
+
width="56"
|
|
6
|
+
alt="Ambiten"
|
|
7
|
+
/>
|
|
8
|
+
</p> <h2> @ambiten/core</h2>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>A runtime and context-aware data platform for MongoDB applications.</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
Runtime-aware models, transactions, middleware, multi-tenancy, observability, and execution boundaries designed for modern applications.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://www.npmjs.com/package/@ambiten/core">
|
|
21
|
+
<img src="https://img.shields.io/npm/v/@Ambiten/core?color=0ea5e9&label=npm&style=flat-square" alt="npm version" />
|
|
22
|
+
</a>
|
|
23
|
+
<!-- <a href="https://ambiten.dev">
|
|
24
|
+
<img src="https://img.shields.io/badge/docs-ambiten.dev-22c55e?style=flat-square" alt="documentation" />
|
|
25
|
+
</a> -->
|
|
26
|
+
<a href="https://github.com/AmbitenHQ/ambiten/stargazers">
|
|
27
|
+
<img src="https://img.shields.io/github/stars/AmbitenHQ/ambiten?style=flat-square&color=1E88E5" alt="GitHub stars" />
|
|
28
|
+
</a>
|
|
29
|
+
<img src="https://img.shields.io/badge/multi--tenant-native-6366f1?style=flat-square" alt="multi-tenant native" />
|
|
30
|
+
<img src="https://img.shields.io/badge/context-aware-14b8a6?style=flat-square" alt="context aware" />
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
@ambiten/core is the foundation of the Ambiten platform.
|
|
38
|
+
|
|
39
|
+
It provides the runtime responsible for context propagation, model execution, transaction coordination, multi-tenancy, middleware orchestration, and operational observability across MongoDB applications.
|
|
40
|
+
|
|
41
|
+
Rather than treating data access as an isolated persistence concern, Ambiten treats execution itself as a runtime responsibility.
|
|
42
|
+
|
|
43
|
+
The goal is to reduce infrastructure plumbing while keeping execution predictable, observable, and safe under real production conditions.
|
|
44
|
+
|
|
45
|
+
## What Ambiten Is
|
|
46
|
+
|
|
47
|
+
Ambiten is not just a MongoDB ODM.
|
|
48
|
+
|
|
49
|
+
It is a runtime and context-aware execution platform that coordinates context propagation, transactions, multi-tenancy, middleware, instrumentation, and runtime policies across the entire execution lifecycle of an application.
|
|
50
|
+
|
|
51
|
+
Traditional ODMs focus on mapping data.
|
|
52
|
+
|
|
53
|
+
Ambiten focuses on coordinating execution.
|
|
54
|
+
|
|
55
|
+
> Mongoose manages models.
|
|
56
|
+
> Ambiten manages execution.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @ambiten/core mongodb
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import {
|
|
66
|
+
AmbitenClient,
|
|
67
|
+
AmbitenModel,
|
|
68
|
+
AmbitenSchema,
|
|
69
|
+
AmbitenContext
|
|
70
|
+
} from "@ambiten/core";
|
|
71
|
+
|
|
72
|
+
const client = new AmbitenClient({
|
|
73
|
+
uri: process.env.MONGODB_URI,
|
|
74
|
+
options: {
|
|
75
|
+
dbName: "app"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
await client.connect();
|
|
80
|
+
|
|
81
|
+
const userSchema = new AmbitenSchema({
|
|
82
|
+
name: String,
|
|
83
|
+
email: String
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const UserModel = new AmbitenModel({
|
|
87
|
+
collectionName: "users",
|
|
88
|
+
schema: userSchema,
|
|
89
|
+
provider: client
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
await AmbitenContext.run(
|
|
93
|
+
{
|
|
94
|
+
tenantId: "tenant-a",
|
|
95
|
+
requestId: "req-001"
|
|
96
|
+
},
|
|
97
|
+
async () => {
|
|
98
|
+
await UserModel.create({
|
|
99
|
+
name: "Alice",
|
|
100
|
+
email: "alice@example.com"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The application code remains focused on product behavior.
|
|
107
|
+
|
|
108
|
+
The runtime carries execution state.
|
|
109
|
+
|
|
110
|
+
## Execution Model
|
|
111
|
+
|
|
112
|
+
Ambiten organizes execution around request-scoped runtime boundaries.
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
Request
|
|
116
|
+
↓
|
|
117
|
+
Adapter
|
|
118
|
+
↓
|
|
119
|
+
AmbitenContext
|
|
120
|
+
↓
|
|
121
|
+
Middleware
|
|
122
|
+
↓
|
|
123
|
+
AmbitenModel
|
|
124
|
+
↓
|
|
125
|
+
Provider / AmbitenClient
|
|
126
|
+
↓
|
|
127
|
+
MongoDB
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Instead of manually threading tenant IDs, transaction sessions, request metadata, instrumentation payloads, or infrastructure state across services, the runtime keeps execution context attached to the active boundary.
|
|
131
|
+
|
|
132
|
+
This allows the same execution model to remain consistent across HTTP requests, background workers, queues, scheduled jobs, transactions, and serverless environments.
|
|
133
|
+
|
|
134
|
+
## Core Capabilities
|
|
135
|
+
|
|
136
|
+
### Context Runtime
|
|
137
|
+
|
|
138
|
+
AmbitenContext provides request-scoped runtime state through AsyncLocalStorage.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
await AmbitenContext.run(
|
|
142
|
+
{
|
|
143
|
+
tenantId: "tenant-a"
|
|
144
|
+
},
|
|
145
|
+
async () => {
|
|
146
|
+
await UserModel.find({});
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The active context can carry tenant identity, request metadata, sessions, budgets, runtime observers, instrumentation metadata, and operational state without forcing application services to manually pass them through every execution layer.
|
|
152
|
+
|
|
153
|
+
### Runtime Models
|
|
154
|
+
|
|
155
|
+
AmbitenModel provides CRUD and aggregation capabilities that participate directly in the runtime.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
await UserModel.updateOne(
|
|
159
|
+
{ email: "alice@example.com" },
|
|
160
|
+
{
|
|
161
|
+
$set: {
|
|
162
|
+
active: true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Operations can execute inside middleware boundaries, transaction scopes, tenant-aware resolution, instrumentation flows, caching layers, and policy enforcement without departing from familiar MongoDB patterns.
|
|
169
|
+
|
|
170
|
+
### Multi-Tenancy & Transactions
|
|
171
|
+
|
|
172
|
+
Tenant isolation and transactional execution are coordinated through the runtime.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
await AmbitenContext.withTransaction(async () => {
|
|
176
|
+
await UserModel.create(user);
|
|
177
|
+
await AuditModel.create(log);
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The runtime propagates active sessions automatically while tenant-aware resolution remains attached to the current execution boundary.
|
|
182
|
+
|
|
183
|
+
Application code stays focused on business logic rather than infrastructure coordination.
|
|
184
|
+
|
|
185
|
+
### Observability & Instrumentation
|
|
186
|
+
|
|
187
|
+
Ambiten includes runtime instrumentation through utilities such as `measureQuery()`.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
await measureQuery(
|
|
191
|
+
{
|
|
192
|
+
operation: "find",
|
|
193
|
+
collectionName: "users"
|
|
194
|
+
},
|
|
195
|
+
async () => {
|
|
196
|
+
return UserModel.find({});
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Instrumentation can expose execution duration, tenant scope, transaction state, cache behavior, collection activity, and operational metadata for downstream observability systems.
|
|
202
|
+
|
|
203
|
+
## Adapter-Driven Runtime
|
|
204
|
+
|
|
205
|
+
Ambiten is adapter-driven.
|
|
206
|
+
|
|
207
|
+
The same runtime model can operate across Express, Fastify, GraphQL systems, NestJS applications, background workers, queues, and serverless environments while preserving consistent execution behavior.
|
|
208
|
+
|
|
209
|
+
The runtime remains responsible for execution coordination regardless of deployment model.
|
|
210
|
+
|
|
211
|
+
## Why Ambiten Exists
|
|
212
|
+
|
|
213
|
+
As applications grow, execution concerns become scattered across services, middleware, repositories, background workers, and infrastructure layers.
|
|
214
|
+
|
|
215
|
+
Context propagation becomes manual.
|
|
216
|
+
|
|
217
|
+
Transactions become difficult to coordinate.
|
|
218
|
+
|
|
219
|
+
Tenant isolation becomes inconsistent.
|
|
220
|
+
|
|
221
|
+
Observability becomes fragmented.
|
|
222
|
+
|
|
223
|
+
Ambiten exists to centralize those concerns inside the runtime itself so applications remain focused on business logic while execution behavior stays consistent, observable, and safe.
|
|
224
|
+
|
|
225
|
+
## Documentation
|
|
226
|
+
|
|
227
|
+
The official documentation covers runtime architecture, context propagation, transactions, middleware, instrumentation, multi-tenancy, adapters, deployment strategy, and production-oriented workflows.
|
|
228
|
+
|
|
229
|
+
Documentation:
|
|
230
|
+
|
|
231
|
+
https://ambiten.dev
|
|
232
|
+
|
|
233
|
+
## Ecosystem
|
|
234
|
+
|
|
235
|
+
The Ambiten ecosystem extends beyond the core runtime and includes adapters, logging infrastructure, project scaffolding, GraphQL integration, observability tooling, and future platform capabilities built around the same execution model.
|
|
236
|
+
|
|
237
|
+
Additional packages continue to evolve around the platform.
|
|
238
|
+
|
|
239
|
+
## Philosophy
|
|
240
|
+
|
|
241
|
+
> Execution behavior should be enforced by the runtime, not maintained manually across application code.
|
|
242
|
+
|
|
243
|
+
Ambiten exists to make systems more predictable, observable, and operationally consistent as complexity grows.
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT
|
package/bin/bootstrap.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const cliPath = path.resolve(__dirname, '../dist/index-cli.js');
|
|
8
|
+
|
|
9
|
+
const result = spawnSync(
|
|
10
|
+
process.execPath,
|
|
11
|
+
[cliPath, ...process.argv.slice(2)],
|
|
12
|
+
{
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
env: {
|
|
15
|
+
...process.env,
|
|
16
|
+
Ambiten_DISABLE_SIGNAL_HANDLERS: '1',
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (result.error) {
|
|
22
|
+
console.error('Failed to launch Ambiten CLI:', result.error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
process.exit(result.status ?? 0);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface AmbitenCacheOptions {
|
|
2
|
+
ttlSeconds?: number;
|
|
3
|
+
prefix?: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
tenantId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AmbitenCacheClient {
|
|
8
|
+
get(key: string): Promise<string | null>;
|
|
9
|
+
set(key: string, value: string, options?: {
|
|
10
|
+
EX?: number;
|
|
11
|
+
}): Promise<unknown>;
|
|
12
|
+
del(key: string | string[]): Promise<unknown>;
|
|
13
|
+
scan?(cursor: number, options?: {
|
|
14
|
+
MATCH?: string;
|
|
15
|
+
COUNT?: number;
|
|
16
|
+
}): Promise<[string, string[]] | {
|
|
17
|
+
cursor: number;
|
|
18
|
+
keys: string[];
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export declare class AmbitenCache {
|
|
22
|
+
private readonly client;
|
|
23
|
+
constructor(client?: AmbitenCacheClient);
|
|
24
|
+
/**
|
|
25
|
+
* Builds a tenant-aware cache key.
|
|
26
|
+
* Key format: {prefix}:{tenantId}:{namespace}:{key}
|
|
27
|
+
* - prefix: Optional string to namespace cache keys (default: "Ambiten")
|
|
28
|
+
* - tenantId: Resolved tenant ID for multi-tenancy (explicit > context > "default")
|
|
29
|
+
* - namespace: Optional string to further namespace keys (default: "cache")
|
|
30
|
+
* - key: The original cache key provided by the caller
|
|
31
|
+
*
|
|
32
|
+
* Resolution priority:
|
|
33
|
+
* 1. Explicit tenantId from options
|
|
34
|
+
* 2. Active Ambiten runtime tenantId
|
|
35
|
+
* 3. "default"
|
|
36
|
+
*/
|
|
37
|
+
private buildKey;
|
|
38
|
+
/**
|
|
39
|
+
* Reads and deserializes a cached value.
|
|
40
|
+
*/
|
|
41
|
+
get<T>(key: string, options?: AmbitenCacheOptions): Promise<T | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Serializes and writes a cached value.
|
|
44
|
+
*/
|
|
45
|
+
set<T>(key: string, value: T, options?: AmbitenCacheOptions): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns cached value if available, otherwise computes, stores, and returns it.
|
|
48
|
+
*/
|
|
49
|
+
wrap<T>(key: string, fetcher: () => Promise<T>, options?: AmbitenCacheOptions): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Invalidates one cache key.
|
|
52
|
+
*/
|
|
53
|
+
invalidate(key: string, options?: AmbitenCacheOptions): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Invalidates cache keys by pattern using SCAN.
|
|
56
|
+
*/
|
|
57
|
+
invalidatePattern(pattern: string): Promise<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Internal event hook point for future observability and policy integrations.
|
|
60
|
+
*/
|
|
61
|
+
private emit;
|
|
62
|
+
}
|
|
63
|
+
export declare function createAmbitenCache(client?: AmbitenCacheClient): AmbitenCache;
|
|
64
|
+
//# sourceMappingURL=ambitenCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambitenCache.d.ts","sourceRoot":"","sources":["../../src/ambiten-cache/ambitenCache.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CACD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,CAAC,CACH,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CACrE;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,GAAE,kBAA0B;IAE/D;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,QAAQ;IAYhB;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAmB3E;;OAEG;IACG,GAAG,CAAC,CAAC,EACT,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC;IAYhB;;OAEG;IACG,IAAI,CAAC,CAAC,EACV,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC;IAab;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3E;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyCzD;;OAEG;IACH,OAAO,CAAC,IAAI;CAIb;AAED,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,kBAA0B,GAAG,YAAY,CAEnF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AmbitenCache = void 0;
|
|
4
|
+
exports.createAmbitenCache = createAmbitenCache;
|
|
5
|
+
const redis_manager_1 = require("../redis-manager");
|
|
6
|
+
const context_1 = require("../context");
|
|
7
|
+
class AmbitenCache {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client = redis_manager_1.redis) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builds a tenant-aware cache key.
|
|
14
|
+
* Key format: {prefix}:{tenantId}:{namespace}:{key}
|
|
15
|
+
* - prefix: Optional string to namespace cache keys (default: "Ambiten")
|
|
16
|
+
* - tenantId: Resolved tenant ID for multi-tenancy (explicit > context > "default")
|
|
17
|
+
* - namespace: Optional string to further namespace keys (default: "cache")
|
|
18
|
+
* - key: The original cache key provided by the caller
|
|
19
|
+
*
|
|
20
|
+
* Resolution priority:
|
|
21
|
+
* 1. Explicit tenantId from options
|
|
22
|
+
* 2. Active Ambiten runtime tenantId
|
|
23
|
+
* 3. "default"
|
|
24
|
+
*/
|
|
25
|
+
buildKey(key, options = {}) {
|
|
26
|
+
const ctx = context_1.AmbitenContext.get();
|
|
27
|
+
const prefix = options.prefix ?? 'Ambiten';
|
|
28
|
+
const tenantId = options.tenantId ?? ctx.tenantId ?? 'default';
|
|
29
|
+
const namespace = options.namespace ?? 'cache';
|
|
30
|
+
return [prefix, tenantId, namespace, key]
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.join(':');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reads and deserializes a cached value.
|
|
36
|
+
*/
|
|
37
|
+
async get(key, options) {
|
|
38
|
+
const namespacedKey = this.buildKey(key, options);
|
|
39
|
+
const cached = await this.client.get(namespacedKey);
|
|
40
|
+
if (cached === null || cached === undefined) {
|
|
41
|
+
this.emit('miss', namespacedKey);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
this.emit('hit', namespacedKey);
|
|
46
|
+
return JSON.parse(cached);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
await this.client.del(namespacedKey);
|
|
50
|
+
this.emit('corrupt', namespacedKey);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Serializes and writes a cached value.
|
|
56
|
+
*/
|
|
57
|
+
async set(key, value, options = {}) {
|
|
58
|
+
const namespacedKey = this.buildKey(key, options);
|
|
59
|
+
await this.client.set(namespacedKey, JSON.stringify(value), { EX: options.ttlSeconds ?? 60 });
|
|
60
|
+
this.emit('set', namespacedKey);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns cached value if available, otherwise computes, stores, and returns it.
|
|
64
|
+
*/
|
|
65
|
+
async wrap(key, fetcher, options = {}) {
|
|
66
|
+
const existing = await this.get(key, options);
|
|
67
|
+
if (existing !== null) {
|
|
68
|
+
return existing;
|
|
69
|
+
}
|
|
70
|
+
const result = await fetcher();
|
|
71
|
+
await this.set(key, result, options);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Invalidates one cache key.
|
|
76
|
+
*/
|
|
77
|
+
async invalidate(key, options) {
|
|
78
|
+
const namespacedKey = this.buildKey(key, options);
|
|
79
|
+
await this.client.del(namespacedKey);
|
|
80
|
+
this.emit('invalidate', namespacedKey);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Invalidates cache keys by pattern using SCAN.
|
|
84
|
+
*/
|
|
85
|
+
async invalidatePattern(pattern) {
|
|
86
|
+
if (!pattern || typeof pattern !== 'string') {
|
|
87
|
+
throw new Error('Pattern must be a non-empty string.');
|
|
88
|
+
}
|
|
89
|
+
if (!this.client.scan) {
|
|
90
|
+
throw new Error('Cache client does not support scan().');
|
|
91
|
+
}
|
|
92
|
+
let cursor = 0;
|
|
93
|
+
let deletedCount = 0;
|
|
94
|
+
do {
|
|
95
|
+
const result = await this.client.scan(cursor, {
|
|
96
|
+
MATCH: pattern,
|
|
97
|
+
COUNT: 100
|
|
98
|
+
});
|
|
99
|
+
const nextCursor = Array.isArray(result)
|
|
100
|
+
? Number(result[0])
|
|
101
|
+
: result.cursor;
|
|
102
|
+
const keys = Array.isArray(result)
|
|
103
|
+
? result[1]
|
|
104
|
+
: result.keys;
|
|
105
|
+
if (keys.length > 0) {
|
|
106
|
+
await this.client.del(keys);
|
|
107
|
+
deletedCount += keys.length;
|
|
108
|
+
}
|
|
109
|
+
cursor = nextCursor;
|
|
110
|
+
} while (cursor !== 0);
|
|
111
|
+
if (deletedCount > 0) {
|
|
112
|
+
this.emit('invalidatePattern', pattern);
|
|
113
|
+
}
|
|
114
|
+
return deletedCount;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Internal event hook point for future observability and policy integrations.
|
|
118
|
+
*/
|
|
119
|
+
emit(event, key) {
|
|
120
|
+
void event;
|
|
121
|
+
void key;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.AmbitenCache = AmbitenCache;
|
|
125
|
+
function createAmbitenCache(client = redis_manager_1.redis) {
|
|
126
|
+
return new AmbitenCache(client);
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ambiten-cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Emmanuel Nodolomwanyi - Ambiten Team
|
|
3
|
+
* @package - @Ambiten/core
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { AmbitenClient } from './lib-core';
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
AmbitenClient: typeof AmbitenClient;
|
|
10
|
+
Buffer: any;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export * from './lib-core';
|
|
14
|
+
export { AmbitenBootstrapFactory } from './lib-core/bootstrap';
|
|
15
|
+
export * from './config';
|
|
16
|
+
export * from './graphql';
|
|
17
|
+
export * from './tanancy';
|
|
18
|
+
export * from './context';
|
|
19
|
+
export * from './plugins';
|
|
20
|
+
export * from './debug';
|
|
21
|
+
export { measureQueryForBrowser } from './instrumentation';
|
|
22
|
+
export * from './ambiten-cache';
|
|
23
|
+
export * from './utils/builders';
|
|
24
|
+
export * from './utils';
|
|
25
|
+
export * from './gc';
|
|
26
|
+
export * from './redis-manager';
|
|
27
|
+
export * from './types';
|
|
28
|
+
export type { AmbitenRuntime } from './types/ambiten-runtime-type';
|
|
29
|
+
export type { SchemaType } from './types/schema.type';
|
|
30
|
+
export type { Document } from './types/document';
|
|
31
|
+
export type { ErrorType } from './utils/error/errorTypes';
|
|
32
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY3C,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,aAAa,EAAE,OAAO,aAAa,CAAC;QACpC,MAAM,EAAE,GAAG,CAAC;KACZ;CACD;AAOD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC;AACrB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author Emmanuel Nodolomwanyi - Ambiten Team
|
|
4
|
+
* @package - @Ambiten/core
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.measureQueryForBrowser = exports.AmbitenBootstrapFactory = void 0;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const lib_core_1 = require("./lib-core");
|
|
11
|
+
/**
|
|
12
|
+
* Ambiten Core Library for Browser
|
|
13
|
+
* This module provides core functionalities for Ambiten in a browser environment.
|
|
14
|
+
* It includes database operations, configuration, and more.
|
|
15
|
+
* @module Ambiten Core Browser Module
|
|
16
|
+
* @version 1.0.0
|
|
17
|
+
*/
|
|
18
|
+
console.log('Ambiten Core Library Loaded for (Browser)');
|
|
19
|
+
window.AmbitenClient = lib_core_1.AmbitenClient;
|
|
20
|
+
window.Buffer = Buffer;
|
|
21
|
+
tslib_1.__exportStar(require("./lib-core"), exports);
|
|
22
|
+
var bootstrap_1 = require("./lib-core/bootstrap");
|
|
23
|
+
Object.defineProperty(exports, "AmbitenBootstrapFactory", { enumerable: true, get: function () { return bootstrap_1.AmbitenBootstrapFactory; } });
|
|
24
|
+
tslib_1.__exportStar(require("./config"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./graphql"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./tanancy"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./context"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./plugins"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./debug"), exports);
|
|
30
|
+
var instrumentation_1 = require("./instrumentation");
|
|
31
|
+
Object.defineProperty(exports, "measureQueryForBrowser", { enumerable: true, get: function () { return instrumentation_1.measureQueryForBrowser; } });
|
|
32
|
+
tslib_1.__exportStar(require("./ambiten-cache"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./utils/builders"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./gc"), exports);
|
|
36
|
+
tslib_1.__exportStar(require("./redis-manager"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambiten-core-cli.d.ts","sourceRoot":"","sources":["../../src/cli/ambiten-core-cli.ts"],"names":[],"mappings":";AAMA,wBAAsB,eAAe,CAAC,IAAI,WAAe,iBA+BxD;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.runBootstrapCLI = runBootstrapCLI;
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const generate_project_1 = require("../init-cli/generate.project");
|
|
7
|
+
const buildInteractiveConfig_1 = require("./buildInteractiveConfig");
|
|
8
|
+
async function runBootstrapCLI(argv = process.argv) {
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program
|
|
11
|
+
.name('Ambiten')
|
|
12
|
+
.description('Ambiten CLI')
|
|
13
|
+
.version('1.0.0', '-v, --version', 'Output the current CLI version');
|
|
14
|
+
program
|
|
15
|
+
.command('init')
|
|
16
|
+
.description('Initialize an Ambiten-powered project')
|
|
17
|
+
.argument('[projectName]', 'Name of the project')
|
|
18
|
+
.option('--with-graphql', 'Include GraphQL starter support')
|
|
19
|
+
.option('--with-redis', 'Enable Redis cache defaults')
|
|
20
|
+
.option('--logger', 'Enable logger configuration')
|
|
21
|
+
.option('--multi-tenant', 'Enable multi-tenant mode')
|
|
22
|
+
.option('--uri <mongodbUri>', 'MongoDB connection URI')
|
|
23
|
+
.option('--rbac', 'Reserve RBAC feature scaffolding')
|
|
24
|
+
.option('--with-garbage-collector', 'Enable garbage collector starter files')
|
|
25
|
+
.option('--install', 'Auto-install dependencies after scaffolding')
|
|
26
|
+
.action(async (projectName, options) => {
|
|
27
|
+
try {
|
|
28
|
+
const config = await (0, buildInteractiveConfig_1.buildInteractiveConfig)(projectName, options);
|
|
29
|
+
await (0, generate_project_1.generateProject)(config);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('[Ambiten CLI] Failed to initialize project:', error);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
await program.parseAsync(argv);
|
|
37
|
+
}
|
|
38
|
+
exports.default = runBootstrapCLI;
|
|
39
|
+
if (require.main === module) {
|
|
40
|
+
void runBootstrapCLI(process.argv);
|
|
41
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AmbitenConfig } from '../types';
|
|
2
|
+
import type { BootstrapCliOptions } from './types';
|
|
3
|
+
export declare function buildInteractiveConfig(projectNameArg: string | undefined, options: BootstrapCliOptions): Promise<AmbitenConfig>;
|
|
4
|
+
//# sourceMappingURL=buildInteractiveConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildInteractiveConfig.d.ts","sourceRoot":"","sources":["../../src/cli/buildInteractiveConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA6BnD,wBAAsB,sBAAsB,CAC1C,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAsMxB"}
|