@appweaver/cli 1.0.21 → 1.0.23
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/package.json +1 -1
- package/skill/GUIDELINES.md +1 -1
- package/skill/references/client.md +22 -0
package/package.json
CHANGED
package/skill/GUIDELINES.md
CHANGED
|
@@ -18,7 +18,7 @@ provides factory methods for creating resource models, services, policies, and r
|
|
|
18
18
|
- `appweaver.json` / `appweaver.{env}.json` - central configuration
|
|
19
19
|
- `Dockerfile` - Docker image definition
|
|
20
20
|
|
|
21
|
-
**IMPORTANT:** `{env}` is controlled by `NODE_ENV`
|
|
21
|
+
**IMPORTANT:** `{env}` is controlled by `NODE_ENV` environment variable.
|
|
22
22
|
|
|
23
23
|
## Application entrypoint
|
|
24
24
|
|
|
@@ -44,6 +44,7 @@ Reads an OpenAPI v3 schema and generates TypeScript types and a typed client cla
|
|
|
44
44
|
| `--typesPath [path]` | Output path for generated TypeScript types only | same as `outputPath` |
|
|
45
45
|
| `--clientPath [path]` | Output path for generated client class only | same as `outputPath` |
|
|
46
46
|
| `--clientName [name]` | Custom name for the generated client class | derived from schema title |
|
|
47
|
+
| `--framework [name]` | Framework for the generated client class (`fetch` or `angular`) | `fetch` |
|
|
47
48
|
| `--typesOnly` | Generate TypeScript types only, skip client class generation | `false` |
|
|
48
49
|
| `--clientOnly` | Generate client class only, skip TypeScript types generation | `false` |
|
|
49
50
|
| `--noTypes` | Generate client class without TypeScript type support | `false` |
|
|
@@ -158,6 +159,27 @@ The generated second type argument to `resourceClient` (e.g., `['aggregate', 'ex
|
|
|
158
159
|
removes those methods from the returned `ResourceClient` at the TypeScript level, preventing accidental calls to
|
|
159
160
|
operations not exposed by the API.
|
|
160
161
|
|
|
162
|
+
### Angular client (`--framework angular`)
|
|
163
|
+
|
|
164
|
+
Passing `--framework angular` generates a client class extending `AngularClient` instead of `FetchClient`. The
|
|
165
|
+
generated class is constructed with Angular's `HttpClient` and all its methods return RxJS `Observable`s instead of
|
|
166
|
+
`Promise`s:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { ClientConfig, ClientError } from '@appweaver/client';
|
|
170
|
+
import { AngularClient } from '@appweaver/client/angular';
|
|
171
|
+
import { HttpClient } from '@angular/common/http';
|
|
172
|
+
|
|
173
|
+
// In an Angular service or provider:
|
|
174
|
+
const client = new CMSAPIClient(httpClient, { baseUrl: 'http://localhost:3000' });
|
|
175
|
+
client.user.query({ filter: { enabled: true } }).subscribe((users) => {});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Important:** `AngularClient` is only available from the `@appweaver/client/angular` subpath — it is not exported from
|
|
179
|
+
the main `@appweaver/client` entry point. This keeps `rxjs` completely out of the module graph (runtime and types) for
|
|
180
|
+
`FetchClient` users. `rxjs` is an **optional peer dependency**: Angular projects already have it installed, while
|
|
181
|
+
fetch-only projects do not need it at all.
|
|
182
|
+
|
|
161
183
|
---
|
|
162
184
|
|
|
163
185
|
## Runtime library
|