@geek-fun/serverlessinsight 0.7.6 → 0.7.7

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 CHANGED
@@ -1,54 +1,74 @@
1
- # ServerlessInsight
2
-
3
1
  <div align="center">
4
2
 
5
- [![Node.js CI](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml/badge.svg)](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml)
6
- [![release](https://github.com/geek-fun/serverlessinsight/actions/workflows/release.yml/badge.svg)](https://github.com/geek-fun/serverlessinsight/actions/workflows/release.yml)
7
- [![npm version](https://badge.fury.io/js/@geek-fun%2Fserverlessinsight.svg)](https://badge.fury.io/js/@geek-fun%2Fserverlessinsight)
8
- [![Known Vulnerabilities](https://snyk.io/test/github/geek-fun/serverlessinsight/badge.svg)](https://snyk.io/test/github/geek-fun/serverlessinsight)
9
- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
10
- [![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
11
-
12
- **Describe your app. We handle the rest.**
3
+ # ServerlessInsight
13
4
 
14
- *Full life cycle cross-provider serverless application management for your fast-growing business*
5
+ **Full life cycle cross-provider serverless management — describe your app, we handle the rest.**
15
6
 
16
- [Website](https://serverlessinsight.geekfun.club) • [Documentation](https://serverlessinsight.geekfun.club) • [Examples](./samples) • [中文文档](./README.zh-CN.md)
7
+ **Open source. Multi-cloud. Infrastructure as Code.**
17
8
 
18
- </div>
9
+ [![Release](https://img.shields.io/github/v/release/geek-fun/serverlessinsight?color=orange&label=release&style=for-the-badge&logo=github)](https://github.com/geek-fun/serverlessinsight/releases)
10
+ [![npm version](https://img.shields.io/npm/v/@geek-fun/serverlessinsight?color=orange&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@geek-fun/serverlessinsight)
11
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=for-the-badge&logo=apache)](LICENSE)
12
+ [![Stars](https://img.shields.io/github/stars/geek-fun/serverlessinsight?style=for-the-badge&logo=github)](https://github.com/geek-fun/serverlessinsight/stargazers)
13
+ [![CI](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml/badge.svg?style=for-the-badge)](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml)
19
14
 
20
- ---
15
+ <p>
16
+ <img src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white"/>
17
+ <img src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white"/>
18
+ <img src="https://img.shields.io/badge/Alibaba%20Cloud-FF6A00?style=for-the-badge&logo=alibabacloud&logoColor=white"/>
19
+ <img src="https://img.shields.io/badge/Tencent%20Cloud-0A9AED?style=for-the-badge&logo=tencentqq&logoColor=white"/>
20
+ <img src="https://img.shields.io/badge/Huawei%20Cloud-FF0000?style=for-the-badge&logo=hauwei&logoColor=white"/>
21
+ <img src="https://img.shields.io/badge/AWS-232F3E?style=for-the-badge&logo=amazonwebservices&logoColor=white"/>
22
+ </p>
21
23
 
22
- ServerlessInsight is a powerful serverless framework for managing serverless applications across multiple cloud providers. It provides a unified interface to deploy, manage, and debug serverless functions and resources using Infrastructure as Code (IaC) principles.
24
+ [npm i -g @geek-fun/serverlessinsight](https://www.npmjs.com/package/@geek-fun/serverlessinsight) · [Docs](https://serverlessinsight.geekfun.club) · [Website](https://serverlessinsight.geekfun.club) · [GitHub](https://github.com/geek-fun/serverlessinsight)
23
25
 
24
- Whether you're building on AWS, Alibaba Cloud, Huawei Cloud, or other providers, ServerlessInsight simplifies your development workflow with:
26
+ English · [简体中文](README.zh-CN.md)
25
27
 
26
- - **Multi-cloud support** - Work with multiple cloud providers using a single tool
27
- - **Infrastructure as Code** - Define your serverless infrastructure in YAML
28
- - **Local development** - Test your functions locally before deploying
29
- - **Type-safe templates** - Validate your configurations before deployment
28
+ </div>
30
29
 
31
30
  ---
32
31
 
33
- ## ✨ Features
32
+ ServerlessInsight is a **cross-provider serverless framework** — it replaces cloud-specific CLI tools, web consoles, and DIY scripts with a single unified tool. Define your serverless infrastructure in YAML once, deploy to Alibaba Cloud, Tencent Cloud, Huawei Cloud, and more. Think of it as Terraform for serverless, purpose-built for functions, API gateways, storage, and databases.
33
+
34
+ <p align="center">
35
+ <img src="https://img.shields.io/badge/Alibaba%20Cloud-FF6A00?logo=alibabacloud&logoColor=white" />
36
+ <img src="https://img.shields.io/badge/Tencent%20Cloud-0A9AED?logo=tencentqq&logoColor=white" />
37
+ <img src="https://img.shields.io/badge/Huawei%20Cloud-FF0000?logo=huawei&logoColor=white" />
38
+ <img src="https://img.shields.io/badge/Volcengine-1677FF?logoColor=white" />
39
+ <img src="https://img.shields.io/badge/AWS-232F3E?logo=amazonwebservices&logoColor=white" />
40
+ <img src="https://img.shields.io/badge/Azure-0078D4?logo=microsoftazure&logoColor=white" />
41
+ <img src="https://img.shields.io/badge/GCP-4285F4?logo=googlecloud&logoColor=white" />
42
+ </p>
43
+
44
+ ## Installation
45
+
46
+ <a href="https://www.npmjs.com/package/@geek-fun/serverlessinsight">
47
+ <img src="https://img.shields.io/badge/npm_install-g_--g_@geek--fun/serverlessinsight-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="npm install">
48
+ </a>
49
+ &nbsp;
50
+ <a href="https://github.com/geek-fun/serverlessinsight/releases">
51
+ <img src="https://img.shields.io/badge/Releases-GitHub-lightgrey?style=for-the-badge&logo=github" alt="Releases">
52
+ </a>
53
+ &nbsp;
54
+ <a href="https://serverlessinsight.geekfun.club">
55
+ <img src="https://img.shields.io/badge/Docs-serverlessinsight.geekfun.club-blue?style=for-the-badge&logo=gitbook&logoColor=white" alt="Docs">
56
+ </a>
34
57
 
35
- - 🌍 **Multi-Cloud Provider Support** - Deploy to Alibaba Cloud, Huawei Cloud, and more
36
- - 📦 **Unified Configuration** - Single YAML format for all providers
37
- - 🚀 **Quick Deployment** - Deploy serverless applications with a single command
38
- - 🔍 **Template Validation** - Validate your IaC templates before deployment
39
- - 🏠 **Local Testing** - Run and debug serverless functions locally
40
- - 🔄 **Template Generation** - Generate provider-specific IaC templates
41
- - 🌐 **API Gateway Integration** - Configure HTTP endpoints for your functions
42
- - 🌐 **Custom Domain Binding** - Automatic domain binding with DNS verification for OSS and API Gateway
43
- - 💾 **Resource Management** - Manage storage, databases, and other cloud resources
44
- - 🔐 **Security First** - Built-in validation and security best practices
45
- - 📊 **Comprehensive Logging** - Debug and monitor your applications
58
+ ```bash
59
+ npm install -g @geek-fun/serverlessinsight
60
+ si --version
61
+ ```
46
62
 
47
- ---
63
+ ## Key Features
64
+
65
+ ### Multi-Cloud, One Config
48
66
 
49
- ## ☁️ Supported Providers
67
+ Define your infrastructure once in YAML and deploy across Alibaba Cloud, Tencent Cloud, Huawei Cloud, and Volcengine — with AWS, Azure, and GCP on the roadmap. No more juggling cloud-specific CLIs or Terraform modules for every provider.
50
68
 
51
- ServerlessInsight supports the following cloud providers:
69
+ - **Unified configuration** — single `serverless.yml` format for all providers
70
+ - **Provider-specific template generation** — generate native IaC templates from your config
71
+ - **Cross-provider awareness** — the same abstractions work across different clouds
52
72
 
53
73
  | Provider | Functions | API Gateway | Storage | Databases | Status |
54
74
  | ----------------- | ---------------- | -------------- | -------------- | ---------------- | ------- |
@@ -60,147 +80,61 @@ ServerlessInsight supports the following cloud providers:
60
80
  | **Azure** | 🔜 Planned | 🔜 Planned | 🔜 Planned | 🔜 Planned | Planned |
61
81
  | **Google Cloud** | 🔜 Planned | 🔜 Planned | 🔜 Planned | 🔜 Planned | Planned |
62
82
 
63
- ---
64
-
65
- ## 🚀 Getting Started
66
-
67
- ### Prerequisites
68
-
69
- - **Node.js** 16.x or higher
70
- - Cloud provider credentials (Alibaba Cloud AccessKey, Huawei Cloud credentials, etc.)
71
-
72
- ### Installation
73
-
74
- Install ServerlessInsight globally using npm:
75
-
76
- ```bash
77
- npm install -g @geek-fun/serverlessinsight
78
- ```
83
+ ### Infrastructure as Code
79
84
 
80
- Verify the installation:
85
+ Declarative YAML configuration with validation, planning, and state management — following proven IaC patterns.
81
86
 
82
- ```bash
83
- si --version
84
- ```
87
+ - **Plan before deploy** — `si plan` shows exactly what will change before anything happens
88
+ - **State tracking** — incremental deployments with drift detection via local state files
89
+ - **Validation** — type-safe template validation catches config errors before they reach the cloud
90
+ - **Partial failure recovery** — successfully deployed resources are saved even when others fail; retry to continue
85
91
 
86
- ---
87
-
88
- ## 📚 Usage
92
+ ### Quick Deployment
89
93
 
90
94
  ```bash
91
- # Validate your serverless configuration
95
+ # Validate your config
92
96
  si validate -f serverless.yml
93
97
 
94
- # Generate deployment plan (see what will change)
98
+ # Preview changes
95
99
  si plan -f serverless.yml
96
100
 
97
- # Deploy your serverless application
98
- si deploy -f serverless.yml -s dev
99
-
100
- # Run your application locally for debugging
101
- si local -f serverless.yml -s local
101
+ # Deploy to production
102
+ si deploy -f serverless.yml -s prod
102
103
 
103
- # Show deployed resource information
104
- si show -f serverless.yml
105
-
106
- # Destroy the deployed stack
104
+ # Destroy when done
107
105
  si destroy -f serverless.yml
108
106
  ```
109
107
 
110
- ---
111
-
112
- ## 💡 Examples
113
-
114
- ServerlessInsight uses a simple YAML format to define your serverless infrastructure:
115
-
116
- ```yaml
117
- version: 0.0.1
118
- provider:
119
- name: aliyun
120
- region: cn-hongkong
121
-
122
- service: my-api-service
123
-
124
- functions:
125
- hello_function:
126
- name: hello-world-fn
127
- code:
128
- runtime: nodejs18
129
- handler: index.handler
130
- path: ./src
131
- memory: 512
132
- timeout: 10
133
- environment:
134
- NODE_ENV: production
135
-
136
- events:
137
- api_gateway:
138
- type: API_GATEWAY
139
- name: my-api-gateway
140
- triggers:
141
- - method: GET
142
- path: /api/hello
143
- backend: ${functions.hello_function}
144
- ```
145
-
146
- For more examples, check out the [samples](./samples) directory:
108
+ ### Local Development
147
109
 
148
- - [API Gateway Example](./samples/aliyun-poc-api.yml) - Deploy functions with HTTP endpoints
149
- - [Storage Example](./samples/aliyun-poc-bucket.yml) - Configure OSS buckets
150
- - [Custom Domain Example](./samples/aliyun-poc-domain.yml) - Configure OSS static website with custom domain binding
151
- - [Database Example](./samples/aliyun-poc-rds.yml) - Set up RDS databases
152
- - [Table Store Example](./samples/aliyun-poc-table.yml) - Configure OTS table storage
153
- - [Elasticsearch Example](./samples/aliyun-poc-es.yml) - Deploy Elasticsearch Serverless
154
- - [GPU Functions Example](./samples/aliyun-poc-fc-gpu.yml) - Deploy GPU-enabled functions
155
- - [Huawei Cloud Example](./samples/huawei-poc-fc.yml) - Deploy to Huawei Cloud FunctionGraph
110
+ Run and debug your serverless functions locally without deploying to the cloud.
156
111
 
157
- ---
112
+ - **LocalStack server** — test functions, buckets, and API endpoints locally
113
+ - **Bucket file serving** — access local storage files via HTTP for rapid iteration
114
+ - **Same config, different target** — `si local -f serverless.yml -s local` uses your existing config
158
115
 
159
- ## 🔧 Local Development
116
+ ### API Gateway & Custom Domain
160
117
 
161
- ```bash
162
- # Clone and setup
163
- git clone https://github.com/geek-fun/serverlessinsight.git
164
- cd serverlessinsight
165
- npm install
118
+ Configure HTTP endpoints and bind custom domains with automatic DNS verification.
166
119
 
167
- # Build and link for development
168
- npm run build
169
- npm link
170
-
171
- # Run local development server
172
- si local -f serverless.yml -s local
120
+ - **API Gateway integration** — define triggers with HTTP methods and paths
121
+ - **Custom domain binding** — automatic CNAME + DNS TXT ownership verification for OSS and API Gateway
122
+ - **CDN acceleration** — edge caching and global content delivery for static sites
123
+ - **OSS Transfer Acceleration** — cross-region data transfers through Alibaba backbone
173
124
 
174
- # Run tests
175
- npm test
125
+ ### Resource Management
176
126
 
177
- # Lint code
178
- npm run lint:check
179
- ```
127
+ Beyond functions — manage the full serverless stack including storage, databases, and more.
180
128
 
181
- ### Local Testing with Buckets
182
-
183
- When running the local development server, you can test bucket operations by accessing files through the LocalStack server:
184
-
185
- ```bash
186
- # List all files in a bucket
187
- curl http://localhost:4567/si_buckets/<bucket_key>/
188
-
189
- # Access a specific file from a bucket
190
- curl http://localhost:4567/si_buckets/<bucket_key>/path/to/file.html
191
-
192
- # List files in a subdirectory
193
- curl http://localhost:4567/si_buckets/<bucket_key>/subdir/
194
- ```
195
-
196
- The bucket handler serves files from the directory specified in your bucket's `website.code` configuration.
129
+ - **Object storage** — OSS (Alibaba), COS (Tencent), TOS (Volcengine)
130
+ - **Databases** — RDS, OTS, ESS, TDSQL-C with more on the way
131
+ - **Elasticsearch Serverless** — deploy and manage ES clusters
132
+ - **GPU functions** — deploy GPU-enabled serverless functions
197
133
 
198
134
  ### Architecture
199
135
 
200
136
  ServerlessInsight follows a **functional client architecture** that cleanly separates cloud provider SDKs from business logic:
201
137
 
202
- #### Layered Design
203
-
204
138
  ```
205
139
  ┌─────────────────────────────────────────┐
206
140
  │ Resource / Planner / Executor Layer │ ← Provider-agnostic business logic
@@ -217,289 +151,101 @@ ServerlessInsight follows a **functional client architecture** that cleanly sepa
217
151
  └─────────────────────────────────────────┘
218
152
  ```
219
153
 
220
- #### Key Principles
221
-
222
- - **Functional & Pure**: All business logic uses pure functions with immutable data
223
- - **SDK Encapsulation**: Provider SDKs are accessed ONLY through client modules
224
- - **Operation Functions**: Clients expose high-level operation functions (e.g., `createFunction`, `getFunction`)
225
- - **No Classes**: Prefer `type` over `interface`, and functional patterns over classes
226
- - **Minimal Side Effects**: File I/O and other side effects are isolated at boundaries
227
-
228
- #### Client Pattern Example
229
-
230
- ```typescript
231
- // ✅ Client exposes operation functions, not raw SDKs
232
- export type AliyunClient = {
233
- fc3: {
234
- createFunction: (config: Fc3FunctionConfig, codeBase64: string) => Promise<void>;
235
- getFunction: (functionName: string) => Promise<Fc3FunctionInfo | null>;
236
- // ... other operations
237
- };
238
- // ... other services
239
- };
240
-
241
- // ✅ Resource layer uses clean client API
242
- const client = createAliyunClient(context);
243
- const codeBase64 = readFileAsBase64(codePath);
244
- await client.fc3.createFunction(config, codeBase64);
245
- ```
246
-
247
- This architecture enables:
248
-
249
- - **Better Testing**: Mock client operations instead of SDKs
250
- - **Maintainability**: Provider changes isolated to client layer
251
- - **Type Safety**: Strong typing throughout the stack
252
- - **Code Reuse**: Shared client operations across resources
253
-
254
- ---
255
-
256
- ## 🌐 Custom Domain Binding
257
-
258
- ServerlessInsight provides automatic custom domain binding for OSS buckets and API Gateway with built-in DNS verification.
154
+ - **Functional & pure** — business logic uses pure functions with immutable data
155
+ - **SDK encapsulation** — provider SDKs accessed ONLY through client modules
156
+ - **No classes** — prefer `type` over `interface`, functional patterns over classes
259
157
 
260
- ### OSS Custom Domain Binding
158
+ ## Development
261
159
 
262
- When you configure a custom domain for an OSS bucket (static website hosting), ServerlessInsight automatically:
160
+ ServerlessInsight is built with [Node.js](https://nodejs.org/) + [TypeScript](https://www.typescriptlang.org/), [Commander.js](https://github.com/tj/commander.js/) CLI, and pure functional architecture.
263
161
 
264
- 1. **Binds the domain** to your OSS bucket
265
- 2. **Creates DNS CNAME records** pointing to the correct OSS endpoint
266
- 3. **Handles domain ownership verification** via DNS TXT records when required by the cloud provider
267
- 4. **Manages retry logic** with DNS propagation polling for reliable binding
268
-
269
- ```yaml
270
- buckets:
271
- my_website:
272
- name: my-website-bucket
273
- security:
274
- acl: PUBLIC_READ
275
- website:
276
- code: ./dist
277
- domain: www.example.com # Custom domain binding
278
- index: index.html
279
- error_page: 404.html
280
- ```
162
+ ### Prerequisites
281
163
 
282
- ### Domain Ownership Verification Flow
164
+ - **Node.js** >= 16
283
165
 
284
- When binding a custom domain that requires ownership verification:
166
+ ### Quick Start
285
167
 
168
+ ```bash
169
+ git clone https://github.com/geek-fun/serverlessinsight.git
170
+ cd serverlessinsight
171
+ npm install
172
+ npm run build
173
+ npm link
286
174
  ```
287
- ┌─────────────────────────────────────────────────────────────────┐
288
- │ OSS Custom Domain Binding │
289
- └─────────────────────────────────────────────────────────────────┘
290
- │
291
- ▼
292
- ┌───────────────────────┐
293
- │ PutCname (Attempt) │
294
- └───────────────────────┘
295
- │
296
- ┌───────────────────┴───────────────────┐
297
- │ │
298
- ▼ ▼
299
- ┌───────────────┐ ┌─────────────────┐
300
- │ Success │ │ NeedVerifyDomain│
301
- └───────────────┘ │ Ownership │
302
- └─────────────────┘
303
- │
304
- ▼
305
- ┌─────────────────────────┐
306
- │ CreateCnameToken API │
307
- │ (Get TXT record value) │
308
- └─────────────────────────┘
309
- │
310
- ▼
311
- ┌─────────────────────────┐
312
- │ Check existing TXT │
313
- │ records (avoid dupes) │
314
- └─────────────────────────┘
315
- │
316
- ▼
317
- ┌─────────────────────────┐
318
- │ Add DNS TXT Record │
319
- │ (_dnsauth.domain) │
320
- └─────────────────────────┘
321
- │
322
- ▼
323
- ┌─────────────────────────┐
324
- │ Poll DNS Propagation │
325
- │ (up to 10 × 1 min) │
326
- └─────────────────────────┘
327
- │
328
- ▼
329
- ┌─────────────────────────┐
330
- │ Retry PutCname │
331
- │ (up to 5 × 30 sec) │
332
- └─────────────────────────┘
333
- ```
334
-
335
- ### Supported Domain Types
336
-
337
- For OSS static website hosting, ServerlessInsight supports:
338
-
339
- | Domain Type | CNAME Target | Use Case |
340
- | ----------------- | ----------------------------- | ---------------------------------------------- |
341
- | Root domain (`@`) | `bucket.region.taihangcda.cn` | Bypasses DNS CNAME restriction on root domains |
342
- | Subdomain (`www`) | `bucket.region.taihangcda.cn` | Standard CNAME for all subdomains |
343
- | Any subdomain | `bucket.region.taihangcda.cn` | Unified CNAME endpoint for all domain types |
344
-
345
- > 💡 **Note**: All domain types now use the recommended `taihangcda.cn` CNAME endpoint, which is derived automatically from your bucket's actual extranet endpoint via the `GetBucketInfo` API.
346
-
347
- For detailed configuration, see [OSS Custom Domain Binding Guide](./docs/oss-custom-domain-binding.md).
348
-
349
- ### CDN Acceleration & OSS Transfer Acceleration
350
-
351
- ServerlessInsight supports CDN acceleration and OSS Transfer Acceleration for buckets, enabling global content delivery and optimized origin fetch.
352
175
 
353
- **CDN** (`cdn`): Create a CDN distribution in front of your bucket for edge caching and global acceleration. Accepts `boolean` (simple on/off) or `object` for advanced configuration:
176
+ ### Scripts
354
177
 
355
- ```yaml
356
- buckets:
357
- # Simple: CDN with sensible defaults
358
- my_site:
359
- name: my-static-site
360
- website:
361
- code: ./dist
362
- index: index.html
363
- domain:
364
- domain_name: www.example.com
365
- certificate_id: cas-abc123
366
- cdn: true
367
-
368
- # Advanced: CDN with custom config
369
- releases:
370
- name: app-releases
371
- security:
372
- acl: PRIVATE
373
- domain:
374
- domain_name: releases.example.com
375
- cdn:
376
- enabled: true
377
- cdn_type: download # web | download | video
378
- scope: global # domestic | overseas | global
379
- ```
178
+ | Command | Description |
179
+ |---------|-------------|
180
+ | `npm run build` | TypeScript compilation |
181
+ | `npm test` | Run all tests with coverage |
182
+ | `npm run test:unit` | Unit tests only |
183
+ | `npm run test:service` | Service tests only |
184
+ | `npm run lint:check` | ESLint check |
185
+ | `npm run lint:fix` | Auto-fix lint issues |
380
186
 
381
- **Transfer Acceleration** (`accelerate`): Enables OSS Transfer Acceleration for cross-region/global data transfers. Routes traffic through Alibaba backbone network:
187
+ ### Sample Config
382
188
 
383
189
  ```yaml
384
- buckets:
385
- cross_region_backups:
386
- name: backup-bucket
387
- domain:
388
- domain_name: backups.internal.example.com
389
- accelerate: true # No CDN, just accelerate
390
-
391
- # CDN + Accelerate (dual-layer)
392
- global_assets:
393
- name: global-assets
394
- domain:
395
- domain_name: assets.example.com
396
- cdn:
397
- enabled: true
398
- cdn_type: web
399
- accelerate: true # CDN origin uses accelerated endpoint
400
- ```
401
-
402
- **Backward Compatibility**: Existing `website.domain` config continues to work. When a bucket uses `website.domain` without the top-level `domain` block, a deprecation notice is logged suggesting migration to the canonical form.
403
-
404
- ---
405
-
406
- ## 🗄️ State Management
407
-
408
- ServerlessInsight uses a state-based deployment model that tracks all deployed resources in a local state file (`.serverlessinsight/state-{app}-{service}.json` in the project directory). This enables:
409
-
410
- - **Incremental deployments** - Only changed resources are updated
411
- - **Drift detection** - Identifies differences between local state and cloud resources
412
- - **Safe destruction** - Knows which resources to clean up
413
-
414
- ### Partial Failure Recovery
415
-
416
- When deploying multiple resources, if one fails, ServerlessInsight ensures that:
190
+ version: 0.0.1
191
+ provider:
192
+ name: aliyun
193
+ region: cn-hongkong
417
194
 
418
- 1. **Successfully deployed resources are always saved to state** - Even if subsequent resources fail, your state file will contain all resources that were successfully created/updated/deleted
419
- 2. **Clear error reporting** - You'll see which resources succeeded and which failed
420
- 3. **Easy retry** - Simply run `deploy` again to continue from where you left off
195
+ service: my-api-service
421
196
 
422
- Example partial failure output:
197
+ functions:
198
+ hello_function:
199
+ name: hello-world-fn
200
+ code:
201
+ runtime: nodejs18
202
+ handler: index.handler
203
+ path: ./src
204
+ memory: 512
205
+ timeout: 10
423
206
 
207
+ events:
208
+ api_gateway:
209
+ type: API_GATEWAY
210
+ name: my-api-gateway
211
+ triggers:
212
+ - method: GET
213
+ path: /api/hello
214
+ backend: ${functions.hello_function}
424
215
  ```
425
- ⚠️ PARTIAL DEPLOYMENT FAILURE: 2 resource(s) succeeded, but functions.api_handler failed.
426
- State has been saved for successfully deployed resources. Run deploy again to retry failed resources.
427
- Next steps: 1) Review the error above, 2) Fix any configuration issues, 3) Run deploy again to continue.
428
- ```
429
-
430
- ### State File Location
431
-
432
- The state file is stored as `.serverlessinsight/state-{app}-{service}.json` in your project directory (e.g., `.serverlessinsight/state-myapp-myservice.json`). This file:
433
-
434
- - Should be committed to version control for team collaboration
435
- - Contains resource metadata and identifiers
436
- - Is automatically updated after each successful operation
437
-
438
- ### State Recovery
439
-
440
- If you encounter state drift (cloud resources exist that aren't in your state file):
441
-
442
- 1. **Manual import** - Currently, resources must be manually added to the state file
443
- 2. **Clean start** - Delete the state file and resources in the cloud, then redeploy
444
-
445
- > 💡 **Tip**: Always backup your state file before making manual modifications.
446
-
447
- ---
448
-
449
- ## 📘 Documentation
450
-
451
- For comprehensive documentation, visit [serverlessinsight.geekfun.club](https://serverlessinsight.geekfun.club)
452
216
 
453
- Additional resources:
217
+ More in the [samples](./samples) directory.
454
218
 
455
- - [Quick Start Guide](https://serverlessinsight.geekfun.club)
456
- - [Configuration Reference](https://serverlessinsight.geekfun.club)
457
- - [API Documentation](https://serverlessinsight.geekfun.club)
458
- - [Best Practices](https://serverlessinsight.geekfun.club)
219
+ ## Community
459
220
 
460
- ---
461
-
462
- ## 🤝 Contributing
221
+ <p align="center">
222
+ <a href="https://github.com/geek-fun/serverlessinsight/discussions"><img src="https://img.shields.io/badge/GitHub_Discussions-Join-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub Discussions" /></a>
223
+ &nbsp;&nbsp;&nbsp;
224
+ <a href="https://github.com/geek-fun/serverlessinsight/issues"><img src="https://img.shields.io/badge/GitHub_Issues-Report-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub Issues" /></a>
225
+ &nbsp;&nbsp;&nbsp;
226
+ <a href="https://github.com/geek-fun"><img src="https://img.shields.io/badge/GitHub-Follow-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub" /></a>
227
+ </p>
463
228
 
464
- We welcome contributions from the community! Here's how you can help:
229
+ ## Contributing
465
230
 
466
- 1. **Fork the repository**
467
- 2. **Create a feature branch** (`git checkout -b feature/amazing-feature`)
468
- 3. **Commit your changes** (`git commit -m 'Add amazing feature'`)
469
- 4. **Push to the branch** (`git push origin feature/amazing-feature`)
470
- 5. **Open a Pull Request**
231
+ Contributions welcome! Open an issue or pull request. See the [AGENTS.md](AGENTS.md) for coding conventions.
471
232
 
472
- ---
233
+ ## Sponsor
473
234
 
474
- ## 👥 Community
235
+ <p align="center">
236
+ <a href="https://github.com/sponsors/geek-fun"><img src="https://img.shields.io/badge/GitHub_Sponsors-%E2%9D%A4_Support-EA4AAA?style=for-the-badge&logo=githubsponsors&logoColor=white" alt="GitHub Sponsors" /></a>
237
+ </p>
475
238
 
476
- Join our community to get help, share ideas, and contribute:
239
+ ## Star History
477
240
 
478
- - **GitHub Issues** - [Report bugs or request features](https://github.com/geek-fun/serverlessinsight/issues)
479
- - **Website** - [serverlessinsight.geekfun.club](https://serverlessinsight.geekfun.club)
241
+ <a href="https://www.star-history.com/?repos=geek-fun/serverlessinsight&type=date">
242
+ <picture>
243
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date&theme=dark" />
244
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date" />
245
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date" />
246
+ </picture>
247
+ </a>
480
248
 
481
- ---
482
-
483
- ## 📄 License
484
-
485
- This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
486
-
487
- ---
249
+ ## License
488
250
 
489
- ## 🙏 Acknowledgments
490
-
491
- ServerlessInsight is built with these amazing technologies:
492
-
493
- - [Node.js](https://nodejs.org/) - JavaScript runtime
494
- - [TypeScript](https://www.typescriptlang.org/) - Type-safe JavaScript
495
- - [Commander.js](https://github.com/tj/commander.js/) - CLI framework
496
-
497
- ---
498
-
499
- <div align="center">
500
-
501
- **Made with ❤️ by the [geek-fun](https://github.com/geek-fun) team**
502
-
503
- [⬆ Back to Top](#serverlessinsight)
504
-
505
- </div>
251
+ [Apache 2.0](LICENSE) © GEEKFUN
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",
@@ -103,7 +103,12 @@ const transformFCResponse = (result) => {
103
103
  const statusCode = isNaN(parsedStatus) ? 200 : parsedStatus;
104
104
  let body = rawBody;
105
105
  if (isBase64Encoded && typeof body === 'string') {
106
- body = Buffer.from(body, 'base64').toString('utf-8');
106
+ const decoded = Buffer.from(body, 'base64');
107
+ const contentType = String(typeof headers === 'object' && headers ? headers['content-type'] || '' : '');
108
+ const isBinary = /^(image|audio|video)\//.test(contentType) ||
109
+ contentType === 'application/pdf' ||
110
+ contentType.includes('font/');
111
+ body = isBinary ? decoded : decoded.toString('utf-8');
107
112
  }
108
113
  // Only JSON-parse if the response Content-Type indicates JSON — otherwise pass through as-is.
109
114
  // Aliyun API Gateway PASSTHROUGH mode sends raw body; si-local mirrors this behavior.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",