( meta: (typeof operationMeta)[keyof typeof operationMeta], cmdOpts: Record<string, unknown>, )
| 53 | } |
| 54 | |
| 55 | function buildOpts( |
| 56 | meta: (typeof operationMeta)[keyof typeof operationMeta], |
| 57 | cmdOpts: Record<string, unknown>, |
| 58 | ): Record<string, string | undefined> { |
| 59 | const opts: Record<string, string | undefined> = {} |
| 60 | const rawBody = cmdOpts.body as string | undefined |
| 61 | if (rawBody) |
| 62 | try { |
| 63 | const parsed = JSON.parse(rawBody) as Record<string, unknown> |
| 64 | for (const [k, v] of Object.entries(parsed)) if (v !== undefined) opts[k] = String(v) |
| 65 | return opts |
| 66 | } catch { |
| 67 | console.error('Invalid --body JSON') |
| 68 | process.exit(1) |
| 69 | } |
| 70 | |
| 71 | for (const p of meta.pathParams) opts[p.name] = String(cmdOpts[p.name] ?? '') |
| 72 | for (const p of meta.bodyParams) opts[p.name] = String(cmdOpts[p.name] ?? '') |
| 73 | return opts |
| 74 | } |
| 75 | |
| 76 | function toKebab(str: string): string { |
| 77 | return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() |
no outgoing calls
no test coverage detected