@ahoo-wang/fetcher-generator 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("commander"),a=require("./index.cjs");require("@ahoo-wang/fetcher");require("yaml");require("fs");require("path");class f{getTimestamp(){return new Date().toTimeString().slice(0,8)}info(e,...t){const o=this.getTimestamp();t.length>0?console.log(`[${o}] ℹ️ ${e}`,...t):console.log(`[${o}] ℹ️ ${e}`)}success(e,...t){const o=this.getTimestamp();t.length>0?console.log(`[${o}] ✅ ${e}`,...t):console.log(`[${o}] ✅ ${e}`)}error(e,...t){const o=this.getTimestamp();t.length>0?console.error(`[${o}] ❌ ${e}`,...t):console.error(`[${o}] ❌ ${e}`)}progress(e,t=0,...o){const i=this.getTimestamp(),r=" ".repeat(t);o.length>0?console.log(`[${i}] 🔄 ${r}${e}`,...o):console.log(`[${i}] 🔄 ${r}${e}`)}progressWithCount(e,t,o,i=0,...r){const s=this.getTimestamp(),p=" ".repeat(i),l=`[${e}/${t}]`;r.length>0?console.log(`[${s}] 🔄 ${p}${l} ${o}`,...r):console.log(`[${s}] 🔄 ${p}${l} ${o}`)}}function h(n){if(!n)return!1;try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return n.length>0}}async function $(n){const e=new f;process.on("SIGINT",()=>{e.error("Generation interrupted by user"),process.exit(130)}),h(n.input)||(e.error("Invalid input: must be a valid file path or HTTP/HTTPS URL"),process.exit(2));try{e.info("Starting code generation...");const t={inputPath:n.input,outputDir:n.output,configPath:n.config,tsConfigFilePath:n.tsConfigFilePath,logger:e};await new a.CodeGenerator(t).generate(),e.success(`Code generation completed successfully! Files generated in: ${n.output}`)}catch(t){e.error(`Error during code generation: ${t}`),process.exit(1)}}const d="3.1.1",m={version:d};function u(){return c.program.name("fetcher-generator").description("OpenAPI Specification TypeScript code generator for Wow").version(m.version,"-v, --version"),c.program.command("generate").description("Generate TypeScript code from OpenAPI specification").requiredOption("-i, --input <file>","Input OpenAPI specification file path or URL (http/https)").option("-o, --output <path>","Output directory path","src/generated").option("-c, --config <file>","Configuration file path",a.DEFAULT_CONFIG_PATH).option("-t, --ts-config-file-path <file>","TypeScript configuration file path").action($),c.program}function g(){u().parse()}g();exports.runCLI=g;exports.setupCLI=u;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("commander"),a=require("./index.cjs");require("@ahoo-wang/fetcher");require("yaml");require("fs");require("path");class f{getTimestamp(){return new Date().toTimeString().slice(0,8)}info(e,...t){const o=this.getTimestamp();t.length>0?console.log(`[${o}] ℹ️ ${e}`,...t):console.log(`[${o}] ℹ️ ${e}`)}success(e,...t){const o=this.getTimestamp();t.length>0?console.log(`[${o}] ✅ ${e}`,...t):console.log(`[${o}] ✅ ${e}`)}error(e,...t){const o=this.getTimestamp();t.length>0?console.error(`[${o}] ❌ ${e}`,...t):console.error(`[${o}] ❌ ${e}`)}progress(e,t=0,...o){const i=this.getTimestamp(),r=" ".repeat(t);o.length>0?console.log(`[${i}] 🔄 ${r}${e}`,...o):console.log(`[${i}] 🔄 ${r}${e}`)}progressWithCount(e,t,o,i=0,...r){const s=this.getTimestamp(),p=" ".repeat(i),l=`[${e}/${t}]`;r.length>0?console.log(`[${s}] 🔄 ${p}${l} ${o}`,...r):console.log(`[${s}] 🔄 ${p}${l} ${o}`)}}function h(n){if(!n)return!1;try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return n.length>0}}async function $(n){const e=new f;process.on("SIGINT",()=>{e.error("Generation interrupted by user"),process.exit(130)}),h(n.input)||(e.error("Invalid input: must be a valid file path or HTTP/HTTPS URL"),process.exit(2));try{e.info("Starting code generation...");const t={inputPath:n.input,outputDir:n.output,configPath:n.config,tsConfigFilePath:n.tsConfigFilePath,logger:e};await new a.CodeGenerator(t).generate(),e.success(`Code generation completed successfully! Files generated in: ${n.output}`)}catch(t){e.error(`Error during code generation: ${t}`),process.exit(1)}}const d="3.1.2",m={version:d};function u(){return c.program.name("fetcher-generator").description("OpenAPI Specification TypeScript code generator for Wow").version(m.version,"-v, --version"),c.program.command("generate").description("Generate TypeScript code from OpenAPI specification").requiredOption("-i, --input <file>","Input OpenAPI specification file path or URL (http/https)").option("-o, --output <path>","Output directory path","src/generated").option("-c, --config <file>","Configuration file path",a.DEFAULT_CONFIG_PATH).option("-t, --ts-config-file-path <file>","TypeScript configuration file path").action($),c.program}function g(){u().parse()}g();exports.runCLI=g;exports.setupCLI=u;
3
3
  //# sourceMappingURL=cli.cjs.map
package/dist/cli.js CHANGED
@@ -63,7 +63,7 @@ async function h(n) {
63
63
  e.error(`Error during code generation: ${t}`), process.exit(1);
64
64
  }
65
65
  }
66
- const $ = "3.1.1", m = {
66
+ const $ = "3.1.2", m = {
67
67
  version: $
68
68
  };
69
69
  function d() {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ts-morph"),f=require("@ahoo-wang/fetcher"),k=require("@ahoo-wang/fetcher-wow"),K=require("yaml"),ye=require("fs"),L=require("path");function T(o){return o.$ref.split("/").pop()}function S(o,e){const t=T(o);return e.schemas?.[t]}function H(o,e){const t=T(o);return e.requestBodies?.[t]}function Y(o,e){const t=T(o);return e.parameters?.[t]}function v(o,e){return{key:T(o),schema:S(o,e)}}const xe=/[-_\s.]+/;function O(o){return o.split(xe)}function X(o){return Array.isArray(o)?o.flatMap(e=>z(O(e))):z(O(o))}function z(o){return o.flatMap(e=>{if(e.length===0)return[];const t=[];let n="";for(let r=0;r<e.length;r++){const i=e[r],s=/[A-Z]/.test(i),a=r>0&&/[a-z]/.test(e[r-1]);s&&a&&n?(t.push(n),n=i):n+=i}return n&&t.push(n),t})}function R(o){return o===""||o.length===0?"":X(o).filter(t=>t.length>0).map(t=>{const n=t.charAt(0),r=t.slice(1);return(/[a-zA-Z]/.test(n)?n.toUpperCase():n)+r.toLowerCase()}).join("")}function h(o){const e=R(o);return e.charAt(0).toLowerCase()+e.slice(1)}function Z(o){return o===""||Array.isArray(o)&&o.length===0?"":X(o).filter(t=>t.length>0).map(t=>t.toUpperCase()).join("_")}function g(o){return!!(o&&typeof o=="object"&&"$ref"in o)}function j(o,e){if(e&&!g(e)&&e.content)return e.content[o]?.schema}function ee(o){return j(f.ContentTypeValues.APPLICATION_JSON,o)}function Ae(o){return j(f.ContentTypeValues.TEXT_EVENT_STREAM,o)}function Ce(o){return j("*/*",o)}const Pe=["string","number","integer","boolean","null"];function te(o){return Array.isArray(o)?!0:Pe.includes(o)}function U(o){return Array.isArray(o.enum)&&o.enum.length>0}function I(o){return o.type==="object"&&!!o.properties}function N(o){return o.type==="array"&&!!o.items}function $e(o){return Array.isArray(o.anyOf)&&o.anyOf.length>0}function Te(o){return Array.isArray(o.oneOf)&&o.oneOf.length>0}function b(o){return Array.isArray(o.allOf)&&o.allOf.length>0}function B(o){return $e(o)||Te(o)||b(o)}function ve(o){return o.includes("|")||o.includes("&")?`(${o})[]`:`${o}[]`}function Ie(o){return o.type==="object"&&!o.properties&&o.additionalProperties!==void 0}function Ee(o){return o.type!=="object"?!1:o.properties?Object.keys(o.properties).length===0:!0}function Se(o){return o.readOnly===!0}function w(o){if(Array.isArray(o))return o.map(e=>w(e)).join(" | ");switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"any"}}function Re(o){if(!I(o))return[];const e=o.required||[];return Object.keys(o.properties).filter(t=>!e.includes(t))}function we(o,e){return o.operation.operationId&&e.operation.operationId?o.operation.operationId.localeCompare(e.operation.operationId):o.path&&e.path?o.path.localeCompare(e.path):o.method&&e.method?o.method.localeCompare(e.method):0}function ne(o){const e=[];for(const[t,n]of Object.entries(o))oe(n).forEach(r=>{e.push({method:r.method,operation:r.operation,path:t})});return e.sort(we)}function oe(o){return[{method:"get",operation:o.get},{method:"put",operation:o.put},{method:"post",operation:o.post},{method:"delete",operation:o.delete},{method:"options",operation:o.options},{method:"head",operation:o.head},{method:"patch",operation:o.patch},{method:"trace",operation:o.trace}].filter(({operation:e})=>e!==void 0)}function G(o){return o.responses[200]}function J(o){const e=G(o);return ee(e)}function De(o,e){return o.parameters?o.parameters.map(t=>g(t)?Y(t,e):t).filter(t=>t.in==="path"):[]}const Oe="string";function re(o){return!o.schema||g(o.schema)||!o.schema.type||!te(o.schema.type)?Oe:w(o.schema.type)}function ie(o){return o.startsWith("http://")||o.startsWith("https://")?Ne(o):be(o)}async function Ne(o){return await(await fetch(o)).text()}function be(o){return new Promise((e,t)=>{ye.readFile(o,"utf-8",(n,r)=>{n?t(n):e(r)})})}async function Me(o){const e=await ie(o);switch(se(e)){case"json":return JSON.parse(e);case"yaml":return K.parse(e);default:throw new Error(`Unsupported file format: ${o}`)}}async function qe(o){const e=await ie(o);switch(se(e)){case"json":return JSON.parse(e);case"yaml":return K.parse(e);default:throw new Error(`Unsupported file format: ${o}`)}}function se(o){const e=o.trimStart();if(e.startsWith("{")||e.startsWith("["))return"json";if(e.startsWith("-")||e.startsWith("%YAML"))return"yaml";try{return JSON.parse(e),"json"}catch{if(e.length>0)return"yaml"}throw new Error("Unable to infer file format")}const ae="types.ts",Fe="@";function je(o){return f.combineURLs(o.path,ae)}function ce(o,e,t){const n=f.combineURLs(e,t),r=o.getSourceFile(n);return r||o.createSourceFile(n,"",{overwrite:!0})}function C(o,e,t){let n=o.getImportDeclaration(r=>r.getModuleSpecifierValue()===e);n||(n=o.addImportDeclaration({moduleSpecifier:e})),t.forEach(r=>{n.getNamedImports().some(s=>s.getName()===r)||n.addNamedImport(r)})}function m(o,e,t){if(t.path.startsWith(Fe)){C(o,t.path,[t.name]);return}const n=o.getDirectoryPath(),r=L.join(e,t.path,ae);let i=L.relative(n,r);i=i.replace(/\.ts$/,""),i.startsWith(".")||(i="./"+i),C(o,i,[t.name])}function Ge(o,e,t,n){o.path!==n.path&&m(e,t,n)}function ge(o,e=`
2
- `){if(!Array.isArray(o))return;const t=o.filter(n=>typeof n=="string"&&n.length>0);return t.length>0?t.join(e):void 0}function P(o,e){const t=ge(e);t&&o.addJsDoc(t)}function _(o,e){const t=[o.title,o.description];return e&&t.push(`- key: ${e}`),o.format&&t.push(`- format: ${o.format}`),Q(t,o,"default"),Q(t,o,"example"),ke(t,o),Le(t,o),ze(t,o),t}function _e(o,e,t){const n=_(e,t);P(o,n)}function We(o,e,t){const n=_(e,t);pe(n,"schema",e),P(o,n)}function Q(o,e,t){const n=e[t];if(n){if(typeof n!="object"){o.push(`- ${t}: \`${n}\``);return}pe(o,t,n)}}function pe(o,e,t){o.push(`- ${e}: `),o.push("```json"),o.push(JSON.stringify(t)),o.push("```")}function ke(o,e){const t=["- Numeric Constraints"];e.minimum!==void 0&&t.push(` - minimum: ${e.minimum}`),e.maximum!==void 0&&t.push(` - maximum: ${e.maximum}`),e.exclusiveMinimum!==void 0&&t.push(` - exclusiveMinimum: ${e.exclusiveMinimum}`),e.exclusiveMaximum!==void 0&&t.push(` - exclusiveMaximum: ${e.exclusiveMaximum}`),e.multipleOf!==void 0&&t.push(` - multipleOf: ${e.multipleOf}`),t.length!==1&&o.push(...t)}function Le(o,e){const t=["- String Constraints"];e.minLength!==void 0&&t.push(` - minLength: ${e.minLength}`),e.maxLength!==void 0&&t.push(` - maxLength: ${e.maxLength}`),e.pattern!==void 0&&t.push(` - pattern: ${e.pattern}`),t.length!==1&&o.push(...t)}function ze(o,e){const t=["- Array Constraints"];e.minItems!==void 0&&t.push(` - minItems: ${e.minItems}`),e.maxItems!==void 0&&t.push(` - maxItems: ${e.maxItems}`),e.uniqueItems!==void 0&&t.push(` - uniqueItems: ${e.uniqueItems}`),t.length!==1&&o.push(...t)}function Ue(o){const e=o.split(".");return e.length!=2||e[0].length===0||e[1].length===0?null:e}function Be(o){const e=Ue(o.name);return e?{tag:o,contextAlias:e[0],aggregateName:e[1]}:null}function Je(o){const e=o?.map(n=>Be(n)).filter(n=>n!==null);if(!e)return new Map;const t=new Map;return e.forEach(n=>{t.set(n.tag.name,{aggregate:n,commands:new Map,events:new Map})}),t}function Qe(o){if(!o)return null;const e=o.split(".");return e.length!=3?null:e[2]}const Ve="#/components/responses/wow.CommandOk",Ke="#/components/parameters/wow.id";class He{constructor(e){this.openAPI=e,this.aggregates=Je(e.tags),this.build()}aggregates;build(){const e=ne(this.openAPI.paths);for(const t of e)this.commands(t.path,t),this.state(t.operation),this.events(t.operation),this.fields(t.operation)}resolve(){const e=new Map;for(const t of this.aggregates.values()){if(!t.state||!t.fields)continue;const n=t.aggregate.contextAlias;let r=e.get(n);r||(r=new Set,e.set(n,r)),r.add(t)}return e}commands(e,t){const n=t.operation;if(n.operationId==="wow.command.send")return;const r=Qe(n.operationId);if(!r)return;const i=G(n);if(!i||!g(i)||i.$ref!==Ve||!n.requestBody)return;const s=n.parameters??[],a=s.filter(l=>g(l)&&l.$ref===Ke).at(0),c=s.filter(l=>!g(l)&&l.in==="path");if(a){const l=Y(a,this.openAPI.components);c.push(l)}const p=n.requestBody.content[f.ContentTypeValues.APPLICATION_JSON].schema,x=v(p,this.openAPI.components);x.schema.title=x.schema.title||n.summary,x.schema.description=x.schema.description||n.description;const he={name:r,method:t.method,path:e,pathParameters:c,summary:n.summary,description:n.description,schema:x,operation:n};n.tags?.forEach(l=>{const W=this.aggregates.get(l);W&&W.commands.set(r,he)})}state(e){if(!e.operationId?.endsWith(".snapshot_state.single"))return;const t=J(e);if(!g(t))return;const n=v(t,this.openAPI.components);e.tags?.forEach(r=>{const i=this.aggregates.get(r);i&&(i.state=n)})}events(e){if(!this.openAPI.components||!e.operationId?.endsWith(".event.list_query"))return;const t=J(e);if(g(t))return;const n=t?.items;if(!g(n))return;const i=S(n,this.openAPI.components).properties.body.items.anyOf.map(s=>{const a=s.title,c=s.properties.name.const,u=s.properties.body,p=v(u,this.openAPI.components);return p.schema.title=p.schema.title||s.title,{title:a,name:c,schema:p}});e.tags?.forEach(s=>{const a=this.aggregates.get(s);a&&i.forEach(c=>{a.events.set(c.name,c)})})}fields(e){if(!this.openAPI.components||!e.operationId?.endsWith(".snapshot.count"))return;const n=H(e.requestBody,this.openAPI.components).content[f.ContentTypeValues.APPLICATION_JSON].schema,i=S(n,this.openAPI.components).properties?.field,s=v(i,this.openAPI.components);e.tags?.forEach(a=>{const c=this.aggregates.get(a);c&&(c.fields=s)})}}const $="@ahoo-wang/fetcher-wow",Ye={"wow.command.CommandResult":"CommandResult","wow.command.CommandResultArray":"CommandResultArray","wow.MessageHeaderSqlType":"MessageHeaderSqlType","wow.api.BindingError":"BindingError","wow.api.DefaultErrorInfo":"ErrorInfo","wow.api.RecoverableType":"RecoverableType","wow.api.command.DefaultDeleteAggregate":"DeleteAggregate","wow.api.command.DefaultRecoverAggregate":"RecoverAggregate","wow.api.messaging.FunctionInfoData":"FunctionInfo","wow.api.messaging.FunctionKind":"FunctionKind","wow.api.modeling.AggregateId":"AggregateId","wow.api.query.Condition":"Condition","wow.api.query.ConditionOptions":"ConditionOptions","wow.api.query.ListQuery":"ListQuery","wow.api.query.Operator":"Operator","wow.api.query.PagedQuery":"PagedQuery","wow.api.query.Pagination":"Pagination","wow.api.query.Projection":"Projection","wow.api.query.Sort":"FieldSort","wow.api.query.Sort.Direction":"SortDirection","wow.command.CommandStage":"CommandStage","wow.command.SimpleWaitSignal":"WaitSignal","wow.configuration.Aggregate":"Aggregate","wow.configuration.BoundedContext":"BoundedContext","wow.configuration.WowMetadata":"WowMetadata","wow.modeling.DomainEvent":"DomainEvent","wow.openapi.BatchResult":"BatchResult","wow.messaging.CompensationTarget":"CompensationTarget"};function d(o){if(!o)return{name:"",path:"/"};const e=Ye[o];if(e)return{name:e,path:$};const t=o.split(".");let n=-1;for(let c=0;c<t.length;c++)if(t[c]&&/^[A-Z]/.test(t[c])){n=c;break}const r=t.slice(0,n),i=r.length>0?`/${r.join("/")}`:"/",s=t.slice(n);return{name:R(s),path:i}}function E(o){const e=T(o);return d(e)}function D(o){return`${Z(o)}_BOUNDED_CONTEXT_ALIAS`}class Xe{constructor(e,t,n,r){this.modelInfo=e,this.sourceFile=t,this.keySchema=n,this.outputDir=r}generate(){const e=this.process();e&&We(e,this.keySchema.schema,this.keySchema.key)}process(){const{schema:e}=this.keySchema;return U(e)?this.processEnum(e):I(e)?this.processInterface(e):N(e)?this.processArray(e):b(e)?this.processIntersection(e):B(e)?this.processComposition(e):this.processTypeAlias(e)}resolveReference(e){const t=E(e);return Ge(this.modelInfo,this.sourceFile,this.outputDir,t),t}resolveAdditionalProperties(e){return e.additionalProperties===void 0||e.additionalProperties===!1?"":e.additionalProperties===!0?"[key: string]: any":`[key: string]: ${this.resolveType(e.additionalProperties)}`}resolvePropertyDefinitions(e){const{properties:t}=e;return Object.entries(t).map(([n,r])=>{const i=this.resolveType(r);if(!g(r)){const s=_(r),a=ge(s,`
2
+ `){if(!Array.isArray(o))return;const t=o.filter(n=>typeof n=="string"&&n.length>0);return t.length>0?t.join(e):void 0}function P(o,e){const t=ge(e);t&&o.addJsDoc(t)}function _(o,e){const t=[o.title,o.description];return e&&t.push(`- key: ${e}`),o.format&&t.push(`- format: ${o.format}`),Q(t,o,"default"),Q(t,o,"example"),ke(t,o),Le(t,o),ze(t,o),t}function _e(o,e,t){const n=_(e,t);P(o,n)}function We(o,e,t){const n=_(e,t);pe(n,"schema",e),P(o,n)}function Q(o,e,t){const n=e[t];if(n){if(typeof n!="object"){o.push(`- ${t}: \`${n}\``);return}pe(o,t,n)}}function pe(o,e,t){o.push(`- ${e}: `),o.push("```json"),o.push(JSON.stringify(t,null,2)),o.push("```")}function ke(o,e){const t=["- Numeric Constraints"];e.minimum!==void 0&&t.push(` - minimum: ${e.minimum}`),e.maximum!==void 0&&t.push(` - maximum: ${e.maximum}`),e.exclusiveMinimum!==void 0&&t.push(` - exclusiveMinimum: ${e.exclusiveMinimum}`),e.exclusiveMaximum!==void 0&&t.push(` - exclusiveMaximum: ${e.exclusiveMaximum}`),e.multipleOf!==void 0&&t.push(` - multipleOf: ${e.multipleOf}`),t.length!==1&&o.push(...t)}function Le(o,e){const t=["- String Constraints"];e.minLength!==void 0&&t.push(` - minLength: ${e.minLength}`),e.maxLength!==void 0&&t.push(` - maxLength: ${e.maxLength}`),e.pattern!==void 0&&t.push(` - pattern: ${e.pattern}`),t.length!==1&&o.push(...t)}function ze(o,e){const t=["- Array Constraints"];e.minItems!==void 0&&t.push(` - minItems: ${e.minItems}`),e.maxItems!==void 0&&t.push(` - maxItems: ${e.maxItems}`),e.uniqueItems!==void 0&&t.push(` - uniqueItems: ${e.uniqueItems}`),t.length!==1&&o.push(...t)}function Ue(o){const e=o.split(".");return e.length!=2||e[0].length===0||e[1].length===0?null:e}function Be(o){const e=Ue(o.name);return e?{tag:o,contextAlias:e[0],aggregateName:e[1]}:null}function Je(o){const e=o?.map(n=>Be(n)).filter(n=>n!==null);if(!e)return new Map;const t=new Map;return e.forEach(n=>{t.set(n.tag.name,{aggregate:n,commands:new Map,events:new Map})}),t}function Qe(o){if(!o)return null;const e=o.split(".");return e.length!=3?null:e[2]}const Ve="#/components/responses/wow.CommandOk",Ke="#/components/parameters/wow.id";class He{constructor(e){this.openAPI=e,this.aggregates=Je(e.tags),this.build()}aggregates;build(){const e=ne(this.openAPI.paths);for(const t of e)this.commands(t.path,t),this.state(t.operation),this.events(t.operation),this.fields(t.operation)}resolve(){const e=new Map;for(const t of this.aggregates.values()){if(!t.state||!t.fields)continue;const n=t.aggregate.contextAlias;let r=e.get(n);r||(r=new Set,e.set(n,r)),r.add(t)}return e}commands(e,t){const n=t.operation;if(n.operationId==="wow.command.send")return;const r=Qe(n.operationId);if(!r)return;const i=G(n);if(!i||!g(i)||i.$ref!==Ve||!n.requestBody)return;const s=n.parameters??[],a=s.filter(l=>g(l)&&l.$ref===Ke).at(0),c=s.filter(l=>!g(l)&&l.in==="path");if(a){const l=Y(a,this.openAPI.components);c.push(l)}const p=n.requestBody.content[f.ContentTypeValues.APPLICATION_JSON].schema,x=v(p,this.openAPI.components);x.schema.title=x.schema.title||n.summary,x.schema.description=x.schema.description||n.description;const he={name:r,method:t.method,path:e,pathParameters:c,summary:n.summary,description:n.description,schema:x,operation:n};n.tags?.forEach(l=>{const W=this.aggregates.get(l);W&&W.commands.set(r,he)})}state(e){if(!e.operationId?.endsWith(".snapshot_state.single"))return;const t=J(e);if(!g(t))return;const n=v(t,this.openAPI.components);e.tags?.forEach(r=>{const i=this.aggregates.get(r);i&&(i.state=n)})}events(e){if(!this.openAPI.components||!e.operationId?.endsWith(".event.list_query"))return;const t=J(e);if(g(t))return;const n=t?.items;if(!g(n))return;const i=S(n,this.openAPI.components).properties.body.items.anyOf.map(s=>{const a=s.title,c=s.properties.name.const,u=s.properties.body,p=v(u,this.openAPI.components);return p.schema.title=p.schema.title||s.title,{title:a,name:c,schema:p}});e.tags?.forEach(s=>{const a=this.aggregates.get(s);a&&i.forEach(c=>{a.events.set(c.name,c)})})}fields(e){if(!this.openAPI.components||!e.operationId?.endsWith(".snapshot.count"))return;const n=H(e.requestBody,this.openAPI.components).content[f.ContentTypeValues.APPLICATION_JSON].schema,i=S(n,this.openAPI.components).properties?.field,s=v(i,this.openAPI.components);e.tags?.forEach(a=>{const c=this.aggregates.get(a);c&&(c.fields=s)})}}const $="@ahoo-wang/fetcher-wow",Ye={"wow.command.CommandResult":"CommandResult","wow.command.CommandResultArray":"CommandResultArray","wow.MessageHeaderSqlType":"MessageHeaderSqlType","wow.api.BindingError":"BindingError","wow.api.DefaultErrorInfo":"ErrorInfo","wow.api.RecoverableType":"RecoverableType","wow.api.command.DefaultDeleteAggregate":"DeleteAggregate","wow.api.command.DefaultRecoverAggregate":"RecoverAggregate","wow.api.messaging.FunctionInfoData":"FunctionInfo","wow.api.messaging.FunctionKind":"FunctionKind","wow.api.modeling.AggregateId":"AggregateId","wow.api.query.Condition":"Condition","wow.api.query.ConditionOptions":"ConditionOptions","wow.api.query.ListQuery":"ListQuery","wow.api.query.Operator":"Operator","wow.api.query.PagedQuery":"PagedQuery","wow.api.query.Pagination":"Pagination","wow.api.query.Projection":"Projection","wow.api.query.Sort":"FieldSort","wow.api.query.Sort.Direction":"SortDirection","wow.command.CommandStage":"CommandStage","wow.command.SimpleWaitSignal":"WaitSignal","wow.configuration.Aggregate":"Aggregate","wow.configuration.BoundedContext":"BoundedContext","wow.configuration.WowMetadata":"WowMetadata","wow.modeling.DomainEvent":"DomainEvent","wow.openapi.BatchResult":"BatchResult","wow.messaging.CompensationTarget":"CompensationTarget"};function d(o){if(!o)return{name:"",path:"/"};const e=Ye[o];if(e)return{name:e,path:$};const t=o.split(".");let n=-1;for(let c=0;c<t.length;c++)if(t[c]&&/^[A-Z]/.test(t[c])){n=c;break}const r=t.slice(0,n),i=r.length>0?`/${r.join("/")}`:"/",s=t.slice(n);return{name:R(s),path:i}}function E(o){const e=T(o);return d(e)}function D(o){return`${Z(o)}_BOUNDED_CONTEXT_ALIAS`}class Xe{constructor(e,t,n,r){this.modelInfo=e,this.sourceFile=t,this.keySchema=n,this.outputDir=r}generate(){const e=this.process();e&&We(e,this.keySchema.schema,this.keySchema.key)}process(){const{schema:e}=this.keySchema;return U(e)?this.processEnum(e):I(e)?this.processInterface(e):N(e)?this.processArray(e):b(e)?this.processIntersection(e):B(e)?this.processComposition(e):this.processTypeAlias(e)}resolveReference(e){const t=E(e);return Ge(this.modelInfo,this.sourceFile,this.outputDir,t),t}resolveAdditionalProperties(e){return e.additionalProperties===void 0||e.additionalProperties===!1?"":e.additionalProperties===!0?"[key: string]: any":`[key: string]: ${this.resolveType(e.additionalProperties)}`}resolvePropertyDefinitions(e){const{properties:t}=e;return Object.entries(t).map(([n,r])=>{const i=this.resolveType(r);if(!g(r)){const s=_(r),a=ge(s,`
3
3
  * `);if(a)return`
4
4
  /**
5
5
  * ${a}