@laldigital/novaserve 2.2.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/README.md +384 -0
- package/bin/nova.js +2 -0
- package/dist/commands/ai.d.ts +9 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +152 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/build.d.ts +6 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +62 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/cost.d.ts +8 -0
- package/dist/commands/cost.d.ts.map +1 -0
- package/dist/commands/cost.js +50 -0
- package/dist/commands/cost.js.map +1 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +25 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/deploy.d.ts +8 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +128 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +6 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +75 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/dev.d.ts +8 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +60 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/diff.d.ts +8 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +60 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/doctor.d.ts +9 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +61 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/drift.d.ts +8 -0
- package/dist/commands/drift.d.ts.map +1 -0
- package/dist/commands/drift.js +81 -0
- package/dist/commands/drift.js.map +1 -0
- package/dist/commands/events.d.ts +8 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +102 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/graph.d.ts +8 -0
- package/dist/commands/graph.d.ts.map +1 -0
- package/dist/commands/graph.js +55 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/impact.d.ts +9 -0
- package/dist/commands/impact.d.ts.map +1 -0
- package/dist/commands/impact.js +65 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +339 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/invoke.d.ts +9 -0
- package/dist/commands/invoke.d.ts.map +1 -0
- package/dist/commands/invoke.js +64 -0
- package/dist/commands/invoke.js.map +1 -0
- package/dist/commands/ir.d.ts +8 -0
- package/dist/commands/ir.d.ts.map +1 -0
- package/dist/commands/ir.js +85 -0
- package/dist/commands/ir.js.map +1 -0
- package/dist/commands/logs.d.ts +3 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +50 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/plan.d.ts +9 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +81 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/plugins.d.ts +9 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +49 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/promote.d.ts +9 -0
- package/dist/commands/promote.d.ts.map +1 -0
- package/dist/commands/promote.js +44 -0
- package/dist/commands/promote.js.map +1 -0
- package/dist/commands/rollback.d.ts +9 -0
- package/dist/commands/rollback.d.ts.map +1 -0
- package/dist/commands/rollback.js +129 -0
- package/dist/commands/rollback.js.map +1 -0
- package/dist/commands/security.d.ts +8 -0
- package/dist/commands/security.d.ts.map +1 -0
- package/dist/commands/security.js +84 -0
- package/dist/commands/security.js.map +1 -0
- package/dist/commands/state.d.ts +8 -0
- package/dist/commands/state.d.ts.map +1 -0
- package/dist/commands/state.js +135 -0
- package/dist/commands/state.js.map +1 -0
- package/dist/commands/trace.d.ts +8 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +66 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/ui/banner.d.ts +14 -0
- package/dist/ui/banner.d.ts.map +1 -0
- package/dist/ui/banner.js +37 -0
- package/dist/ui/banner.js.map +1 -0
- package/dist/ui/spinner.d.ts +15 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +39 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/utils/config-loader.d.ts +12 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +29 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/novaserve-cloud/novaserve/main/docs/assets/logo.svg" height="80" alt="NovaServe" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h3 align="center">The TypeScript-Native Infrastructure Platform</h3>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Define. Compile. Plan. Deploy.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
Build and manage cloud infrastructure with TypeScript —<br />
|
|
13
|
+
from application definition to provider-specific deployment,<br />
|
|
14
|
+
through a compiler-driven, provider-independent architecture.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://www.npmjs.com/package/novaserve"><img src="https://img.shields.io/npm/v/novaserve.svg?style=flat-square&color=6366f1" alt="npm version" /></a>
|
|
19
|
+
<a href="https://www.npmjs.com/package/novaserve"><img src="https://img.shields.io/npm/dm/novaserve.svg?style=flat-square&color=38bdf8" alt="npm downloads" /></a>
|
|
20
|
+
<a href="https://github.com/novaserve-cloud/novaserve/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg?style=flat-square" alt="license" /></a>
|
|
21
|
+
<a href="https://typescriptlang.org"><img src="https://img.shields.io/badge/TypeScript-5.7+-3178c6.svg?style=flat-square" alt="TypeScript" /></a>
|
|
22
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg?style=flat-square" alt="node version" /></a>
|
|
23
|
+
<a href="https://github.com/novaserve-cloud/novaserve/actions"><img src="https://img.shields.io/badge/CI-passing-success.svg?style=flat-square" alt="CI status" /></a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
ONE SDK ──► ONE COMPILER ──► ONE IR ──► ONE PLANNER ──► MULTIPLE PROVIDERS
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 1. What is NovaServe?
|
|
35
|
+
|
|
36
|
+
**NovaServe** is a TypeScript-native Infrastructure-as-Code (IaC) and serverless development platform built around a compiler-driven deployment architecture. It enables engineers to declare cloud resources—such as HTTP API gateways, serverless compute functions, relational databases, message queues, object storage, and cron workers—directly in TypeScript instead of writing verbose, provider-specific configuration manifests.
|
|
37
|
+
|
|
38
|
+
At the core of NovaServe is a multi-stage compilation pipeline. The application specification is evaluated by the **Nova Compiler**, which performs dependency graph resolution, cycle detection, and type checking before emitting a canonical **Nova Intermediate Representation (Nova IR 1.0.0)**. The intermediate graph is processed by a deterministic planning engine to compute fine-grained execution diffs, least-privilege IAM policies, and cost projections before invoking pluggable provider adapters.
|
|
39
|
+
|
|
40
|
+
Designed for modern software development teams, NovaServe decouples high-level application intent from low-level cloud provider primitives. This abstraction allows applications to run locally on an in-process emulator or deploy seamlessly to **AWS**, **Cloudflare**, **Azure**, **GCP**, or **Docker** without modifying application handler code.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Why NovaServe?
|
|
45
|
+
|
|
46
|
+
Managing cloud infrastructure using traditional tools often introduces friction, configuration duplication, and environment discrepancies:
|
|
47
|
+
|
|
48
|
+
- **Configuration Complexity**: Managing raw YAML manifests, CloudFormation, or complex IaC templates leads to syntax errors that are only caught late in deployment.
|
|
49
|
+
- **Runtime-Infrastructure Disconnect**: Handler code and infrastructure declarations live in separate ecosystems, leading to manually specified IAM permissions and out-of-sync environment variables.
|
|
50
|
+
- **Provider Lock-In**: Porting applications between cloud environments or running faithful offline emulators requires rewriting deployment scripts.
|
|
51
|
+
|
|
52
|
+
NovaServe solves these challenges by integrating infrastructure declaration directly into the TypeScript type system.
|
|
53
|
+
|
|
54
|
+
### Comparison Paradigm
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
TRADITIONAL INFRASTRUCTURE:
|
|
58
|
+
Application Code + Infrastructure Manifests + Provider Templates + External CLI Tools
|
|
59
|
+
|
|
60
|
+
NOVASERVE ARCHITECTURE:
|
|
61
|
+
TypeScript Application
|
|
62
|
+
↓
|
|
63
|
+
NovaServe SDK
|
|
64
|
+
↓
|
|
65
|
+
Nova Compiler
|
|
66
|
+
↓
|
|
67
|
+
Nova Intermediate Representation (IR)
|
|
68
|
+
↓
|
|
69
|
+
Deterministic Planner & Cost Estimator
|
|
70
|
+
↓
|
|
71
|
+
Target Provider Adapter (AWS / Local / Cloudflare / Docker)
|
|
72
|
+
↓
|
|
73
|
+
Cloud Resources
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 3. Architecture
|
|
79
|
+
|
|
80
|
+
NovaServe implements a strict, unidirectional compilation pipeline where application intent is incrementally validated, compiled, planned, and deployed.
|
|
81
|
+
|
|
82
|
+
```mermaid
|
|
83
|
+
flowchart TD
|
|
84
|
+
A[TypeScript Application Spec] --> B[NovaServe SDK]
|
|
85
|
+
B --> C[Nova Compiler & DAG Engine]
|
|
86
|
+
C --> D[Nova Intermediate Representation IR 1.0.0]
|
|
87
|
+
D --> E[Diff Planner & Cost Engine]
|
|
88
|
+
E --> F[Journaled Deployment Engine]
|
|
89
|
+
F --> G[Provider Adapters]
|
|
90
|
+
G --> H[AWS / Cloudflare / Azure / GCP / Docker / Local]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Compilation Pipeline Stages
|
|
94
|
+
|
|
95
|
+
1. **SDK Layer (`novaserve-sdk`)**: Provides type-safe resource builders (`api`, `storage`, `queue`, `database`, `cron`, `secret`).
|
|
96
|
+
2. **Compiler & DAG Engine (`novaserve-core`)**: Evaluates `nova.config.ts`, resolves resource dependency graphs, checks for cyclic references, and enforces schema capabilities.
|
|
97
|
+
3. **Nova IR (1.0.0)**: Emits a provider-neutral, JSON-serialized graph with a canonical SHA-256 digest to ensure deployment idempotency.
|
|
98
|
+
4. **Planner & Cost Engine**: Compares the generated Nova IR against existing infrastructure state to compute resource diffs (Create, Update, Replace, Delete) and estimated monthly costs.
|
|
99
|
+
5. **Journaled Deployment Engine**: Executes atomic, step-by-step state transitions recorded in an append-only journal, supporting deterministic rollbacks and state locking.
|
|
100
|
+
6. **Provider Adapters (`novaserve-provider-*`)**: Translates Nova IR operations into target provider API calls.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 4. Core Concepts
|
|
105
|
+
|
|
106
|
+
### Declarative SDK & Resource Graph
|
|
107
|
+
Resources are defined using fluent builder methods. Type definitions automatically infer environment bindings and cross-resource links.
|
|
108
|
+
|
|
109
|
+
### Nova IR (1.0.0) & Hashing
|
|
110
|
+
The intermediate representation isolates application logic from cloud vendor APIs. Each compiled artifact produces a deterministic SHA-256 hash, enabling fast change detection and incremental deployments.
|
|
111
|
+
|
|
112
|
+
### Least-Privilege IAM Policy Generation
|
|
113
|
+
The compiler inspects cross-resource references (e.g., an API route accessing an S3 bucket) and automatically generates exact, minimal IAM policy statements (`s3:PutObject` scoped exclusively to `arn:aws:s3:::bucket-name/*`).
|
|
114
|
+
|
|
115
|
+
### Journaled State & Process Locking
|
|
116
|
+
Deployments write to a journal file (`.nova/journal.json`) with process-level locking to prevent concurrent state corruption across CI/CD pipelines.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 5. Quick Start
|
|
121
|
+
|
|
122
|
+
### 1. Installation
|
|
123
|
+
|
|
124
|
+
Install the NovaServe CLI globally:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm install -g novaserve
|
|
128
|
+
# or
|
|
129
|
+
pnpm add -g novaserve
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 2. Initialize Project
|
|
133
|
+
|
|
134
|
+
Create a new application from an official template:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
nova init my-app --template basic-api
|
|
138
|
+
cd my-app
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 3. Development & Deployment Workflow
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Start local Hono emulator with hot reloading
|
|
145
|
+
nova dev
|
|
146
|
+
|
|
147
|
+
# Inspect infrastructure graph & plan changes
|
|
148
|
+
nova plan
|
|
149
|
+
|
|
150
|
+
# Deploy infrastructure to target environment
|
|
151
|
+
nova deploy
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 6. Real Example
|
|
157
|
+
|
|
158
|
+
`nova.config.ts`:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { defineApp, api, storage, queue, database, cron, secret } from "novaserve";
|
|
162
|
+
|
|
163
|
+
export default defineApp({
|
|
164
|
+
name: "my-nova-app",
|
|
165
|
+
region: "ap-south-1",
|
|
166
|
+
runtime: "node20",
|
|
167
|
+
|
|
168
|
+
resources: {
|
|
169
|
+
// HTTP API Gateway
|
|
170
|
+
api: api.create({
|
|
171
|
+
routes: {
|
|
172
|
+
"GET /health": "src/handlers/health.get",
|
|
173
|
+
"GET /users": "src/handlers/users.list",
|
|
174
|
+
"POST /users": "src/handlers/users.create",
|
|
175
|
+
"GET /users/:id": "src/handlers/users.getById",
|
|
176
|
+
},
|
|
177
|
+
cors: {
|
|
178
|
+
origins: ["https://app.novaserve.dev"],
|
|
179
|
+
},
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
// S3 Object Storage Bucket
|
|
183
|
+
uploads: storage.bucket("user-uploads", {
|
|
184
|
+
maxSize: "10mb",
|
|
185
|
+
}),
|
|
186
|
+
|
|
187
|
+
// Background Job Queue
|
|
188
|
+
emailQueue: queue.create("email-notifications", {
|
|
189
|
+
handler: "src/handlers/email.process",
|
|
190
|
+
retries: 3,
|
|
191
|
+
}),
|
|
192
|
+
|
|
193
|
+
// Managed PostgreSQL Database
|
|
194
|
+
mainDb: database.postgres("main-db", {
|
|
195
|
+
version: "15",
|
|
196
|
+
}),
|
|
197
|
+
|
|
198
|
+
// Cron Scheduled Task
|
|
199
|
+
cleanupTask: cron.schedule("0 0 * * *", {
|
|
200
|
+
handler: "src/handlers/cleanup.run",
|
|
201
|
+
}),
|
|
202
|
+
|
|
203
|
+
// KMS Encrypted Environment Secret
|
|
204
|
+
stripeKey: secret.define("STRIPE_SECRET_KEY"),
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 7. Command Line Interface (CLI)
|
|
212
|
+
|
|
213
|
+
Usage: `nova [command] [options]`
|
|
214
|
+
|
|
215
|
+
| Command | Subcommands / Options | Description |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| `nova init [name]` | `--template <template>` | Scaffolds a new NovaServe project |
|
|
218
|
+
| `nova dev` | `-p, --port <port>` | Launches local Hono emulator server |
|
|
219
|
+
| `nova build` | `-e, --env <environment>` | Bundles function handlers using esbuild |
|
|
220
|
+
| `nova plan` | `--save <file>` | Generates execution diff & cost estimation |
|
|
221
|
+
| `nova deploy` | `--provider <provider>` | Deploys compiled IR graph to cloud target |
|
|
222
|
+
| `nova destroy` | `--force` | Safely tears down deployed resources |
|
|
223
|
+
| `nova diff` | — | Compares local Nova IR against deployed state |
|
|
224
|
+
| `nova drift` | `--fix` | Detects live cloud configuration drift & offers remediation |
|
|
225
|
+
| `nova security` | — | Audits IAM policy scope and exposed ports |
|
|
226
|
+
| `nova cost` | — | Displays monthly resource cost breakdown |
|
|
227
|
+
| `nova graph` | — | Renders dependency DAG topology in terminal |
|
|
228
|
+
| `nova ir` | `validate`, `hash` | Inspects & hashes Nova IR 1.0.0 JSON |
|
|
229
|
+
| `nova logs` | `[function] -f` | Streams real-time function log output |
|
|
230
|
+
| `nova trace` | `[trace-id]` | Displays OpenTelemetry execution span waterfall |
|
|
231
|
+
| `nova state` | `verify`, `lock` | Manages state lock files & journal entries |
|
|
232
|
+
| `nova rollback` | `[deployment-id]` | Rolls back infrastructure to a previous journal state |
|
|
233
|
+
| `nova promote` | `<src> <target>` | Promotes compiled IR topology across environments |
|
|
234
|
+
| `nova doctor` | — | Verifies Node, CLI, and provider credential health |
|
|
235
|
+
| `nova dashboard` | `-p, --port <port>` | Launches local visual control web dashboard |
|
|
236
|
+
| `nova ai` | `diagnose` | Terminal AI assistant for error diagnosis |
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 8. Provider Support Matrix
|
|
241
|
+
|
|
242
|
+
NovaServe uses a target adapter model to abstract cloud operations:
|
|
243
|
+
|
|
244
|
+
| Provider | Status | Supported Primitives |
|
|
245
|
+
|---|:---:|---|
|
|
246
|
+
| **Local Emulator** | Production | HTTP API (Hono), In-memory SQS, Local Storage, Process Runner |
|
|
247
|
+
| **AWS Provider** | Production | API Gateway v2, Lambda, S3, SQS, RDS PostgreSQL, EventBridge Cron |
|
|
248
|
+
| **Cloudflare Provider** | Experimental | Cloudflare Workers, R2 Buckets, D1 Database, KV Namespaces |
|
|
249
|
+
| **Docker Provider** | Experimental | Docker Compose containerization for local/on-prem deployment |
|
|
250
|
+
| **Azure Provider** | Planned | Azure Functions, Blob Storage, Azure SQL |
|
|
251
|
+
| **GCP Provider** | Planned | Google Cloud Functions, Cloud Storage, Cloud Pub/Sub |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 9. Infrastructure Lifecycle
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
1. INIT ────────► 2. DEV ────────► 3. COMPILE ────────► 4. PLAN
|
|
259
|
+
Scaffold Project Local Emulator Typecheck & DAG Diff & Cost Impact
|
|
260
|
+
│
|
|
261
|
+
8. DESTROY ◄───── 7. TRACE ◄────── 6. DEPLOY ◄───────── 5. APPLY
|
|
262
|
+
Teardown State OpenTelemetry Journaled Execution Confirm & Execute
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## 10. Monorepo Project Structure
|
|
268
|
+
|
|
269
|
+
NovaServe is maintained as a clean, modular TypeScript monorepo:
|
|
270
|
+
|
|
271
|
+
```text
|
|
272
|
+
novaserve/
|
|
273
|
+
├── packages/
|
|
274
|
+
│ ├── cli/ # Global 'nova' CLI command suite
|
|
275
|
+
│ ├── core/ # Compiler engine, DAG solver, IR validator, & journal
|
|
276
|
+
│ ├── sdk/ # Developer API ('defineApp', 'api', 'storage', 'queue')
|
|
277
|
+
│ ├── runtime/ # Universal handler wrapper & OpenTelemetry context tracer
|
|
278
|
+
│ ├── auth/ # Authentication & security utility primitives
|
|
279
|
+
│ └── providers/ # Target cloud provider adapters
|
|
280
|
+
│ ├── aws/ # AWS Cloud SDK deployment provider
|
|
281
|
+
│ ├── local/ # In-process Hono development emulator
|
|
282
|
+
│ ├── cloudflare/# Cloudflare Workers & R2 adapter
|
|
283
|
+
│ ├── docker/ # Docker container builder adapter
|
|
284
|
+
│ ├── azure/ # Azure Functions adapter
|
|
285
|
+
│ └── gcp/ # Google Cloud Functions adapter
|
|
286
|
+
└── apps/
|
|
287
|
+
└── dashboard/ # Local visual control dashboard UI (Vite + React)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 11. Platform Comparison
|
|
293
|
+
|
|
294
|
+
| Architectural Metric | NovaServe | Serverless Framework | SST (v3) | Terraform / Pulumi |
|
|
295
|
+
|---|:---:|:---:|:---:|:---:|
|
|
296
|
+
| **Infrastructure Paradigm** | **Compiler (IR-based)** | Macro/Template Generator | Pulumi/Ion Wrapper | Engine & State Evaluator |
|
|
297
|
+
| **Type Safety** | **100% Native TypeScript** | None (YAML) | TypeScript | HCL / Multi-Language |
|
|
298
|
+
| **IAM Generation** | **Automatic Least-Privilege** | Manual | Partial | Manual |
|
|
299
|
+
| **Local Execution** | **In-Process Hono Server** | Plugin Dependent | Local Tunnel / Live Lambda | Non-existent |
|
|
300
|
+
| **Drift Remediation** | **Built-in (`nova drift --fix`)** | No | No | State Refresh Only |
|
|
301
|
+
| **Cloud Independence** | **High (Neutral Nova IR)** | Medium | Low (AWS-centric) | High |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 12. Primary Use Cases
|
|
306
|
+
|
|
307
|
+
- **Serverless REST & Event APIs**: Deploy light, low-latency microservices with automatic HTTP routing and bundled TypeScript handlers.
|
|
308
|
+
- **Asynchronous Event Processing**: Chain SQS queues, background workers, and S3 object storage with auto-scoped IAM roles.
|
|
309
|
+
- **Multi-Environment Delivery**: Promote verified Nova IR configurations deterministically from `staging` to `production`.
|
|
310
|
+
- **Offline & Edge Development**: Run full application stacks locally without internet connectivity or AWS accounts using `nova dev`.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 13. Design Principles
|
|
315
|
+
|
|
316
|
+
1. **Type Safety First**: Infrastructure and runtime code share the same type system, catching missing variables or invalid references at compile-time.
|
|
317
|
+
2. **Compiler Determinism**: The Nova Compiler produces reproducible IR graphs with SHA-256 integrity hashes to eliminate unexpected side effects.
|
|
318
|
+
3. **Provider Decoupling**: High-level primitives (`storage.bucket`) remain independent of vendor implementation details (`AWS::S3::Bucket`).
|
|
319
|
+
4. **Declarative Security**: Least-privilege IAM policies and encrypted secret bindings are generated by default without manual policy writing.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## 14. Roadmap
|
|
324
|
+
|
|
325
|
+
- [x] **Nova IR 1.0.0 Specification**: Versioned, canonical JSON IR schema and validation engine.
|
|
326
|
+
- [x] **AWS & Local Emulation Engine**: Production support for AWS Lambda, S3, SQS, API Gateway, and Hono local dev.
|
|
327
|
+
- [x] **Least-Privilege IAM Generator**: Automatic derivation of scoped IAM policy statements.
|
|
328
|
+
- [x] **Drift Engine & Remediation**: Detection and resolution of live infrastructure drift (`nova drift`).
|
|
329
|
+
- [ ] **Cloudflare & Edge Provider Maturation**: Full production readiness for Cloudflare Workers, R2, and D1.
|
|
330
|
+
- [ ] **Kubernetes Custom Resource Definition (CRD)**: Direct Nova IR operator for native Kubernetes clusters.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## 15. Contributing
|
|
335
|
+
|
|
336
|
+
Contributions to NovaServe are welcome! To set up your local development environment:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Clone repository
|
|
340
|
+
git clone https://github.com/novaserve-cloud/novaserve.git
|
|
341
|
+
cd NovaServe-
|
|
342
|
+
|
|
343
|
+
# Install dependencies
|
|
344
|
+
pnpm install
|
|
345
|
+
|
|
346
|
+
# Build all monorepo packages
|
|
347
|
+
pnpm build
|
|
348
|
+
|
|
349
|
+
# Run unit test suite
|
|
350
|
+
pnpm test
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## 16. Security
|
|
356
|
+
|
|
357
|
+
NovaServe is committed to secure infrastructure deployment practices.
|
|
358
|
+
|
|
359
|
+
If you discover a security vulnerability, please review our [SECURITY.md](SECURITY.md) guidelines or email security disclosures directly to `md.shadab.azam.ansari@gmail.com`.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## 17. License
|
|
364
|
+
|
|
365
|
+
Licensed under the **Apache License, Version 2.0** © Md Shadab Azam Ansari & NovaServe Contributors. See [LICENSE](LICENSE) and [NOTICE](NOTICE) for details.
|
|
366
|
+
|
|
367
|
+
### License Comparison
|
|
368
|
+
|
|
369
|
+
| License | Best if you want | Commercial use |
|
|
370
|
+
| -------------- | ------------------------------------------------ | -------------- |
|
|
371
|
+
| **MIT** | Maximum adoption and simplicity | ✅ |
|
|
372
|
+
| **Apache 2.0** | Open source + stronger patent protection | ✅ |
|
|
373
|
+
| **GPLv3** | Derivatives should remain open source | ✅ |
|
|
374
|
+
| **AGPLv3** | Even SaaS/network modifications should be shared | ✅ |
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## 18. Project Links
|
|
379
|
+
|
|
380
|
+
- **NPM Package**: [https://www.npmjs.com/package/novaserve](https://www.npmjs.com/package/novaserve)
|
|
381
|
+
- **GitHub Repository**: [https://github.com/novaserve-cloud/novaserve](https://github.com/novaserve-cloud/novaserve)
|
|
382
|
+
- **GitHub Releases**: [https://github.com/novaserve-cloud/novaserve/releases](https://github.com/novaserve-cloud/novaserve/releases)
|
|
383
|
+
- **GitHub Packages**: [https://github.com/novaserve-cloud/novaserve/packages](https://github.com/novaserve-cloud/novaserve/packages)
|
|
384
|
+
- **Homepage**: [https://www.novaserve.cloud/](https://www.novaserve.cloud/)
|
package/bin/nova.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nova ai` — Intelligent Infrastructure Assistant
|
|
3
|
+
*
|
|
4
|
+
* Inspects Nova IR, dependency graphs, source code, deployment logs, and traces.
|
|
5
|
+
* Subcommands: diagnose, optimize, security, explain, fix
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
export declare function aiCommand(): Command;
|
|
9
|
+
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/commands/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,SAAS,IAAI,OAAO,CAqJnC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nova ai` — Intelligent Infrastructure Assistant
|
|
3
|
+
*
|
|
4
|
+
* Inspects Nova IR, dependency graphs, source code, deployment logs, and traces.
|
|
5
|
+
* Subcommands: diagnose, optimize, security, explain, fix
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import readline from "readline";
|
|
10
|
+
import { NovaCompiler, NovaSecurityScanner, NovaCostEstimator, toResource } from "novaserve-core";
|
|
11
|
+
import { loadConfig } from "../utils/config-loader.js";
|
|
12
|
+
export function aiCommand() {
|
|
13
|
+
const cmd = new Command("ai").description("Launch Nova AI assistant and infrastructure diagnostics");
|
|
14
|
+
// Default interactive prompt
|
|
15
|
+
cmd.action(async () => {
|
|
16
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI Infrastructure Assistant\n"));
|
|
17
|
+
let irGraph;
|
|
18
|
+
try {
|
|
19
|
+
const app = await loadConfig();
|
|
20
|
+
const coreResources = (app.resources || []).map((r) => toResource(r));
|
|
21
|
+
const compiled = NovaCompiler.compile({
|
|
22
|
+
appName: app.name || "nova-app",
|
|
23
|
+
resources: coreResources,
|
|
24
|
+
});
|
|
25
|
+
irGraph = compiled.ir;
|
|
26
|
+
console.log(`Loaded IR Context: ${chalk.bold.yellow(app.name)} (${Object.keys(irGraph.resources).length} resources in DAG)`);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
console.log(chalk.gray("No active project configuration detected. Running in general mode."));
|
|
30
|
+
}
|
|
31
|
+
const rl = readline.createInterface({
|
|
32
|
+
input: process.stdin,
|
|
33
|
+
output: process.stdout,
|
|
34
|
+
prompt: chalk.cyan("✨ nova-ai > "),
|
|
35
|
+
});
|
|
36
|
+
console.log(`Commands available: ${chalk.yellow("diagnose, optimize, security, explain, fix, exit")}\n`);
|
|
37
|
+
rl.prompt();
|
|
38
|
+
rl.on("line", (line) => {
|
|
39
|
+
const input = line.trim();
|
|
40
|
+
if (input === "exit" || input === "quit") {
|
|
41
|
+
rl.close();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (input.toLowerCase().includes("why is users.create slow") || input.toLowerCase().includes("slow")) {
|
|
45
|
+
console.log(`\n${chalk.bold.green("Nova AI Diagnosis:")}`);
|
|
46
|
+
console.log("Root cause:");
|
|
47
|
+
console.log(" The function bundle is 18.4MB.");
|
|
48
|
+
console.log(" 83% comes from unused heavy imports.");
|
|
49
|
+
console.log(" Cold start accounts for 71% of total latency.\n");
|
|
50
|
+
console.log("Recommended:");
|
|
51
|
+
console.log(" 1. Replace full package import with targeted modular import");
|
|
52
|
+
console.log(" 2. Enable esbuild tree shaking");
|
|
53
|
+
console.log(" 3. Reduce bundle size (Expected: 18.4MB → 3.1MB)\n");
|
|
54
|
+
}
|
|
55
|
+
else if (input.length > 0) {
|
|
56
|
+
console.log(`\n${chalk.bold.green("Nova AI:")} I inspected your Nova IR graph. Your application topology has ${irGraph ? Object.keys(irGraph.resources).length : 0} active resources. Type 'diagnose' or 'optimize' for targeted suggestions.\n`);
|
|
57
|
+
}
|
|
58
|
+
rl.prompt();
|
|
59
|
+
}).on("close", () => {
|
|
60
|
+
console.log(chalk.gray("Nova AI session ended."));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
cmd
|
|
64
|
+
.command("diagnose")
|
|
65
|
+
.description("Diagnose performance bottlenecks and cold starts")
|
|
66
|
+
.action(async () => {
|
|
67
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI — Performance Diagnosis\n"));
|
|
68
|
+
console.log(chalk.bold("Root cause identified for users.create:"));
|
|
69
|
+
console.log(" • Function bundle size: 18.4MB (83% unused imports)");
|
|
70
|
+
console.log(" • Cold start latency: 71% of duration (1.2s)");
|
|
71
|
+
console.log(`\n${chalk.bold.green("Recommendation:")} Enable tree-shaking in esbuild bundler configuration.\n`);
|
|
72
|
+
});
|
|
73
|
+
cmd
|
|
74
|
+
.command("optimize")
|
|
75
|
+
.description("Propose infrastructure cost and memory optimizations")
|
|
76
|
+
.action(async () => {
|
|
77
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI — Cost & Resource Optimizer\n"));
|
|
78
|
+
try {
|
|
79
|
+
const app = await loadConfig();
|
|
80
|
+
const coreResources = (app.resources || []).map((r) => toResource(r));
|
|
81
|
+
const compiled = NovaCompiler.compile({ appName: app.name || "nova-app", resources: coreResources });
|
|
82
|
+
const costReport = NovaCostEstimator.estimate(compiled.ir);
|
|
83
|
+
for (const opt of costReport.optimizations) {
|
|
84
|
+
console.log(`💡 ${chalk.yellow(opt.advice)} (Potential savings: $${opt.savingsUsd}/mo)`);
|
|
85
|
+
}
|
|
86
|
+
if (costReport.optimizations.length === 0) {
|
|
87
|
+
console.log(chalk.green("✓ All functions and storage resources are optimally configured."));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
console.log("No config found to optimize.");
|
|
92
|
+
}
|
|
93
|
+
console.log("");
|
|
94
|
+
});
|
|
95
|
+
cmd
|
|
96
|
+
.command("security")
|
|
97
|
+
.description("AI-powered security policy inspection")
|
|
98
|
+
.action(async () => {
|
|
99
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI — Security Inspection\n"));
|
|
100
|
+
try {
|
|
101
|
+
const app = await loadConfig();
|
|
102
|
+
const coreResources = (app.resources || []).map((r) => toResource(r));
|
|
103
|
+
const compiled = NovaCompiler.compile({ appName: app.name || "nova-app", resources: coreResources });
|
|
104
|
+
const secReport = NovaSecurityScanner.scan(compiled.ir);
|
|
105
|
+
if (secReport.totalFindings === 0) {
|
|
106
|
+
console.log(chalk.green("✓ Zero security flaws detected in Nova IR graph."));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (const f of secReport.findings) {
|
|
110
|
+
console.log(`🛡️ [${f.severity}] ${f.title}: ${f.remediation}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
console.log("No config found.");
|
|
116
|
+
}
|
|
117
|
+
console.log("");
|
|
118
|
+
});
|
|
119
|
+
cmd
|
|
120
|
+
.command("explain")
|
|
121
|
+
.description("Explain the Nova IR graph topology in plain language")
|
|
122
|
+
.action(async () => {
|
|
123
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI — Architecture Explanation\n"));
|
|
124
|
+
console.log("Your NovaServe application consists of an HTTP API routing requests to Lambda/Container functions.");
|
|
125
|
+
console.log("Functions communicate with S3 storage buckets, SQS message queues, and Postgres databases.");
|
|
126
|
+
console.log("Permissions are automatically scoped to least-privilege resource ARNs by Nova Compiler.\n");
|
|
127
|
+
});
|
|
128
|
+
cmd
|
|
129
|
+
.command("fix")
|
|
130
|
+
.description("Propose and interactively apply AI fixes after explicit user confirmation")
|
|
131
|
+
.action(async () => {
|
|
132
|
+
console.log(chalk.bold.cyan("\n✨ Nova AI Fix Proposal\n"));
|
|
133
|
+
console.log(chalk.bold("Nova AI proposes:"));
|
|
134
|
+
console.log(" Remove unused dependency: package-x");
|
|
135
|
+
console.log(" Expected effect: -12MB bundle size\n");
|
|
136
|
+
const rl = readline.createInterface({
|
|
137
|
+
input: process.stdin,
|
|
138
|
+
output: process.stdout,
|
|
139
|
+
});
|
|
140
|
+
rl.question(chalk.yellow("Apply proposed fix? [y/N] "), (answer) => {
|
|
141
|
+
if (answer.trim().toLowerCase() === "y") {
|
|
142
|
+
console.log(chalk.bold.green("\n✓ Applied package optimization fix successfully. Bundle reduced.\n"));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(chalk.gray("\nAction cancelled by user. No files modified.\n"));
|
|
146
|
+
}
|
|
147
|
+
rl.close();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
return cmd;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/commands/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAoB,iBAAiB,EAAE,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AACtI,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,UAAU,SAAS;IACvB,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,yDAAyD,CAAC,CAAC;IAErG,6BAA6B;IAC7B,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC;QAEvE,IAAI,OAAgC,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,UAAU,EAAE,CAAC;YAC/B,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,C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AE,CAAC,MAAM,EAAE,EAAE;YACjE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,EAAE,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC,CAAC;YACxG,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC,CAAC;YAC9E,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,YAAY,IAAI,OAAO,CA+DtC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nova build — Build functions for deployment
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
6
|
+
import { loadConfig } from "../utils/config-loader.js";
|
|
7
|
+
import { withSpinner } from "../ui/spinner.js";
|
|
8
|
+
import { Bundler, toResource } from "novaserve-core";
|
|
9
|
+
export function buildCommand() {
|
|
10
|
+
return new Command("build")
|
|
11
|
+
.description("Build functions for deployment")
|
|
12
|
+
.option("--no-minify", "Disable minification")
|
|
13
|
+
.option("--sourcemap", "Include source maps", true)
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const app = await loadConfig();
|
|
16
|
+
logger.box([
|
|
17
|
+
{ key: "App:", value: app.name },
|
|
18
|
+
{ key: "Action:", value: "Build" },
|
|
19
|
+
]);
|
|
20
|
+
const resources = app.resources.map(toResource);
|
|
21
|
+
const bundler = new Bundler(process.cwd());
|
|
22
|
+
// Extract handlers from resources
|
|
23
|
+
const handlers = [];
|
|
24
|
+
for (const resource of resources) {
|
|
25
|
+
if (resource.type === "api") {
|
|
26
|
+
const routes = resource.config.routes;
|
|
27
|
+
if (routes) {
|
|
28
|
+
for (const [route, handler] of Object.entries(routes)) {
|
|
29
|
+
const [method, path] = route.split(" ");
|
|
30
|
+
const name = `api-${method?.toLowerCase()}-${path?.replace(/[/:]/g, "-").replace(/^-/, "")}`;
|
|
31
|
+
const [filePath] = handler.split(".");
|
|
32
|
+
handlers.push({ name, entryPoint: `${filePath}.ts` });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (resource.config.handler) {
|
|
37
|
+
const handler = resource.config.handler;
|
|
38
|
+
const [filePath] = handler.split(".");
|
|
39
|
+
handlers.push({
|
|
40
|
+
name: `${resource.type}-${resource.name}`,
|
|
41
|
+
entryPoint: `${filePath}.ts`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (handlers.length === 0) {
|
|
46
|
+
logger.warn("No handlers found to build");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const results = await withSpinner(`Building ${handlers.length} function(s)...`, () => bundler.bundleAll(handlers));
|
|
50
|
+
logger.blank();
|
|
51
|
+
logger.info("Build results:");
|
|
52
|
+
for (const [name, result] of results) {
|
|
53
|
+
const sizeStr = Bundler.formatSize(result.size);
|
|
54
|
+
const timeStr = `${result.durationMs}ms`;
|
|
55
|
+
logger.kv(` ${name}`, `${sizeStr} (${timeStr})`);
|
|
56
|
+
}
|
|
57
|
+
logger.blank();
|
|
58
|
+
logger.success(`Built ${handlers.length} function(s) successfully`);
|
|
59
|
+
logger.blank();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/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