@redocly/cli 2.47.0 → 2.49.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.
Files changed (133) hide show
  1. package/lib/chunks/{QRD3XQNU.js → 2U54VUOE.js} +1 -1
  2. package/lib/chunks/3JJEI7CJ.js +456 -0
  3. package/lib/chunks/4I2OVMBJ.js +11 -0
  4. package/lib/chunks/{REBHK2JR.js → 4JDAOKRJ.js} +1 -1
  5. package/lib/chunks/5JIGUBC3.js +7 -0
  6. package/lib/chunks/{QVV2EKMT.js → 5SAFIITS.js} +1 -1
  7. package/lib/chunks/6KCIFTIG.js +57 -0
  8. package/lib/chunks/{5NR4DJW4.js → 6VSHPQXO.js} +1 -1
  9. package/lib/chunks/{W2NJCZOS.js → 74WJ7S7J.js} +1 -1
  10. package/lib/chunks/{QL4V2A4A.js → 7R5PBTLG.js} +1 -1
  11. package/lib/chunks/BT3ELZVX.js +42 -0
  12. package/lib/chunks/C5TR4MMN.js +19 -0
  13. package/lib/chunks/CCR5RYCX.js +20 -0
  14. package/lib/chunks/DCN3GSUA.js +7 -0
  15. package/lib/chunks/{TEQA5OM7.js → E5I67ZCZ.js} +1 -1
  16. package/lib/chunks/FUMCRNTK.js +78 -0
  17. package/lib/chunks/GNMJA2V2.js +16 -0
  18. package/lib/chunks/GRJG3TOI.js +14 -0
  19. package/lib/chunks/HA22GUKQ.js +7 -0
  20. package/lib/chunks/HJ36YGCI.js +184 -0
  21. package/lib/chunks/HJYFWIVE.js +9 -0
  22. package/lib/chunks/HL5FOKC4.js +16 -0
  23. package/lib/chunks/{SL6AH3N2.js → JBNPGEIJ.js} +1 -1
  24. package/lib/chunks/KHEMMNFU.js +26 -0
  25. package/lib/chunks/{SN2EC2ZR.js → KK2STV73.js} +1 -1
  26. package/lib/chunks/KK77ANZH.js +7 -0
  27. package/lib/chunks/L3TZNNJJ.js +13 -0
  28. package/lib/chunks/M6KLAAY4.js +7 -0
  29. package/lib/chunks/MHITBEGC.js +90 -0
  30. package/lib/chunks/NB54XRRU.js +10 -0
  31. package/lib/chunks/NSIQWNYL.js +7 -0
  32. package/lib/chunks/{YQW463Z7.js → NTPLYWAB.js} +1 -1
  33. package/lib/chunks/{5PXRDPHV.js → NUNOXB7Z.js} +1 -1
  34. package/lib/chunks/NWMTC4AN.js +7 -0
  35. package/lib/chunks/NYLAOZPO.js +22 -0
  36. package/lib/chunks/O4R6BSAS.js +20 -0
  37. package/lib/chunks/OKITK6EF.js +30 -0
  38. package/lib/chunks/OUCZOBEX.js +22 -0
  39. package/lib/chunks/PFYPTG4G.js +7 -0
  40. package/lib/chunks/QZH7EL26.js +7 -0
  41. package/lib/chunks/R4XFBOJU.js +9 -0
  42. package/lib/chunks/REFX2EKS.js +13 -0
  43. package/lib/chunks/{S4MX7JPH.js → RXOEH2LN.js} +1 -1
  44. package/lib/chunks/SGBB4RNM.js +11 -0
  45. package/lib/chunks/SQVG3CEM.js +8 -0
  46. package/lib/chunks/{RIFZSMUA.js → T5EPIBMA.js} +1 -1
  47. package/lib/chunks/TLQZAJQU.js +18 -0
  48. package/lib/chunks/TSB6PODJ.js +13 -0
  49. package/lib/chunks/TSRK76GA.js +19 -0
  50. package/lib/chunks/{34J2ZJDK.js → U2H2LXZE.js} +1 -1
  51. package/lib/chunks/UKSQ7B5H.js +2268 -0
  52. package/lib/chunks/UMQN5HTL.js +42 -0
  53. package/lib/chunks/V2LJ4UGM.js +7 -0
  54. package/lib/chunks/VBPP2WUF.js +7 -0
  55. package/lib/chunks/WPGKH5NI.js +177 -0
  56. package/lib/chunks/WXVC3KOI.js +67 -0
  57. package/lib/chunks/{KEUH3PST.js → YI34NB7D.js} +1 -1
  58. package/lib/chunks/YOJGIGE3.js +7 -0
  59. package/lib/chunks/{TO2KJ36N.js → YP5GHFYE.js} +1 -1
  60. package/lib/chunks/YXXYE4G2.js +7 -0
  61. package/lib/chunks/ZBL4IVEW.js +11 -0
  62. package/lib/chunks/ZMCRMR2V.js +5400 -0
  63. package/lib/chunks/ZOUQBK53.js +14 -0
  64. package/lib/chunks/ZXKOHMC6.js +177 -0
  65. package/lib/eject-assets/AGENTS.md +137 -0
  66. package/lib/eject-assets/generators/cli/docs.ts +224 -0
  67. package/lib/eject-assets/generators/cli/engine-source.ts +21 -0
  68. package/lib/eject-assets/generators/cli/index.ts +90 -0
  69. package/lib/eject-assets/generators/cli/render.ts +348 -0
  70. package/lib/eject-assets/generators/go/client.ts +57 -0
  71. package/lib/eject-assets/generators/go/descriptor.ts +41 -0
  72. package/lib/eject-assets/generators/go/index.ts +336 -0
  73. package/lib/eject-assets/generators/go/models.ts +179 -0
  74. package/lib/eject-assets/generators/go/naming.ts +49 -0
  75. package/lib/eject-assets/generators/go/operations.ts +296 -0
  76. package/lib/eject-assets/generators/go/pagination.ts +194 -0
  77. package/lib/eject-assets/generators/go/types.ts +60 -0
  78. package/lib/eject-assets/generators/mock/faker.ts +214 -0
  79. package/lib/eject-assets/generators/mock/index.ts +35 -0
  80. package/lib/eject-assets/generators/mock/render.ts +282 -0
  81. package/lib/eject-assets/generators/mock/sample.ts +316 -0
  82. package/lib/eject-assets/generators/mock/values.ts +63 -0
  83. package/lib/eject-assets/generators/php/client.ts +63 -0
  84. package/lib/eject-assets/generators/php/descriptor.ts +58 -0
  85. package/lib/eject-assets/generators/php/index.ts +237 -0
  86. package/lib/eject-assets/generators/php/models.ts +275 -0
  87. package/lib/eject-assets/generators/php/naming.ts +51 -0
  88. package/lib/eject-assets/generators/php/operations.ts +232 -0
  89. package/lib/eject-assets/generators/php/pagination.ts +133 -0
  90. package/lib/eject-assets/generators/php/types.ts +148 -0
  91. package/lib/eject-assets/generators/python/client.ts +123 -0
  92. package/lib/eject-assets/generators/python/descriptor.ts +52 -0
  93. package/lib/eject-assets/generators/python/index.ts +251 -0
  94. package/lib/eject-assets/generators/python/models.ts +242 -0
  95. package/lib/eject-assets/generators/python/naming.ts +46 -0
  96. package/lib/eject-assets/generators/python/operations.ts +147 -0
  97. package/lib/eject-assets/generators/python/pagination.ts +128 -0
  98. package/lib/eject-assets/generators/python/types.ts +54 -0
  99. package/lib/eject-assets/generators/swr/index.ts +37 -0
  100. package/lib/eject-assets/generators/swr/render.ts +78 -0
  101. package/lib/eject-assets/generators/tanstack-query/index.ts +48 -0
  102. package/lib/eject-assets/generators/tanstack-query/render.ts +346 -0
  103. package/lib/eject-assets/generators/transformers/index.ts +46 -0
  104. package/lib/eject-assets/generators/transformers/render.ts +506 -0
  105. package/lib/eject-assets/generators/typescript/banner.ts +35 -0
  106. package/lib/eject-assets/generators/typescript/client.ts +254 -0
  107. package/lib/eject-assets/generators/typescript/descriptor.ts +137 -0
  108. package/lib/eject-assets/generators/typescript/index.ts +101 -0
  109. package/lib/eject-assets/generators/typescript/inline-runtime.ts +135 -0
  110. package/lib/eject-assets/generators/typescript/operation-signature.ts +62 -0
  111. package/lib/eject-assets/generators/typescript/operation-types.ts +17 -0
  112. package/lib/eject-assets/generators/typescript/operations.ts +524 -0
  113. package/lib/eject-assets/generators/typescript/response-headers.ts +74 -0
  114. package/lib/eject-assets/generators/typescript/type-guards.ts +159 -0
  115. package/lib/eject-assets/generators/typescript/types.ts +172 -0
  116. package/lib/eject-assets/generators/zod/index.ts +32 -0
  117. package/lib/eject-assets/generators/zod/schemas.ts +456 -0
  118. package/lib/eject-assets/skills/cli-generator/SKILL.md +121 -0
  119. package/lib/eject-assets/skills/client-generators/SKILL.md +142 -0
  120. package/lib/eject-assets/skills/go-generator/SKILL.md +96 -0
  121. package/lib/eject-assets/skills/mock-generator/SKILL.md +50 -0
  122. package/lib/eject-assets/skills/php-generator/SKILL.md +112 -0
  123. package/lib/eject-assets/skills/python-generator/SKILL.md +110 -0
  124. package/lib/eject-assets/skills/swr-generator/SKILL.md +50 -0
  125. package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +55 -0
  126. package/lib/eject-assets/skills/transformers-generator/SKILL.md +47 -0
  127. package/lib/eject-assets/skills/typescript-generator/SKILL.md +95 -0
  128. package/lib/eject-assets/skills/zod-generator/SKILL.md +54 -0
  129. package/lib/index.js +271 -193
  130. package/package.json +1 -1
  131. package/lib/chunks/B6HS7CVY.js +0 -184
  132. package/lib/chunks/PIJLRHNN.js +0 -8
  133. package/lib/chunks/Y5HLCNL5.js +0 -2542
@@ -0,0 +1,42 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as x,b as f,c as m,d}from"./R4XFBOJU.js";import{b as y,d as h,e as l}from"./NB54XRRU.js";import{m as P}from"./HJYFWIVE.js";import{join as E}from"node:path";function q(e,t){let n=x(e,"tanstack-query");if(n.length===0)return"";let r=t.pagination??new Map;return[j(n,t,r),...n.filter(f).map(i=>K(i,t.queryKeyPrefix)),Q(e,n,r,t.queryKeyPrefix,t.argsStyle),...R(n,r)].join(`
8
+ `)}function b(e,t){if(!f(e))return!1;let n=t.get(e.name);return n!==void 0&&n.spec.style!=="link"}function j(e,t,n){let r=[...e.some(a=>b(a,n))?["infiniteQueryOptions"]:[],...e.some(f)?["queryOptions"]:[]],s=[...e.filter(m).map(d),"RequestOptions"].sort().map(a=>`type ${a}`),i=[];return r.length>0&&i.push(`import { ${r.join(", ")} } from "@tanstack/${t.framework}-query";`),i.push(`import { client, ${s.join(", ")} } from "${t.sdkModule}";`),i.join(`
9
+ `)}function K(e,t){let n=M(e,t);return m(e)?`export const ${e.name}QueryKey = (vars?: ${d(e)}) =>
10
+ vars === undefined ? ([${n}] as const) : ([${n}, vars] as const);`:`export const ${e.name}QueryKey = () => [${n}] as const;`}function M(e,t){return t===void 0?`"${e.name}"`:`${h(t)}, "${e.name}"`}function Q(e,t,n,r,s){return`/**
11
+ * Build the factories over a specific client instance \u2014 its config, middleware, and
12
+ * retry apply to every call (\`createQueryFactories(createClient(OPERATIONS, config))\`).
13
+ * The module-level exports below are these factories bound to the generated module's default \`client\`.
14
+ */
15
+ export const createQueryFactories = (instance: typeof client = client) => ({
16
+ `+t.flatMap(a=>{if(!f(a))return[S(a,r)];let o=n.get(a.name);return o!==void 0&&o.spec.style!=="link"?[k(a),F(e,a,o.spec,s)]:[k(a)]}).join(`,
17
+ `)+`
18
+ });`}function k(e){let{params:t,keyArg:n,callArgs:r}=O(e);return` ${e.name}Options: (${t}) => queryOptions({
19
+ queryKey: ${e.name}QueryKey(${n}),
20
+ queryFn: ({ signal }) => instance.${e.name}(${r}, { ...init, signal, envelope: undefined }),
21
+ })`}function S(e,t){let n=m(e)?`(vars: ${d(e)}) => instance.${e.name}(vars, { ...init, envelope: undefined })`:`() => instance.${e.name}({}, { ...init, envelope: undefined })`;return` ${e.name}Mutation: (${v}) => ({
22
+ mutationKey: [${M(e,t)}] as const,
23
+ mutationFn: ${n},
24
+ })`}function F(e,t,n,r){let{params:s,keyArg:i}=O(t),a=l(n.param),o=r==="flat"?`{ ...vars, ${a}: pageParam }`:`{ ...vars, query: { ...vars.query, ${a}: pageParam } }`;return` ${t.name}InfiniteOptions: (${s}) => infiniteQueryOptions({
25
+ queryKey: [...${t.name}QueryKey(${i}), "infinite"] as const,
26
+ queryFn: ({ pageParam, signal }) => instance.${t.name}(${o}, { ...init, signal, envelope: undefined }),
27
+ `+I(e,t,n,r)+" })"}function I(e,t,n,r){let s=w(n.param),i=r==="flat"?T("vars",n.param):`vars.query?.${s}`;if(n.style==="cursor"){let c=n.hasMore===void 0?"":` if (lastPage${g(n.hasMore)} === false) return undefined;
28
+ `,$=C(e,t,n.nextCursor),p=$.length===0?` return lastPage${g(n.nextCursor)};
29
+ `:` const next = lastPage${g(n.nextCursor)};
30
+ return ${$.join(" || ")} ? undefined : next;
31
+ `;return` initialPageParam: ${i},
32
+ getNextPageParam: (lastPage) => {
33
+ `+c+p+` },
34
+ `}let a=n.style==="offset"?"lastPageParam + count":"lastPageParam + 1",o=n.style==="offset"?"0":"1";return` initialPageParam: ${i} ?? ${o},
35
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => {
36
+ const count = ${N(n.items)};
37
+ return count === 0 ? undefined : ${a};
38
+ },
39
+ `}function C(e,t,n){let r=t.successResponses.find(u=>u.contentType.toLowerCase().includes("json")),s=P(r.schema,"",e),i=P(r.schema,n,e),a=n.slice(1).split("/"),o=a.length>1;if(!o&&s?.kind==="object"){let u=s.properties.find(A=>A.name===a[0]);o=u===void 0||!u.required}let c=i?.kind==="union"?i.members:i?[i]:[],$=c.some(u=>u.kind==="null"),p=c.some(u=>u.kind==="scalar"&&u.scalar==="string");return[...o?["next === undefined"]:[],...$?["next === null"]:[],...p?['next === ""']:[]]}var v='init?: Omit<RequestOptions, "envelope">';function O(e){return m(e)?{params:`vars: ${d(e)}, ${v}`,keyArg:"vars",callArgs:"vars"}:{params:v,keyArg:"",callArgs:"{}"}}function w(e){return y(e)?e:`[${l(e)}]`}function T(e,t){return y(t)?`${e}.${t}`:`${e}[${l(t)}]`}function g(e){return e.slice(1).split("/").map(n=>n.replaceAll("~1","/").replaceAll("~0","~")).map((n,r)=>{let s=y(n);return r===0?s?`.${n}`:`[${l(n)}]`:s?`?.${n}`:`?.[${l(n)}]`}).join("")}function N(e){return e===""?"lastPage?.length ?? 0":`lastPage${g(e)}?.length ?? 0`}function R(e,t){return["const defaultFactories = createQueryFactories();",...e.flatMap(r=>f(r)?b(r,t)?[`${r.name}Options`,`${r.name}InfiniteOptions`]:[`${r.name}Options`]:[`${r.name}Mutation`]).map(r=>`export const ${r} = defaultFactories.${r};`)]}function z(e){return({model:t,output:n,banner:r,emit:s,pagination:i})=>{let a=q(t,{argsStyle:s.argsStyle??"grouped",sdkModule:`./${n.stem}.${s.importExt??"js"}`,framework:e,pagination:i,queryKeyPrefix:s.queryKeyPrefix});if(a==="")return[];let o=r.map(c=>`// ${c}`).join(`
40
+ `);return[{path:E(n.dir,`${n.stem}.tanstack.ts`),content:`${o}
41
+
42
+ ${a}`}]}}export{z as a};
@@ -0,0 +1,19 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as j}from"./SQVG3CEM.js";import{c as F}from"./UKSQ7B5H.js";import{b as J,c as R,d as T,e as U,f as ne,g as W,h as te}from"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import{c as z,d as S,e as x,g as G,h as I,i as Q,j as X,k as Z,n as ee}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var k=z.python,u=new j;function M(e){return u.typeName(e)}function E(e){let{identifier:n,renamed:o}=u.memberName(e);return{python:n,renamed:o}}function C(e){let n=e.services.flatMap(t=>t.operations),o=x(n.map(t=>t.name),{style:"snake",reserved:k});return n.map((t,a)=>({op:t,ident:o[a]}))}var L=["self","body","headers","timeout","retry","idempotency_key"];function oe(e){return u.literal(e)}function se(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function re(e,n){let o=new Set;return`[${(e.successResponseHeaders??[]).map(a=>{let r=S(a.name,{style:"snake",reserved:k}),l=r,i=2;for(;o.has(l);)l=`${r}_${i++}`;o.add(l);let m=ee(a.schema,n);return`(${u.string(a.name)}, ${u.string(l)}, ${u.string(m)})`}).join(", ")}]`}function h(e,n="string"){if(Q(e))return`Optional[${h(X(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${h(e.items,n)}]`;case"record":return`Dict[str, ${h(e.value,n)}]`;case"ref":return M(e.name);case"literal":return`Literal[${u.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(o=>h(o,n)).join(", ")}]`;case"null":return"None";case"omit":return M(e.base);case"object":case"intersection":case"unknown":return"Any"}}function B(e,n,o,t,a,r,l,i=!1){let m=x([...n.pathParams,...n.queryParams].map(P=>P.name),{style:"snake",reserved:k,taken:L}),c=n.pathParams.map((P,v)=>({param:P,python:m[v]})),s=n.queryParams.map((P,v)=>({param:P,python:m[n.pathParams.length+v]})),p=c.map(({param:P,python:v})=>`${v}: ${h(P.schema,r)}`),f=n.requestBody?[`body: ${h(n.requestBody.schema,r)}`]:[],g=[...s.map(({param:P,python:v})=>{let w=h(P.schema,r),A=w.startsWith("Optional[")?w:`Optional[${w}]`;return`${v}: ${A} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],y=R(n),_=T(n),N=i?`Envelope[${y===void 0?"None":h(y,r)}]`:_!==void 0?`${a?"AsyncIterator":"Iterator"}[ServerSentEvent]`:t==="result"?"Result":y===void 0?"None":h(y,r),O=a&&_===void 0?"async def":"def",d=a?"await ":"",$=a?"send_async":"send",b=["self",...p,...f,"*",...g].join(", "),D=i?`${o}_with_headers`:o;e.block(`${O} ${D}(${b}) -> ${N}:`,()=>{e.doc(i?`Like ${o}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${o}"]`),e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)'),e.line("params: Dict[str, Any] = dict(auth_query)");for(let{param:A,python:q}of s)e.block(`if ${q} is not None:`,()=>{e.line(`params[${u.string(A.name)}] = encode(${q})`)});let P=c.map(({param:A,python:q})=>`${u.string(A.name)}: ${q}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${P}})`),_!==void 0){let A=_.schema!==void 0&&_.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${a?"aiter_sse":"iter_sse"}(_open, data_kind="${A}")`);return}U(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?U(n)?", data=form_data, files=form_files":", json_body=encode(body)":"";e.line(`response = ${d}${$}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params=params${v}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let w=y===void 0?"None":`decode(${h(y,r)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${w}, headers=read_envelope_headers(response, ${re(n,l)}), response=response)`)):t==="result"?(e.block("if not response.is_success:",()=>{e.line("return Result(data=None, error=_safe_json(response), response=response)")}),e.line(`return Result(data=${w}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(y===void 0?"return None":`return ${w}`))}),e.blank()}function ae(e,n,o,t,a,r){let l=R(n),i=l===void 0?"Any":h(l,r),m=x([...n.pathParams,...n.queryParams].map(d=>d.name),{style:"snake",reserved:k,taken:L}),c=n.pathParams.map((d,$)=>({param:d,python:m[$]})),s=n.queryParams.map((d,$)=>({param:d,python:m[n.pathParams.length+$]})),p=c.map(({param:d,python:$})=>`${$}: ${h(d.schema,r)}`),f=[...s.map(({param:d,python:$})=>{let b=h(d.schema,r),D=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${$}: ${D} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],g=["self",...p,"*",...f].join(", "),y=t?"AsyncIterator":"Iterator",_=t?"aiter_pages":"iter_pages",N=t?"aiter_items":"iter_items",O=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:D}of s)e.block(`if ${D} is not None:`,()=>{e.line(`base[${u.string(b.name)}] = encode(${D})`)});let d=t?"async def":"def",$=t?"await ":"";e.block(`${d} _page(page_params: Dict[str, Any]) -> Tuple[Any, Any]:`,()=>{e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)');let b=c.map(({param:D,python:P})=>`${u.string(D.name)}: ${P}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${b}})`),e.line(`response = ${$}${t?"send_async":"send"}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params={**page_params, **auth_query}, timeout=timeout, retry=retry)`),e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line("return _safe_json(response), response")})};t?(e.block(`async def ${o}_pages(${g}) -> ${y}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.block(`async for page in ${_}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${o}_items(${g}) -> ${y}[${a}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.block(`async for item in ${N}(_page, op["pagination"], base):`,()=>{e.line(a==="Any"?"yield item":`yield decode(${a}, item)`)})})):(e.block(`def ${o}_pages(${g}) -> ${y}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.line(i==="Any"?`return ${_}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${_}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${o}_items(${g}) -> ${y}[${a}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.line(a==="Any"?`return ${N}(_page, op["pagination"], base)`:`return (decode(${a}, item) for item in ${N}(_page, op["pagination"], base))`)})),e.blank()}function ce(e){return ne(e).map(o=>o.kind==="literal"?u.string(o.value):E(o.name).python).join(" + ")}function ie(e,n){let o=n.servers??[];if(o.length===0)return;let t=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),o.forEach((a,r)=>{let l=S(a.description??`server${r+1}`,{style:"snake",reserved:k});t.has(l)&&(l=`${l}_${r+1}`),t.add(l);let i=a.variables.map(m=>`${E(m.name).python}: str = ${u.string(m.default)}`);r>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${l}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${ce(a)}`)})})}),e.blank()}function H(e,n,o,t,a,r,l){let i=t?"AsyncClient":"Client",m=t?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${t?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${u.string(r)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:c,ident:s}of C(n)){B(e,c,s,o,t,l),T(c)===void 0&&(c.successResponseHeaders?.length??0)>0&&B(e,c,s,o,t,l,n,!0);let p=a.get(s);if(p!==void 0){let f=R(c),g=te(f,typeof p.items=="string"?p.items:void 0,n);ae(e,c,s,t,g===void 0?"Any":h(g,l),l)}}}),e.blank()}function K(e){let n=new Map,o=new Set,t=[];for(let{name:r,schema:l}of e.schemas){let i=I(l,e);if(!(i===void 0||!i.cases.every(c=>G(c.schema,e)?.properties.some(s=>s.name===i.property)===!0))){for(let c of i.cases){let s=n.get(c.schemaName);if(s!==void 0&&s.value!==c.value){o.add(c.schemaName);continue}n.set(c.schemaName,{property:i.property,value:c.value})}t.push({name:r,property:i.property,members:i.cases.map(c=>c.schemaName)})}}let a=new Map;for(let r of t)r.members.some(l=>o.has(l))||a.set(r.name,E(r.property).python);for(let r of o)n.delete(r);return{pins:n,unions:a}}function pe(e,n,o,t,a,r,l){let i=a==="pydantic";i||e.line("@dataclass");let m=i?`class ${M(n)}(BaseModel):`:`class ${M(n)}:`;e.block(m,()=>{e.doc(r),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let c=[...o.filter(p=>p.required),...o.filter(p=>!p.required)],s=[];c.length===0&&e.line("pass");for(let p of c){let{python:f,renamed:g}=E(p.name);g&&!i&&s.push([f,p.name]);let y=g&&i?`alias=${u.string(p.name)}`:void 0,_=l?.property===p.name?`Literal[${u.literal(l.value)}]`:h(p.schema,t);if(p.required){let N=y===void 0?"":` = Field(${y})`;e.line(`${f}: ${_}${N}`)}else{let N=_.startsWith("Optional[")?_:`Optional[${_}]`,O=y===void 0?"None":`Field(default=None, ${y})`;e.line(`${f}: ${N} = ${O}`)}}if(s.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let p=s.map(([f,g])=>`"${f}": ${u.string(g)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${p}}`)}}),e.blank(),e.blank()}function Y(e,n="string",o="dataclass"){let t=new j,{pins:a,unions:r}=o==="pydantic"?K(e):{pins:new Map,unions:new Map};t.line("from __future__ import annotations"),t.blank(),o==="dataclass"&&t.line("from dataclasses import dataclass"),t.line("from enum import Enum");let l=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];o==="dataclass"&&l.splice(2,0,"ClassVar"),r.size>0&&l.unshift("Annotated"),t.line(`from typing import ${l.join(", ")}`),o==="pydantic"&&t.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&t.line("from datetime import date, datetime"),t.blank(),t.blank();let i=[];for(let{name:m,schema:c}of e.schemas){let s=Z(c);if(s!==void 0){let p=s.scalar==="string"?"str, Enum":"int, Enum";t.block(`class ${M(m)}(${p}):`,()=>{t.doc(c.description),s.values.forEach((f,g)=>{t.line(`${s.memberNames[g]} = ${u.literal(f)}`)})}),t.blank(),t.blank();continue}if(c.kind==="object"||c.kind==="intersection"){let p=G(c,e);if(p!==void 0){pe(t,m,p.properties,n,o,p.description??c.description,a.get(m));continue}}i.push(()=>{let p=I(c,e);if(p!==void 0){let y=p.cases.map(_=>`${_.value} -> ${M(_.schemaName)}`).join(", ");t.line(`# Discriminated by "${p.property}": ${y}`)}let f=r.get(m),g=f===void 0?h(c,n):`Annotated[${h(c,n)}, Field(discriminator=${u.string(f)})]`;t.line(`${M(m)} = ${g}`),t.blank()})}for(let m of i)m();return t.toString()}function le(e,n){let o=[];for(let{name:t,schema:a}of e.schemas){if(n.has(t))continue;let r=I(a,e);if(r===void 0)continue;let l=r.cases.map(i=>`${u.string(i.value)}: ${M(i.schemaName)}`).join(", ");o.push(`DISCRIMINATORS[${M(t)}] = (${u.string(r.property)}, {${l}})`)}return o}var Ve={type:"object",properties:{models:{enum:["dataclass","pydantic"],default:"dataclass",description:"Model style: standard-library dataclasses (default, httpx is the only dependency), or pydantic BaseModel classes (adds pydantic)."}},additionalProperties:!1};function V(e){let n=e.lastIndexOf("/")>=0?"/":"\\",o=e.lastIndexOf(n),t=o>=0?e.slice(0,o+1):"",a=(o>=0?e.slice(o+1):e).replace(/\.[^.]+$/,"");return`${t}${S(a,{style:"snake",reserved:k})}.py`}var ze=({model:e,output:n,banner:o,emit:t,options:a,pagination:r})=>{let l=t.errorMode??"throw",i=t.dateType??"string",m=a?.models??"dataclass",c=m==="pydantic"?K(e):void 0,s=new j;if(s.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),s.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),s.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),s.blank(),s.line(Y(e,i,m).trimEnd()),s.blank(),s.blank(),ie(s,e),t.runtime==="module"){s.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let d of Object.keys(F))s.line(`from ${d.replace(/\.py$/,"")} import *`);s.blank(),s.blank()}else{s.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let d of Object.values(F)){let $=d.split(`
8
+ `).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
9
+ `).trim();s.line($),s.blank()}s.blank()}let p=le(e,new Set(c?.unions.keys()));if(p.length>0){s.line("# Discriminated unions dispatch by their property inside decode().");for(let d of p)s.line(d);s.blank()}s.block("def _safe_json(response: httpx.Response) -> Any:",()=>{s.block("try:",()=>{s.line("return response.json()")}),s.block("except Exception:",()=>{s.line("return None")})}),s.blank();let f=new Map;for(let{op:d,ident:$}of C(e))f.set($,se(r?.get(d.name)?.spec));s.line("_OPERATIONS = {"),s.indent(()=>{for(let{op:d,ident:$}of C(e)){let b={id:d.specName??d.name,method:d.method.toUpperCase(),path:d.path,...W(d,e).length>0?{security:W(d,e)}:{},...f.get($)!==void 0?{pagination:f.get($)}:{}};s.line(`"${$}": ${oe(b)},`)}}),s.line("}"),s.blank(),s.blank();let g=t.serverUrl??e.serverUrl??"";H(s,e,l,!1,f,g,i),H(s,e,l,!0,f,g,i);let y={path:V(n.path),content:s.toString()};if(t.runtime!=="module")return[y];let _=o.map(d=>`# ${d}`).join(`
10
+ `),N=V(n.path).replace(/[^\\/]+$/,""),O=Object.entries(F).map(([d,$])=>({path:`${N}${d}`,content:`${_}
11
+
12
+ ${$.split(`
13
+ `).map(b=>b.startsWith("from ._")?b.replace("from ._","from _"):b).join(`
14
+ `).trim()}
15
+ `}));return[y,...O]};function de(e,n){let o=V(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),t=C(n.model).find(r=>r.op.name===e.name)?.ident??S(e.name,{style:"snake",reserved:k}),a=[...e.pathParams.map(r=>{let l=S(r.name,{style:"snake",reserved:k});return`${l}="<${l}>"`}),...e.queryParams.filter(r=>r.required).map(r=>`${S(r.name,{style:"snake",reserved:k})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${o} import Client
16
+
17
+ client = Client()
18
+ result = client.${t}(${a.join(", ")})
19
+ `}}var Je=({model:e,output:n,emit:o,pagination:t})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:J(e,{title:`${e.title} Python SDK reference`,frontmatter:o.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:a=>de(a,{model:e,emit:o,outputPath:n.path}),paginated:new Set(t?.keys()??[])})}];export{Je as pythonDocs,ze as pythonGenerator,Ve as pythonOptions,de as pythonSample,h as pythonType,Y as renderPythonModels};
@@ -0,0 +1,20 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as N}from"./NSIQWNYL.js";import{b as U}from"./UKSQ7B5H.js";import{b as Q,c as D,d as R,e as I,f as X,g as Z,h as ee}from"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import{c as z,d as P,e as w,f as q,g as _,h as E,i as V,j as H,k as O,n as Y}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var m=z.php,G=new N;function h(e){return G.typeName(e)}function y(e){return G.memberName(e)}function l(e){return G.string(e)}function ne(e){return P(e.name,{style:"camel",reserved:m})}function B(e){let n=e.services.flatMap(i=>i.operations),a=w(n.map(i=>i.name),{style:"camel",reserved:m});return new Map(n.map((i,r)=>[i.name,a[r]]))}function ue(e){return X(e).map(a=>a.kind==="literal"?l(a.value):`$${y(a.name)}`).join(" . ")}function te(e,n){let a=n.servers??[];if(a.length===0)return;let i=new Set;e.line("/** The declared servers; variables default to the values from the description. */"),e.line("final class Servers"),e.block("{",()=>{a.forEach((r,t)=>{let s=P(r.description??`server${t+1}`,{style:"camel",reserved:m});i.has(s)&&(s=`${s}${t+1}`),i.add(s);let o=r.variables.map(c=>`string $${y(c.name)} = ${l(c.default)}`);t>0&&e.blank(),e.line(`public static function ${s}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${ue(r)};`)},"}")})},"}"),e.blank()}function re(e,n){let a=Z(e,n).map(i=>`[${i.map(t=>t.kind==="apiKey"?`['kind' => 'apiKey', 'scheme' => ${l(t.scheme)}, 'name' => ${l(t.name)}, 'in' => ${l(t.in)}]`:`['kind' => ${l(t.kind)}, 'scheme' => ${l(t.scheme)}]`).join(", ")}]`);if(a.length!==0)return`[${a.join(", ")}]`}function ie(e){return`[${[`'style' => ${l(e.style)}`,...e.param!==void 0?[`'param' => ${l(e.param)}`]:[],...e.nextCursor!==void 0?[`'nextCursor' => ${l(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`'hasMore' => ${l(e.hasMore)}`]:[],...e.limitParam!==void 0?[`'limitParam' => ${l(e.limitParam)}`]:[],...e.items!==void 0?[`'items' => ${l(e.items)}`]:[]].join(", ")}]`}function ae(e,n){let a=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=P(r.name,{style:"camel",reserved:m}),s=2;for(;a.has(t);)t=`${P(r.name,{style:"camel",reserved:m})}_${s++}`;a.add(t);let o=Y(r.schema,n);return`[${l(r.name)}, ${l(t)}, ${l(o)}]`}).join(", ")}]`}function T(e,n){let a=n.schemas.find(t=>t.name===e);if(a===void 0)return"other";let i=a.schema,r=O(i);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(i.kind==="object"||i.kind==="intersection")&&_(i,n)!==void 0?"class":"other"}function f(e,n,a="string"){if(V(e)){let i=f(H(e),n,a);return x(i)}switch(e.kind){case"scalar":return a==="Date"&&e.scalar==="string"&&F(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let i=T(e.name,n);if(i==="class"||i==="enum")return h(e.name);let r=q(e,n);return r===void 0?"mixed":f(r,n,a)}case"enum":return{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float";case"omit":return h(e.base);case"union":return de(e.members,n,a);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function F(e){let n=e.metadata?.format;return n==="date"||n==="date-time"}function x(e){return e==="mixed"||e.startsWith("?")||e.endsWith("|null")?e:e.includes("|")?`${e}|null`:`?${e}`}function de(e,n,a){let i=[];for(let r of e){if(r.kind==="null")continue;let t=f(r,n,a);if(t==="mixed")return"mixed";let s=t.startsWith("?")?t.slice(1):t;i.includes(s)||i.push(s),t.startsWith("?")&&!i.includes("null")&&i.push("null")}return i.length===0?"mixed":i.join("|")}function K(e,n,a){if(e===void 0)return;let i=H(e);if(i.kind==="ref"){let t=q(i,n);return T(i.name,n)==="other"?K(t,n,a):void 0}if(i.kind!=="array")return;let r=f(i.items,n,a);return r==="mixed"?void 0:r}function se(e,n){let a=n.schemas.find(i=>i.name===e);return a!==void 0&&E(a.schema,n)!==void 0}function M(e,n,a,i){let r=H(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&F(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return M({kind:"ref",name:r.base},n,a,i);if(r.kind==="ref"){let t=T(r.name,a);if(t==="class")return`${h(r.name)}::fromArray(${n})`;if(t==="enum")return`${h(r.name)}::from(${n})`;if(se(r.name,a))return`unmarshal${h(r.name)}(${n})`;let s=q(r,a);return s===void 0?void 0:M(s,n,a,i)}if(r.kind==="array"){let t=M(r.items,"$item",a,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=M(r.value,"$item",a,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function A(e,n,a,i="string"){let r=H(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"){if(r.metadata?.format==="date")return`${n}->format('Y-m-d')`;if(r.metadata?.format==="date-time")return`${n}->format(\\DateTimeInterface::ATOM)`}if(r.kind==="omit")return A({kind:"ref",name:r.base},n,a,i);if(r.kind==="ref"){let t=T(r.name,a);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(se(r.name,a))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let s=q(r,a);return s===void 0?void 0:A(s,n,a,i)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,s=A(t,"$item",a,i);return s===void 0?void 0:`array_map(static fn ($item) => ${s}, ${n})`}}function pe(e,n,a,i,r,t){let s=[...a.filter(o=>o.required),...a.filter(o=>!o.required)];e.doc(h(n),t),e.line(`final class ${h(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of s){let c=f(o.schema,i,r);if(o.required)e.line(`public ${c} $${y(o.name)},`);else{let u=x(c);e.line(`public ${u} $${y(o.name)} = null,`)}}},") {"),e.line("}"),e.blank(),e.line("public static function fromArray(array $data): self"),e.block("{",()=>{e.block("return new self(",()=>{for(let o of s){let c=`$data[${l(o.name)}]`,u=M(o.schema,c,i,r),p=y(o.name);o.required?e.line(`${p}: ${u??c},`):u===void 0?e.line(`${p}: ${c} ?? null,`):e.line(`${p}: isset(${c}) ? ${u} : null,`)}},");")},"}"),e.blank(),e.line("public function toArray(): array"),e.block("{",()=>{e.line("$data = [];");for(let o of s){let c=`$this->${y(o.name)}`,u=A(o.schema,c,i,r)??c;o.required?e.line(`$data[${l(o.name)}] = ${u};`):e.block(`if (${c} !== null) {`,()=>{e.line(`$data[${l(o.name)}] = ${u};`)},"}")}e.line("return $data;")},"}")},"}"),e.blank()}function L(e,n="string"){let a=new N;for(let{name:i,schema:r}of e.schemas){let t=O(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";a.doc(h(i),r.description),a.line(`enum ${h(i)}: ${o}`),a.block("{",()=>{let c=w(t.values.map(u=>String(u)),{style:"pascal",reserved:m});t.values.forEach((u,p)=>{let g=typeof u=="string"?l(u):String(u);a.line(`case ${c[p]} = ${g};`)})},"}"),a.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=_(r,e);if(o!==void 0){pe(a,i,o.properties,e,n,o.description??r.description);continue}}let s=E(r,e);if(s!==void 0){let o=h(i),c=s.cases.map(u=>`${u.value} -> ${h(u.schemaName)}`).join(", ");a.line(`/** ${o} is a discriminated union (${l(s.property)}): ${c}. */`),a.line(`function unmarshal${o}(array $data): mixed`),a.block("{",()=>{a.block(`return match ($data[${l(s.property)}] ?? null) {`,()=>{for(let u of s.cases)a.line(`${l(u.value)} => ${h(u.schemaName)}::fromArray($data),`);a.line("default => $data,")},"};")},"}"),a.blank();continue}}return a.toString()}var oe=new Set(["post","put","patch"]),$e=["body","headers","idempotencyKey"];function W(e,n,a,i){let r=w([...e.pathParams,...e.queryParams].map(c=>c.name),{style:"camel",reserved:m,taken:$e}),t=e.pathParams.map((c,u)=>({php:r[u],wire:c.name,type:f(c.schema,n,i)})),s=e.queryParams.map((c,u)=>{let p=r[e.pathParams.length+u];return{php:p,wire:c.name,type:f(c.schema,n,i),value:A(c.schema,`$${p}`,n,i)??`$${p}`}}),o=[...t.map(({php:c,type:u})=>`${u} $${c}`),...a&&e.requestBody?[`${I(e)?"array":f(e.requestBody.schema,n,i)} $body`]:[],...s.map(({php:c,type:u})=>`${x(u)} $${c} = null`),"?array $headers = null",...a&&oe.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:s,signature:o}}function fe(e,n,a){e.line(`$op = OPERATIONS[${l(n.specName??n.name)}];`),e.line("[$authHeaders, $query, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);");for(let{php:r,wire:t,value:s}of a.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${l(t)}] = ${s};`)},"}");let i=a.pathArgs.map(({php:r,wire:t})=>`${l(t)} => $${r}`).join(", ");e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${i}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}")}function J(e,n,a,i,r,t=!1){let s=W(n,i,!0,r),o=R(n),c=D(n),u=o===void 0&&c===void 0&&n.successResponses.some(b=>b.contentType!==""),p=t?"Envelope":o!==void 0?"\\Generator":c!==void 0?f(c,i,r):u?"string":"void",g=t?`${a}WithHeaders`:a,S=t?void 0:K(c,i,r);e.doc(g,t?`Like ${a}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,S===void 0?[]:[`@return ${S}[]`]),e.line(`public function ${g}(${s.signature.join(", ")}): ${p}`),e.block("{",()=>{if(fe(e,n,s),o!==void 0){let $=o.schema!==void 0&&o.schema.kind!=="unknown";e.line("$url = appendQuery($url, $query);"),e.block("$open = function (array $extraHeaders) use ($url, $requestHeaders): \\CurlHandle {",()=>{e.line("$handle = curl_init($url);"),e.line("$lines = [];"),e.block("foreach (array_merge($requestHeaders, $extraHeaders) as $name => $value) {",()=>{e.line("$lines[] = $name . ': ' . $value;")},"}"),e.line("curl_setopt($handle, CURLOPT_HTTPHEADER, $lines);"),e.line("return $handle;")},"};"),e.line(`yield from iterSse($open, ${$?"true":"false"});`);return}let b=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&I(n))e.line("[$contentType, $encoded] = toMultipart($body);"),b.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let $=A(n.requestBody.schema,"$body",i,r)??"$body";e.line(`$payload = json_encode(${$});`),b.push("'body' => $payload",`'contentType' => ${l(n.requestBody.contentType)}`)}oe.has(n.method.toLowerCase())&&n.requestBody&&b.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${b.join(", ")}]);`),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}");let d=u?"$response['body']":(c===void 0?void 0:M(c,"decodeJson($response)",i,r))??"decodeJson($response)";if(t){e.line(`$data = ${d};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ae(n,i)}), status: $response['status']);`);return}if(u){e.line("return $response['body'];");return}if(p==="void"){e.line("decodeJson($response);");return}e.line(`return ${d};`)},"}"),e.blank()}function le(e,n,a,i,r,t,s,o,c){let u=W(n,i,!1,r),p=a,g=()=>{e.line(`$op = OPERATIONS[${l(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:$,wire:k,value:v}of u.queryArgs)e.block(`if ($${$} !== null) {`,()=>{e.line(`$base[${l(k)}] = ${v};`)},"}");let d=u.pathArgs.map(({php:$,wire:k})=>`${l(k)} => $${$}`).join(", ");e.block("$call = function (array $params) use ($op, $headers): array {",()=>{e.line("[$authHeaders, $authQuery, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);"),e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${d}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}"),e.line("$response = send($this->config, ['operationId' => $op['id'], 'method' => $op['method'], 'url' => $url, 'headers' => $requestHeaders, 'query' => array_merge($params, $authQuery)]);"),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}"),e.line("return [decodeJson($response), $response];")},"};")},S=f(D(n)??{kind:"unknown"},i,r),b=S==="mixed"?"mixed":S;e.line("/**"),e.line(` * ${p} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${b}>`),e.line(" */"),e.line(`public function ${p}Pages(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`yield ${t??"$page"};`)},"}")},"}"),e.blank(),e.line("/**"),e.line(` * The items of every ${p} page.`),e.line(" *"),e.line(` * @return \\Generator<int, ${c}>`),e.line(" */"),e.line(`public function ${p}Items(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`$items = resolvePointer($page, ${l(o??"")});`),e.block("foreach (is_array($items) ? $items : [] as $item) {",()=>{e.line(`yield ${s??"$item"};`)},"}")},"}")},"}"),e.blank()}function me(e){let n=e.split(`
8
+ `),a=0;for(let i=0;i<n.length;i++)if(n[i].trim().startsWith("namespace ")){a=i+1;break}return n.slice(a).join(`
9
+ `).trim()}var nn=({model:e,output:n,banner:a,emit:i,pagination:r})=>{let t=new N,s=i.dateType??"string",o=P(e.title,{style:"pascal",reserved:m});t.line("<?php"),t.blank(),t.line(`// Code generated by @redocly/client-generator (php) from ${l(e.title)} ${e.version}. DO NOT EDIT.`),t.line("// Regenerate with `redocly generate-client`. PHP >= 8.1, curl extension \u2014 zero Composer dependencies."),t.blank(),t.line("declare(strict_types=1);"),t.blank(),t.line(`namespace ${o};`),t.blank(),t.line(L(e,s)),te(t,e),i.runtime==="module"?(t.line("// \u2500\u2500\u2500 Runtime (a real file beside this one, written by the same run) \u2500\u2500\u2500"),t.line("require_once __DIR__ . '/runtime.php';"),t.blank()):(t.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator php runtime) \u2500\u2500\u2500"),t.line(me(U)),t.blank());let c=e.services.flatMap(d=>d.operations),u=B(e),p=new Map;for(let d of c){let $=r?.get(d.name)?.spec;$!==void 0&&p.set(d.name,$)}t.block("const OPERATIONS = [",()=>{for(let d of c){let $=d.specName??d.name,k=re(d,e),v=p.get(d.name),j=[`'id' => ${l($)}`,`'method' => ${l(d.method.toUpperCase())}`,`'path' => ${l(d.path)}`,...k!==void 0?[`'security' => ${k}`]:[],...v!==void 0?[`'pagination' => ${ie(v)}`]:[]];t.line(`${l($)} => [${j.join(", ")}],`)}},"];"),t.blank(),t.doc("Client",`Client for ${e.title} (${e.version}).`),t.line("class Client"),t.block("{",()=>{t.line("public function __construct(private Config $config)"),t.block("{",()=>{t.block("if ($this->config->serverUrl === '') {",()=>{t.line(`$this->config->serverUrl = ${l(i.serverUrl??e.serverUrl??"")};`)},"}")},"}"),t.blank();for(let d of c){let $=u.get(d.name);J(t,d,$,e,s),R(d)===void 0&&(d.successResponseHeaders?.length??0)>0&&J(t,d,$,e,s,!0);let k=p.get(d.name);if(k===void 0)continue;let v=D(d),j=v===void 0?void 0:M(v,"$page",e,s),C=ee(v,k.items,e),ce=C===void 0?void 0:M(C,"$item",e,s);le(t,d,$,e,s,j,ce,k.items,C===void 0?"mixed":f(C,e,s))}},"}");let g={path:n.path.replace(/\.[^.\\/]+$/,".php"),content:t.toString()};if(i.runtime!=="module")return[g];let S=a.map(d=>`// ${d}`).join(`
10
+ `),b=U.replace(/^namespace .*$/m,`namespace ${o};`).replace(/^<\?php\n/,`<?php
11
+
12
+ ${S}
13
+ `).trimEnd();return[g,{path:g.path.replace(/[^\\/]+$/,"runtime.php"),content:`${b}
14
+ `}]};function he(e,n){let a=[...e.pathParams.map(t=>`${l(`<${y(t.name)}>`)}`),...e.requestBody?["$body"]:[],...e.queryParams.length>0?[`${y(e.queryParams[0].name)}: ${l("<value>")}`]:[]],i=P(n.model.title,{style:"pascal",reserved:m});return{lang:"php",label:"PHP SDK",source:`require '${n.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,".php")}';
15
+
16
+ use ${i}\\{Client, Config};
17
+
18
+ $client = new Client(new Config());
19
+ $result = $client->${B(n.model).get(e.name)??ne(e)}(${a.join(", ")});
20
+ `}}var tn=({model:e,output:n,emit:a,pagination:i})=>[{path:n.path.replace(/\.[^.\\/]+$/,".php.md"),content:Q(e,{title:`${e.title} PHP SDK reference`,frontmatter:a.docsFrontmatter===!0,language:{name:"php",label:"PHP",fence:"php",requires:"The SDK needs the curl extension."},sample:r=>he(r,{model:e,emit:a,outputPath:n.path}),paginated:new Set(i?.keys()??[])})}];export{tn as phpDocs,nn as phpGenerator,he as phpSample,f as phpType,L as renderPhpModels};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a}from"./OUCZOBEX.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{a as mockGenerator};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as T,b as O,c as A,d as E}from"./5PXRDPHV.js";import{c as m,k as C,r as $}from"./YQW463Z7.js";import{a as R,b as y}from"./QRD3XQNU.js";import{a as q}from"./BXI4SF2U.js";import{O as u,c as H}from"./B6HS7CVY.js";import"./NEWT5A6S.js";import{e as z}from"./RFWIIJFG.js";import{createReadStream as F,createWriteStream as k,existsSync as V}from"node:fs";import{appendFile as N,mkdir as j,rm as _,writeFile as W}from"node:fs/promises";import B from"node:path";import{createInterface as G}from"node:readline";var w=class{outputPath;entriesPath;creatorVersion;writeChain=Promise.resolve();directoryEnsured=!1;started=!1;count=0;constructor(t,r){this.outputPath=B.resolve(process.cwd(),t),this.entriesPath=`${this.outputPath}.entries.tmp`,this.creatorVersion=r}get entryCount(){return this.count}add(t){let r=`${JSON.stringify(t)}
7
+ import{a as T,b as O,c as A,d as E}from"./NUNOXB7Z.js";import{c as m,k as C,r as $}from"./NTPLYWAB.js";import{a as R,b as y}from"./2U54VUOE.js";import{a as q}from"./BXI4SF2U.js";import{O as u,c as H}from"./HJ36YGCI.js";import"./NEWT5A6S.js";import{e as z}from"./RFWIIJFG.js";import{createReadStream as F,createWriteStream as k,existsSync as V}from"node:fs";import{appendFile as N,mkdir as j,rm as _,writeFile as W}from"node:fs/promises";import B from"node:path";import{createInterface as G}from"node:readline";var w=class{outputPath;entriesPath;creatorVersion;writeChain=Promise.resolve();directoryEnsured=!1;started=!1;count=0;constructor(t,r){this.outputPath=B.resolve(process.cwd(),t),this.entriesPath=`${this.outputPath}.entries.tmp`,this.creatorVersion=r}get entryCount(){return this.count}add(t){let r=`${JSON.stringify(t)}
8
8
  `,n=this.writeChain.catch(()=>{}).then(()=>this.append(r)).then(()=>{this.count+=1});return this.writeChain=n.catch(()=>{}),n}async finalize(){await this.writeChain.catch(()=>{}),await this.ensureDirectory(),await this.writeDocument(),await _(this.entriesPath,{force:!0})}async append(t){if(await this.ensureDirectory(),!this.started){await W(this.entriesPath,t,"utf8"),this.started=!0;return}await N(this.entriesPath,t,"utf8")}async ensureDirectory(){this.directoryEnsured||(await j(B.dirname(this.outputPath),{recursive:!0}),this.directoryEnsured=!0)}async writeDocument(){let t=k(this.outputPath,{encoding:"utf8"}),r=n=>new Promise((o,s)=>{t.write(n,i=>i?s(i):o())});try{let n=JSON.stringify({name:"redocly-cli proxy",version:this.creatorVersion});await r(`{
9
9
  "log": {
10
10
  "version": "1.2",
@@ -0,0 +1,78 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{g}from"./OKITK6EF.js";import{k as u,l as m}from"./4I2OVMBJ.js";import{c as C,d as j}from"./ZMCRMR2V.js";import{O as b}from"./HJ36YGCI.js";import{a as S,b as k}from"./HJYFWIVE.js";import{join as $}from"node:path";function h(r){return(r??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function v(r){return[r.group===void 0?void 0:u(r.group),r.name].filter(Boolean).join(" ")}function N(r,e){return[r,v(e),...e.positionals.map(o=>`<${o.name}>`),...e.flags.filter(o=>o.required).map(o=>`--${o.name} <${o.type}>`),...e.body?[e.body.required?"--json '<json>'":"[--json '<json>']"]:[]].filter(o=>o!=="").join(" ")}function T(r,e){r.line("| Flag | Type | Required | Description |"),r.line("| ---- | ---- | -------- | ----------- |");for(let n of e){let o=[h(n.description),n.enum===void 0?"":`One of ${n.enum.map(t=>`\`${t}\``).join(", ")}.`,n.type==="array"?"Repeat the flag for multiple values.":""].filter(t=>t!=="").join(" ");r.line(`| \`--${n.name}\` | ${n.type} | ${n.required?"yes":"no"} | ${o} |`)}r.blank()}function D(r,e,n){if(r.line(`### \`${v(e)}\``),r.blank(),e.summary!==void 0&&(r.line(h(e.summary)),r.blank()),r.line(`\`${e.method} ${e.path}\``),r.blank(),r.line("```sh"),r.line(N(n.name,e)),r.line("```"),r.blank(),e.positionals.length>0){r.line("| Argument | Description |"),r.line("| -------- | ----------- |");for(let t of e.positionals)r.line(`| \`<${t.name}>\` | ${h(t.description)} |`);r.blank()}e.flags.length>0&&T(r,e.flags);let o=[e.body===void 0?"":`Takes a JSON body${e.body.required?" (required)":""}: \`--json '<json>'\`, \`--json @file.json\`, or \`--json @-\` for stdin.`,e.unsupportedBody===void 0?"":`Takes a \`${e.unsupportedBody}\` body, which the CLI cannot build \u2014 call this operation through the generated client instead.`,e.paginated===!0?"Paginated: `--page-all` follows every page, printing one JSON page per line.":"",e.sse===!0?"Streams server-sent events as one JSON object per line.":"",e.blob===!0?"Returns binary content, so `--output <path>` is required.":""].filter(t=>t!=="");for(let t of o)r.line(t);o.length>0&&r.blank()}function w(r,e){let n=new S;e.frontmatter&&(n.line("---"),n.line(`title: ${e.title}`),n.line("---"),n.blank()),n.line(`# ${e.title}`),n.blank(),n.line(`Generated command-line reference for \`${e.name}\`, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line("## Usage"),n.blank(),n.line("```sh"),n.line(`${e.name} <command> [flags]`),n.line(`${e.name} --help`),n.line(`${e.name} schema <command> # request/response schemas`),n.line("```"),n.blank(),n.line("Install the file under any `bin` name: the command takes that name, and the credential variables below do not change."),n.blank(),n.line("## Global flags"),n.blank(),n.line("| Flag | Description |"),n.line("| ---- | ----------- |");let o=e.schemes.some(i=>i.kind==="bearer");for(let[i,s]of[["--server-url <url>","Override the server URL included in the client."],["--format <json\\|ndjson>","Output format."],["--dry-run","Print the prepared request, credentials redacted, without sending it."],["--page-all","Follow pagination, printing one JSON page per line."],["--output <path>","Write the response body to a file. Required for binary responses."],...o?[["--token <token>","Bearer token, overriding the environment."]]:[],["--json <json\\|@file\\|@->","Request body, inline or from a file or stdin."]])n.line(`| \`${i}\` | ${s} |`);n.blank();let t=m(e.name);if(n.line("## Credentials"),n.blank(),e.schemes.length===0)n.line("The description declares no security schemes, so no credentials are read.");else{n.line("Credentials come from the environment:"),n.blank(),n.line("| Scheme | Variable |"),n.line("| ------ | -------- |");for(let i of e.schemes){let s=i.kind==="bearer"?`\`${t}_TOKEN\` (or \`--token\`)`:i.kind==="basic"?`\`${t}_USERNAME\` and \`${t}_PASSWORD\``:`\`${t}_API_KEY_${m(i.key)}\``;n.line(`| ${i.kind} (\`${i.key}\`) | ${s} |`)}}n.blank(),n.line("## Exit codes"),n.blank(),n.line("| Code | Meaning |"),n.line("| ---- | ------- |");for(let[i,s]of[[0,"success"],[1,"API error (status other than 401 or 403)"],[2,"auth error (401 or 403)"],[3,"validation error"],[4,"usage error (unknown command or flag, bad `--json`)"]])n.line(`| ${i} | ${s} |`);n.blank(),n.line("Errors print one JSON object to stderr, so stdout stays clean for piping."),n.blank();let a=[...new Set(r.map(i=>i.group))];for(let i of a){let s=r.filter(l=>l.group===i);i===void 0?(n.line("## Commands"),n.blank()):(n.line(`## ${i}`),n.blank(),n.line(`Addressed as \`${e.name} ${u(i)} <command>\`.`),n.blank());for(let l of s)D(n,l,e)}return n.toString().replace(/\n{3,}/g,`
8
+
9
+ `).trimEnd()+`
10
+ `}function R(){return j["cli.ts"]}function x(){return C["cli.ts"]}var O="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function q(r){return k.snake(r).replace(/_/g,"-")}function E(r){let e=r.schema,n=e.kind==="array"?"array":e.kind==="scalar"&&(e.scalar==="integer"||e.scalar==="number")?"number":e.kind==="scalar"&&e.scalar==="boolean"?"boolean":"string";return{name:q(r.name),param:r.name,type:n,required:r.required,...e.kind==="enum"?{enum:e.values.map(String)}:{},...r.description!==void 0?{description:r.description}:{}}}function F(r){let e=r.successResponses;return e.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function M(r){return r.successResponses.find(e=>e.contentType.toLowerCase().includes("json"))?.schema}function U(r,e,n){if(n!=="flat")return{};let o=g(r,e.schemas);return"mergeBody"in o&&o.mergeBody?{merged:!0}:{}}function _(r,e,n){return n!=="flat"?{}:"collisions"in g(r,e.schemas)?{argsStyle:"grouped"}:{}}function f(r,e){let n=[];for(let o of r.services)for(let t of o.operations){let a=t.requestBody?.contentType.toLowerCase().includes("json")?t.requestBody:void 0,i=M(t);n.push({...t.tags.length>0?{group:t.tags[0]}:{},name:t.name,...t.summary!==void 0?{summary:t.summary}:{},method:t.method.toUpperCase(),path:t.path,positionals:t.pathParams.map(s=>({name:s.name,type:E(s).type,...s.description!==void 0?{description:s.description}:{}})),flags:t.queryParams.map(E),...a?{body:{required:a.required,...U(t,r,e.argsStyle)}}:{},...a===void 0&&t.requestBody!==void 0?{unsupportedBody:t.requestBody.contentType}:{},...e.pagination?.has(t.name)===!0?{paginated:!0}:{},..._(t,r,e.argsStyle),...t.sse!==void 0?{sse:!0}:{},...F(t)?{blob:!0}:{},...a!==void 0||i!==void 0?{schemas:{...a?{request:a.schema}:{},...i!==void 0?{response:i}:{}}}:{}})}return n}var P=`function isProcessEntry(): boolean {
11
+ if (process.argv[1] === undefined) return false;
12
+ try {
13
+ return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+ if (isProcessEntry()) {
19
+ process.exit(await run());
20
+ }`;function p(r,e){return JSON.stringify(r,null,e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function y(r){return r.securitySchemes.map(e=>({key:e.key,kind:e.kind==="bearer"||e.kind==="basic"?e.kind:"apiKey"}))}function B(r){return r.group===void 0?`${r.name} (keeps the bare word, so the "${r.name}" group has no help page)`:`${r.name} (run it as "${u(r.group)} ${r.name}")`}function I(r){let e=new Set(r.filter(o=>o.group).map(o=>u(o.group))),n=r.filter(o=>e.has(o.name));n.length!==0&&b.warn(`generate-client: cli reads a leading group name as the group, so ${n.length} operation(s) named after a tag resolve unusually \u2014 rename the operation or the tag: ${n.map(B).join(", ")}.
21
+ `)}function A(r,e){let n=f(r,{pagination:e.pagination,argsStyle:e.argsStyle});I(n);let o=y(r),t=`./${e.stem}.${e.importExt}`,a=["client","configure",...e.zodSelected?["use"]:[]];return["#!/usr/bin/env node",O,`import { readFileSync, realpathSync, writeFileSync } from "node:fs";
22
+ import { fileURLToPath } from "node:url";`,[`import { ${a.join(", ")} } from "${t}";`,...e.zodSelected?[`import { zodValidation } from "./${e.stem}.zod.${e.importExt}";`]:[]].join(`
23
+ `),e.runtime==="module"?`import { invokedName, runCli, type CliCommand, type CliWiring } from "./runtime/cli.${e.importExt}";`:`// \u2500\u2500\u2500 Embedded cli engine (@redocly/client-generator) \u2500\u2500\u2500
24
+ `+R(),`export const COMMANDS: CliCommand[] = ${p(n,2)};`,...e.zodSelected?['use(zodValidation(process.argv.includes("--dry-run") ? { response: false } : {}));']:[],`export const wiring: CliWiring = {
25
+ name: invokedName(process.argv[1], ${p(e.stem)}),
26
+ envPrefix: ${p(m(e.stem))},
27
+ client,
28
+ ${e.argsStyle==="flat"?` argsStyle: "flat",
29
+ `:""} configure,
30
+ schemes: ${p(o)},
31
+ env: process.env,
32
+ stdin: () => readFileSync(0, "utf-8"),
33
+ readFile: (path: string) => readFileSync(path, "utf-8"),
34
+ writeFile: (path: string, data: Uint8Array) => writeFileSync(path, data),
35
+ stdout: (line: string) => console.log(line),
36
+ stderr: (line: string) => console.error(line),
37
+ };
38
+
39
+ /** Run this CLI programmatically; defaults to the process argv. */
40
+ export const run = (argv: string[] = process.argv.slice(2)): Promise<number> =>
41
+ runCli(COMMANDS, wiring, argv);
42
+
43
+ // Re-exported so a composed entry can run these commands without its own runtime copy.
44
+ export { runCli };
45
+
46
+ // Self-execute only as the process entry, so importing this module is side-effect-safe:
47
+ // composed binaries and login-style wrappers import COMMANDS/wiring/run instead of
48
+ // editing this generated file.
49
+ ${P}`].join(`
50
+
51
+ `)+`
52
+ `}function H(r,e){let n=m(e),o=new Map;r.forEach(({alias:s},l)=>{let c=s.replace(/[^A-Za-z0-9]/g,"_"),d=/^[A-Za-z_]/.test(c)?c:`_${c}`;o.set(s,[...o.values()].includes(d)?`${d}_${l}`:d)});let t=s=>o.get(s),a=r.map(({alias:s,modulePath:l},c)=>{let d=t(s);return`import { COMMANDS as ${d}Commands, wiring as ${d}Wiring${c===0?", runCli":""} } from ${JSON.stringify(l)};`}),i=r.map(({alias:s})=>{let l=t(s),c=q(s),d=`${n}_${m(s)}`;return` {
53
+ namespace: ${JSON.stringify(c)},
54
+ commands: ${l}Commands,
55
+ wiring: { ...${l}Wiring, envPrefix: ${JSON.stringify(d)} },
56
+ },`});return["#!/usr/bin/env node",O,['import { realpathSync } from "node:fs";','import { fileURLToPath } from "node:url";',...a].join(`
57
+ `),`/** The composed sources \u2014 import SOURCES to layer custom commands around this binary. */
58
+ export const SOURCES = [
59
+ ${i.join(`
60
+ `)}
61
+ ];
62
+
63
+ /** Run the composed CLI programmatically; defaults to the process argv. */
64
+ export const run = (argv: string[] = process.argv.slice(2)): Promise<number> =>
65
+ runCli(SOURCES, argv);
66
+
67
+ // Re-exported so a wrapper (a custom \`login\` command) can run these sources itself.
68
+ export { runCli };
69
+
70
+ ${P}`].join(`
71
+
72
+ `)+`
73
+ `}var oe=({model:r,output:e,banner:n,emit:o,selected:t,pagination:a})=>{let i=A(r,{stem:e.stem,importExt:o.importExt??"js",zodSelected:t?.includes("zod")??!1,pagination:a,argsStyle:o.argsStyle??"grouped",runtime:o.runtime??"inline"}),s={path:$(e.dir,`${e.stem}.cli.ts`),content:i};if(o.runtime!=="module")return[s];let l=n.map(c=>`// ${c}`).join(`
74
+ `);return[s,{path:$(e.dir,"runtime","cli.ts"),content:`${l}
75
+
76
+ ${x().trim()}
77
+ `}]},ie=({model:r,output:e,emit:n,pagination:o})=>{let t=w(f(r,{pagination:o}),{title:`${r.title} command-line reference`,frontmatter:n.docsFrontmatter===!0,name:e.stem,schemes:y(r)});return[{path:$(e.dir,`${e.stem}.cli.md`),content:t}]};function se(r,e){let n=f(e.model,{pagination:e.pagination}).find(t=>t.name===r.name);return n===void 0?void 0:{lang:"shell",label:"CLI",source:`npx tsx client.cli.ts ${["client",...n.group?[u(n.group)]:[],n.name,...n.positionals.map(t=>`<${t.name}>`),...n.flags.filter(t=>t.required).map(t=>`--${t.name} <${t.type}>`),...n.body?["--json '<json>'"]:[]].slice(1).join(" ")}
78
+ `}}export{H as a,oe as b,ie as c,se as d};
@@ -0,0 +1,16 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as $,b as a,c,d as i,e as m,f}from"./R4XFBOJU.js";import{k as l}from"./NB54XRRU.js";import{join as p}from"node:path";function k(t,n){let e=$(t,"swr");if(e.length===0)return"";let s=e.some(a),o=e.some(r=>!a(r));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],f(e,n.sdkModule,s),...e.flatMap(r=>a(r)?g(r):[S(r)])].join(`
8
+
9
+ `)}function y(t,n,e){return`export function use${l(t.name)}(${n}) {
10
+ return ${e};
11
+ }`}function g(t){let n=c(t),e=n?`vars: ${i(t)}`:"",s=n?`[${JSON.stringify(t.name)}, vars]`:`[${JSON.stringify(t.name)}]`,o=`export const ${t.name}Key = (${e}) => ${s} as const;`,r=`useSWR(${`${t.name}Key(${n?"vars":""})`}, () => ${m(t,"vars",!0)})`,d=n?`vars: ${i(t)}, init?: Omit<RequestOptions, "envelope">`:'init?: Omit<RequestOptions, "envelope">';return[o,y(t,d,r)]}function S(t){let n=c(t)?`(_key: string, { arg }: {
12
+ arg: ${i(t)};
13
+ }) => ${m(t,"arg",!1)}`:`() => ${m(t,"arg",!1)}`,e=`useSWRMutation(${JSON.stringify(t.name)}, ${n})`;return y(t,"",e)}var x=({model:t,output:n,banner:e,emit:s})=>{let o=k(t,{sdkModule:`./${n.stem}.${s.importExt??"js"}`});if(o==="")return[];let u=e.map(r=>`// ${r}`).join(`
14
+ `);return[{path:p(n.dir,`${n.stem}.swr.ts`),content:`${u}
15
+
16
+ ${o}`}]};export{x as a};
@@ -0,0 +1,14 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as S,b as d}from"./REFX2EKS.js";import{a as C}from"./UKSQ7B5H.js";import{b as H,c as D,d as G,e as K,f as J,g as z,h as Q}from"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import{a as j}from"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import{b as A,c as I,d as v,e as L,g as E,h as x,i as B,j as F,k as W,n as _}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var c=new S,b=I.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||b.has(e))throw new j(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function w(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=d(o.name),i=2;for(;t.has(a);)a=`${d(o.name)}${i++}`;t.add(a),n.push({op:o,ident:a})}return n}function oe(e){return J(e).map(n=>n.kind==="literal"?c.string(n.value):v(n.name,{style:"camel",reserved:b})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let i=`${d(o.description??`server${a+1}`)}URL`;r.has(i)&&(i=`${i}${a+1}`),r.add(i);let s=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} string`),u=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${i} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${i}(${s.join(", ")}) string {`,()=>{e.line(`return ${oe(o)}`)},"}"),e.blank()})}function Y(e,t){let n=z(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${c.string(o.scheme)}, Kind: "apiKey", Name: ${c.string(o.name)}, In: ${c.string(o.in)}}`:`{Scheme: ${c.string(o.scheme)}, Kind: ${c.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function Z(e){return`&PaginationSpec{${[`Style: ${c.string(e.style)}`,...e.param!==void 0?[`Param: ${c.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${c.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${c.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${c.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${c.string(e.items)}`]:[]].join(", ")}}`}function g(e,t="string"){if(B(e)){let n=g(F(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${g(e.items,t)}`;case"record":return`map[string]${g(e.value,t)}`;case"ref":return d(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return d(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(d(t),o),e.block(`type ${d(t)} struct {`,()=>{for(let a of n){let i=d(a.name),s=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!s.startsWith("*")&&!s.startsWith("[]")&&!s.startsWith("map[")&&s!=="any"&&(s=`*${s}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${i} ${s} ${u}`)}},"}"),e.blank()}function N(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>x(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=ie(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function ie(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=W(o);if(a!==void 0){let s=a.scalar==="string"?"string":"int64";n.doc(d(r),o.description),n.line(`type ${d(r)} ${s}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let f=A.pascal(String(l))||"Value",m="";for(let k=2;u.has(f+m);k++)m=String(k);u.add(f+m);let h=d(r)+f+m;n.line(`${h} ${d(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let s=E(o,e);if(s!==void 0){ae(n,r,s.properties,t,s.description??o.description);continue}}let i=x(o,e);if(i!==void 0){let s=d(r),u=i.cases.map(l=>`${l.value} -> ${d(l.schemaName)}`).join(", ");n.line(`// ${s} is a discriminated union ("${i.property}"): ${u}.`),n.line(`type ${s} = any`),n.blank(),n.line(`// Unmarshal${s} decodes into the member selected by "${i.property}".`),n.block(`func Unmarshal${s}(data []byte) (${s}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${i.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of i.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${d(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(d(r),o.description),n.line(`type ${d(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function R(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var se=["c","ctx","body","params","out","op"];function T(e,t){let n=L(e.pathParams.map(r=>r.name),{style:"camel",reserved:b,taken:se});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:g(r.schema,t)}))}function le(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=d(r.name),a=o,i=2;for(;n.has(a);)a=`${o}${i++}`;n.add(a);let s=_(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[s];return{field:a,name:r.name,...u}})}function U(e,t,n,r,o,a=!1){let i=T(t,r),s=t.queryParams.length>0,u=D(t),l=u===void 0?void 0:g(u,r),f=a?le(t,o):[];a&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let p of f)e.line(`${p.field} ${p.goType}`)},"}"),e.blank());let m=["ctx context.Context",...i.map(({go:p,type:P})=>`${p} ${P}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...s?[`params *${n}Params`]:[]],h=G(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:h!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,$=p=>a?l===void 0?`return headers, ${p}`:`return out, headers, ${p}`:l===void 0?`return ${p}`:`return out, ${p}`,M=a?`${n}WithHeaders`:n;e.doc(M,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${M}(${m.join(", ")}) ${k} {`,()=>{h===void 0&&l!==void 0&&e.line(`var out ${l}`),a&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),s&&e.block("if params != nil {",()=>{for(let y of t.queryParams){let O=d(y.name);e.block(`if params.${O} != nil {`,()=>{if(y.schema.kind==="array"){let q=g(y.schema.items,r);e.block(`for _, item := range *params.${O} {`,()=>{e.line(`query.Add(${c.string(y.name)}, ${R("item",q)})`)},"}")}else e.line(`query.Set(${c.string(y.name)}, ${R(`*params.${O}`,g(y.schema,r))})`)},"}")}},"}");let p=i.map(({param:y,go:O,type:q})=>`${c.string(y.name)}: ${R(O,q)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${p}})`),h!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${h.schema!==void 0&&h.schema.kind!=="unknown"})`);return}let P=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&K(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: reader"),P.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: bytes.NewReader(payload)"),P.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${P.join(", ")}})`),e.block("if err != nil {",()=>{e.line($("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line($("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line($("err"))},"}");for(let y of f)e.line(`headers.${y.field} = ${y.helper}(resp.Header, ${c.string(y.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function ee(e,t,n,r,o,a){let i=T(t,r),s=t.queryParams.length>0,u=["ctx context.Context",...i.map(({go:f,type:m})=>`${f} ${m}`),...s?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),s&&e.block("if params != nil {",()=>{for(let f of t.queryParams){let m=d(f.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(f.name)}, ${R(`*params.${m}`,g(f.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let f=i.map(({param:m,go:h,type:k})=>`${c.string(m.name)}: ${R(h,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${f}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${u}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${u}) func(yield func(${a}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${a}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${a}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${a}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function ne(e){let t=e.split(`
8
+ `),n=[],r=!1;for(let o of t)if(!o.startsWith("package ")){if(o.startsWith("import (")){r=!0;continue}if(r){o.startsWith(")")&&(r=!1);continue}o.startsWith("import ")||n.push(o)}return n.join(`
9
+ `).trim()}var te=["bytes","context","encoding/base64","encoding/json","errors","fmt","io","math/rand","mime/multipart","net/http","net/url","strconv","strings","time"];function re(e,t,n,r,o,a){e.line(ne(N(t,r))),e.blank(),X(e,t),a&&(e.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator go runtime) \u2500\u2500\u2500"),e.line(ne(C)),e.blank()),e.block("type operationMeta struct {",()=>{e.line("ID string"),e.line("Method string"),e.line("Path string"),e.line("Security [][]SecuritySpec"),e.line("Pagination *PaginationSpec")},"}"),e.blank(),e.block("var operations = map[string]operationMeta{",()=>{for(let{op:i,ident:s}of w(t)){let u=i.specName??i.name,l=Y(i,t),f=o.get(s),m=[`ID: ${c.string(u)}`,`Method: ${c.string(i.method.toUpperCase())}`,`Path: ${c.string(i.path)}`,...l!==void 0?[`Security: ${l}`]:[],...f!==void 0?[`Pagination: ${Z(f)}`]:[]];e.line(`${c.string(u)}: {${m.join(", ")}},`)}},"}"),e.blank();for(let{op:i,ident:s}of w(t))i.queryParams.length!==0&&(e.block(`type ${s}Params struct {`,()=>{for(let u of i.queryParams){let l=g(u.schema,r);e.line(`${d(u.name)} ${l.startsWith("*")?l:`*${l}`}`)}},"}"),e.blank());e.doc("Client",`Client for ${t.title} (${t.version}).`),e.block("type Client struct {",()=>{e.line("config Config")},"}"),e.blank(),e.block("func New(config Config) *Client {",()=>{e.block('if config.ServerURL == "" {',()=>{e.line(`config.ServerURL = ${c.string(n.serverUrl??t.serverUrl??"")}`)},"}"),e.line("return &Client{config: config}")},"}"),e.blank();for(let{op:i,ident:s}of w(t)){U(e,i,s,r),G(i)===void 0&&(i.successResponseHeaders?.length??0)>0&&U(e,i,s,r,t,!0);let u=o.get(s);if(u===void 0)continue;let l=D(i),f=l===void 0?"any":g(l,r),m=Q(l,u.items,t);ee(e,i,s,r,f,m===void 0?"any":g(m,r))}}var ze=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let a=new S,i=r.dateType??"string",s=V(r.goPackage),u=new Map;for(let{op:$,ident:M}of w(e)){let p=o?.get($.name)?.spec;p!==void 0&&u.set(M,p)}a.line(`// Code generated by @redocly/client-generator (go) from "${e.title}" ${e.version}. DO NOT EDIT.`),a.line("// Regenerate with `redocly generate-client`. Standard library only \u2014 zero dependencies."),a.line(`package ${s}`),a.blank();let l=r.runtime!=="module",f=l?te:(()=>{let $=new S;re($,e,r,i,u,!1);let M=$.toString();return te.filter(p=>new RegExp(`\\b${p.split("/").pop()}\\.`).test(M))})();a.block("import (",()=>{for(let $ of f)a.line(c.string($))},")"),a.blank(),re(a,e,r,i,u,l);let m={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:a.toString()};if(l)return[m];let h=n.map($=>`// ${$}`).join(`
10
+ `),k=C.replace(/^package .*$/m,`package ${s}`);return[m,{path:m.path.replace(/[^\\/]+$/,"runtime.go"),content:`${h}
11
+ ${k.trimEnd()}
12
+ `}]};function ce(e,t){let n=t.emit.dateType??"string",r=t.emit.goPackage??"client",o=w(t.model).find(u=>u.op.name===e.name)?.ident??d(e.name),a=["ctx",...e.pathParams.map(u=>`"<${v(u.name,{style:"camel",reserved:b})}>"`),...e.requestBody?[`${g(e.requestBody.schema,n)}{ /* \u2026 */ }`]:[],...e.queryParams.length>0?["nil"]:[]],i=`client.${o}(${a.join(", ")})`,s=G(e)!==void 0?`stream := ${i}`:D(e)===void 0?`err := ${i}`:`result, err := ${i}`;return{lang:"go",label:"Go SDK",source:`client := ${r}.New(${r}.Config{})
13
+ ${s}
14
+ `}}var Qe=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".go.md"),content:H(e,{title:`${e.title} Go SDK reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"go",label:"Go",fence:"go",requires:"The SDK needs the standard library only."},sample:o=>ce(o,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];export{Qe as goDocs,ze as goGenerator,ce as goSample,g as goType,N as renderGoModels};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{d as a,e as b,f as c}from"./MHITBEGC.js";import"./UKSQ7B5H.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};