@geek-fun/serverlessinsight 0.9.1 → 0.9.2
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/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -3
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +109 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +2 -2
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/CHANGELOG.md +17 -0
- package/README.md +76 -0
- package/README.zh-CN.md +67 -0
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/index.js +75 -23
- package/dist/src/commands/plan.js +21 -1
- package/dist/src/commands/schema.js +24 -0
- package/dist/src/commands/show.js +64 -10
- package/dist/src/commands/validate.js +34 -2
- package/dist/src/common/aliyunClient/fc3Operations.js +32 -1
- package/dist/src/common/constants.js +7 -1
- package/dist/src/common/jsonOutput.js +77 -0
- package/dist/src/common/logger.js +6 -3
- package/dist/src/common/noColor.js +9 -0
- package/dist/src/common/planFormatter.js +12 -6
- package/dist/src/common/siCron.js +415 -0
- package/dist/src/common/stateBackend/saasStateBackend.js +5 -4
- package/dist/src/common/tencentClient/scfOperations.js +2 -0
- package/dist/src/common/volcengineClient/vefaasOperations.js +45 -0
- package/dist/src/lang/en.js +43 -0
- package/dist/src/lang/index.js +36 -1
- package/dist/src/lang/zh-CN.js +43 -0
- package/dist/src/parser/functionParser.js +47 -1
- package/dist/src/stack/aliyunStack/fc3Planner.js +26 -0
- package/dist/src/stack/aliyunStack/fc3Resource.js +159 -2
- package/dist/src/stack/localStack/event.js +2 -13
- package/dist/src/stack/localStack/function.js +2 -13
- package/dist/src/stack/localStack/index.js +8 -1
- package/dist/src/stack/localStack/timer.js +162 -0
- package/dist/src/stack/localStack/utils.js +19 -1
- package/dist/src/stack/scfStack/scfPlanner.js +52 -18
- package/dist/src/stack/scfStack/scfResource.js +170 -1
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +49 -0
- package/dist/src/stack/volcengineStack/vefaasResource.js +215 -2
- package/dist/src/validator/functionSchema.js +25 -2
- package/dist/src/validator/iacSchema.js +2 -1
- package/dist/src/validator/index.js +4 -1
- package/dist/src/validator/rootSchema.js +49 -18
- package/dist/src/validator/schemaExport.js +60 -0
- package/dist/src/validator/semanticValidation.js +79 -0
- package/dist/src/validator/templateRefSchema.js +9 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/samples/aliyun-poc-timer.yml +39 -0
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"id": "iam-test-app-dev-sls"
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
|
-
"lastUpdated": "2026-
|
|
25
|
+
"lastUpdated": "2026-10-05T14:49:15.540Z"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"lineage": "
|
|
30
|
+
"lineage": "d6afcb3e-804c-4f78-85a9-6c691d18ec9a",
|
|
31
31
|
"serial": 3
|
|
32
32
|
}
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
"id": "test-fn"
|
|
84
84
|
}
|
|
85
85
|
],
|
|
86
|
-
"lastUpdated": "2026-
|
|
86
|
+
"lastUpdated": "2026-10-05T14:49:46.375Z"
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
89
|
"shared": {}
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
-
"lineage": "
|
|
92
|
+
"lineage": "6c7b9a3b-ec45-4fdd-a21c-41ba81171fe4",
|
|
93
93
|
"serial": 4
|
|
94
94
|
}
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"topicName": "insight-poc-tencent-log-default-log_fn-fn-logs"
|
|
94
94
|
}
|
|
95
95
|
],
|
|
96
|
-
"lastUpdated": "2026-
|
|
96
|
+
"lastUpdated": "2026-10-05T14:46:50.513Z"
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"shared": {
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
"logsetId": "logset-1"
|
|
114
114
|
}
|
|
115
115
|
],
|
|
116
|
-
"lastUpdated": "2026-
|
|
116
|
+
"lastUpdated": "2026-10-05T14:46:50.488Z"
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
|
-
"lineage": "
|
|
121
|
+
"lineage": "18440897-9452-47e9-b001-dd3bbe4b2b68",
|
|
122
122
|
"serial": 4
|
|
123
123
|
}
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
]
|
|
112
112
|
}
|
|
113
113
|
],
|
|
114
|
-
"lastUpdated": "2026-
|
|
114
|
+
"lastUpdated": "2026-10-05T14:49:58.301Z",
|
|
115
115
|
"status": "ready"
|
|
116
116
|
},
|
|
117
117
|
"events.gateway_event": {
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
"stageName": "RELEASE"
|
|
187
187
|
}
|
|
188
188
|
],
|
|
189
|
-
"lastUpdated": "2026-
|
|
189
|
+
"lastUpdated": "2026-10-05T14:49:58.302Z"
|
|
190
190
|
}
|
|
191
191
|
},
|
|
192
192
|
"shared": {
|
|
@@ -205,11 +205,11 @@
|
|
|
205
205
|
"id": "insight-poc-deploy-app-dev-sls"
|
|
206
206
|
}
|
|
207
207
|
],
|
|
208
|
-
"lastUpdated": "2026-
|
|
208
|
+
"lastUpdated": "2026-10-05T14:49:53.292Z"
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
},
|
|
213
|
-
"lineage": "
|
|
213
|
+
"lineage": "ad95a71d-fd9c-4f1b-9fe5-859461238c47",
|
|
214
214
|
"serial": 2
|
|
215
215
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "3.0",
|
|
3
|
+
"provider": "aliyun",
|
|
4
|
+
"app": "insight-poc-timer-app",
|
|
5
|
+
"service": "insight-poc-timer",
|
|
6
|
+
"stages": {
|
|
7
|
+
"dev": {
|
|
8
|
+
"resources": {
|
|
9
|
+
"functions.insight_poc_fn": {
|
|
10
|
+
"mode": "managed",
|
|
11
|
+
"region": "cn-hangzhou",
|
|
12
|
+
"definition": {
|
|
13
|
+
"functionName": "insight-poc-timer-fn",
|
|
14
|
+
"runtime": "nodejs18",
|
|
15
|
+
"handler": "index.handler",
|
|
16
|
+
"memorySize": 512,
|
|
17
|
+
"timeout": 10,
|
|
18
|
+
"diskSize": null,
|
|
19
|
+
"environment": {},
|
|
20
|
+
"vpcConfig": null,
|
|
21
|
+
"gpuConfig": null,
|
|
22
|
+
"customContainerConfig": null,
|
|
23
|
+
"nasConfig": null,
|
|
24
|
+
"logConfig": null,
|
|
25
|
+
"codeHash": "c96b718fa999add5e047823c3d7abfa1397fa8d0075bc6a4f3592785fcd4b76f"
|
|
26
|
+
},
|
|
27
|
+
"instances": [
|
|
28
|
+
{
|
|
29
|
+
"type": "ALIYUN_FC3_FUNCTION",
|
|
30
|
+
"sid": "si:aliyun:fc3:dev:insight-poc-timer-fn",
|
|
31
|
+
"id": "insight-poc-timer-fn",
|
|
32
|
+
"functionName": "insight-poc-timer-fn",
|
|
33
|
+
"functionArn": null,
|
|
34
|
+
"functionId": null,
|
|
35
|
+
"runtime": "nodejs18",
|
|
36
|
+
"handler": "index.handler",
|
|
37
|
+
"memorySize": 512,
|
|
38
|
+
"timeout": 10,
|
|
39
|
+
"diskSize": null,
|
|
40
|
+
"cpu": null,
|
|
41
|
+
"environment": {},
|
|
42
|
+
"vpcConfig": {},
|
|
43
|
+
"gpuConfig": {},
|
|
44
|
+
"nasConfig": {},
|
|
45
|
+
"logConfig": {},
|
|
46
|
+
"customContainerConfig": {},
|
|
47
|
+
"description": null,
|
|
48
|
+
"internetAccess": null,
|
|
49
|
+
"role": "acs:ram::123456789012:role/insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
50
|
+
"codeChecksum": null,
|
|
51
|
+
"codeSize": null,
|
|
52
|
+
"createdTime": null,
|
|
53
|
+
"lastModifiedTime": null,
|
|
54
|
+
"state": "Running",
|
|
55
|
+
"stateReason": null,
|
|
56
|
+
"stateReasonCode": null,
|
|
57
|
+
"lastUpdateStatus": null,
|
|
58
|
+
"lastUpdateStatusReason": null,
|
|
59
|
+
"lastUpdateStatusReasonCode": null,
|
|
60
|
+
"tags": [
|
|
61
|
+
{
|
|
62
|
+
"key": null,
|
|
63
|
+
"value": null
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "ALIYUN_FC3_TIMER_TRIGGER",
|
|
69
|
+
"id": "billing-run",
|
|
70
|
+
"sid": "si:aliyun:fc3-timer-trigger:dev:insight-poc-timer-fn.billing-run",
|
|
71
|
+
"attributes": {
|
|
72
|
+
"cron": "0 23 3 * * *",
|
|
73
|
+
"payload": "{\"job\":\"billing-run\"}",
|
|
74
|
+
"enable": true,
|
|
75
|
+
"description": "daily billing run"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "ALIYUN_FC3_TIMER_TRIGGER",
|
|
80
|
+
"id": "report-hourly",
|
|
81
|
+
"sid": "si:aliyun:fc3-timer-trigger:dev:insight-poc-timer-fn.report-hourly",
|
|
82
|
+
"attributes": {
|
|
83
|
+
"cron": "@every 1h",
|
|
84
|
+
"enable": false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"sid": "si:aliyun:ram_role:dev:insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
89
|
+
"id": "insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
90
|
+
"type": "ALIYUN_RAM_ROLE",
|
|
91
|
+
"roleArn": "acs:ram::123456789012:role/insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
92
|
+
"roleName": "insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
93
|
+
"roleId": "role-123",
|
|
94
|
+
"arn": "acs:ram::123456789012:role/insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role",
|
|
95
|
+
"policyName": "insight-poc-timer-app-insight-poc-timer-dev-insight-poc-fn-role-policy",
|
|
96
|
+
"trustedServices": [
|
|
97
|
+
"fc.aliyuncs.com"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"lastUpdated": "2026-10-05T14:48:23.124Z"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"shared": {}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"lineage": "bc279628-644f-414b-b151-663e346b5b15",
|
|
108
|
+
"serial": 3
|
|
109
|
+
}
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"serverSideEncryptionConfiguration": null
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
|
-
"lastUpdated": "2026-
|
|
47
|
+
"lastUpdated": "2026-10-05T14:50:14.852Z"
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"shared": {}
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"lineage": "
|
|
53
|
+
"lineage": "f0c451bb-e226-4714-be2f-ccfd5712b87b",
|
|
54
54
|
"serial": 4
|
|
55
55
|
}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
],
|
|
65
65
|
"status": "ready",
|
|
66
|
-
"lastUpdated": "2026-
|
|
66
|
+
"lastUpdated": "2026-10-05T14:46:53.601Z"
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"shared": {
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"projectId": "proj-123"
|
|
84
84
|
}
|
|
85
85
|
],
|
|
86
|
-
"lastUpdated": "2026-
|
|
86
|
+
"lastUpdated": "2026-10-05T14:46:50.558Z"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
|
-
"lineage": "
|
|
91
|
+
"lineage": "aa1bb86e-1a63-47b8-b559-faf855f7e046",
|
|
92
92
|
"serial": 5
|
|
93
93
|
}
|
|
@@ -137,12 +137,12 @@
|
|
|
137
137
|
"accessGroupName": "nested-drift-fn-dev-nas-access-mnt-data"
|
|
138
138
|
}
|
|
139
139
|
],
|
|
140
|
-
"lastUpdated": "2026-
|
|
140
|
+
"lastUpdated": "2026-10-05T14:46:50.462Z"
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
"shared": {}
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
|
-
"lineage": "
|
|
146
|
+
"lineage": "cde939d6-def6-4641-b671-8e75348d2589",
|
|
147
147
|
"serial": 5
|
|
148
148
|
}
|
package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup
CHANGED
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
]
|
|
119
119
|
}
|
|
120
120
|
],
|
|
121
|
-
"lastUpdated": "2026-
|
|
121
|
+
"lastUpdated": "2026-10-05T14:48:50.425Z",
|
|
122
122
|
"status": "ready"
|
|
123
123
|
}
|
|
124
124
|
},
|
|
@@ -138,11 +138,11 @@
|
|
|
138
138
|
"id": "role-reconcile-test-app-dev-sls"
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
|
-
"lastUpdated": "2026-
|
|
141
|
+
"lastUpdated": "2026-10-05T14:48:45.424Z"
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
|
-
"lineage": "
|
|
146
|
+
"lineage": "bd0d6c03-492e-4d6e-b89c-d0adabefd9ed",
|
|
147
147
|
"serial": 2
|
|
148
148
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.2] - 2026-10-05
|
|
11
|
+
|
|
10
12
|
### ⚠️ Breaking change
|
|
11
13
|
|
|
12
14
|
- **Generated API Gateway resource names are now collision-safe.** Aliyun apiNames
|
|
@@ -34,6 +36,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
34
36
|
|
|
35
37
|
### Added
|
|
36
38
|
|
|
39
|
+
- Schedule functions with `functions.*.triggers.timer`: a provider-agnostic si-cron
|
|
40
|
+
expression (5-field, 6-field with seconds, or `@every <duration>`, interpreted in
|
|
41
|
+
UTC) is translated to each provider's cron dialect (Aliyun FC3, Tencent SCF,
|
|
42
|
+
Volcengine veFaaS), validated before deploy — including per-provider capability
|
|
43
|
+
limits (Tencent allows at most 10 timers per function) — registered by trigger
|
|
44
|
+
name in state, and drift-checked so console-side edits or deletions are detected
|
|
45
|
+
and repaired on the next deploy
|
|
46
|
+
([#259](https://github.com/geek-fun/serverlessinsight/pull/259)).
|
|
47
|
+
- `si local` now fires `triggers.timer` schedules locally and invokes your handler
|
|
48
|
+
with the provider's timer event shape, so timer-driven code can be debugged
|
|
49
|
+
without deploying
|
|
50
|
+
([#259](https://github.com/geek-fun/serverlessinsight/pull/259)).
|
|
51
|
+
- Agent- and script-friendly CLI foundation: `--json` outputs, exported JSON Schema,
|
|
52
|
+
and documented exit/error code conventions
|
|
53
|
+
([#256](https://github.com/geek-fun/serverlessinsight/pull/256)).
|
|
37
54
|
- Huawei Cloud FunctionGraph is now first-class in runtime compatibility checks:
|
|
38
55
|
standard runtime ids map to the officially supported FunctionGraph runtimes
|
|
39
56
|
(Node.js 10–20, Python 3.6/3.9/3.10/3.12, Java 8/11/17/21, Go 1.x, .NET Core 3.1),
|
package/README.md
CHANGED
|
@@ -95,11 +95,52 @@ si deploy -f serverless.yml -s prod
|
|
|
95
95
|
si destroy -f serverless.yml
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
### Using si with AI agents & scripts
|
|
99
|
+
|
|
100
|
+
The CLI is built to be driven by agents and shell scripts: logs always go to
|
|
101
|
+
**stderr** while result data goes to **stdout**, so piping stdout into `jq`
|
|
102
|
+
always yields a single parseable JSON document.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
si plan --json -f serverless.yml | jq '.summary'
|
|
106
|
+
si validate --json -f serverless.yml | jq '.valid'
|
|
107
|
+
si show --json -f serverless.yml | jq '.resourceCount'
|
|
108
|
+
si schema | jq '.$id' # self-contained draft-07 JSON Schema of the IaC format
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Stable output envelopes** (each carries a version field, so shapes only ever
|
|
112
|
+
change under a new version):
|
|
113
|
+
|
|
114
|
+
- `si plan --json` → `{ planVersion: 1, provider, app, service, stage,
|
|
115
|
+
changes: [{ logicalId, type, action: "create|update|destroy|recreate",
|
|
116
|
+
attributes, drifted?, driftReasons? }], summary: { create, update, destroy,
|
|
117
|
+
recreate, unchanged } }`
|
|
118
|
+
- `si validate --json` → `{ validateVersion: 1, valid, errors: [{ path,
|
|
119
|
+
keyword, message, allowedValues? }] }`
|
|
120
|
+
- `si show --json` → `{ showVersion: 1, provider, app, service, stage,
|
|
121
|
+
stateLocation, backend: "saas|bucket_store|local", locked, lock, resources,
|
|
122
|
+
resourceCount, ... }`
|
|
123
|
+
- failures (in `--json` mode) → `{ error: { code, message } }` on stdout
|
|
124
|
+
|
|
125
|
+
**Exit codes**: `si plan` exits `0` when there are no changes, `2` when
|
|
126
|
+
changes are present (terraform convention), `1` on errors. `si validate`
|
|
127
|
+
exits `0` when valid, `1` when validation fails.
|
|
128
|
+
|
|
129
|
+
**Stable error codes**: error `code`s are the i18n message keys behind the
|
|
130
|
+
translated message (e.g. `RAM_ROLE_NOT_FOUND_IN_CLOUD`) — they are identical
|
|
131
|
+
under every locale, so agents can map codes to self-healing actions regardless
|
|
132
|
+
of `LANG`.
|
|
133
|
+
|
|
134
|
+
**Colors**: ANSI color is disabled when the `NO_COLOR` environment variable is
|
|
135
|
+
set ([no-color.org](https://no-color.org)) or `--no-color` is passed, keeping
|
|
136
|
+
piped output clean in non-TTY environments.
|
|
137
|
+
|
|
98
138
|
### Local Development
|
|
99
139
|
|
|
100
140
|
Run and debug your serverless functions locally without deploying to the cloud.
|
|
101
141
|
|
|
102
142
|
- **LocalStack server** — test functions, buckets, and API endpoints locally
|
|
143
|
+
- **Timer triggers fire locally** — `functions.*.triggers.timer` schedules run against UTC wall-clock (`@every` from server start) and invoke your handler with the provider's timer event shape
|
|
103
144
|
- **Bucket file serving** — access local storage files via HTTP for rapid iteration
|
|
104
145
|
- **Same config, different target** — `si local -f serverless.yml -s local` uses your existing config
|
|
105
146
|
|
|
@@ -112,6 +153,41 @@ Configure HTTP endpoints and bind custom domains with automatic DNS verification
|
|
|
112
153
|
- **CDN acceleration** — edge caching and global content delivery for static sites
|
|
113
154
|
- **OSS Transfer Acceleration** — cross-region data transfers through Alibaba backbone
|
|
114
155
|
|
|
156
|
+
### Timer Triggers
|
|
157
|
+
|
|
158
|
+
Schedule functions with a provider-agnostic `si-cron` expression under `functions.*.triggers.timer`:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
functions:
|
|
162
|
+
my_fn:
|
|
163
|
+
triggers:
|
|
164
|
+
timer:
|
|
165
|
+
- name: billing-run # required — drift detection is name-keyed
|
|
166
|
+
cron: '0 23 3 * * *' # required — si-cron, interpreted in UTC
|
|
167
|
+
payload: '{"job":"billing-run"}' # optional, passed through verbatim
|
|
168
|
+
enable: true # optional, default true
|
|
169
|
+
description: daily billing # optional
|
|
170
|
+
- name: report-hourly
|
|
171
|
+
cron: '@every 1h'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`cron` accepts a standard 5-field expression (`minute hour day month weekday`),
|
|
175
|
+
a 6-field expression with a seconds prefix, or `@every <duration>` (`30s`,
|
|
176
|
+
`5m`, `1h`, `1d`, …). si-cron is always **UTC** — the synthesis layer
|
|
177
|
+
translates it into each provider's dialect (Aliyun FC3 6-field, Tencent SCF
|
|
178
|
+
7-field with year, Volcengine veFaaS 5-field crontab) including the UTC+8
|
|
179
|
+
field shift, so the same YAML fires at the same instant everywhere. Invalid
|
|
180
|
+
expressions and provider capability limits (Tencent SCF allows at most 10
|
|
181
|
+
timers per function) fail at `si validate`, before any deploy.
|
|
182
|
+
|
|
183
|
+
**`functions.*.triggers` vs top-level `events`**: `triggers` (http, timer)
|
|
184
|
+
are things that *invoke this function* — they are function-owned, die with
|
|
185
|
+
the function, and have no independent configuration surface. Top-level
|
|
186
|
+
`events` (e.g. `API_GATEWAY`) are infrastructure resources with their own
|
|
187
|
+
config face — custom domains, certificates, route tables — that keep living
|
|
188
|
+
when a backend function is removed. Rule of thumb: independent
|
|
189
|
+
configuration surface → `events`; pure scheduling/event binding → `triggers`.
|
|
190
|
+
|
|
115
191
|
### Resource Management
|
|
116
192
|
|
|
117
193
|
Beyond functions — manage the full serverless stack including storage, databases, and more.
|
package/README.zh-CN.md
CHANGED
|
@@ -95,11 +95,47 @@ si deploy -f serverless.yml -s prod
|
|
|
95
95
|
si destroy -f serverless.yml
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
### 在 AI agent 与脚本中使用 si
|
|
99
|
+
|
|
100
|
+
CLI 专为 agent 与脚本驱动而设计:日志始终输出到 **stderr**,结果数据输出到
|
|
101
|
+
**stdout**,因此将 stdout 管道给 `jq` 总能得到单个可解析的 JSON 文档。
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
si plan --json -f serverless.yml | jq '.summary'
|
|
105
|
+
si validate --json -f serverless.yml | jq '.valid'
|
|
106
|
+
si show --json -f serverless.yml | jq '.resourceCount'
|
|
107
|
+
si schema | jq '.$id' # IaC 格式的自包含 draft-07 JSON Schema
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**稳定的输出 envelope**(每个都带版本号字段,结构只会在新版本号下变化):
|
|
111
|
+
|
|
112
|
+
- `si plan --json` → `{ planVersion: 1, provider, app, service, stage,
|
|
113
|
+
changes: [{ logicalId, type, action: "create|update|destroy|recreate",
|
|
114
|
+
attributes, drifted?, driftReasons? }], summary: { create, update, destroy,
|
|
115
|
+
recreate, unchanged } }`
|
|
116
|
+
- `si validate --json` → `{ validateVersion: 1, valid, errors: [{ path,
|
|
117
|
+
keyword, message, allowedValues? }] }`
|
|
118
|
+
- `si show --json` → `{ showVersion: 1, provider, app, service, stage,
|
|
119
|
+
stateLocation, backend: "saas|bucket_store|local", locked, lock, resources,
|
|
120
|
+
resourceCount, ... }`
|
|
121
|
+
- 失败时(`--json` 模式)→ stdout 输出 `{ error: { code, message } }`
|
|
122
|
+
|
|
123
|
+
**退出码**:`si plan` 无变更时退出 `0`,有变更时退出 `2`(terraform
|
|
124
|
+
惯例),出错时退出 `1`。`si validate` 校验通过退出 `0`,校验失败退出 `1`。
|
|
125
|
+
|
|
126
|
+
**稳定错误码**:错误 `code` 是翻译消息背后的 i18n key(例如
|
|
127
|
+
`RAM_ROLE_NOT_FOUND_IN_CLOUD`)——在所有语言环境下保持一致,agent
|
|
128
|
+
可以据此映射自愈动作,不受 `LANG` 影响。
|
|
129
|
+
|
|
130
|
+
**颜色**:设置 `NO_COLOR` 环境变量([no-color.org](https://no-color.org))或传入
|
|
131
|
+
`--no-color` 时禁用 ANSI 颜色,保证非 TTY 环境下管道输出干净。
|
|
132
|
+
|
|
98
133
|
### 本地开发
|
|
99
134
|
|
|
100
135
|
无需部署到云端,即可本地运行和调试你的 Serverless 函数。
|
|
101
136
|
|
|
102
137
|
- **LocalStack 服务** —— 在本地测试函数、存储桶和 API 端点
|
|
138
|
+
- **定时触发器本地触发** —— `functions.*.triggers.timer` 调度按 UTC 墙钟执行(`@every` 自服务启动起算),以对应云平台的 timer 事件形状调用你的处理函数
|
|
103
139
|
- **存储桶文件服务** —— 通过 HTTP 访问本地存储文件,加速迭代
|
|
104
140
|
- **同一配置,不同目标** —— `si local -f serverless.yml -s local` 复用你现有的配置
|
|
105
141
|
|
|
@@ -112,6 +148,37 @@ si destroy -f serverless.yml
|
|
|
112
148
|
- **CDN 加速** —— 为静态站点提供边缘缓存与全球内容分发
|
|
113
149
|
- **OSS 传输加速** —— 通过阿里云骨干网进行跨区域数据传输
|
|
114
150
|
|
|
151
|
+
### 定时触发器
|
|
152
|
+
|
|
153
|
+
在 `functions.*.triggers.timer` 下使用 provider 无关的 `si-cron` 表达式调度函数:
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
functions:
|
|
157
|
+
my_fn:
|
|
158
|
+
triggers:
|
|
159
|
+
timer:
|
|
160
|
+
- name: billing-run # 必填 —— 漂移检测按 name 定位
|
|
161
|
+
cron: '0 23 3 * * *' # 必填 —— si-cron,按 UTC 解释
|
|
162
|
+
payload: '{"job":"billing-run"}' # 可选,原样透传
|
|
163
|
+
enable: true # 可选,默认 true
|
|
164
|
+
description: 每日出账 # 可选
|
|
165
|
+
- name: report-hourly
|
|
166
|
+
cron: '@every 1h'
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`cron` 支持标准 5 段表达式(`分 时 日 月 周`)、带秒前缀的 6 段,或
|
|
170
|
+
`@every <时长>`(`30s`、`5m`、`1h`、`1d` 等)。si-cron 一律按 **UTC** 解释——
|
|
171
|
+
合成层负责翻译成各家方言(阿里云 FC3 六段、腾讯云 SCF 含年的七段、火山引擎
|
|
172
|
+
veFaaS 五段 crontab),并完成 UTC+8 字段平移,因此同一份 YAML 在所有云平台
|
|
173
|
+
触发时刻一致。非法表达式与平台能力上限(腾讯云 SCF 单函数最多 10 个定时触发器)
|
|
174
|
+
在 `si validate` 阶段即报错,不会进入部署。
|
|
175
|
+
|
|
176
|
+
**`functions.*.triggers` 与顶层 `events` 的区分**:`triggers`(http、timer)
|
|
177
|
+
是「调用本函数的东西」——函数级归属、随函数级联删除、没有独立配置面。顶层
|
|
178
|
+
`events`(如 `API_GATEWAY`)是拥有独立配置面的基础设施资源——自定义域名、
|
|
179
|
+
证书、路由表——删除后端函数后它们依然存在。经验法则:有独立配置面 →
|
|
180
|
+
`events`;纯调度/事件绑定 → `triggers`。
|
|
181
|
+
|
|
115
182
|
### 资源管理
|
|
116
183
|
|
|
117
184
|
不止于函数——管理包含存储、数据库等在内的完整 Serverless 技术栈。
|
package/codecov
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ca1d64196d2d34771084afe76ea657d581bf628e31d993ff8e52ea09cc88a56d codecov
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-----BEGIN PGP SIGNATURE-----
|
|
2
|
+
|
|
3
|
+
iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmpO+3UACgkQgGuyiu13
|
|
4
|
+
mGm0UxAAne5/lA7YQHQlWt455twIGwZgcSX13LTQw45+goIfZC7IGDQ7J6/kLyJG
|
|
5
|
+
sGvkfSmYEODgsgo6474CWcm16VPMZa3QWa4z6EdfyNHhDo5nNe358ZPA1dOemMKZ
|
|
6
|
+
eV2/9WpDcIEIAhsCj8HKjNjsLBcGrAQRbOw2tABg2dbE8Yg94SMdEqjMCswOQn3i
|
|
7
|
+
OPsybWDjbAdqUVIWylUXbned5/hVnzNAMeo6WvC5+LNw1iS+8rzSIUu5iSxCz9jV
|
|
8
|
+
XBe0ZNZ/z1jLZ0NHQXWoOWVT6aHI3Aml/V+ttduuSPwVqWUtqT+XWnnxXJlkt3fQ
|
|
9
|
+
uB8Fy9NBkj5qkls81pUyt0Z9QuMvnI/OxWiUZ6jOEItiZMkK87ryPiheBoaU4kuf
|
|
10
|
+
fcpoRz/EVNsAgcrHBFQCiam7I32h5R5O9orDiU4pKzahSdgelnvOPIZQzSKT5m/M
|
|
11
|
+
50tuts7npVQib2op7XCv+6d3t8ZnUHzXnqiej6n/vWxE3nWJiw39a5ww7RDO1RQB
|
|
12
|
+
8oNPX3qvPGpNmspXSf57oLyJqiSs4t7B9yIacCMPnlVDZt3MseXP/UHH7cXMmRuX
|
|
13
|
+
bU2mkdieBgkGtkNkB76sp/ob5FWQmynW1+Q3ZcDGrGeysnRgDGWD2Yy92lcABZDc
|
|
14
|
+
DXolC9kpvP+UrUXG5XSTIKksMbH4YacgNIKHzwyhOgViMLWBA4g=
|
|
15
|
+
=fH2Y
|
|
16
|
+
-----END PGP SIGNATURE-----
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Full-lifecycle serverless IaC — one open-source platform to develop, deploy and operate serverless across clouds.",
|
|
5
5
|
"homepage": "https://serverlessinsight.com",
|
|
6
6
|
"main": "dist/src/index.js",
|