specli 0.0.5 → 0.0.7

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 (208) hide show
  1. package/cli.ts +13 -4
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +2331 -0
  5. package/dist/cli.js.map +53 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +2032 -0
  9. package/dist/index.js.map +48 -0
  10. package/dist/src/ai/tools.d.ts +139 -0
  11. package/dist/src/ai/tools.d.ts.map +1 -0
  12. package/dist/src/ai/tools.js +1656 -0
  13. package/dist/src/ai/tools.js.map +45 -0
  14. package/dist/src/cli/auth-requirements.d.ts +10 -0
  15. package/dist/src/cli/auth-requirements.d.ts.map +1 -0
  16. package/dist/src/cli/auth-requirements.js +66 -0
  17. package/dist/src/cli/auth-requirements.js.map +10 -0
  18. package/dist/src/cli/auth-schemes.d.ts +22 -0
  19. package/dist/src/cli/auth-schemes.d.ts.map +1 -0
  20. package/dist/src/cli/auth-schemes.js +116 -0
  21. package/dist/src/cli/auth-schemes.js.map +11 -0
  22. package/dist/src/cli/capabilities.d.ts +32 -0
  23. package/dist/src/cli/capabilities.d.ts.map +1 -0
  24. package/dist/src/cli/capabilities.js +45 -0
  25. package/dist/src/cli/capabilities.js.map +10 -0
  26. package/dist/src/cli/command-id.d.ts +8 -0
  27. package/dist/src/cli/command-id.d.ts.map +1 -0
  28. package/dist/src/cli/command-id.js +18 -0
  29. package/dist/src/cli/command-id.js.map +11 -0
  30. package/dist/src/cli/command-index.d.ts +6 -0
  31. package/dist/src/cli/command-index.d.ts.map +1 -0
  32. package/dist/src/cli/command-index.js +15 -0
  33. package/dist/src/cli/command-index.js.map +10 -0
  34. package/dist/src/cli/command-model.d.ts +40 -0
  35. package/dist/src/cli/command-model.d.ts.map +1 -0
  36. package/dist/src/cli/command-model.js +274 -0
  37. package/dist/src/cli/command-model.js.map +18 -0
  38. package/dist/src/cli/compile.d.ts +15 -0
  39. package/dist/src/cli/compile.d.ts.map +1 -0
  40. package/dist/src/cli/compile.js +146 -0
  41. package/dist/src/cli/compile.js.map +11 -0
  42. package/dist/src/cli/crypto.d.ts +2 -0
  43. package/dist/src/cli/crypto.d.ts.map +1 -0
  44. package/dist/src/cli/crypto.js +15 -0
  45. package/dist/src/cli/crypto.js.map +10 -0
  46. package/dist/src/cli/derive-name.d.ts +9 -0
  47. package/dist/src/cli/derive-name.d.ts.map +1 -0
  48. package/dist/src/cli/derive-name.js +70 -0
  49. package/dist/src/cli/derive-name.js.map +10 -0
  50. package/dist/src/cli/exec.d.ts +14 -0
  51. package/dist/src/cli/exec.d.ts.map +1 -0
  52. package/dist/src/cli/exec.js +2077 -0
  53. package/dist/src/cli/exec.js.map +49 -0
  54. package/dist/src/cli/main.d.ts +10 -0
  55. package/dist/src/cli/main.d.ts.map +1 -0
  56. package/dist/src/cli/main.js +2032 -0
  57. package/dist/src/cli/main.js.map +48 -0
  58. package/dist/src/cli/naming.d.ts +12 -0
  59. package/dist/src/cli/naming.d.ts.map +1 -0
  60. package/dist/src/cli/naming.js +216 -0
  61. package/dist/src/cli/naming.js.map +12 -0
  62. package/dist/src/cli/operations.d.ts +3 -0
  63. package/dist/src/cli/operations.d.ts.map +1 -0
  64. package/dist/src/cli/operations.js +103 -0
  65. package/dist/src/cli/operations.js.map +10 -0
  66. package/dist/src/cli/params.d.ts +19 -0
  67. package/dist/src/cli/params.d.ts.map +1 -0
  68. package/dist/src/cli/params.js +79 -0
  69. package/dist/src/cli/params.js.map +12 -0
  70. package/dist/src/cli/pluralize.d.ts +2 -0
  71. package/dist/src/cli/pluralize.d.ts.map +1 -0
  72. package/dist/src/cli/pluralize.js +43 -0
  73. package/dist/src/cli/pluralize.js.map +10 -0
  74. package/dist/src/cli/positional.d.ts +19 -0
  75. package/dist/src/cli/positional.d.ts.map +1 -0
  76. package/dist/src/cli/positional.js +39 -0
  77. package/dist/src/cli/positional.js.map +10 -0
  78. package/dist/src/cli/request-body.d.ts +20 -0
  79. package/dist/src/cli/request-body.d.ts.map +1 -0
  80. package/dist/src/cli/request-body.js +82 -0
  81. package/dist/src/cli/request-body.js.map +12 -0
  82. package/dist/src/cli/runtime/argv.d.ts +3 -0
  83. package/dist/src/cli/runtime/argv.d.ts.map +1 -0
  84. package/dist/src/cli/runtime/argv.js +22 -0
  85. package/dist/src/cli/runtime/argv.js.map +10 -0
  86. package/dist/src/cli/runtime/auth/resolve.d.ts +9 -0
  87. package/dist/src/cli/runtime/auth/resolve.d.ts.map +1 -0
  88. package/dist/src/cli/runtime/auth/resolve.js +38 -0
  89. package/dist/src/cli/runtime/auth/resolve.js.map +10 -0
  90. package/dist/src/cli/runtime/body-flags.d.ts +41 -0
  91. package/dist/src/cli/runtime/body-flags.d.ts.map +1 -0
  92. package/dist/src/cli/runtime/body-flags.js +86 -0
  93. package/dist/src/cli/runtime/body-flags.js.map +10 -0
  94. package/dist/src/cli/runtime/body.d.ts +15 -0
  95. package/dist/src/cli/runtime/body.d.ts.map +1 -0
  96. package/dist/src/cli/runtime/body.js +40 -0
  97. package/dist/src/cli/runtime/body.js.map +11 -0
  98. package/dist/src/cli/runtime/collect.d.ts +2 -0
  99. package/dist/src/cli/runtime/collect.d.ts.map +1 -0
  100. package/dist/src/cli/runtime/collect.js +9 -0
  101. package/dist/src/cli/runtime/collect.js.map +10 -0
  102. package/dist/src/cli/runtime/compat.d.ts +35 -0
  103. package/dist/src/cli/runtime/compat.d.ts.map +1 -0
  104. package/dist/src/cli/runtime/compat.js +62 -0
  105. package/dist/src/cli/runtime/compat.js.map +10 -0
  106. package/dist/src/cli/runtime/context.d.ts +16 -0
  107. package/dist/src/cli/runtime/context.d.ts.map +1 -0
  108. package/dist/src/cli/runtime/context.js +936 -0
  109. package/dist/src/cli/runtime/context.js.map +32 -0
  110. package/dist/src/cli/runtime/execute.d.ts +33 -0
  111. package/dist/src/cli/runtime/execute.d.ts.map +1 -0
  112. package/dist/src/cli/runtime/execute.js +670 -0
  113. package/dist/src/cli/runtime/execute.js.map +22 -0
  114. package/dist/src/cli/runtime/generated.d.ts +14 -0
  115. package/dist/src/cli/runtime/generated.d.ts.map +1 -0
  116. package/dist/src/cli/runtime/generated.js +869 -0
  117. package/dist/src/cli/runtime/generated.js.map +23 -0
  118. package/dist/src/cli/runtime/headers.d.ts +9 -0
  119. package/dist/src/cli/runtime/headers.d.ts.map +1 -0
  120. package/dist/src/cli/runtime/headers.js +36 -0
  121. package/dist/src/cli/runtime/headers.js.map +10 -0
  122. package/dist/src/cli/runtime/index.d.ts +4 -0
  123. package/dist/src/cli/runtime/index.d.ts.map +1 -0
  124. package/dist/src/cli/runtime/index.js +1808 -0
  125. package/dist/src/cli/runtime/index.js.map +46 -0
  126. package/dist/src/cli/runtime/profile/secrets.d.ts +25 -0
  127. package/dist/src/cli/runtime/profile/secrets.d.ts.map +1 -0
  128. package/dist/src/cli/runtime/profile/secrets.js +51 -0
  129. package/dist/src/cli/runtime/profile/secrets.js.map +11 -0
  130. package/dist/src/cli/runtime/profile/store.d.ts +15 -0
  131. package/dist/src/cli/runtime/profile/store.d.ts.map +1 -0
  132. package/dist/src/cli/runtime/profile/store.js +102 -0
  133. package/dist/src/cli/runtime/profile/store.js.map +11 -0
  134. package/dist/src/cli/runtime/request.d.ts +36 -0
  135. package/dist/src/cli/runtime/request.d.ts.map +1 -0
  136. package/dist/src/cli/runtime/request.js +571 -0
  137. package/dist/src/cli/runtime/request.js.map +21 -0
  138. package/dist/src/cli/runtime/server-url.d.ts +8 -0
  139. package/dist/src/cli/runtime/server-url.d.ts.map +1 -0
  140. package/dist/src/cli/runtime/server-url.js +55 -0
  141. package/dist/src/cli/runtime/server-url.js.map +11 -0
  142. package/dist/src/cli/runtime/template.d.ts +5 -0
  143. package/dist/src/cli/runtime/template.d.ts.map +1 -0
  144. package/dist/src/cli/runtime/template.js +29 -0
  145. package/dist/src/cli/runtime/template.js.map +10 -0
  146. package/dist/src/cli/runtime/validate/ajv.d.ts +3 -0
  147. package/dist/src/cli/runtime/validate/ajv.d.ts.map +1 -0
  148. package/dist/src/cli/runtime/validate/ajv.js +17 -0
  149. package/dist/src/cli/runtime/validate/ajv.js.map +10 -0
  150. package/dist/src/cli/runtime/validate/coerce.d.ts +4 -0
  151. package/dist/src/cli/runtime/validate/coerce.d.ts.map +1 -0
  152. package/dist/src/cli/runtime/validate/coerce.js +60 -0
  153. package/dist/src/cli/runtime/validate/coerce.js.map +10 -0
  154. package/dist/src/cli/runtime/validate/error.d.ts +3 -0
  155. package/dist/src/cli/runtime/validate/error.d.ts.map +1 -0
  156. package/dist/src/cli/runtime/validate/error.js +21 -0
  157. package/dist/src/cli/runtime/validate/error.js.map +10 -0
  158. package/dist/src/cli/runtime/validate/index.d.ts +5 -0
  159. package/dist/src/cli/runtime/validate/index.d.ts.map +1 -0
  160. package/dist/src/cli/runtime/validate/index.js +122 -0
  161. package/dist/src/cli/runtime/validate/index.js.map +13 -0
  162. package/dist/src/cli/runtime/validate/schema.d.ts +9 -0
  163. package/dist/src/cli/runtime/validate/schema.d.ts.map +1 -0
  164. package/dist/src/cli/runtime/validate/schema.js +36 -0
  165. package/dist/src/cli/runtime/validate/schema.js.map +10 -0
  166. package/dist/src/cli/schema-shape.d.ts +5 -0
  167. package/dist/src/cli/schema-shape.d.ts.map +1 -0
  168. package/dist/src/cli/schema-shape.js +41 -0
  169. package/dist/src/cli/schema-shape.js.map +10 -0
  170. package/dist/src/cli/schema.d.ts +30 -0
  171. package/dist/src/cli/schema.d.ts.map +1 -0
  172. package/dist/src/cli/schema.js +38 -0
  173. package/dist/src/cli/schema.js.map +10 -0
  174. package/dist/src/cli/server.d.ts +16 -0
  175. package/dist/src/cli/server.d.ts.map +1 -0
  176. package/dist/src/cli/server.js +64 -0
  177. package/dist/src/cli/server.js.map +11 -0
  178. package/dist/src/cli/spec-id.d.ts +3 -0
  179. package/dist/src/cli/spec-id.d.ts.map +1 -0
  180. package/dist/src/cli/spec-id.js +21 -0
  181. package/dist/src/cli/spec-id.js.map +11 -0
  182. package/dist/src/cli/spec-loader.d.ts +7 -0
  183. package/dist/src/cli/spec-loader.d.ts.map +1 -0
  184. package/dist/src/cli/spec-loader.js +110 -0
  185. package/dist/src/cli/spec-loader.js.map +15 -0
  186. package/dist/src/cli/stable-json.d.ts +4 -0
  187. package/dist/src/cli/stable-json.d.ts.map +1 -0
  188. package/dist/src/cli/stable-json.js +35 -0
  189. package/dist/src/cli/stable-json.js.map +10 -0
  190. package/dist/src/cli/strings.d.ts +3 -0
  191. package/dist/src/cli/strings.d.ts.map +1 -0
  192. package/dist/src/cli/strings.js +16 -0
  193. package/dist/src/cli/strings.js.map +10 -0
  194. package/dist/src/cli/types.d.ts +53 -0
  195. package/dist/src/cli/types.d.ts.map +1 -0
  196. package/dist/src/cli/types.js +9 -0
  197. package/dist/src/cli/types.js.map +10 -0
  198. package/package.json +31 -4
  199. package/src/ai/tools.ts +211 -0
  200. package/src/cli/main.ts +3 -2
  201. package/src/cli/runtime/body.ts +3 -3
  202. package/src/cli/runtime/compat.ts +89 -0
  203. package/src/cli/runtime/execute.ts +98 -39
  204. package/src/cli/runtime/generated.ts +111 -4
  205. package/src/cli/runtime/profile/secrets.ts +42 -1
  206. package/src/cli/runtime/profile/store.ts +15 -13
  207. package/src/cli/runtime/request.ts +12 -4
  208. package/src/cli/spec-loader.ts +2 -2
@@ -0,0 +1,36 @@
1
+ // src/cli/runtime/validate/schema.ts
2
+ function deriveValidationSchemas(action) {
3
+ const query = { type: "object", properties: {}, required: [] };
4
+ const header = { type: "object", properties: {}, required: [] };
5
+ const cookie = { type: "object", properties: {}, required: [] };
6
+ for (const p of action.params) {
7
+ if (p.kind !== "flag")
8
+ continue;
9
+ const target = p.in === "query" ? query : p.in === "header" ? header : p.in === "cookie" ? cookie : undefined;
10
+ if (!target)
11
+ continue;
12
+ const schema = p.schema ?? (p.type === "unknown" ? {} : { type: p.type });
13
+ target.properties[p.name] = schema;
14
+ if (p.required) {
15
+ if (!target.required)
16
+ target.required = [];
17
+ target.required.push(p.name);
18
+ }
19
+ }
20
+ if (!query.required?.length)
21
+ delete query.required;
22
+ if (!header.required?.length)
23
+ delete header.required;
24
+ if (!cookie.required?.length)
25
+ delete cookie.required;
26
+ return {
27
+ querySchema: Object.keys(query.properties).length ? query : undefined,
28
+ headerSchema: Object.keys(header.properties).length ? header : undefined,
29
+ cookieSchema: Object.keys(cookie.properties).length ? cookie : undefined
30
+ };
31
+ }
32
+ export {
33
+ deriveValidationSchemas
34
+ };
35
+
36
+ //# debugId=B7803722EF1A23FC64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/cli/runtime/validate/schema.ts"],
4
+ "sourcesContent": [
5
+ "import type { CommandAction } from \"../../command-model.ts\";\nimport type { JsonSchema } from \"../../types.ts\";\n\nexport type ValidationSchemas = {\n\tquerySchema?: JsonSchema;\n\theaderSchema?: JsonSchema;\n\tcookieSchema?: JsonSchema;\n};\n\ntype ObjectSchema = {\n\ttype: \"object\";\n\tproperties: Record<string, JsonSchema>;\n\trequired?: string[];\n};\n\nexport function deriveValidationSchemas(\n\taction: CommandAction,\n): ValidationSchemas {\n\t// We validate only simple containers for now.\n\t// Deep style/encoding differences for OpenAPI params are out of scope for v1.\n\tconst query: ObjectSchema = { type: \"object\", properties: {}, required: [] };\n\tconst header: ObjectSchema = { type: \"object\", properties: {}, required: [] };\n\tconst cookie: ObjectSchema = { type: \"object\", properties: {}, required: [] };\n\n\tfor (const p of action.params) {\n\t\tif (p.kind !== \"flag\") continue;\n\t\tconst target =\n\t\t\tp.in === \"query\"\n\t\t\t\t? query\n\t\t\t\t: p.in === \"header\"\n\t\t\t\t\t? header\n\t\t\t\t\t: p.in === \"cookie\"\n\t\t\t\t\t\t? cookie\n\t\t\t\t\t\t: undefined;\n\t\tif (!target) continue;\n\n\t\tconst schema = p.schema ?? (p.type === \"unknown\" ? {} : { type: p.type });\n\t\ttarget.properties[p.name] = schema;\n\t\tif (p.required) {\n\t\t\tif (!target.required) target.required = [];\n\t\t\ttarget.required.push(p.name);\n\t\t}\n\t}\n\n\tif (!query.required?.length) delete query.required;\n\tif (!header.required?.length) delete header.required;\n\tif (!cookie.required?.length) delete cookie.required;\n\n\treturn {\n\t\tquerySchema: Object.keys(query.properties).length ? query : undefined,\n\t\theaderSchema: Object.keys(header.properties).length ? header : undefined,\n\t\tcookieSchema: Object.keys(cookie.properties).length ? cookie : undefined,\n\t};\n}\n"
6
+ ],
7
+ "mappings": ";AAeO,SAAS,uBAAuB,CACtC,QACoB;AAAA,EAGpB,MAAM,QAAsB,EAAE,MAAM,UAAU,YAAY,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,EAC3E,MAAM,SAAuB,EAAE,MAAM,UAAU,YAAY,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,EAC5E,MAAM,SAAuB,EAAE,MAAM,UAAU,YAAY,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,EAE5E,WAAW,KAAK,OAAO,QAAQ;AAAA,IAC9B,IAAI,EAAE,SAAS;AAAA,MAAQ;AAAA,IACvB,MAAM,SACL,EAAE,OAAO,UACN,QACA,EAAE,OAAO,WACR,SACA,EAAE,OAAO,WACR,SACA;AAAA,IACN,IAAI,CAAC;AAAA,MAAQ;AAAA,IAEb,MAAM,SAAS,EAAE,WAAW,EAAE,SAAS,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK;AAAA,IACvE,OAAO,WAAW,EAAE,QAAQ;AAAA,IAC5B,IAAI,EAAE,UAAU;AAAA,MACf,IAAI,CAAC,OAAO;AAAA,QAAU,OAAO,WAAW,CAAC;AAAA,MACzC,OAAO,SAAS,KAAK,EAAE,IAAI;AAAA,IAC5B;AAAA,EACD;AAAA,EAEA,IAAI,CAAC,MAAM,UAAU;AAAA,IAAQ,OAAO,MAAM;AAAA,EAC1C,IAAI,CAAC,OAAO,UAAU;AAAA,IAAQ,OAAO,OAAO;AAAA,EAC5C,IAAI,CAAC,OAAO,UAAU;AAAA,IAAQ,OAAO,OAAO;AAAA,EAE5C,OAAO;AAAA,IACN,aAAa,OAAO,KAAK,MAAM,UAAU,EAAE,SAAS,QAAQ;AAAA,IAC5D,cAAc,OAAO,KAAK,OAAO,UAAU,EAAE,SAAS,SAAS;AAAA,IAC/D,cAAc,OAAO,KAAK,OAAO,UAAU,EAAE,SAAS,SAAS;AAAA,EAChE;AAAA;",
8
+ "debugId": "B7803722EF1A23FC64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,5 @@
1
+ export type ParamType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "unknown";
2
+ export declare function getSchemaType(schema: unknown): ParamType;
3
+ export declare function getSchemaFormat(schema: unknown): string | undefined;
4
+ export declare function getSchemaEnumStrings(schema: unknown): string[] | undefined;
5
+ //# sourceMappingURL=schema-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-shape.d.ts","sourceRoot":"","sources":["../../../src/cli/schema-shape.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAClB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ,GACR,SAAS,CAAC;AAEb,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAUxD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAInE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAQ1E"}
@@ -0,0 +1,41 @@
1
+ // src/cli/schema-shape.ts
2
+ function getSchemaType(schema) {
3
+ if (!schema || typeof schema !== "object")
4
+ return "unknown";
5
+ const t = schema.type;
6
+ if (t === "string")
7
+ return "string";
8
+ if (t === "number")
9
+ return "number";
10
+ if (t === "integer")
11
+ return "integer";
12
+ if (t === "boolean")
13
+ return "boolean";
14
+ if (t === "array")
15
+ return "array";
16
+ if (t === "object")
17
+ return "object";
18
+ return "unknown";
19
+ }
20
+ function getSchemaFormat(schema) {
21
+ if (!schema || typeof schema !== "object")
22
+ return;
23
+ const f = schema.format;
24
+ return typeof f === "string" ? f : undefined;
25
+ }
26
+ function getSchemaEnumStrings(schema) {
27
+ if (!schema || typeof schema !== "object")
28
+ return;
29
+ const e = schema.enum;
30
+ if (!Array.isArray(e))
31
+ return;
32
+ const values = e.filter((v) => typeof v === "string");
33
+ return values.length ? values : undefined;
34
+ }
35
+ export {
36
+ getSchemaType,
37
+ getSchemaFormat,
38
+ getSchemaEnumStrings
39
+ };
40
+
41
+ //# debugId=8FA3BAE542EBDBEF64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/schema-shape.ts"],
4
+ "sourcesContent": [
5
+ "export type ParamType =\n\t| \"string\"\n\t| \"number\"\n\t| \"integer\"\n\t| \"boolean\"\n\t| \"array\"\n\t| \"object\"\n\t| \"unknown\";\n\nexport function getSchemaType(schema: unknown): ParamType {\n\tif (!schema || typeof schema !== \"object\") return \"unknown\";\n\tconst t = (schema as { type?: unknown }).type;\n\tif (t === \"string\") return \"string\";\n\tif (t === \"number\") return \"number\";\n\tif (t === \"integer\") return \"integer\";\n\tif (t === \"boolean\") return \"boolean\";\n\tif (t === \"array\") return \"array\";\n\tif (t === \"object\") return \"object\";\n\treturn \"unknown\";\n}\n\nexport function getSchemaFormat(schema: unknown): string | undefined {\n\tif (!schema || typeof schema !== \"object\") return undefined;\n\tconst f = (schema as { format?: unknown }).format;\n\treturn typeof f === \"string\" ? f : undefined;\n}\n\nexport function getSchemaEnumStrings(schema: unknown): string[] | undefined {\n\tif (!schema || typeof schema !== \"object\") return undefined;\n\tconst e = (schema as { enum?: unknown }).enum;\n\tif (!Array.isArray(e)) return undefined;\n\n\t// We only surface string enums for now (enough for flag docs + completion).\n\tconst values = e.filter((v) => typeof v === \"string\") as string[];\n\treturn values.length ? values : undefined;\n}\n"
6
+ ],
7
+ "mappings": ";AASO,SAAS,aAAa,CAAC,QAA4B;AAAA,EACzD,IAAI,CAAC,UAAU,OAAO,WAAW;AAAA,IAAU,OAAO;AAAA,EAClD,MAAM,IAAK,OAA8B;AAAA,EACzC,IAAI,MAAM;AAAA,IAAU,OAAO;AAAA,EAC3B,IAAI,MAAM;AAAA,IAAU,OAAO;AAAA,EAC3B,IAAI,MAAM;AAAA,IAAW,OAAO;AAAA,EAC5B,IAAI,MAAM;AAAA,IAAW,OAAO;AAAA,EAC5B,IAAI,MAAM;AAAA,IAAS,OAAO;AAAA,EAC1B,IAAI,MAAM;AAAA,IAAU,OAAO;AAAA,EAC3B,OAAO;AAAA;AAGD,SAAS,eAAe,CAAC,QAAqC;AAAA,EACpE,IAAI,CAAC,UAAU,OAAO,WAAW;AAAA,IAAU;AAAA,EAC3C,MAAM,IAAK,OAAgC;AAAA,EAC3C,OAAO,OAAO,MAAM,WAAW,IAAI;AAAA;AAG7B,SAAS,oBAAoB,CAAC,QAAuC;AAAA,EAC3E,IAAI,CAAC,UAAU,OAAO,WAAW;AAAA,IAAU;AAAA,EAC3C,MAAM,IAAK,OAA8B;AAAA,EACzC,IAAI,CAAC,MAAM,QAAQ,CAAC;AAAA,IAAG;AAAA,EAGvB,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,OAAO,MAAM,QAAQ;AAAA,EACpD,OAAO,OAAO,SAAS,SAAS;AAAA;",
8
+ "debugId": "8FA3BAE542EBDBEF64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,30 @@
1
+ import type { AuthScheme } from "./auth-schemes.js";
2
+ import type { Capabilities } from "./capabilities.js";
3
+ import type { CommandModel } from "./command-model.js";
4
+ import type { PlannedOperation } from "./naming.js";
5
+ import type { ServerInfo } from "./server.js";
6
+ import type { LoadedSpec, NormalizedOperation } from "./types.js";
7
+ export type SchemaOutput = {
8
+ schemaVersion: 1;
9
+ openapi: {
10
+ version: string;
11
+ title?: string;
12
+ infoVersion?: string;
13
+ };
14
+ spec: {
15
+ id: string;
16
+ fingerprint: string;
17
+ source: LoadedSpec["source"];
18
+ };
19
+ capabilities: Capabilities;
20
+ servers: ServerInfo[];
21
+ authSchemes: AuthScheme[];
22
+ operations: NormalizedOperation[];
23
+ planned?: PlannedOperation[];
24
+ commands?: CommandModel;
25
+ commandsIndex?: import("./command-index.js").CommandsIndex;
26
+ };
27
+ export type MinimalSchemaOutput = Pick<SchemaOutput, "schemaVersion" | "openapi" | "spec" | "capabilities" | "commands">;
28
+ export declare function buildSchemaOutput(loaded: LoadedSpec, operations: NormalizedOperation[], planned: PlannedOperation[] | undefined, servers: ServerInfo[], authSchemes: AuthScheme[], commands: CommandModel | undefined, commandsIndex: import("./command-index.js").CommandsIndex | undefined, capabilities: Capabilities): SchemaOutput;
29
+ export declare function toMinimalSchemaOutput(output: SchemaOutput): MinimalSchemaOutput;
30
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/cli/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE,CAAC,CAAC;IACjB,OAAO,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC7B,CAAC;IACF,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,oBAAoB,EAAE,aAAa,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACrC,YAAY,EACZ,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,CAClE,CAAC;AAEF,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,gBAAgB,EAAE,GAAG,SAAS,EACvC,OAAO,EAAE,UAAU,EAAE,EACrB,WAAW,EAAE,UAAU,EAAE,EACzB,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,aAAa,EAAE,OAAO,oBAAoB,EAAE,aAAa,GAAG,SAAS,EACrE,YAAY,EAAE,YAAY,GACxB,YAAY,CAqBd;AAED,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,YAAY,GAClB,mBAAmB,CAQrB"}
@@ -0,0 +1,38 @@
1
+ // src/cli/schema.ts
2
+ function buildSchemaOutput(loaded, operations, planned, servers, authSchemes, commands, commandsIndex, capabilities) {
3
+ return {
4
+ schemaVersion: 1,
5
+ openapi: {
6
+ version: loaded.doc.openapi,
7
+ title: loaded.doc.info?.title,
8
+ infoVersion: loaded.doc.info?.version
9
+ },
10
+ spec: {
11
+ id: loaded.id,
12
+ fingerprint: loaded.fingerprint,
13
+ source: loaded.source
14
+ },
15
+ capabilities,
16
+ servers,
17
+ authSchemes,
18
+ operations,
19
+ planned,
20
+ commands,
21
+ commandsIndex
22
+ };
23
+ }
24
+ function toMinimalSchemaOutput(output) {
25
+ return {
26
+ schemaVersion: output.schemaVersion,
27
+ openapi: output.openapi,
28
+ spec: output.spec,
29
+ capabilities: output.capabilities,
30
+ commands: output.commands
31
+ };
32
+ }
33
+ export {
34
+ toMinimalSchemaOutput,
35
+ buildSchemaOutput
36
+ };
37
+
38
+ //# debugId=FF74A06844E78B4164756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/schema.ts"],
4
+ "sourcesContent": [
5
+ "import type { AuthScheme } from \"./auth-schemes.ts\";\nimport type { Capabilities } from \"./capabilities.ts\";\nimport type { CommandModel } from \"./command-model.ts\";\nimport type { PlannedOperation } from \"./naming.ts\";\nimport type { ServerInfo } from \"./server.ts\";\nimport type { LoadedSpec, NormalizedOperation } from \"./types.ts\";\n\nexport type SchemaOutput = {\n\tschemaVersion: 1;\n\topenapi: {\n\t\tversion: string;\n\t\ttitle?: string;\n\t\tinfoVersion?: string;\n\t};\n\tspec: {\n\t\tid: string;\n\t\tfingerprint: string;\n\t\tsource: LoadedSpec[\"source\"];\n\t};\n\tcapabilities: Capabilities;\n\tservers: ServerInfo[];\n\tauthSchemes: AuthScheme[];\n\toperations: NormalizedOperation[];\n\tplanned?: PlannedOperation[];\n\tcommands?: CommandModel;\n\tcommandsIndex?: import(\"./command-index.ts\").CommandsIndex;\n};\n\nexport type MinimalSchemaOutput = Pick<\n\tSchemaOutput,\n\t\"schemaVersion\" | \"openapi\" | \"spec\" | \"capabilities\" | \"commands\"\n>;\n\nexport function buildSchemaOutput(\n\tloaded: LoadedSpec,\n\toperations: NormalizedOperation[],\n\tplanned: PlannedOperation[] | undefined,\n\tservers: ServerInfo[],\n\tauthSchemes: AuthScheme[],\n\tcommands: CommandModel | undefined,\n\tcommandsIndex: import(\"./command-index.ts\").CommandsIndex | undefined,\n\tcapabilities: Capabilities,\n): SchemaOutput {\n\treturn {\n\t\tschemaVersion: 1,\n\t\topenapi: {\n\t\t\tversion: loaded.doc.openapi,\n\t\t\ttitle: loaded.doc.info?.title,\n\t\t\tinfoVersion: loaded.doc.info?.version,\n\t\t},\n\t\tspec: {\n\t\t\tid: loaded.id,\n\t\t\tfingerprint: loaded.fingerprint,\n\t\t\tsource: loaded.source,\n\t\t},\n\t\tcapabilities,\n\t\tservers,\n\t\tauthSchemes,\n\t\toperations,\n\t\tplanned,\n\t\tcommands,\n\t\tcommandsIndex,\n\t};\n}\n\nexport function toMinimalSchemaOutput(\n\toutput: SchemaOutput,\n): MinimalSchemaOutput {\n\treturn {\n\t\tschemaVersion: output.schemaVersion,\n\t\topenapi: output.openapi,\n\t\tspec: output.spec,\n\t\tcapabilities: output.capabilities,\n\t\tcommands: output.commands,\n\t};\n}\n"
6
+ ],
7
+ "mappings": ";AAiCO,SAAS,iBAAiB,CAChC,QACA,YACA,SACA,SACA,aACA,UACA,eACA,cACe;AAAA,EACf,OAAO;AAAA,IACN,eAAe;AAAA,IACf,SAAS;AAAA,MACR,SAAS,OAAO,IAAI;AAAA,MACpB,OAAO,OAAO,IAAI,MAAM;AAAA,MACxB,aAAa,OAAO,IAAI,MAAM;AAAA,IAC/B;AAAA,IACA,MAAM;AAAA,MACL,IAAI,OAAO;AAAA,MACX,aAAa,OAAO;AAAA,MACpB,QAAQ,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA;AAGM,SAAS,qBAAqB,CACpC,QACsB;AAAA,EACtB,OAAO;AAAA,IACN,eAAe,OAAO;AAAA,IACtB,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,cAAc,OAAO;AAAA,IACrB,UAAU,OAAO;AAAA,EAClB;AAAA;",
8
+ "debugId": "FF74A06844E78B4164756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,16 @@
1
+ import type { OpenApiDoc } from "./types.js";
2
+ export type ServerVariable = {
3
+ name: string;
4
+ default?: string;
5
+ enum?: string[];
6
+ description?: string;
7
+ };
8
+ export type ServerInfo = {
9
+ url: string;
10
+ description?: string;
11
+ variables: ServerVariable[];
12
+ variableNames: string[];
13
+ };
14
+ export declare function listServers(doc: OpenApiDoc): ServerInfo[];
15
+ export declare function getDefaultServerUrl(doc: OpenApiDoc): string | undefined;
16
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA2BF,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,CAyCzD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAEvE"}
@@ -0,0 +1,64 @@
1
+ // src/cli/schema-shape.ts
2
+ function getSchemaEnumStrings(schema) {
3
+ if (!schema || typeof schema !== "object")
4
+ return;
5
+ const e = schema.enum;
6
+ if (!Array.isArray(e))
7
+ return;
8
+ const values = e.filter((v) => typeof v === "string");
9
+ return values.length ? values : undefined;
10
+ }
11
+
12
+ // src/cli/server.ts
13
+ function extractVariableNames(url) {
14
+ const names = [];
15
+ const re = /\{([^}]+)\}/g;
16
+ while (true) {
17
+ const match = re.exec(url);
18
+ if (!match)
19
+ break;
20
+ names.push(match[1] ?? "");
21
+ }
22
+ return names.map((n) => n.trim()).filter(Boolean);
23
+ }
24
+ function listServers(doc) {
25
+ const servers = doc.servers ?? [];
26
+ const out = [];
27
+ for (const raw of servers) {
28
+ const s = raw;
29
+ if (!s || typeof s !== "object")
30
+ continue;
31
+ if (typeof s.url !== "string")
32
+ continue;
33
+ const variableNames = extractVariableNames(s.url);
34
+ const variables = [];
35
+ const rawVars = s.variables && typeof s.variables === "object" && !Array.isArray(s.variables) ? s.variables : {};
36
+ for (const name of variableNames) {
37
+ const v = rawVars[name];
38
+ const def = v?.default;
39
+ const desc = v?.description;
40
+ variables.push({
41
+ name,
42
+ default: typeof def === "string" ? def : undefined,
43
+ enum: getSchemaEnumStrings(v),
44
+ description: typeof desc === "string" ? desc : undefined
45
+ });
46
+ }
47
+ out.push({
48
+ url: s.url,
49
+ description: typeof s.description === "string" ? s.description : undefined,
50
+ variables,
51
+ variableNames
52
+ });
53
+ }
54
+ return out;
55
+ }
56
+ function getDefaultServerUrl(doc) {
57
+ return listServers(doc)[0]?.url;
58
+ }
59
+ export {
60
+ listServers,
61
+ getDefaultServerUrl
62
+ };
63
+
64
+ //# debugId=48EC706FB473AF1D64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/schema-shape.ts", "../../../src/cli/server.ts"],
4
+ "sourcesContent": [
5
+ "export type ParamType =\n\t| \"string\"\n\t| \"number\"\n\t| \"integer\"\n\t| \"boolean\"\n\t| \"array\"\n\t| \"object\"\n\t| \"unknown\";\n\nexport function getSchemaType(schema: unknown): ParamType {\n\tif (!schema || typeof schema !== \"object\") return \"unknown\";\n\tconst t = (schema as { type?: unknown }).type;\n\tif (t === \"string\") return \"string\";\n\tif (t === \"number\") return \"number\";\n\tif (t === \"integer\") return \"integer\";\n\tif (t === \"boolean\") return \"boolean\";\n\tif (t === \"array\") return \"array\";\n\tif (t === \"object\") return \"object\";\n\treturn \"unknown\";\n}\n\nexport function getSchemaFormat(schema: unknown): string | undefined {\n\tif (!schema || typeof schema !== \"object\") return undefined;\n\tconst f = (schema as { format?: unknown }).format;\n\treturn typeof f === \"string\" ? f : undefined;\n}\n\nexport function getSchemaEnumStrings(schema: unknown): string[] | undefined {\n\tif (!schema || typeof schema !== \"object\") return undefined;\n\tconst e = (schema as { enum?: unknown }).enum;\n\tif (!Array.isArray(e)) return undefined;\n\n\t// We only surface string enums for now (enough for flag docs + completion).\n\tconst values = e.filter((v) => typeof v === \"string\") as string[];\n\treturn values.length ? values : undefined;\n}\n",
6
+ "import { getSchemaEnumStrings } from \"./schema-shape.ts\";\nimport type { OpenApiDoc } from \"./types.ts\";\n\nexport type ServerVariable = {\n\tname: string;\n\tdefault?: string;\n\tenum?: string[];\n\tdescription?: string;\n};\n\nexport type ServerInfo = {\n\turl: string;\n\tdescription?: string;\n\tvariables: ServerVariable[];\n\tvariableNames: string[];\n};\n\ntype RawServerVariable = {\n\tdefault?: unknown;\n\tenum?: unknown;\n\tdescription?: unknown;\n};\n\ntype RawServer = {\n\turl?: unknown;\n\tdescription?: unknown;\n\tvariables?: unknown;\n};\n\nfunction extractVariableNames(url: string): string[] {\n\tconst names: string[] = [];\n\tconst re = /\\{([^}]+)\\}/g;\n\n\twhile (true) {\n\t\tconst match = re.exec(url);\n\t\tif (!match) break;\n\t\tnames.push(match[1] ?? \"\");\n\t}\n\n\treturn names.map((n) => n.trim()).filter(Boolean);\n}\n\nexport function listServers(doc: OpenApiDoc): ServerInfo[] {\n\tconst servers = doc.servers ?? [];\n\tconst out: ServerInfo[] = [];\n\n\tfor (const raw of servers) {\n\t\tconst s = raw as RawServer;\n\t\tif (!s || typeof s !== \"object\") continue;\n\t\tif (typeof s.url !== \"string\") continue;\n\n\t\tconst variableNames = extractVariableNames(s.url);\n\t\tconst variables: ServerVariable[] = [];\n\n\t\tconst rawVars =\n\t\t\ts.variables &&\n\t\t\ttypeof s.variables === \"object\" &&\n\t\t\t!Array.isArray(s.variables)\n\t\t\t\t? (s.variables as Record<string, RawServerVariable>)\n\t\t\t\t: {};\n\n\t\tfor (const name of variableNames) {\n\t\t\tconst v = rawVars[name];\n\t\t\tconst def = v?.default;\n\t\t\tconst desc = v?.description;\n\t\t\tvariables.push({\n\t\t\t\tname,\n\t\t\t\tdefault: typeof def === \"string\" ? def : undefined,\n\t\t\t\tenum: getSchemaEnumStrings(v),\n\t\t\t\tdescription: typeof desc === \"string\" ? desc : undefined,\n\t\t\t});\n\t\t}\n\n\t\tout.push({\n\t\t\turl: s.url,\n\t\t\tdescription:\n\t\t\t\ttypeof s.description === \"string\" ? s.description : undefined,\n\t\t\tvariables,\n\t\t\tvariableNames,\n\t\t});\n\t}\n\n\treturn out;\n}\n\nexport function getDefaultServerUrl(doc: OpenApiDoc): string | undefined {\n\treturn listServers(doc)[0]?.url;\n}\n"
7
+ ],
8
+ "mappings": ";AA2BO,SAAS,oBAAoB,CAAC,QAAuC;AAAA,EAC3E,IAAI,CAAC,UAAU,OAAO,WAAW;AAAA,IAAU;AAAA,EAC3C,MAAM,IAAK,OAA8B;AAAA,EACzC,IAAI,CAAC,MAAM,QAAQ,CAAC;AAAA,IAAG;AAAA,EAGvB,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,OAAO,MAAM,QAAQ;AAAA,EACpD,OAAO,OAAO,SAAS,SAAS;AAAA;;;ACLjC,SAAS,oBAAoB,CAAC,KAAuB;AAAA,EACpD,MAAM,QAAkB,CAAC;AAAA,EACzB,MAAM,KAAK;AAAA,EAEX,OAAO,MAAM;AAAA,IACZ,MAAM,QAAQ,GAAG,KAAK,GAAG;AAAA,IACzB,IAAI,CAAC;AAAA,MAAO;AAAA,IACZ,MAAM,KAAK,MAAM,MAAM,EAAE;AAAA,EAC1B;AAAA,EAEA,OAAO,MAAM,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO;AAAA;AAG1C,SAAS,WAAW,CAAC,KAA+B;AAAA,EAC1D,MAAM,UAAU,IAAI,WAAW,CAAC;AAAA,EAChC,MAAM,MAAoB,CAAC;AAAA,EAE3B,WAAW,OAAO,SAAS;AAAA,IAC1B,MAAM,IAAI;AAAA,IACV,IAAI,CAAC,KAAK,OAAO,MAAM;AAAA,MAAU;AAAA,IACjC,IAAI,OAAO,EAAE,QAAQ;AAAA,MAAU;AAAA,IAE/B,MAAM,gBAAgB,qBAAqB,EAAE,GAAG;AAAA,IAChD,MAAM,YAA8B,CAAC;AAAA,IAErC,MAAM,UACL,EAAE,aACF,OAAO,EAAE,cAAc,YACvB,CAAC,MAAM,QAAQ,EAAE,SAAS,IACtB,EAAE,YACH,CAAC;AAAA,IAEL,WAAW,QAAQ,eAAe;AAAA,MACjC,MAAM,IAAI,QAAQ;AAAA,MAClB,MAAM,MAAM,GAAG;AAAA,MACf,MAAM,OAAO,GAAG;AAAA,MAChB,UAAU,KAAK;AAAA,QACd;AAAA,QACA,SAAS,OAAO,QAAQ,WAAW,MAAM;AAAA,QACzC,MAAM,qBAAqB,CAAC;AAAA,QAC5B,aAAa,OAAO,SAAS,WAAW,OAAO;AAAA,MAChD,CAAC;AAAA,IACF;AAAA,IAEA,IAAI,KAAK;AAAA,MACR,KAAK,EAAE;AAAA,MACP,aACC,OAAO,EAAE,gBAAgB,WAAW,EAAE,cAAc;AAAA,MACrD;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EAEA,OAAO;AAAA;AAGD,SAAS,mBAAmB,CAAC,KAAqC;AAAA,EACxE,OAAO,YAAY,GAAG,EAAE,IAAI;AAAA;",
9
+ "debugId": "48EC706FB473AF1D64756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { LoadedSpec } from "./types.js";
2
+ export declare function getSpecId(loaded: Pick<LoadedSpec, "doc" | "fingerprint">): string;
3
+ //# sourceMappingURL=spec-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-id.d.ts","sourceRoot":"","sources":["../../../src/cli/spec-id.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,SAAS,CACxB,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,aAAa,CAAC,GAC7C,MAAM,CAMR"}
@@ -0,0 +1,21 @@
1
+ // src/cli/strings.ts
2
+ function kebabCase(input) {
3
+ const trimmed = input.trim();
4
+ if (!trimmed)
5
+ return "";
6
+ return trimmed.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_.:/]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
7
+ }
8
+
9
+ // src/cli/spec-id.ts
10
+ function getSpecId(loaded) {
11
+ const title = loaded.doc.info?.title;
12
+ const fromTitle = title ? kebabCase(title) : "";
13
+ if (fromTitle)
14
+ return fromTitle;
15
+ return loaded.fingerprint.slice(0, 12);
16
+ }
17
+ export {
18
+ getSpecId
19
+ };
20
+
21
+ //# debugId=A0EF73B41552326E64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/strings.ts", "../../../src/cli/spec-id.ts"],
4
+ "sourcesContent": [
5
+ "export function kebabCase(input: string): string {\n\tconst trimmed = input.trim();\n\tif (!trimmed) return \"\";\n\n\t// Convert spaces/underscores/dots to dashes, split camelCase.\n\treturn trimmed\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n\t\t.replace(/[\\s_.:/]+/g, \"-\")\n\t\t.replace(/[^a-zA-Z0-9-]/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.toLowerCase();\n}\n\nexport function titleCase(input: string): string {\n\treturn input\n\t\t.split(/\\s+/g)\n\t\t.filter(Boolean)\n\t\t.map((w) => w[0]?.toUpperCase() + w.slice(1))\n\t\t.join(\" \");\n}\n",
6
+ "import { kebabCase } from \"./strings.ts\";\nimport type { LoadedSpec } from \"./types.ts\";\n\nexport function getSpecId(\n\tloaded: Pick<LoadedSpec, \"doc\" | \"fingerprint\">,\n): string {\n\tconst title = loaded.doc.info?.title;\n\tconst fromTitle = title ? kebabCase(title) : \"\";\n\tif (fromTitle) return fromTitle;\n\n\treturn loaded.fingerprint.slice(0, 12);\n}\n"
7
+ ],
8
+ "mappings": ";AAAO,SAAS,SAAS,CAAC,OAAuB;AAAA,EAChD,MAAM,UAAU,MAAM,KAAK;AAAA,EAC3B,IAAI,CAAC;AAAA,IAAS,OAAO;AAAA,EAGrB,OAAO,QACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,cAAc,GAAG,EACzB,QAAQ,kBAAkB,GAAG,EAC7B,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE,EACpB,YAAY;AAAA;;;ACRR,SAAS,SAAS,CACxB,QACS;AAAA,EACT,MAAM,QAAQ,OAAO,IAAI,MAAM;AAAA,EAC/B,MAAM,YAAY,QAAQ,UAAU,KAAK,IAAI;AAAA,EAC7C,IAAI;AAAA,IAAW,OAAO;AAAA,EAEtB,OAAO,OAAO,YAAY,MAAM,GAAG,EAAE;AAAA;",
9
+ "debugId": "A0EF73B41552326E64756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,7 @@
1
+ import type { LoadedSpec } from "./types.js";
2
+ export type LoadSpecOptions = {
3
+ spec?: string;
4
+ embeddedSpecText?: string;
5
+ };
6
+ export declare function loadSpec(options: LoadSpecOptions): Promise<LoadedSpec>;
7
+ //# sourceMappingURL=spec-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-loader.d.ts","sourceRoot":"","sources":["../../../src/cli/spec-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAeF,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CA+B5E"}
@@ -0,0 +1,110 @@
1
+ // src/cli/spec-loader.ts
2
+ import SwaggerParser from "@apidevtools/swagger-parser";
3
+
4
+ // src/cli/crypto.ts
5
+ async function sha256Hex(text) {
6
+ const data = new TextEncoder().encode(text);
7
+ const hash = await crypto.subtle.digest("SHA-256", data);
8
+ const bytes = new Uint8Array(hash);
9
+ let out = "";
10
+ for (const b of bytes)
11
+ out += b.toString(16).padStart(2, "0");
12
+ return out;
13
+ }
14
+
15
+ // src/cli/runtime/compat.ts
16
+ import { parse as parseYaml } from "yaml";
17
+ var isBun = typeof globalThis.Bun !== "undefined";
18
+ function parseYamlContent(text) {
19
+ if (isBun) {
20
+ const { YAML } = globalThis.Bun;
21
+ return YAML.parse(text);
22
+ }
23
+ return parseYaml(text);
24
+ }
25
+
26
+ // src/cli/strings.ts
27
+ function kebabCase(input) {
28
+ const trimmed = input.trim();
29
+ if (!trimmed)
30
+ return "";
31
+ return trimmed.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_.:/]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
32
+ }
33
+
34
+ // src/cli/spec-id.ts
35
+ function getSpecId(loaded) {
36
+ const title = loaded.doc.info?.title;
37
+ const fromTitle = title ? kebabCase(title) : "";
38
+ if (fromTitle)
39
+ return fromTitle;
40
+ return loaded.fingerprint.slice(0, 12);
41
+ }
42
+
43
+ // src/cli/stable-json.ts
44
+ function stableStringify(value, options) {
45
+ const visiting = new WeakSet;
46
+ return JSON.stringify(sort(value, visiting), null, options?.space);
47
+ }
48
+ function sort(value, visiting) {
49
+ if (value === null)
50
+ return null;
51
+ if (Array.isArray(value)) {
52
+ if (visiting.has(value))
53
+ return { __specli_circular: true };
54
+ visiting.add(value);
55
+ const out = value.map((v) => sort(v, visiting));
56
+ visiting.delete(value);
57
+ return out;
58
+ }
59
+ if (typeof value === "object") {
60
+ if (visiting.has(value))
61
+ return { __specli_circular: true };
62
+ visiting.add(value);
63
+ const obj = value;
64
+ const out = {};
65
+ for (const key of Object.keys(obj).sort()) {
66
+ out[key] = sort(obj[key], visiting);
67
+ }
68
+ visiting.delete(value);
69
+ return out;
70
+ }
71
+ return value;
72
+ }
73
+
74
+ // src/cli/spec-loader.ts
75
+ function isProbablyUrl(input) {
76
+ return /^https?:\/\//i.test(input);
77
+ }
78
+ function parseSpecText(text) {
79
+ const trimmed = text.trimStart();
80
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
81
+ return JSON.parse(text);
82
+ }
83
+ return parseYamlContent(text);
84
+ }
85
+ async function loadSpec(options) {
86
+ const { spec, embeddedSpecText } = options;
87
+ let source;
88
+ let inputForParser;
89
+ if (typeof embeddedSpecText === "string") {
90
+ source = "embedded";
91
+ inputForParser = parseSpecText(embeddedSpecText);
92
+ } else if (spec) {
93
+ source = isProbablyUrl(spec) ? "url" : "file";
94
+ inputForParser = spec;
95
+ } else {
96
+ throw new Error("Missing spec. Provide --spec <url|path> or build with an embedded spec.");
97
+ }
98
+ const doc = await SwaggerParser.dereference(inputForParser);
99
+ if (!doc || typeof doc !== "object" || typeof doc.openapi !== "string") {
100
+ throw new Error("Loaded spec is not a valid OpenAPI document");
101
+ }
102
+ const fingerprint = await sha256Hex(stableStringify(doc));
103
+ const id = getSpecId({ doc, fingerprint });
104
+ return { source, id, fingerprint, doc };
105
+ }
106
+ export {
107
+ loadSpec
108
+ };
109
+
110
+ //# debugId=2E9579CCB8CDDEED64756E2164756E21
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/spec-loader.ts", "../../../src/cli/crypto.ts", "../../../src/cli/runtime/compat.ts", "../../../src/cli/strings.ts", "../../../src/cli/spec-id.ts", "../../../src/cli/stable-json.ts"],
4
+ "sourcesContent": [
5
+ "import SwaggerParser from \"@apidevtools/swagger-parser\";\n\nimport { sha256Hex } from \"./crypto.ts\";\nimport { parseYamlContent } from \"./runtime/compat.ts\";\nimport { getSpecId } from \"./spec-id.ts\";\nimport { stableStringify } from \"./stable-json.ts\";\nimport type { LoadedSpec, OpenApiDoc, SpecSource } from \"./types.ts\";\n\nexport type LoadSpecOptions = {\n\tspec?: string;\n\tembeddedSpecText?: string;\n};\n\nfunction isProbablyUrl(input: string): boolean {\n\treturn /^https?:\\/\\//i.test(input);\n}\n\nfunction parseSpecText(text: string): unknown {\n\tconst trimmed = text.trimStart();\n\tif (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n\t\treturn JSON.parse(text);\n\t}\n\n\treturn parseYamlContent(text);\n}\n\nexport async function loadSpec(options: LoadSpecOptions): Promise<LoadedSpec> {\n\tconst { spec, embeddedSpecText } = options;\n\n\tlet source: SpecSource;\n\tlet inputForParser: unknown;\n\n\tif (typeof embeddedSpecText === \"string\") {\n\t\tsource = \"embedded\";\n\t\tinputForParser = parseSpecText(embeddedSpecText);\n\t} else if (spec) {\n\t\tsource = isProbablyUrl(spec) ? \"url\" : \"file\";\n\t\tinputForParser = spec;\n\t} else {\n\t\tthrow new Error(\n\t\t\t\"Missing spec. Provide --spec <url|path> or build with an embedded spec.\",\n\t\t);\n\t}\n\n\tconst doc = (await SwaggerParser.dereference(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: unknown\n\t\tinputForParser as any,\n\t)) as OpenApiDoc;\n\n\tif (!doc || typeof doc !== \"object\" || typeof doc.openapi !== \"string\") {\n\t\tthrow new Error(\"Loaded spec is not a valid OpenAPI document\");\n\t}\n\n\tconst fingerprint = await sha256Hex(stableStringify(doc));\n\tconst id = getSpecId({ doc, fingerprint });\n\n\treturn { source, id, fingerprint, doc };\n}\n",
6
+ "export async function sha256Hex(text: string): Promise<string> {\n\tconst data = new TextEncoder().encode(text);\n\tconst hash = await crypto.subtle.digest(\"SHA-256\", data);\n\tconst bytes = new Uint8Array(hash);\n\n\tlet out = \"\";\n\tfor (const b of bytes) out += b.toString(16).padStart(2, \"0\");\n\treturn out;\n}\n",
7
+ "/**\n * Cross-runtime compatibility utilities for Bun and Node.js\n *\n * This module provides abstractions over Bun-specific APIs to allow\n * the exec command to run in Node.js while compile remains Bun-only.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { parse as parseYaml } from \"yaml\";\n\n/**\n * Detect if we're running in Bun\n */\nexport const isBun = typeof globalThis.Bun !== \"undefined\";\n\n/**\n * Read a file's text content - works in both Bun and Node.js\n */\nexport async function readFileText(path: string): Promise<string> {\n\tif (isBun) {\n\t\treturn Bun.file(path).text();\n\t}\n\treturn readFileSync(path, \"utf-8\");\n}\n\n/**\n * Check if a file exists - works in both Bun and Node.js\n */\nexport async function fileExists(path: string): Promise<boolean> {\n\tif (isBun) {\n\t\treturn Bun.file(path).exists();\n\t}\n\treturn existsSync(path);\n}\n\n/**\n * Write text to a file - works in both Bun and Node.js\n */\nexport async function writeFileText(\n\tpath: string,\n\tcontent: string,\n): Promise<void> {\n\tif (isBun) {\n\t\tawait Bun.write(path, content);\n\t\treturn;\n\t}\n\twriteFileSync(path, content, \"utf-8\");\n}\n\n/**\n * Create directory recursively - works in both Bun and Node.js\n */\nexport async function mkdirp(path: string): Promise<void> {\n\tif (isBun) {\n\t\tawait Bun.$`mkdir -p ${path}`;\n\t\treturn;\n\t}\n\tmkdirSync(path, { recursive: true });\n}\n\n/**\n * Parse YAML content - works in both Bun and Node.js\n */\nexport function parseYamlContent(text: string): unknown {\n\tif (isBun) {\n\t\tconst { YAML } = globalThis.Bun;\n\t\treturn YAML.parse(text);\n\t}\n\treturn parseYaml(text);\n}\n\n/**\n * Read from stdin - works in both Bun and Node.js\n */\nexport async function readStdinText(): Promise<string> {\n\tif (isBun) {\n\t\treturn Bun.stdin.text();\n\t}\n\t// Node.js stdin reading\n\treturn new Promise((resolve, reject) => {\n\t\tlet data = \"\";\n\t\tprocess.stdin.setEncoding(\"utf8\");\n\t\tprocess.stdin.on(\"data\", (chunk) => {\n\t\t\tdata += chunk;\n\t\t});\n\t\tprocess.stdin.on(\"end\", () => resolve(data));\n\t\tprocess.stdin.on(\"error\", reject);\n\t});\n}\n",
8
+ "export function kebabCase(input: string): string {\n\tconst trimmed = input.trim();\n\tif (!trimmed) return \"\";\n\n\t// Convert spaces/underscores/dots to dashes, split camelCase.\n\treturn trimmed\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n\t\t.replace(/[\\s_.:/]+/g, \"-\")\n\t\t.replace(/[^a-zA-Z0-9-]/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.toLowerCase();\n}\n\nexport function titleCase(input: string): string {\n\treturn input\n\t\t.split(/\\s+/g)\n\t\t.filter(Boolean)\n\t\t.map((w) => w[0]?.toUpperCase() + w.slice(1))\n\t\t.join(\" \");\n}\n",
9
+ "import { kebabCase } from \"./strings.ts\";\nimport type { LoadedSpec } from \"./types.ts\";\n\nexport function getSpecId(\n\tloaded: Pick<LoadedSpec, \"doc\" | \"fingerprint\">,\n): string {\n\tconst title = loaded.doc.info?.title;\n\tconst fromTitle = title ? kebabCase(title) : \"\";\n\tif (fromTitle) return fromTitle;\n\n\treturn loaded.fingerprint.slice(0, 12);\n}\n",
10
+ "export function stableStringify(\n\tvalue: unknown,\n\toptions?: { space?: number },\n): string {\n\tconst visiting = new WeakSet<object>();\n\treturn JSON.stringify(sort(value, visiting), null, options?.space);\n}\n\nfunction sort(value: unknown, visiting: WeakSet<object>): unknown {\n\tif (value === null) return null;\n\n\tif (Array.isArray(value)) {\n\t\tif (visiting.has(value)) return { __specli_circular: true };\n\t\tvisiting.add(value);\n\t\tconst out = value.map((v) => sort(v, visiting));\n\t\tvisiting.delete(value);\n\t\treturn out;\n\t}\n\n\tif (typeof value === \"object\") {\n\t\tif (visiting.has(value)) return { __specli_circular: true };\n\t\tvisiting.add(value);\n\n\t\tconst obj = value as Record<string, unknown>;\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const key of Object.keys(obj).sort()) {\n\t\t\tout[key] = sort(obj[key], visiting);\n\t\t}\n\n\t\tvisiting.delete(value);\n\t\treturn out;\n\t}\n\n\treturn value;\n}\n"
11
+ ],
12
+ "mappings": "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",
13
+ "debugId": "2E9579CCB8CDDEED64756E2164756E21",
14
+ "names": []
15
+ }
@@ -0,0 +1,4 @@
1
+ export declare function stableStringify(value: unknown, options?: {
2
+ space?: number;
3
+ }): string;
4
+ //# sourceMappingURL=stable-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stable-json.d.ts","sourceRoot":"","sources":["../../../src/cli/stable-json.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAC9B,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B,MAAM,CAGR"}
@@ -0,0 +1,35 @@
1
+ // src/cli/stable-json.ts
2
+ function stableStringify(value, options) {
3
+ const visiting = new WeakSet;
4
+ return JSON.stringify(sort(value, visiting), null, options?.space);
5
+ }
6
+ function sort(value, visiting) {
7
+ if (value === null)
8
+ return null;
9
+ if (Array.isArray(value)) {
10
+ if (visiting.has(value))
11
+ return { __specli_circular: true };
12
+ visiting.add(value);
13
+ const out = value.map((v) => sort(v, visiting));
14
+ visiting.delete(value);
15
+ return out;
16
+ }
17
+ if (typeof value === "object") {
18
+ if (visiting.has(value))
19
+ return { __specli_circular: true };
20
+ visiting.add(value);
21
+ const obj = value;
22
+ const out = {};
23
+ for (const key of Object.keys(obj).sort()) {
24
+ out[key] = sort(obj[key], visiting);
25
+ }
26
+ visiting.delete(value);
27
+ return out;
28
+ }
29
+ return value;
30
+ }
31
+ export {
32
+ stableStringify
33
+ };
34
+
35
+ //# debugId=4C2A1B7ECCB1A47264756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/stable-json.ts"],
4
+ "sourcesContent": [
5
+ "export function stableStringify(\n\tvalue: unknown,\n\toptions?: { space?: number },\n): string {\n\tconst visiting = new WeakSet<object>();\n\treturn JSON.stringify(sort(value, visiting), null, options?.space);\n}\n\nfunction sort(value: unknown, visiting: WeakSet<object>): unknown {\n\tif (value === null) return null;\n\n\tif (Array.isArray(value)) {\n\t\tif (visiting.has(value)) return { __specli_circular: true };\n\t\tvisiting.add(value);\n\t\tconst out = value.map((v) => sort(v, visiting));\n\t\tvisiting.delete(value);\n\t\treturn out;\n\t}\n\n\tif (typeof value === \"object\") {\n\t\tif (visiting.has(value)) return { __specli_circular: true };\n\t\tvisiting.add(value);\n\n\t\tconst obj = value as Record<string, unknown>;\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const key of Object.keys(obj).sort()) {\n\t\t\tout[key] = sort(obj[key], visiting);\n\t\t}\n\n\t\tvisiting.delete(value);\n\t\treturn out;\n\t}\n\n\treturn value;\n}\n"
6
+ ],
7
+ "mappings": ";AAAO,SAAS,eAAe,CAC9B,OACA,SACS;AAAA,EACT,MAAM,WAAW,IAAI;AAAA,EACrB,OAAO,KAAK,UAAU,KAAK,OAAO,QAAQ,GAAG,MAAM,SAAS,KAAK;AAAA;AAGlE,SAAS,IAAI,CAAC,OAAgB,UAAoC;AAAA,EACjE,IAAI,UAAU;AAAA,IAAM,OAAO;AAAA,EAE3B,IAAI,MAAM,QAAQ,KAAK,GAAG;AAAA,IACzB,IAAI,SAAS,IAAI,KAAK;AAAA,MAAG,OAAO,EAAE,mBAAmB,KAAK;AAAA,IAC1D,SAAS,IAAI,KAAK;AAAA,IAClB,MAAM,MAAM,MAAM,IAAI,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;AAAA,IAC9C,SAAS,OAAO,KAAK;AAAA,IACrB,OAAO;AAAA,EACR;AAAA,EAEA,IAAI,OAAO,UAAU,UAAU;AAAA,IAC9B,IAAI,SAAS,IAAI,KAAK;AAAA,MAAG,OAAO,EAAE,mBAAmB,KAAK;AAAA,IAC1D,SAAS,IAAI,KAAK;AAAA,IAElB,MAAM,MAAM;AAAA,IACZ,MAAM,MAA+B,CAAC;AAAA,IACtC,WAAW,OAAO,OAAO,KAAK,GAAG,EAAE,KAAK,GAAG;AAAA,MAC1C,IAAI,OAAO,KAAK,IAAI,MAAM,QAAQ;AAAA,IACnC;AAAA,IAEA,SAAS,OAAO,KAAK;AAAA,IACrB,OAAO;AAAA,EACR;AAAA,EAEA,OAAO;AAAA;",
8
+ "debugId": "4C2A1B7ECCB1A47264756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,3 @@
1
+ export declare function kebabCase(input: string): string;
2
+ export declare function titleCase(input: string): string;
3
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../src/cli/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM/C"}
@@ -0,0 +1,16 @@
1
+ // src/cli/strings.ts
2
+ function kebabCase(input) {
3
+ const trimmed = input.trim();
4
+ if (!trimmed)
5
+ return "";
6
+ return trimmed.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_.:/]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
7
+ }
8
+ function titleCase(input) {
9
+ return input.split(/\s+/g).filter(Boolean).map((w) => w[0]?.toUpperCase() + w.slice(1)).join(" ");
10
+ }
11
+ export {
12
+ titleCase,
13
+ kebabCase
14
+ };
15
+
16
+ //# debugId=F97990A7FD34C33764756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/cli/strings.ts"],
4
+ "sourcesContent": [
5
+ "export function kebabCase(input: string): string {\n\tconst trimmed = input.trim();\n\tif (!trimmed) return \"\";\n\n\t// Convert spaces/underscores/dots to dashes, split camelCase.\n\treturn trimmed\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n\t\t.replace(/[\\s_.:/]+/g, \"-\")\n\t\t.replace(/[^a-zA-Z0-9-]/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.toLowerCase();\n}\n\nexport function titleCase(input: string): string {\n\treturn input\n\t\t.split(/\\s+/g)\n\t\t.filter(Boolean)\n\t\t.map((w) => w[0]?.toUpperCase() + w.slice(1))\n\t\t.join(\" \");\n}\n"
6
+ ],
7
+ "mappings": ";AAAO,SAAS,SAAS,CAAC,OAAuB;AAAA,EAChD,MAAM,UAAU,MAAM,KAAK;AAAA,EAC3B,IAAI,CAAC;AAAA,IAAS,OAAO;AAAA,EAGrB,OAAO,QACL,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,cAAc,GAAG,EACzB,QAAQ,kBAAkB,GAAG,EAC7B,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE,EACpB,YAAY;AAAA;AAGR,SAAS,SAAS,CAAC,OAAuB;AAAA,EAChD,OAAO,MACL,MAAM,MAAM,EACZ,OAAO,OAAO,EACd,IAAI,CAAC,MAAM,EAAE,IAAI,YAAY,IAAI,EAAE,MAAM,CAAC,CAAC,EAC3C,KAAK,GAAG;AAAA;",
8
+ "debugId": "F97990A7FD34C33764756E2164756E21",
9
+ "names": []
10
+ }