@ojiepermana/angular-sdk 22.0.36 → 22.0.41

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,97 +1,51 @@
1
- # SDK Generator
1
+ # @ojiepermana/angular-sdk
2
2
 
3
- OpenAPI → Angular SDK generator shipped as the secondary entrypoint
4
- `@ojiepermana/angular/generator/api`.
3
+ OpenAPI 3.x → Angular SDK generator for the `@ojiepermana/angular` design system.
4
+ Source lives in [`library/sdk`](.); the package publishes as `@ojiepermana/angular-sdk`
5
+ and is also re-exported as the umbrella secondary entry point `@ojiepermana/angular/sdk`.
5
6
 
6
- It generates a **lightweight Angular SDK** from any OpenAPI 3.x spec (including
7
- 3.2.0): typed `HttpClient` services, tree-shakeable fn modules, optional
8
- metadata (permissions / validators), and a navigation tree.
7
+ It generates a **lightweight Angular SDK** from any OpenAPI 3.x spec (including 3.2.0):
8
+ typed `HttpClient` services, tree-shakeable fn modules, optional metadata
9
+ (permissions / validators), and a navigation tree.
9
10
 
10
- ## Local development in this repo
11
+ ## What the published package exposes
11
12
 
12
- ```bash
13
- # 1. Build the schematic runtime
14
- bun run gen:sdk:build
13
+ The npm artifact currently ships the **typed config surface** — the contract you author
14
+ your `sdk.config.json` against from [`public-api.ts`](public-api.ts):
15
15
 
16
- # 2. Scaffold a workspace config
17
- bun run gen:sdk:init
18
-
19
- # 3. Edit sdk.config.json, then generate
20
- bun run gen:sdk
21
-
22
- # 4. Run the split-by-domain regression checks
23
- bun run test:gen:sdk
24
- ```
25
-
26
- ## Consumer usage after publish
27
-
28
- ```bash
29
- # inside an Angular workspace that installed @ojiepermana/angular
30
- ng generate @ojiepermana/angular:sdk-init
31
- # edit config/sdk.config.json
32
- ng generate @ojiepermana/angular:sdk
33
- ```
34
-
35
- The main consumer feature is generating an SDK from
36
- `config/sdk.config.json`. The consumer flow is: initialize the config once,
37
- edit it, then run `sdk` whenever the OpenAPI source changes.
38
-
39
- If a consumer wants short script aliases in `package.json`, they can add this
40
- script block to their workspace:
41
-
42
- ```json
43
- {
44
- "scripts": {
45
- "gen:sdk:init": "ng generate @ojiepermana/angular:sdk-init",
46
- "gen:sdk": "ng generate @ojiepermana/angular:sdk"
47
- }
48
- }
49
- ```
50
-
51
- Consumers do not need a `gen:sdk:build` step. That build command only exists
52
- for developing this repository, where the schematic source under
53
- `projects/angular/generator/api` must be compiled before local execution.
54
-
55
- ## Schematics
56
-
57
- The entrypoint exposes two schematics, registered in the parent collection at [`projects/angular/collection.json`](../../collection.json):
58
-
59
- | Schematic | Script | Purpose |
60
- | ---------- | ---------------------- | ------------------------------------------------ |
61
- | `sdk-init` | `bun run gen:sdk:init` | Create `config/sdk.config.json` from the example |
62
- | `sdk` | `bun run gen:sdk` | Run the generator using `config/sdk.config.json` |
63
-
64
- Both can be invoked directly with `ng generate` too:
65
-
66
- ```bash
67
- bunx ng generate ./projects/angular/collection.json:sdk-init [--force] [--path=custom/sdk.config.json]
68
- bunx ng generate ./projects/angular/collection.json:sdk [--dry-run] [--config=sdk.config.json] [--target=1]
69
-
70
- # after publish / inside a consuming workspace:
71
- ng generate @ojiepermana/angular:sdk-init [--force] [--path=custom/sdk.config.json]
72
- ng generate @ojiepermana/angular:sdk [--dry-run] [--config=sdk.config.json] [--target=1]
16
+ ```ts
17
+ import {
18
+ resolveConfig,
19
+ resolveTarget,
20
+ type SdkConfig,
21
+ type SdkTargetConfig,
22
+ type SdkOutputMode,
23
+ type SdkFeatureFlags,
24
+ } from '@ojiepermana/angular-sdk';
73
25
  ```
74
26
 
75
- ### `init` options
76
-
77
- | Option | Type | Default | Description |
78
- | --------- | ------- | ------------------------ | --------------------------------------------- |
79
- | `--path` | string | `config/sdk.config.json` | Destination path, relative to workspace root. |
80
- | `--force` | boolean | `false` | Overwrite the file if it already exists. |
81
-
82
- ### `sdk` options
83
-
84
- | Option | Type | Default | Description |
85
- | ----------- | ------ | ------------------------ | ------------------------------------------------------------------ |
86
- | `--config` | string | `config/sdk.config.json` | Path to the config file, relative to workspace root. |
87
- | `--target` | string | _(all)_ | Only generate one target. Accepts a 1-based index or `clientName`. |
88
- | `--dry-run` | flag | — | Preview file operations without writing anything. |
27
+ The generator implementation itself lives in the source tree:
28
+
29
+ | Path | Role |
30
+ | -------------------- | ------------------------------------------------------------------------------------------------ |
31
+ | `src/config/` | Config schema + loader (JSONC, `.js`/`.cjs`) `resolveConfig` / `resolveTarget` |
32
+ | `src/parser/` | OpenAPI intermediate representation (`bundle`, `ir`, `types`) |
33
+ | `src/emit/` | One emitter per concern (models, operations, services, client, metadata, navigation, public-api) |
34
+ | `src/layout/` | Post-emit transforms (e.g. `per-domain` split-by-domain reorganisation) |
35
+ | `src/render/` | Template rendering |
36
+ | `src/writer/` | Output-mode wrappers (standalone / library / secondary-entrypoint) |
37
+ | `src/engine.ts` | `generate(target, workspaceRoot)` runs the full pipeline for one target |
38
+ | `schematics/init/` | Scaffolds `config/sdk.config.json` from [`sdk.config.example.json`](sdk.config.example.json) |
39
+ | `schematics/sdk/` | Runs the generator and writes files into the Angular CLI `Tree` |
40
+ | `schematics/ng-add/` | `ng add` support installs peer deps |
41
+ | `bin/` | Compiled JS output of `src/` + `schematics/` (via `tsconfig.schematics.json`) |
89
42
 
90
43
  ## Config shape
91
44
 
45
+ A single config file drives one or more generation targets:
46
+
92
47
  ```jsonc
93
48
  {
94
- "$schema": "./node_modules/@ojiepermana/angular/generator/api/schematics/sdk/schema.json",
95
49
  "targets": [
96
50
  {
97
51
  "input": "./openapi.yaml",
@@ -116,11 +70,12 @@ ng generate @ojiepermana/angular:sdk [--dry-run] [--config=sdk.config.json]
116
70
  }
117
71
  ```
118
72
 
119
- Multiple targets are supported — one config run can emit several SDKs.
73
+ Multiple targets are supported — one config run can emit several SDKs. See
74
+ [`sdk.config.example.json`](sdk.config.example.json) for the canonical template the
75
+ `init` schematic scaffolds.
120
76
 
121
- If `rootUrl` is omitted or left empty, the generated SDK uses same-origin
122
- requests by default. Consumer apps can override it at runtime with
123
- `provideApiConfiguration(...)`.
77
+ If `rootUrl` is omitted or left empty, the generated SDK uses same-origin requests by
78
+ default. Consumer apps can override it at runtime with `provideApiConfiguration(...)`.
124
79
 
125
80
  ### Runtime base URL
126
81
 
@@ -135,8 +90,6 @@ The generated SDK does not read `sdk.config.json` at runtime. The value of
135
90
  - Runtime override: consumer apps can replace the default by providing a new
136
91
  value during bootstrap.
137
92
 
138
- Example runtime override in a consumer app:
139
-
140
93
  ```ts
141
94
  import { bootstrapApplication } from '@angular/platform-browser';
142
95
  import { provideHttpClient } from '@angular/common/http';
@@ -150,8 +103,18 @@ bootstrapApplication(AppComponent, {
150
103
  ```
151
104
 
152
105
  For standalone generated output inside the same workspace, import
153
- `provideApiConfiguration` from the generated SDK barrel instead of an npm
154
- package path.
106
+ `provideApiConfiguration` from the generated SDK barrel instead of an npm package path.
107
+
108
+ ## Output modes
109
+
110
+ | Mode | What it emits | Use when… |
111
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
112
+ | `standalone` | A plain folder (no `ng-package.json`). | You consume the SDK via path alias / `tsconfig.paths` inside the same app. |
113
+ | `library` | Split-by-domain output plus package metadata and nested `ng-package.json` manifests for secondary entrypoints. | You want a buildable/publishable Angular package with efficient deep imports. |
114
+ | `secondary-entrypoint` | Standalone output **plus** a minimal `ng-package.json` pointing at `public-api.ts`, plus nested `ng-package.json` files for split-by-domain secondary entrypoints. | You drop the folder inside an existing library so ng-packagr picks it up as a subpath. |
115
+
116
+ In `library` mode, output also includes `tsconfig.lib.json` and `tsconfig.lib.prod.json`.
117
+ `ng-package.dest` defaults to `dist/<output-folder-name>`.
155
118
 
156
119
  ## Per-domain layout
157
120
 
@@ -162,15 +125,7 @@ secondary entrypoints immediately. You can still set `splitByDomain: false` if
162
125
  you need the older flat library shape. Cross-domain models and client primitives
163
126
  land in `shared/`.
164
127
 
165
- ```jsonc
166
- {
167
- "splitByDomain": true,
168
- "splitDepth": "service", // or "tag"
169
- }
170
- ```
171
-
172
- `splitDepth` controls granularity. It is only read when `splitByDomain` is
173
- `true`.
128
+ `splitDepth` controls granularity. It is only read when `splitByDomain` is `true`.
174
129
 
175
130
  | `splitDepth` | Folder strategy | Example (spec with tags `Access/Role`, `Access/Permission`, `Storage/GCS`, `Storage/S3`, `Auth`) |
176
131
  | ------------ | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
@@ -205,17 +160,6 @@ import { GCSService } from '@my-scope/sdk/storage'; // splitDepth: 'service'
205
160
  import { GCSService } from '@my-scope/sdk/storage/gcs'; // splitDepth: 'tag'
206
161
  ```
207
162
 
208
- ## Output modes
209
-
210
- | Mode | What it emits | Use when… |
211
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
212
- | `standalone` | A plain folder (no `ng-package.json`). | You consume the SDK via path alias / `tsconfig.paths` inside the same app. |
213
- | `library` | Split-by-domain output plus package metadata and nested `ng-package.json` manifests for secondary entrypoints. | You want a buildable/publishable Angular package with efficient deep imports. |
214
- | `secondary-entrypoint` | Standalone output **plus** a minimal `ng-package.json` pointing at `public-api.ts`, plus nested `ng-package.json` files for split-by-domain secondary entrypoints. | You drop the folder inside an existing library so ng-packagr picks it up as a subpath. |
215
-
216
- In `library` mode, output also includes `tsconfig.lib.json` and `tsconfig.lib.prod.json`.
217
- `ng-package.dest` defaults to `dist/<output-folder-name>`.
218
-
219
163
  ## Feature flags
220
164
 
221
165
  All default to `true`. Turn off anything you don't need to shrink the output.
@@ -232,18 +176,9 @@ All default to `true`. Turn off anything you don't need to shrink the output.
232
176
  ## Pipeline
233
177
 
234
178
  ```text
235
- sdk.config.json → loader → spec (YAML/JSON) → IR → emitters → writer → Angular CLI Tree
179
+ sdk.config.json → loader → spec (YAML/JSON) → IR → emitters → layout → writer → Angular CLI Tree
236
180
  ```
237
181
 
238
- - `src/config/` — config schema + loader (supports JSONC and `.js`/`.cjs`).
239
- - `src/parser/` — OpenAPI → intermediate representation.
240
- - `src/emit/` — one module per output concern (models, operations, services, client, metadata, navigation, public-api).
241
- - `src/layout/` — post-emit layout transforms (e.g. `splitByDomain` reorganisation).
242
- - `src/writer/` — mode wrappers (standalone / library / secondary entrypoint).
243
- - `public-api.ts` — published TypeScript entrypoint for `@ojiepermana/angular/generator/api`.
244
- - `schematics/init/` — creates `sdk.config.json` from the example template.
245
- - `schematics/sdk/` — orchestrates engine and writes virtual files into the CLI `Tree`.
246
-
247
182
  ## Generated runtime conventions
248
183
 
249
184
  - Tree-shakeable: `import { listUsers } from './sdk/fn/user/list-users'` pulls only one HTTP call.
@@ -13,6 +13,7 @@ const DEFAULT_FEATURES = {
13
13
  client: true,
14
14
  metadata: true,
15
15
  navigation: true,
16
+ resources: false,
16
17
  };
17
18
  function resolveTarget(raw) {
18
19
  if (!raw || typeof raw !== 'object') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ojiepermana/angular-sdk",
3
- "version": "22.0.36",
3
+ "version": "22.0.41",
4
4
  "description": "OpenAPI 3.x → Angular SDK generator (schematics + config surface) for @ojiepermana/angular.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,6 +19,8 @@ interface SdkFeatureFlags {
19
19
  metadata?: boolean;
20
20
  /** Emit navigation tree derived from tags (parent, x-icon). Default `false`. */
21
21
  navigation?: boolean;
22
+ /** Emit Signal-based resource helpers using rxResource(). Default `false`. */
23
+ resources?: boolean;
22
24
  }
23
25
  interface SdkTargetConfig {
24
26
  /** Path to OpenAPI 3.x spec (YAML or JSON). Required. */
@@ -65,6 +67,7 @@ interface ResolvedFeatureFlags {
65
67
  client: boolean;
66
68
  metadata: boolean;
67
69
  navigation: boolean;
70
+ resources: boolean;
68
71
  }
69
72
  interface ResolvedSdkTarget {
70
73
  input: string;