(path: string, input: ReadonlyArray<InputField>)
| 584 | } |
| 585 | |
| 586 | function promisePath(path: string, input: ReadonlyArray<InputField>) { |
| 587 | if (path.includes("*")) throw new GenerationError({ reason: `Unsupported Promise path wildcard: ${path}` }) |
| 588 | const fields = new Set(input.filter((field) => field.source === "params").map((field) => field.name)) |
| 589 | const segments = path.split(/(:[A-Za-z_][A-Za-z0-9_]*)/g).filter(Boolean) |
| 590 | const template = segments |
| 591 | .map((segment) => { |
| 592 | if (!segment.startsWith(":")) return segment.replaceAll("`", "\\`") |
| 593 | const name = segment.slice(1) |
| 594 | if (!fields.has(name)) throw new GenerationError({ reason: `Missing path parameter: ${name}` }) |
| 595 | return `\${encodeURIComponent(input.${name})}` |
| 596 | }) |
| 597 | .join("") |
| 598 | return `\`${template}\`` |
| 599 | } |
| 600 | |
| 601 | function uniqueModule(base: string, index: number, modules: ReadonlySet<string>) { |
| 602 | if (!modules.has(base.toLowerCase())) return base |
no outgoing calls
no test coverage detected