@ojiepermana/angular 21.0.2 → 21.0.6
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/fesm2022/ojiepermana-angular-generator-api.mjs.map +1 -1
- package/generator/api/README.md +36 -1
- package/generator/api/bin/schematics/init/index.js +1 -1
- package/generator/api/bin/src/emit/client.js +3 -3
- package/generator/api/bin/src/engine.js +1 -1
- package/generator/api/bin/src/writer/index.js +3 -3
- package/generator/api/sdk.config.example.json +1 -1
- package/package.json +10 -9
- package/types/ojiepermana-angular-generator-api.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ojiepermana-angular-generator-api.mjs","sources":["../../../projects/angular/generator/api/src/config/schema.ts","../../../projects/angular/generator/api/public-api.ts","../../../projects/angular/generator/api/ojiepermana-angular-generator-api.ts"],"sourcesContent":["/**\n * Public config shape for the SDK generator.\n *\n * Users place an `sdk.config.json` at the workspace root describing one or more\n * generation targets. All paths are resolved relative to the workspace root\n * (i.e. the directory containing the config file).\n */\n\nexport type SdkOutputMode = 'standalone' | 'library' | 'secondary-entrypoint';\n\nexport interface SdkFeatureFlags {\n /** Emit `models/*.ts` (type-only DTO interfaces). Default `true`. */\n models?: boolean;\n /** Emit tree-shakeable operation functions in `fn/<tag>/*.ts`. Default `true`. */\n operations?: boolean;\n /** Emit grouped Injectable service classes per tag. Default `true`. */\n services?: boolean;\n /** Emit the runtime client primitives (ApiConfiguration, BaseService, etc). Default `true`. */\n client?: boolean;\n /** Emit operation rules + field validators + permission helpers. Default `true`. */\n metadata?: boolean;\n /** Emit navigation tree derived from tags (parent, x-icon). Default `false`. */\n navigation?: boolean;\n}\n\nexport interface SdkTargetConfig {\n /** Path to OpenAPI 3.x spec (YAML or JSON). Required. */\n input: string;\n /** Output directory (relative to workspace root). Required. */\n output: string;\n /** Output mode. Defaults to `\"standalone\"`. */\n mode?: SdkOutputMode;\n /** Optional human-readable name used for logs & the generated `Api` class. */\n clientName?: string;\n /** Package name used when `mode === \"library\"`. */\n packageName?: string;\n /** Package version used when `mode === \"library\"`. Defaults to `0.0.1`. */\n packageVersion?: string;\n /** Default rootUrl baked into ApiConfiguration. Defaults to
|
|
1
|
+
{"version":3,"file":"ojiepermana-angular-generator-api.mjs","sources":["../../../projects/angular/generator/api/src/config/schema.ts","../../../projects/angular/generator/api/public-api.ts","../../../projects/angular/generator/api/ojiepermana-angular-generator-api.ts"],"sourcesContent":["/**\n * Public config shape for the SDK generator.\n *\n * Users place an `sdk.config.json` at the workspace root describing one or more\n * generation targets. All paths are resolved relative to the workspace root\n * (i.e. the directory containing the config file).\n */\n\nexport type SdkOutputMode = 'standalone' | 'library' | 'secondary-entrypoint';\n\nexport interface SdkFeatureFlags {\n /** Emit `models/*.ts` (type-only DTO interfaces). Default `true`. */\n models?: boolean;\n /** Emit tree-shakeable operation functions in `fn/<tag>/*.ts`. Default `true`. */\n operations?: boolean;\n /** Emit grouped Injectable service classes per tag. Default `true`. */\n services?: boolean;\n /** Emit the runtime client primitives (ApiConfiguration, BaseService, etc). Default `true`. */\n client?: boolean;\n /** Emit operation rules + field validators + permission helpers. Default `true`. */\n metadata?: boolean;\n /** Emit navigation tree derived from tags (parent, x-icon). Default `false`. */\n navigation?: boolean;\n}\n\nexport interface SdkTargetConfig {\n /** Path to OpenAPI 3.x spec (YAML or JSON). Required. */\n input: string;\n /** Output directory (relative to workspace root). Required. */\n output: string;\n /** Output mode. Defaults to `\"standalone\"`. */\n mode?: SdkOutputMode;\n /** Optional human-readable name used for logs & the generated `Api` class. */\n clientName?: string;\n /** Package name used when `mode === \"library\"`. */\n packageName?: string;\n /** Package version used when `mode === \"library\"`. Defaults to `0.0.1`. */\n packageVersion?: string;\n /** Default rootUrl baked into ApiConfiguration. Defaults to an empty string for same-origin requests. */\n rootUrl?: string;\n /** Feature toggles. Every feature defaults to `true` except `navigation` (default `true` too). */\n features?: SdkFeatureFlags;\n /**\n * When `true`, reorganize emitted files into one folder per domain (derived\n * from OpenAPI tags). Models shared by multiple domains live in `shared/`,\n * domain-owned models live inside each domain. Default `false` (flat layout).\n */\n splitByDomain?: boolean;\n /**\n * Granularity of `splitByDomain`. Only meaningful when `splitByDomain` is\n * `true`. `'service'` (default) groups every tag under its root parent — one\n * folder per backend service (e.g. all Role/Permission/... tags collapse into\n * `access/`). `'tag'` emits one folder per leaf tag, nested under the parent\n * chain (e.g. `storage/gcs/`, `storage/s3/`, `access/role/`).\n */\n splitDepth?: 'service' | 'tag';\n /** Custom file banner. Defaults to a short auto-generated notice. */\n banner?: string;\n}\n\nexport interface SdkConfig {\n targets: SdkTargetConfig[];\n}\n\nexport interface ResolvedFeatureFlags {\n models: boolean;\n operations: boolean;\n services: boolean;\n client: boolean;\n metadata: boolean;\n navigation: boolean;\n}\n\nexport interface ResolvedSdkTarget {\n input: string;\n output: string;\n mode: SdkOutputMode;\n clientName: string;\n packageName: string;\n packageVersion: string;\n rootUrl: string | undefined;\n features: ResolvedFeatureFlags;\n splitByDomain: boolean;\n splitDepth: 'service' | 'tag';\n banner: string;\n}\n\nconst DEFAULT_BANNER = '/* eslint-disable */\\n/* Auto-generated by @ojiepermana/angular/generator/api. DO NOT EDIT. */';\n\nconst DEFAULT_FEATURES: ResolvedFeatureFlags = {\n models: true,\n operations: true,\n services: true,\n client: true,\n metadata: true,\n navigation: true,\n};\n\nexport function resolveTarget(raw: SdkTargetConfig): ResolvedSdkTarget {\n if (!raw || typeof raw !== 'object') {\n throw new Error('Invalid target: expected object');\n }\n if (!raw.input) throw new Error('Target is missing required \"input\"');\n if (!raw.output) throw new Error('Target is missing required \"output\"');\n\n const mode: SdkOutputMode = raw.mode ?? 'standalone';\n if (!['standalone', 'library', 'secondary-entrypoint'].includes(mode)) {\n throw new Error(`Invalid target mode: ${mode}`);\n }\n\n return {\n input: raw.input,\n output: raw.output,\n mode,\n clientName: raw.clientName ?? 'Api',\n packageName: raw.packageName ?? '@local/sdk',\n packageVersion: raw.packageVersion ?? '0.0.1',\n rootUrl: raw.rootUrl,\n features: { ...DEFAULT_FEATURES, ...(raw.features ?? {}) },\n splitByDomain: raw.splitByDomain === true,\n splitDepth: raw.splitDepth === 'tag' ? 'tag' : 'service',\n banner: raw.banner ?? DEFAULT_BANNER,\n };\n}\n\nexport function resolveConfig(raw: unknown): ResolvedSdkTarget[] {\n if (!raw || typeof raw !== 'object') {\n throw new Error('Invalid SDK config: root must be an object');\n }\n const cfg = raw as SdkConfig;\n if (!Array.isArray(cfg.targets) || cfg.targets.length === 0) {\n throw new Error('Invalid SDK config: \"targets\" must be a non-empty array');\n }\n return cfg.targets.map(resolveTarget);\n}\n","/*\n * Public API Surface of @ojiepermana/angular/generator/api\n *\n * This secondary entrypoint is primarily consumed as an Angular schematic\n * collection (`init` and `sdk`). The TypeScript surface intentionally stays\n * small and Node-free so it can be published inside the main library package.\n */\n\nexport type {\n ResolvedFeatureFlags,\n ResolvedSdkTarget,\n SdkConfig,\n SdkFeatureFlags,\n SdkOutputMode,\n SdkTargetConfig,\n} from './src/config/schema';\nexport { resolveConfig, resolveTarget } from './src/config/schema';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AAiFH,MAAM,cAAc,GAAG,gGAAgG;AAEvH,MAAM,gBAAgB,GAAyB;AAC7C,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,UAAU,EAAE,IAAI;CACjB;AAEK,SAAU,aAAa,CAAC,GAAoB,EAAA;IAChD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;AACnC,QAAA,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC;IACpD;IACA,IAAI,CAAC,GAAG,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CA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MAAM,KAAK,CAAC,EAAE;AAC3D,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAC5E;IACA,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACvC;;ACtIA;;;;;;AAMG;;ACNH;;AAEG;;;;"}
|
package/generator/api/README.md
CHANGED
|
@@ -76,7 +76,7 @@ ng generate @ojiepermana/angular:sdk [--dry-run] [--config=sdk.config.json]
|
|
|
76
76
|
"clientName": "Api",
|
|
77
77
|
"packageName": "@my-scope/sdk", // only used in "library" mode
|
|
78
78
|
"packageVersion": "0.0.1", // only used in "library" mode
|
|
79
|
-
"rootUrl": "
|
|
79
|
+
"rootUrl": "", // optional; empty string means same-origin requests
|
|
80
80
|
"splitByDomain": false, // optional, default false — see "Per-domain layout"
|
|
81
81
|
"splitDepth": "service", // "service" (default) | "tag"
|
|
82
82
|
"features": {
|
|
@@ -94,6 +94,41 @@ ng generate @ojiepermana/angular:sdk [--dry-run] [--config=sdk.config.json]
|
|
|
94
94
|
|
|
95
95
|
Multiple targets are supported — one config run can emit several SDKs.
|
|
96
96
|
|
|
97
|
+
If `rootUrl` is omitted or left empty, the generated SDK uses same-origin
|
|
98
|
+
requests by default. Consumer apps can override it at runtime with
|
|
99
|
+
`provideApiConfiguration(...)`.
|
|
100
|
+
|
|
101
|
+
### Runtime base URL
|
|
102
|
+
|
|
103
|
+
The generated SDK does not read `sdk.config.json` at runtime. The value of
|
|
104
|
+
`targets[].rootUrl` is only used during code generation to seed the default
|
|
105
|
+
`ApiConfiguration.rootUrl` value.
|
|
106
|
+
|
|
107
|
+
- `rootUrl: ""` or omitted: requests use the current origin, for example
|
|
108
|
+
`/api/users` on the same host as the Angular app.
|
|
109
|
+
- `rootUrl: "https://api.example.com"`: the generated SDK defaults to that
|
|
110
|
+
absolute backend URL.
|
|
111
|
+
- Runtime override: consumer apps can replace the default by providing a new
|
|
112
|
+
value during bootstrap.
|
|
113
|
+
|
|
114
|
+
Example runtime override in a consumer app:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
118
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
119
|
+
|
|
120
|
+
import { AppComponent } from './app/app.component';
|
|
121
|
+
import { provideApiConfiguration } from '@my-scope/sdk';
|
|
122
|
+
|
|
123
|
+
bootstrapApplication(AppComponent, {
|
|
124
|
+
providers: [provideHttpClient(), provideApiConfiguration('https://api.example.com')],
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For standalone generated output inside the same workspace, import
|
|
129
|
+
`provideApiConfiguration` from the generated SDK barrel instead of an npm
|
|
130
|
+
package path.
|
|
131
|
+
|
|
97
132
|
## Per-domain layout
|
|
98
133
|
|
|
99
134
|
By default the generator emits a flat layout (`models/`, `fn/`, `services/`, …
|
|
@@ -12,10 +12,10 @@ const template_1 = require("../render/template");
|
|
|
12
12
|
*
|
|
13
13
|
* These files are **static** — identical across specs — so we embed them as
|
|
14
14
|
* template literals rather than parsing the IR. The only dynamic bits are the
|
|
15
|
-
* banner comment and the default `rootUrl`.
|
|
15
|
+
* banner comment and the configured default `rootUrl`.
|
|
16
16
|
*/
|
|
17
|
-
function emitClient(
|
|
18
|
-
const defaultRootUrl = target.rootUrl ??
|
|
17
|
+
function emitClient(target) {
|
|
18
|
+
const defaultRootUrl = target.rootUrl ?? '';
|
|
19
19
|
return [
|
|
20
20
|
{ path: 'api-configuration.ts', content: (0, template_1.finalize)(apiConfigurationFile(target, defaultRootUrl)) },
|
|
21
21
|
{ path: 'base-service.ts', content: (0, template_1.finalize)(baseServiceFile(target)) },
|
|
@@ -24,7 +24,7 @@ async function generate(target, workspaceRoot) {
|
|
|
24
24
|
const ir = (0, ir_1.buildIR)(doc);
|
|
25
25
|
const files = [];
|
|
26
26
|
if (target.features.client)
|
|
27
|
-
files.push(...(0, client_1.emitClient)(
|
|
27
|
+
files.push(...(0, client_1.emitClient)(target));
|
|
28
28
|
if (target.features.models)
|
|
29
29
|
files.push(...(0, models_1.emitModels)(ir, target));
|
|
30
30
|
if (target.features.operations)
|
|
@@ -27,9 +27,9 @@ function writeLibrary(files, ir, target) {
|
|
|
27
27
|
version: target.packageVersion,
|
|
28
28
|
description: `Generated SDK for ${ir.title} ${ir.version}`,
|
|
29
29
|
peerDependencies: {
|
|
30
|
-
'@angular/common': '>=
|
|
31
|
-
'@angular/core': '>=
|
|
32
|
-
rxjs: '>=7.
|
|
30
|
+
'@angular/common': '>=21.2.0',
|
|
31
|
+
'@angular/core': '>=21.2.0',
|
|
32
|
+
rxjs: '>=7.8.0',
|
|
33
33
|
},
|
|
34
34
|
sideEffects: false,
|
|
35
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ojiepermana/angular",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ojiepermana/angular.git"
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"url": "https://github.com/ojiepermana/angular/issues"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@angular/common": "
|
|
14
|
-
"@angular/core": "
|
|
15
|
-
"@angular/forms": "
|
|
16
|
-
"@angular/router": "
|
|
17
|
-
"@angular/cdk": "
|
|
18
|
-
"@angular/material": "
|
|
19
|
-
"rxjs": "
|
|
13
|
+
"@angular/common": ">=21.2.0",
|
|
14
|
+
"@angular/core": ">=21.2.0",
|
|
15
|
+
"@angular/forms": ">=21.2.0",
|
|
16
|
+
"@angular/router": ">=21.2.0",
|
|
17
|
+
"@angular/cdk": ">=21.2.7",
|
|
18
|
+
"@angular/material": ">=21.2.7",
|
|
19
|
+
"rxjs": ">=7.8.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"@angular/forms": {
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@angular-devkit/schematics": "^21.2.7",
|
|
36
37
|
"class-variance-authority": "^0.7.1",
|
|
37
38
|
"clsx": "^2.1.1",
|
|
38
39
|
"d3-array": "^3.2.4",
|
|
39
40
|
"d3-scale": "^4.0.2",
|
|
40
41
|
"d3-shape": "^3.2.0",
|
|
41
|
-
"marked": "^
|
|
42
|
+
"marked": "^18.0.2",
|
|
42
43
|
"tailwind-merge": "^3.5.0",
|
|
43
44
|
"tslib": "^2.8.1",
|
|
44
45
|
"yaml": "^2.8.3"
|
|
@@ -33,7 +33,7 @@ interface SdkTargetConfig {
|
|
|
33
33
|
packageName?: string;
|
|
34
34
|
/** Package version used when `mode === "library"`. Defaults to `0.0.1`. */
|
|
35
35
|
packageVersion?: string;
|
|
36
|
-
/** Default rootUrl baked into ApiConfiguration. Defaults to
|
|
36
|
+
/** Default rootUrl baked into ApiConfiguration. Defaults to an empty string for same-origin requests. */
|
|
37
37
|
rootUrl?: string;
|
|
38
38
|
/** Feature toggles. Every feature defaults to `true` except `navigation` (default `true` too). */
|
|
39
39
|
features?: SdkFeatureFlags;
|