@ojiepermana/angular 21.0.0 → 21.0.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.
Files changed (47) hide show
  1. package/collection.json +25 -0
  2. package/fesm2022/ojiepermana-angular-generator-api.mjs +67 -0
  3. package/fesm2022/ojiepermana-angular-generator-api.mjs.map +1 -0
  4. package/fesm2022/ojiepermana-angular-layout.mjs +76 -56
  5. package/fesm2022/ojiepermana-angular-layout.mjs.map +1 -1
  6. package/fesm2022/ojiepermana-angular.mjs +1 -0
  7. package/fesm2022/ojiepermana-angular.mjs.map +1 -1
  8. package/generator/api/README.md +183 -0
  9. package/generator/api/bin/schematics/init/index.js +88 -0
  10. package/generator/api/bin/schematics/sdk/index.js +58 -0
  11. package/generator/api/bin/src/config/loader.js +41 -0
  12. package/generator/api/bin/src/config/schema.js +56 -0
  13. package/generator/api/bin/src/emit/client.js +246 -0
  14. package/generator/api/bin/src/emit/metadata.js +295 -0
  15. package/generator/api/bin/src/emit/models.js +106 -0
  16. package/generator/api/bin/src/emit/navigation.js +56 -0
  17. package/generator/api/bin/src/emit/operations.js +122 -0
  18. package/generator/api/bin/src/emit/public-api.js +54 -0
  19. package/generator/api/bin/src/emit/services.js +87 -0
  20. package/generator/api/bin/src/engine.js +65 -0
  21. package/generator/api/bin/src/layout/per-domain.js +346 -0
  22. package/generator/api/bin/src/parser/bundle.js +25 -0
  23. package/generator/api/bin/src/parser/ir.js +320 -0
  24. package/generator/api/bin/src/parser/types.js +7 -0
  25. package/generator/api/bin/src/render/template.js +58 -0
  26. package/generator/api/bin/src/writer/index.js +69 -0
  27. package/generator/api/schematics/init/schema.json +19 -0
  28. package/generator/api/schematics/sdk/schema.json +19 -0
  29. package/generator/api/sdk.config.example.json +22 -0
  30. package/generator/guide/README.md +84 -0
  31. package/generator/guide/bin/schematics/build/index.js +35 -0
  32. package/generator/guide/bin/schematics/init/index.js +70 -0
  33. package/generator/guide/bin/src/config/loader.js +50 -0
  34. package/generator/guide/bin/src/config/schema.js +12 -0
  35. package/generator/guide/bin/src/engine/component.js +73 -0
  36. package/generator/guide/bin/src/engine/frontmatter.js +42 -0
  37. package/generator/guide/bin/src/engine/index.js +42 -0
  38. package/generator/guide/bin/src/engine/naming.js +39 -0
  39. package/generator/guide/bin/src/engine/render.js +18 -0
  40. package/generator/guide/bin/src/engine/routes.js +106 -0
  41. package/generator/guide/bin/src/engine/walk.js +35 -0
  42. package/generator/guide/guide.config.example.json +9 -0
  43. package/generator/guide/schematics/build/schema.json +14 -0
  44. package/generator/guide/schematics/init/schema.json +19 -0
  45. package/package.json +10 -3
  46. package/types/ojiepermana-angular-generator-api.d.ts +85 -0
  47. package/types/ojiepermana-angular-layout.d.ts +2 -0
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitServices = emitServices;
4
+ const template_1 = require("../render/template");
5
+ /**
6
+ * Emit one Injectable service per tag at `services/<tag-kebab>.service.ts`.
7
+ *
8
+ * Each method returns `Observable<T>` (body-only) plus a `<method>$Response`
9
+ * variant that returns the full `StrictHttpResponse<T>`. Bodies are dispatched
10
+ * through the tree-shakeable fn modules emitted by {@link emitOperations}, so
11
+ * unused methods can be shaken out.
12
+ */
13
+ function emitServices(ir, target) {
14
+ const byTag = groupByTag(ir.operations);
15
+ const files = [];
16
+ for (const [tag, ops] of byTag) {
17
+ files.push({
18
+ path: `services/${(0, template_1.kebabCase)(tag)}.service.ts`,
19
+ content: (0, template_1.finalize)(renderService(tag, ops, target)),
20
+ });
21
+ }
22
+ return files;
23
+ }
24
+ function groupByTag(operations) {
25
+ const map = new Map();
26
+ for (const op of operations) {
27
+ const bucket = map.get(op.tag) ?? [];
28
+ bucket.push(op);
29
+ map.set(op.tag, bucket);
30
+ }
31
+ return map;
32
+ }
33
+ function renderService(tag, ops, target) {
34
+ const className = `${(0, template_1.pascalCase)(tag)}Service`;
35
+ const sorted = [...ops].sort((a, b) => a.operationId.localeCompare(b.operationId));
36
+ const fnImports = [];
37
+ const modelImports = new Set();
38
+ for (const op of sorted) {
39
+ const fnName = (0, template_1.camelCase)(op.operationId);
40
+ const paramsName = `${(0, template_1.pascalCase)(op.operationId)}$Params`;
41
+ fnImports.push(`import { ${fnName}, type ${paramsName} } from '../fn/${(0, template_1.kebabCase)(tag)}/${(0, template_1.kebabCase)(op.operationId)}';`);
42
+ if (op.successRef)
43
+ modelImports.add(op.successRef);
44
+ }
45
+ const modelImportLines = [...modelImports]
46
+ .sort()
47
+ .map((ref) => `import type { ${(0, template_1.pascalCase)(ref)} } from '../models/${(0, template_1.kebabCase)(ref)}';`);
48
+ const methods = sorted.map((op) => renderMethod(op)).join('\n\n');
49
+ return `${target.banner}
50
+
51
+ import { HttpContext, HttpResponse } from '@angular/common/http';
52
+ import { Injectable } from '@angular/core';
53
+ import { Observable } from 'rxjs';
54
+ import { filter, map } from 'rxjs/operators';
55
+
56
+ import { BaseService } from '../base-service';
57
+ import { StrictHttpResponse } from '../strict-http-response';
58
+
59
+ ${fnImports.join('\n')}
60
+ ${modelImportLines.length ? '\n' + modelImportLines.join('\n') : ''}
61
+
62
+ @Injectable({ providedIn: 'root' })
63
+ export class ${className} extends BaseService {
64
+ ${methods}
65
+ }
66
+ `;
67
+ }
68
+ function renderMethod(op) {
69
+ const fnName = (0, template_1.camelCase)(op.operationId);
70
+ const paramsName = `${(0, template_1.pascalCase)(op.operationId)}$Params`;
71
+ const responseType = op.successRef ? (0, template_1.pascalCase)(op.successRef) : 'unknown';
72
+ const hasParams = op.params.length > 0 || Boolean(op.bodySchemaRef);
73
+ const anyRequired = op.params.some((p) => p.required) || (op.bodySchemaRef != null && op.bodyRequired);
74
+ const paramsSig = hasParams ? `params${anyRequired ? '' : '?'}: ${paramsName}` : `params?: ${paramsName}`;
75
+ return ` /** ${op.summary ?? op.operationId} (${op.method.toUpperCase()} ${op.path}) */
76
+ ${fnName}$Response(${paramsSig}, context?: HttpContext): Observable<StrictHttpResponse<${responseType}>> {
77
+ return ${fnName}(this.http, this.rootUrl, params as ${paramsName}, context).pipe(
78
+ filter((r: unknown): r is HttpResponse<unknown> => r instanceof HttpResponse),
79
+ map((r) => r as StrictHttpResponse<${responseType}>),
80
+ );
81
+ }
82
+
83
+ /** ${op.summary ?? op.operationId} (${op.method.toUpperCase()} ${op.path}) */
84
+ ${fnName}(${paramsSig}, context?: HttpContext): Observable<${responseType}> {
85
+ return this.${fnName}$Response(params as ${paramsName}, context).pipe(map((r) => r.body));
86
+ }`;
87
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = generate;
4
+ const node_path_1 = require("node:path");
5
+ const client_1 = require("./emit/client");
6
+ const metadata_1 = require("./emit/metadata");
7
+ const models_1 = require("./emit/models");
8
+ const navigation_1 = require("./emit/navigation");
9
+ const operations_1 = require("./emit/operations");
10
+ const public_api_1 = require("./emit/public-api");
11
+ const services_1 = require("./emit/services");
12
+ const per_domain_1 = require("./layout/per-domain");
13
+ const ir_1 = require("./parser/ir");
14
+ const bundle_1 = require("./parser/bundle");
15
+ const index_1 = require("./writer/index");
16
+ /**
17
+ * Run the generator for a single resolved target. Pure in the sense that it
18
+ * does **not** touch the filesystem — the caller is expected to materialize
19
+ * `result.files` either into an Angular schematic `Tree` or onto disk.
20
+ */
21
+ async function generate(target, workspaceRoot) {
22
+ const specPath = (0, node_path_1.isAbsolute)(target.input) ? target.input : (0, node_path_1.resolve)(workspaceRoot, target.input);
23
+ const doc = await (0, bundle_1.loadSpec)(specPath);
24
+ const ir = (0, ir_1.buildIR)(doc);
25
+ const files = [];
26
+ if (target.features.client)
27
+ files.push(...(0, client_1.emitClient)(ir, target));
28
+ if (target.features.models)
29
+ files.push(...(0, models_1.emitModels)(ir, target));
30
+ if (target.features.operations)
31
+ files.push(...(0, operations_1.emitOperations)(ir, target));
32
+ if (target.features.services)
33
+ files.push(...(0, services_1.emitServices)(ir, target));
34
+ if (target.features.metadata)
35
+ files.push(...(0, metadata_1.emitMetadata)(ir, target));
36
+ if (target.features.navigation)
37
+ files.push(...(0, navigation_1.emitNavigation)(ir, target));
38
+ // public-api barrel is emitted last so it sees the final feature set.
39
+ files.push(...(0, public_api_1.emitPublicApi)(ir, target));
40
+ const laidOut = target.splitByDomain ? (0, per_domain_1.relayoutPerDomain)(files, ir, target) : files;
41
+ const wrapped = applyMode(laidOut, ir, target);
42
+ const outputDir = (0, node_path_1.isAbsolute)(target.output) ? target.output : (0, node_path_1.resolve)(workspaceRoot, target.output);
43
+ return {
44
+ target,
45
+ outputDir,
46
+ files: wrapped,
47
+ stats: {
48
+ schemas: ir.schemas.length,
49
+ operations: ir.operations.length,
50
+ tags: new Set(ir.operations.map((o) => o.tag)).size,
51
+ files: wrapped.length,
52
+ },
53
+ };
54
+ }
55
+ function applyMode(files, ir, target) {
56
+ switch (target.mode) {
57
+ case 'library':
58
+ return (0, index_1.writeLibrary)(files, ir, target);
59
+ case 'secondary-entrypoint':
60
+ return (0, index_1.writeSecondaryEntrypoint)(files, ir, target);
61
+ case 'standalone':
62
+ default:
63
+ return (0, index_1.writeStandalone)(files);
64
+ }
65
+ }
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relayoutPerDomain = relayoutPerDomain;
4
+ /**
5
+ * Post-emit transform that reorganises the flat generator output into a
6
+ * per-domain layout:
7
+ *
8
+ * ```
9
+ * <outputDir>/
10
+ * shared/ client primitives, shared models, metadata, validators
11
+ * <domain>/ one folder per OpenAPI tag (kebab-cased)
12
+ * models/ models only referenced by this domain
13
+ * fn/ tree-shakeable operation functions for this domain
14
+ * services/ Injectable service class(es) for this domain
15
+ * permissions/ per-tag permission rules
16
+ * public-api.ts
17
+ * public-api.ts aggregator: re-exports shared + every domain
18
+ * ```
19
+ *
20
+ * The emitters themselves are not aware of the transform — they keep producing
21
+ * flat paths and relative imports. This module walks the emitted virtual files,
22
+ * rewrites their paths, and patches relative imports so everything still lines
23
+ * up.
24
+ */
25
+ const node_path_1 = require("node:path");
26
+ const template_1 = require("../render/template");
27
+ const SHARED = 'shared';
28
+ const VIRTUAL_ROOT = '/__sdk__';
29
+ function relayoutPerDomain(files, ir, target) {
30
+ const mapping = computeMapping(files, ir, target);
31
+ // 1. Rewrite paths + relative imports, drop the original public-api.ts so we
32
+ // can regenerate it with domain awareness.
33
+ const rewritten = [];
34
+ for (const file of files) {
35
+ if (file.path === 'public-api.ts')
36
+ continue;
37
+ const newPath = mapping.oldToNew.get(file.path);
38
+ if (!newPath)
39
+ continue;
40
+ rewritten.push({
41
+ path: newPath,
42
+ content: rewriteImports(file.content, file.path, newPath, mapping.oldToNew),
43
+ });
44
+ }
45
+ // 2. Emit per-domain + root public-api.ts.
46
+ rewritten.push(...emitPublicApis(ir, target, mapping));
47
+ return rewritten;
48
+ }
49
+ function computeMapping(files, ir, target) {
50
+ // Domain per tag. Two strategies are supported, selected by
51
+ // `target.splitDepth`:
52
+ //
53
+ // 'service' (default): walk each tag's `parent` chain up to the root and
54
+ // use the kebab-cased root name. Every tag collapses into its owning
55
+ // backend service (e.g. `Role`, `Permission`, `Role Permission` →
56
+ // `access`; `Approval Definition`, `Approval Stage`, ... → `approval`;
57
+ // `GCS`, `S3` → `storage`).
58
+ //
59
+ // 'tag': emit one folder per leaf tag, nested under the parent chain so
60
+ // related tags stay grouped (e.g. `storage/gcs`, `storage/s3`,
61
+ // `access/role`, `access/role-permission`). Tags without a parent
62
+ // become a single-segment path (e.g. `auth`).
63
+ //
64
+ // In both cases the resulting string may contain `/` and is treated as a
65
+ // relative path. Collect operation + service lookups up front so callers
66
+ // can iterate without re-scanning.
67
+ const tagByName = new Map(ir.tags.map((t) => [t.name, t]));
68
+ const tagChain = (name) => {
69
+ const chain = [];
70
+ const seen = new Set();
71
+ let current = name;
72
+ while (current && !seen.has(current)) {
73
+ seen.add(current);
74
+ chain.push(current);
75
+ current = tagByName.get(current)?.parent;
76
+ }
77
+ return chain.reverse();
78
+ };
79
+ const domainForTag = (tag) => {
80
+ const chain = tagChain(tag);
81
+ if (chain.length === 0)
82
+ return SHARED;
83
+ if (target.splitDepth === 'tag') {
84
+ return (chain
85
+ .map((segment) => (0, template_1.kebabCase)(segment))
86
+ .filter(Boolean)
87
+ .join('/') || SHARED);
88
+ }
89
+ return (0, template_1.kebabCase)(chain[0]) || SHARED;
90
+ };
91
+ const domainOperations = new Map();
92
+ const domainServices = new Map();
93
+ const tagToDomain = new Map();
94
+ for (const op of ir.operations) {
95
+ const domain = domainForTag(op.tag);
96
+ tagToDomain.set(op.tag, domain);
97
+ const ops = domainOperations.get(domain) ?? [];
98
+ ops.push(op.operationId);
99
+ domainOperations.set(domain, ops);
100
+ const svcs = domainServices.get(domain) ?? [];
101
+ if (!svcs.includes(op.tag))
102
+ svcs.push(op.tag);
103
+ domainServices.set(domain, svcs);
104
+ }
105
+ const domains = [...domainOperations.keys()].sort();
106
+ // Model ownership: a model belongs to a domain only if it is exclusively
107
+ // referenced by that domain's operations (directly or transitively).
108
+ const modelDomains = new Map();
109
+ const markModel = (name, domain) => {
110
+ let set = modelDomains.get(name);
111
+ if (!set) {
112
+ set = new Set();
113
+ modelDomains.set(name, set);
114
+ }
115
+ set.add(domain);
116
+ };
117
+ for (const op of ir.operations) {
118
+ const domain = tagToDomain.get(op.tag) ?? SHARED;
119
+ for (const p of op.params) {
120
+ if (p.rule.ref)
121
+ markModel(p.rule.ref, domain);
122
+ if (p.rule.itemsRef)
123
+ markModel(p.rule.itemsRef, domain);
124
+ }
125
+ if (op.bodySchemaRef)
126
+ markModel(op.bodySchemaRef, domain);
127
+ if (op.successRef)
128
+ markModel(op.successRef, domain);
129
+ }
130
+ // Transitive closure: a model's nested refs inherit its domain set.
131
+ const schemaByName = new Map(ir.schemas.map((s) => [s.name, s]));
132
+ let changed = true;
133
+ while (changed) {
134
+ changed = false;
135
+ for (const [name, domains] of [...modelDomains]) {
136
+ const schema = schemaByName.get(name);
137
+ if (!schema)
138
+ continue;
139
+ const refs = new Set();
140
+ if (schema.arrayItemRef)
141
+ refs.add(schema.arrayItemRef);
142
+ for (const rule of Object.values(schema.properties)) {
143
+ if (rule.ref)
144
+ refs.add(rule.ref);
145
+ if (rule.itemsRef)
146
+ refs.add(rule.itemsRef);
147
+ }
148
+ for (const ref of refs) {
149
+ let target = modelDomains.get(ref);
150
+ if (!target) {
151
+ target = new Set();
152
+ modelDomains.set(ref, target);
153
+ }
154
+ for (const d of domains) {
155
+ if (!target.has(d)) {
156
+ target.add(d);
157
+ changed = true;
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ const modelOwner = new Map();
164
+ for (const schema of ir.schemas) {
165
+ const set = modelDomains.get(schema.name);
166
+ if (!set || set.size !== 1)
167
+ modelOwner.set(schema.name, SHARED);
168
+ else
169
+ modelOwner.set(schema.name, [...set][0]);
170
+ }
171
+ // Build old → new path map.
172
+ const oldToNew = new Map();
173
+ const kebabToSchema = new Map(ir.schemas.map((s) => [(0, template_1.kebabCase)(s.name), s.name]));
174
+ for (const file of files) {
175
+ const np = computeNewPath(file.path, {
176
+ modelOwner,
177
+ kebabToSchema,
178
+ tagToDomain,
179
+ });
180
+ if (np)
181
+ oldToNew.set(file.path, np);
182
+ }
183
+ return { oldToNew, modelOwner, domains, domainOperations, domainServices };
184
+ }
185
+ function computeNewPath(oldPath, ctx) {
186
+ // Root-level client primitives → shared/.
187
+ const rootShared = new Set([
188
+ 'api-configuration.ts',
189
+ 'base-service.ts',
190
+ 'request-builder.ts',
191
+ 'strict-http-response.ts',
192
+ 'api.ts',
193
+ 'api.navigation.ts',
194
+ 'metadata.ts',
195
+ 'metadata-types.ts',
196
+ 'openapi-helpers.ts',
197
+ ]);
198
+ if (rootShared.has(oldPath))
199
+ return `${SHARED}/${oldPath}`;
200
+ if (oldPath.startsWith('models/')) {
201
+ const kebab = oldPath.slice('models/'.length).replace(/\.ts$/, '');
202
+ const name = ctx.kebabToSchema.get(kebab);
203
+ const owner = (name && ctx.modelOwner.get(name)) || SHARED;
204
+ return `${owner}/models/${kebab}.ts`;
205
+ }
206
+ if (oldPath.startsWith('fn/')) {
207
+ // fn/<tag-kebab>/<op-kebab>.ts → <domain>/fn/<op-kebab>.ts
208
+ const parts = oldPath.split('/');
209
+ if (parts.length < 3)
210
+ return undefined;
211
+ const tagKebab = parts[1];
212
+ const fileName = parts.slice(2).join('/');
213
+ const domain = findDomainFromKebab(tagKebab, ctx.tagToDomain);
214
+ return `${domain}/fn/${fileName}`;
215
+ }
216
+ if (oldPath.startsWith('services/')) {
217
+ const fileName = oldPath.slice('services/'.length);
218
+ const tagKebab = fileName.replace(/\.service\.ts$/, '');
219
+ const domain = findDomainFromKebab(tagKebab, ctx.tagToDomain);
220
+ return `${domain}/services/${fileName}`;
221
+ }
222
+ if (oldPath === 'permissions/index.ts')
223
+ return `${SHARED}/permissions/index.ts`;
224
+ if (oldPath.startsWith('permissions/')) {
225
+ const fileName = oldPath.slice('permissions/'.length);
226
+ const tagKebab = fileName.replace(/\.ts$/, '');
227
+ const domain = findDomainFromKebab(tagKebab, ctx.tagToDomain);
228
+ return `${domain}/permissions/${fileName}`;
229
+ }
230
+ if (oldPath.startsWith('validators/'))
231
+ return `${SHARED}/${oldPath}`;
232
+ return undefined;
233
+ }
234
+ function findDomainFromKebab(tagKebab, tagToDomain) {
235
+ for (const [tag, domain] of tagToDomain) {
236
+ if ((0, template_1.kebabCase)(tag) === tagKebab)
237
+ return domain;
238
+ }
239
+ return tagKebab || SHARED;
240
+ }
241
+ function rewriteImports(content, oldPath, newPath, oldToNew) {
242
+ const oldAbs = node_path_1.posix.join(VIRTUAL_ROOT, oldPath);
243
+ const newAbs = node_path_1.posix.join(VIRTUAL_ROOT, newPath);
244
+ const oldDir = (0, node_path_1.dirname)(oldAbs);
245
+ const newDir = (0, node_path_1.dirname)(newAbs);
246
+ const replaceRelative = (spec) => {
247
+ if (!spec.startsWith('./') && !spec.startsWith('../'))
248
+ return spec;
249
+ // Resolve target old absolute (append `.ts` candidates).
250
+ const resolved = node_path_1.posix.normalize(node_path_1.posix.join(oldDir, spec));
251
+ const candidates = [`${resolved}.ts`, `${resolved}/index.ts`, resolved];
252
+ for (const cand of candidates) {
253
+ const rel = cand.startsWith(VIRTUAL_ROOT + '/') ? cand.slice(VIRTUAL_ROOT.length + 1) : null;
254
+ if (!rel)
255
+ continue;
256
+ const np = oldToNew.get(rel);
257
+ if (!np)
258
+ continue;
259
+ const targetAbs = node_path_1.posix.join(VIRTUAL_ROOT, np);
260
+ let nextSpec = node_path_1.posix.relative(newDir, targetAbs).replace(/\.ts$/, '');
261
+ if (!nextSpec.startsWith('.'))
262
+ nextSpec = `./${nextSpec}`;
263
+ return nextSpec;
264
+ }
265
+ return spec;
266
+ };
267
+ return content.replace(/(from\s+['"])([^'"]+)(['"])/g, (_m, a, spec, c) => `${a}${replaceRelative(spec)}${c}`);
268
+ }
269
+ function emitPublicApis(ir, target, mapping) {
270
+ const out = [];
271
+ const schemaNames = ir.schemas.map((s) => s.name);
272
+ // shared/public-api.ts — client primitives + shared models + metadata.
273
+ const sharedLines = [target.banner, ''];
274
+ if (target.features.client) {
275
+ sharedLines.push(`export { ApiConfiguration, provideApiConfiguration } from './api-configuration';`);
276
+ sharedLines.push(`export { BaseService } from './base-service';`);
277
+ sharedLines.push(`export { RequestBuilder } from './request-builder';`);
278
+ sharedLines.push(`export type { StrictHttpResponse } from './strict-http-response';`);
279
+ sharedLines.push(`export { ${target.clientName} } from './api';`);
280
+ sharedLines.push('');
281
+ }
282
+ if (target.features.models) {
283
+ const sharedModels = schemaNames.filter((n) => mapping.modelOwner.get(n) === SHARED);
284
+ for (const name of sharedModels) {
285
+ sharedLines.push(`export type { ${(0, template_1.pascalCase)(name)} } from './models/${(0, template_1.kebabCase)(name)}';`);
286
+ }
287
+ if (sharedModels.length)
288
+ sharedLines.push('');
289
+ }
290
+ if (target.features.metadata) {
291
+ sharedLines.push(`export * from './metadata';`);
292
+ sharedLines.push(`export * from './openapi-helpers';`);
293
+ sharedLines.push('');
294
+ }
295
+ if (target.features.navigation) {
296
+ sharedLines.push(`export { ApiNavigation } from './api.navigation';`);
297
+ }
298
+ out.push({ path: `${SHARED}/public-api.ts`, content: (0, template_1.finalize)(sharedLines.join('\n')) });
299
+ // Per-domain public-api.ts.
300
+ for (const domain of mapping.domains) {
301
+ const lines = [target.banner, ''];
302
+ // Re-export shared namespace for convenience. `domain` may be nested
303
+ // (e.g. `storage/gcs`), so compute the relative path instead of
304
+ // hard-coding `../shared/public-api`.
305
+ const domainDir = node_path_1.posix.join(VIRTUAL_ROOT, domain);
306
+ const sharedTarget = node_path_1.posix.join(VIRTUAL_ROOT, SHARED, 'public-api');
307
+ let sharedSpec = node_path_1.posix.relative(domainDir, sharedTarget);
308
+ if (!sharedSpec.startsWith('.'))
309
+ sharedSpec = `./${sharedSpec}`;
310
+ lines.push(`export * from '${sharedSpec}';`);
311
+ lines.push('');
312
+ if (target.features.models) {
313
+ const ownedModels = schemaNames.filter((n) => mapping.modelOwner.get(n) === domain);
314
+ for (const name of ownedModels) {
315
+ lines.push(`export type { ${(0, template_1.pascalCase)(name)} } from './models/${(0, template_1.kebabCase)(name)}';`);
316
+ }
317
+ if (ownedModels.length)
318
+ lines.push('');
319
+ }
320
+ if (target.features.services) {
321
+ const tags = mapping.domainServices.get(domain) ?? [];
322
+ for (const tag of tags.sort()) {
323
+ lines.push(`export { ${(0, template_1.pascalCase)(tag)}Service } from './services/${(0, template_1.kebabCase)(tag)}.service';`);
324
+ }
325
+ if (tags.length)
326
+ lines.push('');
327
+ }
328
+ if (target.features.operations) {
329
+ const opIds = (mapping.domainOperations.get(domain) ?? []).slice().sort();
330
+ for (const opId of opIds) {
331
+ const fnName = (0, template_1.camelCase)(opId);
332
+ const paramsName = `${(0, template_1.pascalCase)(opId)}$Params`;
333
+ lines.push(`export { ${fnName}, type ${paramsName} } from './fn/${(0, template_1.kebabCase)(opId)}';`);
334
+ }
335
+ }
336
+ out.push({ path: `${domain}/public-api.ts`, content: (0, template_1.finalize)(lines.join('\n')) });
337
+ }
338
+ // Root public-api.ts aggregates everything.
339
+ const rootLines = [target.banner, ''];
340
+ rootLines.push(`export * from './${SHARED}/public-api';`);
341
+ for (const domain of mapping.domains) {
342
+ rootLines.push(`export * from './${domain}/public-api';`);
343
+ }
344
+ out.push({ path: 'public-api.ts', content: (0, template_1.finalize)(rootLines.join('\n')) });
345
+ return out;
346
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadSpec = loadSpec;
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const yaml_1 = __importDefault(require("yaml"));
10
+ /**
11
+ * Load an OpenAPI spec from disk. We deliberately do NOT run Swagger Parser's
12
+ * strict validator here because it rejects OpenAPI 3.2.x, while the rest of
13
+ * the pipeline only needs structural access to `components` + `paths` (which
14
+ * is version-stable across 3.x). Specs that rely on external `$ref`s should
15
+ * be bundled first with a separate tool.
16
+ *
17
+ * Accepts `.yaml`/`.yml`/`.json`.
18
+ */
19
+ async function loadSpec(path) {
20
+ const text = (0, node_fs_1.readFileSync)(path, 'utf8');
21
+ const ext = (0, node_path_1.extname)(path).toLowerCase();
22
+ if (ext === '.json')
23
+ return JSON.parse(text);
24
+ return yaml_1.default.parse(text);
25
+ }