@haddowg/json-api-codegen 1.14.0 → 1.15.0

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
@@ -127,7 +127,10 @@ The output module exports:
127
127
  - `Links` — the typed declared links of each type that declares any.
128
128
  - `ErrorCodes` / `ErrorCode` / `ErrorCodeByStatus` / `hasErrorCode` — the server's documented
129
129
  error codes and a type guard bound to them.
130
- - `pageLimits` — each collection's page defaults and page-size caps.
130
+ - `pageLimits` / `relatedPageLimits` — the page defaults and page-size caps of each collection and
131
+ each related collection.
132
+ - `pageKinds` / `relatedPageKinds` — the pagination strategies each collection and related
133
+ collection offers, the server's default first.
131
134
 
132
135
  With `--schemas`, the sibling module exports `schemas` — the per-type JSON Schema 2020-12 map.
133
136
 
package/dist/cli.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as CodegenConfig } from "./index-DQ_twN9s.mjs";
1
+ import { r as CodegenConfig } from "./index-FaJ8Xx6v.mjs";
2
2
 
3
3
  //#region src/cli.d.ts
4
4
  declare const USAGE = "Usage: json-api-codegen --input <url|file> --output <file> [--server <name>] [--schemas <url|file>] [--examples] [--check]";
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as generateFiles, t as check } from "./src-7yVCQTGQ.mjs";
2
+ import { i as generateFiles, t as check } from "./src-i5j2I9fk.mjs";
3
3
  import { realpathSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  //#region src/cli.ts
@@ -492,11 +492,39 @@ declare class Emitter {
492
492
  private atomicConst;
493
493
  /**
494
494
  * The `pageLimits` const: per collection, the `default`, `minimum` and `maximum` each `page`
495
- * member declares (generator contract 5 adds the paginator's default and page-size cap). A
496
- * menu nests them under each arm's `kind`. Members declaring none, and collections with no
497
- * such member, are left out. The client never clamps a `page` argument to these.
495
+ * member declares. A menu nests them under each arm's `kind`. Members declaring none, and
496
+ * collections with no such member, are left out. The client never clamps a `page` argument
497
+ * to these.
498
498
  */
499
499
  private pageLimitsConst;
500
+ /**
501
+ * The `relatedPageLimits` const: the `pageLimits` shape for each related collection
502
+ * (`GET /{type}/{id}/{rel}`), keyed by parent type, then by relation name. Relations with no
503
+ * bounded member, and parents left with none, are left out.
504
+ */
505
+ private relatedPageLimitsConst;
506
+ /**
507
+ * The `pageKinds` const: per paginated collection, the strategies its `page` parameter offers,
508
+ * the server's default first.
509
+ */
510
+ private pageKindsConst;
511
+ /**
512
+ * The `relatedPageKinds` const: `pageKinds` for each related collection, keyed by parent type,
513
+ * then by relation name.
514
+ */
515
+ private relatedPageKindsConst;
516
+ /**
517
+ * One line per parent type holding `render`'s value for each relation whose related endpoint
518
+ * it answers for. Relations it skips, and parents left with none, are left out.
519
+ */
520
+ private byRelation;
521
+ /** The `page` parameter schema of the GET at `path`, if it has one. */
522
+ private pageSchema;
523
+ /**
524
+ * A page schema's bounded members as literal lines at `depth` (two spaces per level): flat for
525
+ * one strategy, nested under each arm's `kind` for a menu.
526
+ */
527
+ private pageLimitLines;
500
528
  /** One page schema's members that declare a `default`, `minimum` or `maximum`, as literal lines. */
501
529
  private pageMemberLimits;
502
530
  /**
@@ -735,4 +763,4 @@ declare function generateFiles(config: CodegenConfig): Promise<string[]>;
735
763
  declare function check(config: CodegenConfig): Promise<CheckResult>;
736
764
  //#endregion
737
765
  export { operationExamples as A, PathItemObject as B, VerbCollision as C, MINIMUM_CONTRACT as D, MAXIMUM_CONTRACT as E, InfoObject as F, SecurityRequirement as G, ResponseObject as H, MediaTypeObject as I, SecuritySchemeObject as K, OpenApiDocument as L, buildAtomic as M, buildDescriptor as N, checkContract as O, HttpMethod as P, OperationObject as R, Emitter as S, emit as T, SchemaObject as U, RequestBodyObject as V, SchemaOrBool as W, emitExamples as _, examplesOutputPath as a, emitErrorCodes as b, schemasOutputPath as c, hashJson as d, provenanceLines as f, readSchemas as g, readDocument as h, check as i, DescriptorBuilder as j, buildExamples as k, Provenance as l, SchemaBundle as m, CheckResult as n, generate as o, emitSchemas as p, CodegenConfig as r, generateFiles as s, ArtifactDrift as t, deriveProvenance as u, DocumentedErrorCode as v, detectVerbCollisions as w, readErrorCatalogue as x, ErrorCatalogue as y, ParameterObject as z };
738
- //# sourceMappingURL=index-DQ_twN9s.d.mts.map
766
+ //# sourceMappingURL=index-FaJ8Xx6v.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DQ_twN9s.d.mts","names":[],"sources":["../src/openapi.ts","../src/build-descriptor.ts","../src/build-examples.ts","../src/contract.ts","../src/emit.ts","../src/error-codes.ts","../src/emit-examples.ts","../src/reader.ts","../src/emit-schemas.ts","../src/provenance.ts","../src/index.ts"],"mappings":";;;;;;AAQA;;;;UAAiB,YAAA;EACf,IAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,WAAA;EACA,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,YAAA;EAC5B,KAAA,GAAQ,YAAA;EACR,QAAA;EACA,KAAA,YAAiB,YAAA;EACjB,KAAA,YAAiB,YAAA;EACjB,KAAA,YAAiB,YAAA;EACjB,iBAAA;EACA,qBAAA;EAAA,CACC,GAAA;AAAA;;KAIS,YAAA,GAAe,YAAY;AAAA,UAEtB,eAAA;EACf,MAAA,GAAS,YAAY;EAXrB;EAaA,OAAA;AAAA;AAAA,UAGe,iBAAA;EACf,OAAA,GAAU,MAAM,SAAS,eAAA;EACzB,QAAA;AAAA;AAAA,UAGe,cAAA;EACf,OAAA,GAAU,MAAM,SAAS,eAAA;AAAA;AAAA,UAGV,eAAA;EACf,IAAA;EACA,EAAA;EACA,IAAA;EACA,MAAA,GAAS,YAAY;EACrB,KAAA;EACA,OAAA;EApBqB;EAsBrB,WAAA;AAAA;AAAA,UAGe,eAAA;EACf,WAAA;EACA,OAAA;EACA,WAAA;EACA,UAAA,YAAsB,eAAA;EACtB,WAAA,GAAc,iBAAA;EACd,SAAA,GAAY,MAAA,SAAe,cAAA;EAzB3B;EA2BA,U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oB,EAAZ,YAAY;;;;;ARXhD;;;;USEiB,UAAA;ETMP;EAAA,SSJC,MAAA;ETOQ;EAAA,SSLR,MAAA;ETMoB;EAAA,SSJpB,IAAA;AAAA;;iBAwBK,QAAA,CAAS,KAAc;;;;;;iBAYvB,gBAAA,CAAiB,GAAA,EAAK,eAAA,GAAkB,UAAU;;;;;;iBAelD,eAAA,CAAgB,UAAsB,EAAV,UAAU;;;UC7BrC,aAAA;EVpBE;EUsBjB,KAAA;EVrBiB;EUuBjB,MAAA;EVtBiB;EUwBjB,MAAA;EVtBA;EUwBA,OAAA;EVvBY;AAAA;AAId;;EUwBE,QAAA;EVxBqC;AAAA;AAEvC;;;EU4BE,KAAA;AAAA;;UAIe,aAAA;EV7BR;EU+BP,IAAA;EV5Be;EU8Bf,QAAQ;AAAA;;UAIO,WAAA;EACf,EAAA;EACA,SAAA,EAAW,aAAa;AAAA;;AVlChB;AAGV;;iBUsCgB,iBAAA,CAAkB,MAAc;;iBAWhC,kBAAA,CAAmB,MAAc;;;;AVhDP;AAG1C;;;;;;;;;;;iBUiIsB,QAAA,CAAS,MAAA,EAAQ,aAAA,GAAgB,OAAO;;iBAMxC,aAAA,CAAc,MAAA,EAAQ,aAAA,GAAgB,OAAO;AV5HnE;;;;;;AAAA,iBU+IsB,KAAA,CAAM,MAAA,EAAQ,aAAA,GAAgB,OAAA,CAAQ,WAAA"}
1
+ {"version":3,"file":"index-FaJ8Xx6v.d.mts","names":[],"sources":["../src/openapi.ts","../src/build-descriptor.ts","../src/build-examples.ts","../src/contract.ts","../src/emit.ts","../src/error-codes.ts","../src/emit-examples.ts","../src/reader.ts","../src/emit-schemas.ts","../src/provenance.ts","../src/index.ts"],"mappings":";;;;;;AAQA;;;;UAAiB,YAAA;EACf,IAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,WAAA;EACA,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,YAAA;EAC5B,KAAA,GAAQ,YAAA;EACR,QAAA;EACA,KAAA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AAAA;;UAIe,aAAA;EV7BR;EU+BP,IAAA;EV5Be;EU8Bf,QAAQ;AAAA;;UAIO,WAAA;EACf,EAAA;EACA,SAAA,EAAW,aAAa;AAAA;;AVlChB;AAGV;;iBUsCgB,iBAAA,CAAkB,MAAc;;iBAWhC,kBAAA,CAAmB,MAAc;;;;AVhDP;AAG1C;;;;;;;;;;;iBUiIsB,QAAA,CAAS,MAAA,EAAQ,aAAA,GAAgB,OAAO;;iBAMxC,aAAA,CAAc,MAAA,EAAQ,aAAA,GAAgB,OAAO;AV5HnE;;;;;;AAAA,iBU+IsB,KAAA,CAAM,MAAA,EAAQ,aAAA,GAAgB,OAAA,CAAQ,WAAA"}
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as operationExamples, B as PathItemObject, C as VerbCollision, D as MINIMUM_CONTRACT, E as MAXIMUM_CONTRACT, F as InfoObject, G as SecurityRequirement, H as ResponseObject, I as MediaTypeObject, K as SecuritySchemeObject, L as OpenApiDocument, M as buildAtomic, N as buildDescriptor, O as checkContract, P as HttpMethod, R as OperationObject, S as Emitter, T as emit, U as SchemaObject, V as RequestBodyObject, W as SchemaOrBool, _ as emitExamples, a as examplesOutputPath, b as emitErrorCodes, c as schemasOutputPath, d as hashJson, f as provenanceLines, g as readSchemas, h as readDocument, i as check, j as DescriptorBuilder, k as buildExamples, l as Provenance, m as SchemaBundle, n as CheckResult, o as generate, p as emitSchemas, r as CodegenConfig, s as generateFiles, t as ArtifactDrift, u as deriveProvenance, v as DocumentedErrorCode, w as detectVerbCollisions, x as readErrorCatalogue, y as ErrorCatalogue, z as ParameterObject } from "./index-DQ_twN9s.mjs";
1
+ import { A as operationExamples, B as PathItemObject, C as VerbCollision, D as MINIMUM_CONTRACT, E as MAXIMUM_CONTRACT, F as InfoObject, G as SecurityRequirement, H as ResponseObject, I as MediaTypeObject, K as SecuritySchemeObject, L as OpenApiDocument, M as buildAtomic, N as buildDescriptor, O as checkContract, P as HttpMethod, R as OperationObject, S as Emitter, T as emit, U as SchemaObject, V as RequestBodyObject, W as SchemaOrBool, _ as emitExamples, a as examplesOutputPath, b as emitErrorCodes, c as schemasOutputPath, d as hashJson, f as provenanceLines, g as readSchemas, h as readDocument, i as check, j as DescriptorBuilder, k as buildExamples, l as Provenance, m as SchemaBundle, n as CheckResult, o as generate, p as emitSchemas, r as CodegenConfig, s as generateFiles, t as ArtifactDrift, u as deriveProvenance, v as DocumentedErrorCode, w as detectVerbCollisions, x as readErrorCatalogue, y as ErrorCatalogue, z as ParameterObject } from "./index-FaJ8Xx6v.mjs";
2
2
  export { ArtifactDrift, CheckResult, CodegenConfig, DescriptorBuilder, type DocumentedErrorCode, Emitter, type ErrorCatalogue, type HttpMethod, type InfoObject, MAXIMUM_CONTRACT, MINIMUM_CONTRACT, type MediaTypeObject, type OpenApiDocument, type OperationObject, type ParameterObject, type PathItemObject, type Provenance, type RequestBodyObject, type ResponseObject, type SchemaBundle, type SchemaObject, type SchemaOrBool, type SecurityRequirement, type SecuritySchemeObject, type VerbCollision, buildAtomic, buildDescriptor, buildExamples, check, checkContract, deriveProvenance, detectVerbCollisions, emit, emitErrorCodes, emitExamples, emitSchemas, examplesOutputPath, generate, generateFiles, hashJson, operationExamples, provenanceLines, readDocument, readErrorCatalogue, readSchemas, schemasOutputPath };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as DescriptorBuilder, S as operationExamples, T as buildDescriptor, _ as readErrorCatalogue, a as schemasOutputPath, b as checkContract, c as emitSchemas, d as detectVerbCollisions, f as emit, g as emitErrorCodes, h as provenanceLines, i as generateFiles, l as emitExamples, m as hashJson, n as examplesOutputPath, o as readDocument, p as deriveProvenance, r as generate, s as readSchemas, t as check, u as Emitter, v as MAXIMUM_CONTRACT, w as buildAtomic, x as buildExamples, y as MINIMUM_CONTRACT } from "./src-7yVCQTGQ.mjs";
1
+ import { C as DescriptorBuilder, S as operationExamples, T as buildDescriptor, _ as readErrorCatalogue, a as schemasOutputPath, b as checkContract, c as emitSchemas, d as detectVerbCollisions, f as emit, g as emitErrorCodes, h as provenanceLines, i as generateFiles, l as emitExamples, m as hashJson, n as examplesOutputPath, o as readDocument, p as deriveProvenance, r as generate, s as readSchemas, t as check, u as Emitter, v as MAXIMUM_CONTRACT, w as buildAtomic, x as buildExamples, y as MINIMUM_CONTRACT } from "./src-i5j2I9fk.mjs";
2
2
  export { DescriptorBuilder, Emitter, MAXIMUM_CONTRACT, MINIMUM_CONTRACT, buildAtomic, buildDescriptor, buildExamples, check, checkContract, deriveProvenance, detectVerbCollisions, emit, emitErrorCodes, emitExamples, emitSchemas, examplesOutputPath, generate, generateFiles, hashJson, operationExamples, provenanceLines, readDocument, readErrorCatalogue, readSchemas, schemasOutputPath };
@@ -1604,6 +1604,33 @@ function refName(ref) {
1604
1604
  function isSchema(value) {
1605
1605
  return typeof value === "object" && value !== null;
1606
1606
  }
1607
+ /** A `{ … }` object literal of pre-rendered entry lines, or `{}` when there are none. */
1608
+ function objectBody(lines) {
1609
+ return lines.length === 0 ? "{}" : `{\n${lines.join("\n")}\n}`;
1610
+ }
1611
+ /** The `kind` const a page strategy menu arm is selected by. */
1612
+ function armKind(arm) {
1613
+ const kind = arm.properties?.["kind"];
1614
+ return isSchema(kind) && typeof kind.const === "string" ? kind.const : void 0;
1615
+ }
1616
+ /**
1617
+ * The strategies a page schema offers, as a tuple literal, read from the `x-paginator` stamp: a
1618
+ * single strategy's name, or a menu's arm kinds with its stamped default first. `undefined` when
1619
+ * the schema is absent, unstamped, or a menu whose default is not one of its arms.
1620
+ */
1621
+ function pageKinds(schema) {
1622
+ const stamp = schema?.["x-paginator"];
1623
+ if (typeof stamp !== "object" || stamp === null) return;
1624
+ const { strategy, default: fallback } = stamp;
1625
+ let kinds;
1626
+ if (strategy === "multi") {
1627
+ const arms = (schema?.oneOf ?? []).flatMap((arm) => armKind(arm) ?? []);
1628
+ if (typeof fallback !== "string" || !arms.includes(fallback)) return;
1629
+ kinds = [fallback, ...arms.filter((kind) => kind !== fallback)];
1630
+ } else if (typeof strategy === "string") kinds = [strategy];
1631
+ else return;
1632
+ return `[${kinds.map((kind) => stringLiteral(kind)).join(", ")}]`;
1633
+ }
1607
1634
  /** PascalCase a JSON:API wire type for use in a TS identifier (e.g. `public-profiles` -> `PublicProfiles`). */
1608
1635
  function pascalCase(value) {
1609
1636
  return value.split(/[^a-zA-Z0-9]+/).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
@@ -1960,6 +1987,9 @@ var Emitter = class {
1960
1987
  this.includedAliases(),
1961
1988
  this.atomicConst(),
1962
1989
  this.pageLimitsConst(),
1990
+ this.relatedPageLimitsConst(),
1991
+ this.pageKindsConst(),
1992
+ this.relatedPageKindsConst(),
1963
1993
  emitErrorCodes(readErrorCatalogue(this.doc)),
1964
1994
  this.boundFactory()
1965
1995
  ].join("\n\n")}\n`;
@@ -2291,23 +2321,14 @@ var Emitter = class {
2291
2321
  }
2292
2322
  /**
2293
2323
  * The `pageLimits` const: per collection, the `default`, `minimum` and `maximum` each `page`
2294
- * member declares (generator contract 5 adds the paginator's default and page-size cap). A
2295
- * menu nests them under each arm's `kind`. Members declaring none, and collections with no
2296
- * such member, are left out. The client never clamps a `page` argument to these.
2324
+ * member declares. A menu nests them under each arm's `kind`. Members declaring none, and
2325
+ * collections with no such member, are left out. The client never clamps a `page` argument
2326
+ * to these.
2297
2327
  */
2298
2328
  pageLimitsConst() {
2299
2329
  const typeLines = [];
2300
2330
  for (const type of Object.keys(this.descriptor)) {
2301
- const path = this.descriptor[type].paths["fetchMany"];
2302
- const schema = (path === void 0 ? void 0 : this.doc.paths?.[path]?.get?.parameters)?.find((param) => param.name === "page")?.schema;
2303
- if (schema === void 0) continue;
2304
- let body = [];
2305
- if (schema.oneOf !== void 0) for (const arm of schema.oneOf) {
2306
- const kind = isSchema(arm.properties?.["kind"]) ? arm.properties["kind"].const : void 0;
2307
- const members = this.pageMemberLimits(arm, " ");
2308
- if (typeof kind === "string" && members.length > 0) body.push(` ${propertyKey(kind)}: {\n${members.join("\n")}\n },`);
2309
- }
2310
- else body = this.pageMemberLimits(schema, " ");
2331
+ const body = this.pageLimitLines(this.pageSchema(this.descriptor[type].paths["fetchMany"]), 2);
2311
2332
  if (body.length > 0) typeLines.push(` ${propertyKey(type)}: {\n${body.join("\n")}\n },`);
2312
2333
  }
2313
2334
  return `${[
@@ -2317,7 +2338,96 @@ var Emitter = class {
2317
2338
  " * is absent and `maximum` is the largest value it serves. The client sends the `page` you pass",
2318
2339
  " * unchanged, so read these to bound a page-size picker.",
2319
2340
  " */"
2320
- ].join("\n")}\nexport const pageLimits = ${typeLines.length === 0 ? "{}" : `{\n${typeLines.join("\n")}\n}`} as const`;
2341
+ ].join("\n")}\nexport const pageLimits = ${objectBody(typeLines)} as const`;
2342
+ }
2343
+ /**
2344
+ * The `relatedPageLimits` const: the `pageLimits` shape for each related collection
2345
+ * (`GET /{type}/{id}/{rel}`), keyed by parent type, then by relation name. Relations with no
2346
+ * bounded member, and parents left with none, are left out.
2347
+ */
2348
+ relatedPageLimitsConst() {
2349
+ const lines = this.byRelation((path) => {
2350
+ const body = this.pageLimitLines(this.pageSchema(path), 3);
2351
+ return body.length === 0 ? void 0 : `{\n${body.join("\n")}\n }`;
2352
+ });
2353
+ return `${[
2354
+ "/**",
2355
+ " * The bounds each related collection's `page` parameter declares, keyed by parent type, then by",
2356
+ " * relation name, then as in `pageLimits`: by strategy for a related collection offering several,",
2357
+ " * then by wire key. Relations whose related endpoint declares no bounds are left out.",
2358
+ " */"
2359
+ ].join("\n")}\nexport const relatedPageLimits = ${objectBody(lines)} as const`;
2360
+ }
2361
+ /**
2362
+ * The `pageKinds` const: per paginated collection, the strategies its `page` parameter offers,
2363
+ * the server's default first.
2364
+ */
2365
+ pageKindsConst() {
2366
+ const lines = [];
2367
+ for (const type of Object.keys(this.descriptor)) {
2368
+ const kinds = pageKinds(this.pageSchema(this.descriptor[type].paths["fetchMany"]));
2369
+ if (kinds !== void 0) lines.push(` ${propertyKey(type)}: ${kinds},`);
2370
+ }
2371
+ return `${[
2372
+ "/**",
2373
+ " * The pagination strategies each collection offers, keyed by type. A single strategy is a",
2374
+ " * one-entry tuple; a menu lists its arms' `kind` values with the one the server uses when the",
2375
+ " * request names none first. Unpaginated collections are left out.",
2376
+ " */"
2377
+ ].join("\n")}\nexport const pageKinds = ${objectBody(lines)} as const`;
2378
+ }
2379
+ /**
2380
+ * The `relatedPageKinds` const: `pageKinds` for each related collection, keyed by parent type,
2381
+ * then by relation name.
2382
+ */
2383
+ relatedPageKindsConst() {
2384
+ const lines = this.byRelation((path) => pageKinds(this.pageSchema(path)));
2385
+ return `${[
2386
+ "/**",
2387
+ " * The pagination strategies each related collection offers, keyed by parent type, then by",
2388
+ " * relation name, in the same form as `pageKinds`. Unpaginated relations are left out.",
2389
+ " */"
2390
+ ].join("\n")}\nexport const relatedPageKinds = ${objectBody(lines)} as const`;
2391
+ }
2392
+ /**
2393
+ * One line per parent type holding `render`'s value for each relation whose related endpoint
2394
+ * it answers for. Relations it skips, and parents left with none, are left out.
2395
+ */
2396
+ byRelation(render) {
2397
+ const lines = [];
2398
+ for (const type of Object.keys(this.descriptor)) {
2399
+ const resource = this.descriptor[type];
2400
+ const template = resource.paths["fetchRelated"];
2401
+ if (template === void 0) continue;
2402
+ const relLines = [];
2403
+ for (const [name, relation] of Object.entries(resource.relations)) {
2404
+ if (relation.related === false) continue;
2405
+ const value = render(template.replace("{rel}", relation.uriField ?? name));
2406
+ if (value !== void 0) relLines.push(` ${propertyKey(name)}: ${value},`);
2407
+ }
2408
+ if (relLines.length > 0) lines.push(` ${propertyKey(type)}: {\n${relLines.join("\n")}\n },`);
2409
+ }
2410
+ return lines;
2411
+ }
2412
+ /** The `page` parameter schema of the GET at `path`, if it has one. */
2413
+ pageSchema(path) {
2414
+ return (path === void 0 ? void 0 : this.doc.paths?.[path]?.get?.parameters)?.find((param) => param.name === "page")?.schema;
2415
+ }
2416
+ /**
2417
+ * A page schema's bounded members as literal lines at `depth` (two spaces per level): flat for
2418
+ * one strategy, nested under each arm's `kind` for a menu.
2419
+ */
2420
+ pageLimitLines(schema, depth) {
2421
+ if (schema === void 0) return [];
2422
+ const indent = " ".repeat(depth);
2423
+ if (schema.oneOf === void 0) return this.pageMemberLimits(schema, indent);
2424
+ const lines = [];
2425
+ for (const arm of schema.oneOf) {
2426
+ const kind = armKind(arm);
2427
+ const members = this.pageMemberLimits(arm, `${indent} `);
2428
+ if (kind !== void 0 && members.length > 0) lines.push(`${indent}${propertyKey(kind)}: {\n${members.join("\n")}\n${indent}},`);
2429
+ }
2430
+ return lines;
2321
2431
  }
2322
2432
  /** One page schema's members that declare a `default`, `minimum` or `maximum`, as literal lines. */
2323
2433
  pageMemberLimits(schema, indent) {
@@ -2765,4 +2875,4 @@ async function check(config) {
2765
2875
  //#endregion
2766
2876
  export { DescriptorBuilder as C, operationExamples as S, buildDescriptor as T, readErrorCatalogue as _, schemasOutputPath as a, checkContract as b, emitSchemas as c, detectVerbCollisions as d, emit as f, emitErrorCodes as g, provenanceLines as h, generateFiles as i, emitExamples as l, hashJson as m, examplesOutputPath as n, readDocument as o, deriveProvenance as p, generate as r, readSchemas as s, check as t, Emitter as u, MAXIMUM_CONTRACT as v, buildAtomic as w, buildExamples as x, MINIMUM_CONTRACT as y };
2767
2877
 
2768
- //# sourceMappingURL=src-7yVCQTGQ.mjs.map
2878
+ //# sourceMappingURL=src-i5j2I9fk.mjs.map