@secondlayer/cli 3.1.1 → 3.2.0-beta.1
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 +80 -4
- package/dist/cli.js +490 -360
- package/dist/cli.js.map +12 -11
- package/package.json +6 -7
- package/templates/subscriptions/cloudflare/README.md +39 -0
- package/templates/subscriptions/cloudflare/package.json +15 -0
- package/templates/subscriptions/cloudflare/src/index.ts +34 -0
- package/templates/subscriptions/cloudflare/tsconfig.json +10 -0
- package/templates/subscriptions/cloudflare/wrangler.toml +8 -0
- package/templates/subscriptions/inngest/README.md +29 -0
- package/templates/subscriptions/inngest/package.json +18 -0
- package/templates/subscriptions/inngest/src/inngest.ts +19 -0
- package/templates/subscriptions/inngest/src/server.ts +14 -0
- package/templates/subscriptions/inngest/tsconfig.json +11 -0
- package/templates/subscriptions/node/.env.example +2 -0
- package/templates/subscriptions/node/README.md +34 -0
- package/templates/subscriptions/node/package.json +18 -0
- package/templates/subscriptions/node/src/index.ts +50 -0
- package/templates/subscriptions/node/tsconfig.json +11 -0
- package/templates/subscriptions/trigger/README.md +35 -0
- package/templates/subscriptions/trigger/package.json +17 -0
- package/templates/subscriptions/trigger/src/tasks/subgraph-event.ts +15 -0
- package/templates/subscriptions/trigger/trigger.config.ts +6 -0
- package/templates/subscriptions/trigger/tsconfig.json +10 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ sl subgraphs deploy ./x.ts # deploy to your instance
|
|
|
26
26
|
|---|---|
|
|
27
27
|
| `sl login` | Magic-link email → 6-digit code → writes session to `~/.secondlayer/session.json` |
|
|
28
28
|
| `sl logout` | Revokes the session and clears the local file |
|
|
29
|
-
| `sl whoami` | Prints account, active project, instance URL,
|
|
29
|
+
| `sl whoami` | Prints account, active project, instance URL, plan, status |
|
|
30
30
|
|
|
31
31
|
### Project
|
|
32
32
|
|
|
@@ -50,7 +50,7 @@ One instance per project. The platform API spawns a dedicated `sl-pg-{slug}`,
|
|
|
50
50
|
| Command | What it does |
|
|
51
51
|
|---|---|
|
|
52
52
|
| `sl instance create --plan <launch\|grow\|scale>` | Provision containers. Boxed reveal of `serviceKey` + `anonKey` (shown once). |
|
|
53
|
-
| `sl instance info` | Plan, status, resource usage
|
|
53
|
+
| `sl instance info` | Plan, status, resource usage |
|
|
54
54
|
| `sl instance resize --plan <...>` | Recreate containers with new CPU/memory (~30s downtime) |
|
|
55
55
|
| `sl instance suspend` / `resume` | Stop/start containers, volume preserved |
|
|
56
56
|
| `sl instance keys rotate [--service\|--anon\|--both]` | Bump JWT gen, recreate API container, mint replacement key(s) |
|
|
@@ -95,7 +95,7 @@ invocation. No long-lived key on disk.
|
|
|
95
95
|
|---|---|
|
|
96
96
|
| `sl generate [files...]` (aliases: `gen`, `codegen`) | Generate TS interfaces from Clarity contracts |
|
|
97
97
|
| `sl init` | Scaffold `secondlayer.config.ts` |
|
|
98
|
-
| `sl doctor` | Session + project + instance reachability
|
|
98
|
+
| `sl doctor` | Session + project + instance reachability check |
|
|
99
99
|
| `sl status` | Platform/instance health |
|
|
100
100
|
| `sl account profile` | Update display name / bio / slug |
|
|
101
101
|
| `sl config show/set/reset/clear` | Inspect or reset local config |
|
|
@@ -117,12 +117,88 @@ Every tenant-scoped failure surfaces a typed code and an action hint:
|
|
|
117
117
|
| Code | CLI hint |
|
|
118
118
|
|---|---|
|
|
119
119
|
| `SESSION_EXPIRED` | `Session expired. Run: sl login` |
|
|
120
|
-
| `TRIAL_EXPIRED` | `Your trial expired. Run: sl instance resize --plan <...> and add payment` |
|
|
121
120
|
| `TENANT_SUSPENDED` | `Instance is suspended. Run: sl instance resume` |
|
|
122
121
|
| `NO_ACTIVE_PROJECT` | `No project selected. Run: sl project use <slug>` |
|
|
123
122
|
| `NO_TENANT_FOR_PROJECT` | `Project has no instance. Run: sl instance create --plan launch` |
|
|
124
123
|
| `KEY_ROTATED` | Handled transparently — `http.ts` re-mints and retries once |
|
|
125
124
|
|
|
125
|
+
## Code generation (`sl generate`)
|
|
126
|
+
|
|
127
|
+
Generate type-safe interfaces, functions, and optional React hooks from
|
|
128
|
+
Clarity contracts — works against local `.clar` files, deployed contracts
|
|
129
|
+
(network inferred from address prefix), or glob patterns.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Local .clar files
|
|
133
|
+
sl generate ./contracts/token.clar -o ./src/generated.ts
|
|
134
|
+
|
|
135
|
+
# Deployed contracts (SP/SM → mainnet, ST/SN → testnet)
|
|
136
|
+
sl generate SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault -o ./src/generated.ts
|
|
137
|
+
|
|
138
|
+
# Glob
|
|
139
|
+
sl generate "./contracts/*.clar" -o ./src/generated.ts
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Config-driven mode:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
sl init # creates secondlayer.config.ts
|
|
146
|
+
sl generate # regenerates from the config
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// secondlayer.config.ts
|
|
151
|
+
import { defineConfig } from "@secondlayer/cli"
|
|
152
|
+
import { clarinet, actions, react } from "@secondlayer/cli/plugins"
|
|
153
|
+
|
|
154
|
+
export default defineConfig({
|
|
155
|
+
out: "src/generated.ts",
|
|
156
|
+
plugins: [clarinet(), actions(), react()],
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Plugins
|
|
161
|
+
|
|
162
|
+
| Plugin | What it adds |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `clarinet()` | Parse local Clarinet project |
|
|
165
|
+
| `actions()` | `read.*` + `write.*` helpers on each contract |
|
|
166
|
+
| `react()` | Typed React Query hooks (`useTokenTransfer`, `useTokenBalance`, etc.) |
|
|
167
|
+
| `testing()` | Clarinet SDK test helpers |
|
|
168
|
+
|
|
169
|
+
### Usage examples
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { token } from "./generated/contracts"
|
|
173
|
+
import { makeContractCall, fetchCallReadOnlyFunction } from "@stacks/transactions"
|
|
174
|
+
|
|
175
|
+
// Works with @stacks/transactions directly:
|
|
176
|
+
await makeContractCall({
|
|
177
|
+
...token.transfer({ amount: 100n, recipient: "SP..." }),
|
|
178
|
+
network: "mainnet",
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
// With actions() plugin — read/write helpers:
|
|
182
|
+
const balance = await token.read.getBalance({ account: "SP..." })
|
|
183
|
+
await token.write.transfer({ amount: 100n, recipient: "SP..." })
|
|
184
|
+
|
|
185
|
+
// Maps / vars / constants:
|
|
186
|
+
const supply = await token.vars.totalSupply.get()
|
|
187
|
+
const bal = await token.maps.balances.get("SP...")
|
|
188
|
+
const max = await token.constants.maxSupply.get()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// With react() plugin:
|
|
193
|
+
import { useTokenTransfer, useTokenBalance } from "./generated/hooks"
|
|
194
|
+
|
|
195
|
+
function App() {
|
|
196
|
+
const { transfer, isRequestPending } = useTokenTransfer()
|
|
197
|
+
const { data: balance } = useTokenBalance("SP...")
|
|
198
|
+
// ...
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
126
202
|
## License
|
|
127
203
|
|
|
128
204
|
MIT
|