@kidd-cli/core 0.1.1 → 0.2.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 (51) hide show
  1. package/dist/{config-BvGapuFJ.js → config-Db_sjFU-.js} +60 -65
  2. package/dist/config-Db_sjFU-.js.map +1 -0
  3. package/dist/create-http-client-tZJWlWp1.js +165 -0
  4. package/dist/create-http-client-tZJWlWp1.js.map +1 -0
  5. package/dist/{create-store-BQUX0tAn.js → create-store-D-fQpCql.js} +32 -4
  6. package/dist/create-store-D-fQpCql.js.map +1 -0
  7. package/dist/index.d.ts +21 -6
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +18 -17
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/config.js +2 -2
  12. package/dist/lib/project.d.ts +1 -1
  13. package/dist/lib/project.d.ts.map +1 -1
  14. package/dist/lib/project.js +1 -1
  15. package/dist/lib/store.d.ts +2 -1
  16. package/dist/lib/store.d.ts.map +1 -1
  17. package/dist/lib/store.js +2 -2
  18. package/dist/middleware/auth.d.ts +223 -14
  19. package/dist/middleware/auth.d.ts.map +1 -1
  20. package/dist/middleware/auth.js +973 -408
  21. package/dist/middleware/auth.js.map +1 -1
  22. package/dist/middleware/http.d.ts +10 -16
  23. package/dist/middleware/http.d.ts.map +1 -1
  24. package/dist/middleware/http.js +21 -221
  25. package/dist/middleware/http.js.map +1 -1
  26. package/dist/{middleware-D3psyhYo.js → middleware-BFBKNSPQ.js} +13 -2
  27. package/dist/{middleware-D3psyhYo.js.map → middleware-BFBKNSPQ.js.map} +1 -1
  28. package/dist/{project-NPtYX2ZX.js → project-DuXgjaa_.js} +19 -16
  29. package/dist/project-DuXgjaa_.js.map +1 -0
  30. package/dist/{types-kjpRau0U.d.ts → types-BaZ5WqVM.d.ts} +78 -13
  31. package/dist/types-BaZ5WqVM.d.ts.map +1 -0
  32. package/dist/{types-Cz9h927W.d.ts → types-C0CYivzY.d.ts} +1 -1
  33. package/dist/{types-Cz9h927W.d.ts.map → types-C0CYivzY.d.ts.map} +1 -1
  34. package/package.json +5 -12
  35. package/dist/config-BvGapuFJ.js.map +0 -1
  36. package/dist/create-store-BQUX0tAn.js.map +0 -1
  37. package/dist/lib/output.d.ts +0 -62
  38. package/dist/lib/output.d.ts.map +0 -1
  39. package/dist/lib/output.js +0 -276
  40. package/dist/lib/output.js.map +0 -1
  41. package/dist/lib/prompts.d.ts +0 -24
  42. package/dist/lib/prompts.d.ts.map +0 -1
  43. package/dist/lib/prompts.js +0 -3
  44. package/dist/project-NPtYX2ZX.js.map +0 -1
  45. package/dist/prompts-lLfUSgd6.js +0 -63
  46. package/dist/prompts-lLfUSgd6.js.map +0 -1
  47. package/dist/types-CqKJhsYk.d.ts +0 -135
  48. package/dist/types-CqKJhsYk.d.ts.map +0 -1
  49. package/dist/types-DFtYg5uZ.d.ts +0 -26
  50. package/dist/types-DFtYg5uZ.d.ts.map +0 -1
  51. package/dist/types-kjpRau0U.d.ts.map +0 -1
@@ -1,276 +0,0 @@
1
- import { createCliLogger } from "./logger.js";
2
- import path from "node:path";
3
- import { attempt, err, ok } from "@kidd-cli/utils/fp";
4
- import { jsonStringify } from "@kidd-cli/utils/json";
5
- import fs from "node:fs";
6
- import pinoRedact from "@pinojs/redact";
7
- import { Liquid } from "liquidjs";
8
-
9
- //#region src/context/redact.ts
10
- const CENSOR = "[REDACTED]";
11
- /**
12
- * Keys that are always redacted regardless of their depth in the object tree.
13
- */
14
- const SENSITIVE_KEYS = new Set([
15
- "password",
16
- "secret",
17
- "token",
18
- "apiKey",
19
- "api_key",
20
- "apiSecret",
21
- "api_secret",
22
- "authorization",
23
- "auth",
24
- "credentials",
25
- "private_key",
26
- "privateKey"
27
- ]);
28
- const redactPaths = pinoRedact({
29
- censor: resolveCensor,
30
- paths: [...[
31
- "headers.Authorization",
32
- "env.GITHUB_TOKEN",
33
- "env.LINEAR_API_KEY"
34
- ]],
35
- serialize: false
36
- });
37
- /**
38
- * Censor function for `@pinojs/redact` that preserves null/undefined values.
39
- *
40
- * @private
41
- * @param value - The original value at a redacted path.
42
- * @returns The censor string or the original null/undefined.
43
- */
44
- function resolveCensor(value) {
45
- if (value === null || value === void 0) return value;
46
- return CENSOR;
47
- }
48
- /**
49
- * Deep-clone an object and replace values at sensitive key paths with `[REDACTED]`.
50
- *
51
- * Uses `@pinojs/redact` for specific fixed paths and a recursive walk for
52
- * any-depth key-name matching against {@link SENSITIVE_KEYS}.
53
- *
54
- * @param obj - The object to redact.
55
- * @returns A deep clone with sensitive values replaced.
56
- */
57
- function redactObject(obj) {
58
- return redactSensitiveKeys(redactPaths(obj));
59
- }
60
- /**
61
- * Recursively walk an object and redact values whose key is in {@link SENSITIVE_KEYS}.
62
- * Returns a new object — does not mutate the input.
63
- *
64
- * @private
65
- * @param target - The record to walk.
66
- * @returns A new record with sensitive values replaced.
67
- */
68
- function redactSensitiveKeys(target) {
69
- return Object.fromEntries(Object.entries(target).filter(([key]) => key !== "restore").map(([key, value]) => redactEntry(key, value)));
70
- }
71
- /**
72
- * Process a single key-value entry for sensitive-key redaction.
73
- *
74
- * @private
75
- * @param key - The property key.
76
- * @param value - The property value.
77
- * @returns A [key, value] tuple with the value potentially redacted.
78
- */
79
- function redactEntry(key, value) {
80
- if (SENSITIVE_KEYS.has(key) && value !== void 0 && value !== null) return [key, CENSOR];
81
- if (Array.isArray(value)) return [key, value.map(redactArrayItem)];
82
- if (value && typeof value === "object") return [key, redactSensitiveKeys(value)];
83
- return [key, value];
84
- }
85
- /**
86
- * Redact sensitive keys within an array item if it is an object.
87
- *
88
- * @private
89
- * @param item - The array element.
90
- * @returns The element with sensitive keys redacted, or the original primitive.
91
- */
92
- function redactArrayItem(item) {
93
- if (item && typeof item === "object") return redactSensitiveKeys(item);
94
- return item;
95
- }
96
-
97
- //#endregion
98
- //#region src/lib/output/renderer.ts
99
- /**
100
- * Resolve an unknown error to a string message.
101
- *
102
- * @param error - The error to resolve.
103
- * @returns A string error message.
104
- */
105
- function resolveRenderError(error) {
106
- if (error instanceof Error) return error.message;
107
- return "Unknown error";
108
- }
109
- /**
110
- * Create a Liquid template {@link Renderer}.
111
- *
112
- * @param options - Renderer configuration.
113
- * @returns A Renderer instance.
114
- */
115
- function createRenderer(options) {
116
- const { templates: templatesDir, filters = {}, context } = options;
117
- const liquid = new Liquid();
118
- const templateCache = /* @__PURE__ */ new Map();
119
- for (const [name, fn] of Object.entries(filters)) liquid.registerFilter(name, fn);
120
- return { render(params) {
121
- const [templateError, template] = loadTemplateFromDisk({
122
- cache: templateCache,
123
- templatesDir,
124
- type: params.type
125
- });
126
- if (templateError) return [templateError, null];
127
- return renderTemplate({
128
- extraContext: resolveExtraContext(context, params),
129
- liquid,
130
- params,
131
- template
132
- });
133
- } };
134
- }
135
- /**
136
- * Resolve the full filesystem path to a Liquid template file.
137
- *
138
- * @private
139
- */
140
- function resolveTemplatePath(templatesDir, type) {
141
- const segments = type.split(":");
142
- return `${path.join(templatesDir, ...segments)}.liquid`;
143
- }
144
- /**
145
- * Load a Liquid template from disk, using a cache to avoid redundant reads.
146
- *
147
- * @private
148
- */
149
- function loadTemplateFromDisk(options) {
150
- const { templatesDir, type, cache } = options;
151
- const cached = cache.get(type);
152
- if (cached !== void 0) return ok(cached);
153
- const templatePath = resolveTemplatePath(templatesDir, type);
154
- const [error, content] = attempt(() => fs.readFileSync(templatePath, "utf8"));
155
- if (error || content === null) return err(/* @__PURE__ */ new Error(`Template not found for type '${type}': ${templatePath}`));
156
- cache.set(type, content);
157
- return ok(content);
158
- }
159
- /**
160
- * Resolve additional template context from the user-provided context function.
161
- *
162
- * @private
163
- */
164
- function resolveExtraContext(context, params) {
165
- if (context) return context(params);
166
- return {};
167
- }
168
- /**
169
- * Render a Liquid template with the given parameters and context.
170
- *
171
- * @private
172
- */
173
- function renderTemplate(options) {
174
- const { liquid, template, params, extraContext } = options;
175
- const [error, result] = attempt(() => liquid.parseAndRenderSync(template, {
176
- ...params.data,
177
- ...extraContext
178
- }));
179
- if (error || result === void 0) {
180
- const errorMessage = resolveRenderError(error);
181
- return err(/* @__PURE__ */ new Error(`Failed to render template for ${params.type}: ${errorMessage}`));
182
- }
183
- return ok(result);
184
- }
185
-
186
- //#endregion
187
- //#region src/lib/output/format.ts
188
- /**
189
- * Serialize data to a JSON string.
190
- *
191
- * @param data - The data to serialize.
192
- * @param opts - JSON output options.
193
- * @returns The JSON string.
194
- */
195
- function formatJson(data, opts = {}) {
196
- const { pretty = true, redact = false } = opts;
197
- const [, json] = jsonStringify(resolveProcessed(data, redact), { pretty });
198
- return json || "";
199
- }
200
- /**
201
- * Write content to a file on disk, creating parent directories as needed.
202
- *
203
- * @param params - Write parameters (path and content).
204
- * @returns A Result indicating success or failure.
205
- */
206
- function writeToFile(params) {
207
- const [error] = attempt(() => {
208
- fs.mkdirSync(path.dirname(params.path), { recursive: true });
209
- fs.writeFileSync(params.path, params.content, "utf8");
210
- });
211
- if (error) {
212
- const errorMessage = resolveRenderError(error);
213
- return err(/* @__PURE__ */ new Error(`Failed to write file ${params.path}: ${errorMessage}`));
214
- }
215
- return ok();
216
- }
217
- /**
218
- * Resolve the processed data, optionally redacting sensitive fields.
219
- *
220
- * @private
221
- */
222
- function resolveProcessed(data, redact) {
223
- if (redact && data && typeof data === "object") return redactObject(data);
224
- return data;
225
- }
226
-
227
- //#endregion
228
- //#region src/lib/output/create-output.ts
229
- /**
230
- * Create a new {@link CliOutput} instance for structured CLI output.
231
- *
232
- * @param options - Output configuration.
233
- * @returns A CliOutput instance.
234
- */
235
- function createOutput(options = {}) {
236
- const logger = createCliLogger({ output: options.output ?? process.stdout });
237
- const renderer = resolveRenderer(options);
238
- function toMarkdown(params) {
239
- if (!renderer) return err(/* @__PURE__ */ new Error("Templates directory not configured. Pass `templates` to createOutput()."));
240
- return renderer.render(params);
241
- }
242
- return {
243
- json(data, jsonOptions = {}) {
244
- logger.print(formatJson(data, jsonOptions));
245
- },
246
- print(content) {
247
- logger.print(content);
248
- },
249
- toJson: formatJson,
250
- toMarkdown,
251
- write: writeToFile
252
- };
253
- }
254
- /**
255
- * Resolve a Renderer from the output options, if templates are configured.
256
- *
257
- * @private
258
- */
259
- function resolveRenderer(options) {
260
- if (options.templates) return createRenderer({
261
- context: options.context,
262
- filters: options.filters,
263
- templates: options.templates
264
- });
265
- }
266
-
267
- //#endregion
268
- //#region src/lib/output/defaults.ts
269
- /**
270
- * Default output instance writing to stdout.
271
- */
272
- const output = createOutput();
273
-
274
- //#endregion
275
- export { createOutput, output };
276
- //# sourceMappingURL=output.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output.js","names":[],"sources":["../../src/context/redact.ts","../../src/lib/output/renderer.ts","../../src/lib/output/format.ts","../../src/lib/output/create-output.ts","../../src/lib/output/defaults.ts"],"sourcesContent":["import pinoRedact from '@pinojs/redact'\n\nconst CENSOR = '[REDACTED]'\n\n/**\n * Keys that are always redacted regardless of their depth in the object tree.\n */\nconst SENSITIVE_KEYS: ReadonlySet<string> = new Set([\n 'password',\n 'secret',\n 'token',\n 'apiKey',\n 'api_key',\n 'apiSecret',\n 'api_secret',\n 'authorization',\n 'auth',\n 'credentials',\n 'private_key',\n 'privateKey',\n])\n\n/**\n * Specific nested paths where the key name alone is not sensitive\n * but the location makes it sensitive. Handled by `@pinojs/redact`.\n */\nconst SPECIFIC_PATHS: readonly string[] = [\n 'headers.Authorization',\n 'env.GITHUB_TOKEN',\n 'env.LINEAR_API_KEY',\n]\n\nconst redactPaths = pinoRedact({\n censor: resolveCensor,\n paths: [...SPECIFIC_PATHS],\n serialize: false,\n})\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Censor function for `@pinojs/redact` that preserves null/undefined values.\n *\n * @private\n * @param value - The original value at a redacted path.\n * @returns The censor string or the original null/undefined.\n */\nfunction resolveCensor(value: unknown): unknown {\n if (value === null || value === undefined) {\n return value\n }\n return CENSOR\n}\n\n/**\n * Deep-clone an object and replace values at sensitive key paths with `[REDACTED]`.\n *\n * Uses `@pinojs/redact` for specific fixed paths and a recursive walk for\n * any-depth key-name matching against {@link SENSITIVE_KEYS}.\n *\n * @param obj - The object to redact.\n * @returns A deep clone with sensitive values replaced.\n */\nexport function redactObject<TObj extends object>(obj: TObj): TObj {\n const pathRedacted = redactPaths(obj)\n return redactSensitiveKeys(pathRedacted as Record<string, unknown>) as TObj\n}\n\n/**\n * Recursively walk an object and redact values whose key is in {@link SENSITIVE_KEYS}.\n * Returns a new object — does not mutate the input.\n *\n * @private\n * @param target - The record to walk.\n * @returns A new record with sensitive values replaced.\n */\nfunction redactSensitiveKeys(target: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(target)\n .filter(([key]) => key !== 'restore')\n .map(([key, value]) => redactEntry(key, value))\n )\n}\n\n/**\n * Process a single key-value entry for sensitive-key redaction.\n *\n * @private\n * @param key - The property key.\n * @param value - The property value.\n * @returns A [key, value] tuple with the value potentially redacted.\n */\nfunction redactEntry(key: string, value: unknown): [string, unknown] {\n if (SENSITIVE_KEYS.has(key) && value !== undefined && value !== null) {\n return [key, CENSOR]\n }\n\n if (Array.isArray(value)) {\n return [key, value.map(redactArrayItem)]\n }\n\n if (value && typeof value === 'object') {\n return [key, redactSensitiveKeys(value as Record<string, unknown>)]\n }\n\n return [key, value]\n}\n\n/**\n * Redact sensitive keys within an array item if it is an object.\n *\n * @private\n * @param item - The array element.\n * @returns The element with sensitive keys redacted, or the original primitive.\n */\nfunction redactArrayItem(item: unknown): unknown {\n if (item && typeof item === 'object') {\n return redactSensitiveKeys(item as Record<string, unknown>)\n }\n return item\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { attempt, err, ok } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\nimport { Liquid } from 'liquidjs'\n\nimport type {\n CreateRendererOptions,\n LoadTemplateOptions,\n Renderer,\n RenderTemplateOptions,\n ToMarkdownParams,\n} from './types.js'\n\n/**\n * Resolve an unknown error to a string message.\n *\n * @param error - The error to resolve.\n * @returns A string error message.\n */\nexport function resolveRenderError(error: unknown): string {\n if (error instanceof Error) {\n return error.message\n }\n return 'Unknown error'\n}\n\n/**\n * Create a Liquid template {@link Renderer}.\n *\n * @param options - Renderer configuration.\n * @returns A Renderer instance.\n */\nexport function createRenderer(options: CreateRendererOptions): Renderer {\n const { templates: templatesDir, filters = {}, context } = options\n const liquid = new Liquid()\n const templateCache = new Map<string, string>()\n\n for (const [name, fn] of Object.entries(filters)) {\n liquid.registerFilter(name, fn)\n }\n\n return {\n render(params: ToMarkdownParams): Result<string, Error> {\n const [templateError, template] = loadTemplateFromDisk({\n cache: templateCache,\n templatesDir,\n type: params.type,\n })\n if (templateError) {\n return [templateError, null]\n }\n\n const extraContext = resolveExtraContext(context, params)\n return renderTemplate({ extraContext, liquid, params, template })\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the full filesystem path to a Liquid template file.\n *\n * @private\n */\nfunction resolveTemplatePath(templatesDir: string, type: string): string {\n const segments = type.split(':')\n return `${path.join(templatesDir, ...segments)}.liquid`\n}\n\n/**\n * Load a Liquid template from disk, using a cache to avoid redundant reads.\n *\n * @private\n */\nfunction loadTemplateFromDisk(options: LoadTemplateOptions): Result<string, Error> {\n const { templatesDir, type, cache } = options\n const cached = cache.get(type)\n if (cached !== undefined) {\n return ok(cached)\n }\n\n const templatePath = resolveTemplatePath(templatesDir, type)\n const [error, content] = attempt(() => fs.readFileSync(templatePath, 'utf8'))\n\n if (error || content === null) {\n return err(new Error(`Template not found for type '${type}': ${templatePath}`))\n }\n\n cache.set(type, content)\n return ok(content)\n}\n\n/**\n * Resolve additional template context from the user-provided context function.\n *\n * @private\n */\nfunction resolveExtraContext(\n context: ((params: ToMarkdownParams) => Record<string, unknown>) | undefined,\n params: ToMarkdownParams\n): Record<string, unknown> {\n if (context) {\n return context(params)\n }\n return {}\n}\n\n/**\n * Render a Liquid template with the given parameters and context.\n *\n * @private\n */\nfunction renderTemplate(options: RenderTemplateOptions): Result<string, Error> {\n const { liquid, template, params, extraContext } = options\n const [error, result] = attempt(() =>\n liquid.parseAndRenderSync(template, {\n ...(params.data as object),\n ...extraContext,\n })\n )\n\n if (error || result === undefined) {\n const errorMessage = resolveRenderError(error)\n return err(new Error(`Failed to render template for ${params.type}: ${errorMessage}`))\n }\n\n return ok(result)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { attempt, err, ok } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\nimport { jsonStringify } from '@kidd-cli/utils/json'\n\nimport { redactObject } from '@/context/redact.js'\n\nimport { resolveRenderError } from './renderer.js'\nimport type { JsonOutputOptions, WriteParams } from './types.js'\n\n/**\n * Serialize data to a JSON string.\n *\n * @param data - The data to serialize.\n * @param opts - JSON output options.\n * @returns The JSON string.\n */\nexport function formatJson(data: unknown, opts: JsonOutputOptions = {}): string {\n const { pretty = true, redact = false } = opts\n const processed = resolveProcessed(data, redact)\n const [, json] = jsonStringify(processed, { pretty })\n return json || ''\n}\n\n/**\n * Write content to a file on disk, creating parent directories as needed.\n *\n * @param params - Write parameters (path and content).\n * @returns A Result indicating success or failure.\n */\nexport function writeToFile(params: WriteParams): Result<void, Error> {\n const [error] = attempt(() => {\n fs.mkdirSync(path.dirname(params.path), { recursive: true })\n fs.writeFileSync(params.path, params.content, 'utf8')\n })\n\n if (error) {\n const errorMessage = resolveRenderError(error)\n return err(new Error(`Failed to write file ${params.path}: ${errorMessage}`))\n }\n\n return ok()\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the processed data, optionally redacting sensitive fields.\n *\n * @private\n */\nfunction resolveProcessed(data: unknown, redact: boolean): unknown {\n if (redact && data && typeof data === 'object') {\n return redactObject(data as object)\n }\n return data\n}\n","import { err } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\n\nimport { createCliLogger } from '@/lib/logger.js'\n\nimport { formatJson, writeToFile } from './format.js'\nimport { createRenderer } from './renderer.js'\nimport type {\n CliOutput,\n CreateOutputOptions,\n JsonOutputOptions,\n Renderer,\n ToMarkdownParams,\n} from './types.js'\n\n/**\n * Create a new {@link CliOutput} instance for structured CLI output.\n *\n * @param options - Output configuration.\n * @returns A CliOutput instance.\n */\nexport function createOutput(options: CreateOutputOptions = {}): CliOutput {\n const logger = createCliLogger({ output: options.output ?? process.stdout })\n const renderer = resolveRenderer(options)\n\n function toMarkdown(params: ToMarkdownParams): Result<string, Error> {\n if (!renderer) {\n return err(\n new Error('Templates directory not configured. Pass `templates` to createOutput().')\n )\n }\n return renderer.render(params)\n }\n\n return {\n json(data: unknown, jsonOptions: JsonOutputOptions = {}): void {\n logger.print(formatJson(data, jsonOptions))\n },\n print(content: string): void {\n logger.print(content)\n },\n toJson: formatJson,\n toMarkdown,\n write: writeToFile,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a Renderer from the output options, if templates are configured.\n *\n * @private\n */\nfunction resolveRenderer(options: CreateOutputOptions): Renderer | undefined {\n if (options.templates) {\n return createRenderer({\n context: options.context,\n filters: options.filters,\n templates: options.templates,\n })\n }\n return undefined\n}\n","import { createOutput } from './create-output.js'\nimport type { CliOutput } from './types.js'\n\n/**\n * Default output instance writing to stdout.\n */\nexport const output: CliOutput = createOutput()\n"],"mappings":";;;;;;;;;AAEA,MAAM,SAAS;;;;AAKf,MAAM,iBAAsC,IAAI,IAAI;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAYF,MAAM,cAAc,WAAW;CAC7B,QAAQ;CACR,OAAO,CAAC,GARgC;EACxC;EACA;EACA;EACD,CAI2B;CAC1B,WAAW;CACZ,CAAC;;;;;;;;AAaF,SAAS,cAAc,OAAyB;AAC9C,KAAI,UAAU,QAAQ,UAAU,OAC9B,QAAO;AA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SAAgB,YAAY,QAA0C;CACpE,MAAM,CAAC,SAAS,cAAc;AAC5B,KAAG,UAAU,KAAK,QAAQ,OAAO,KAAK,EAAE,EAAE,WAAW,MAAM,CAAC;AAC5D,KAAG,cAAc,OAAO,MAAM,OAAO,SAAS,OAAO;GACrD;AAEF,KAAI,OAAO;EACT,MAAM,eAAe,mBAAmB,MAAM;AAC9C,SAAO,oBAAI,IAAI,MAAM,wBAAwB,OAAO,KAAK,IAAI,eAAe,CAAC;;AAG/E,QAAO,IAAI;;;;;;;AAYb,SAAS,iBAAiB,MAAe,QAA0B;AACjE,KAAI,UAAU,QAAQ,OAAO,SAAS,SACpC,QAAO,aAAa,KAAe;AAErC,QAAO;;;;;;;;;;;ACtCT,SAAgB,aAAa,UAA+B,EAAE,EAAa;CACzE,MAAM,SAAS,gBAAgB,EAAE,QAAQ,QAAQ,UAAU,QAAQ,QAAQ,CAAC;CAC5E,MAAM,WAAW,gBAAgB,QAAQ;CAEzC,SAAS,WAAW,QAAiD;AACnE,MAAI,CAAC,SACH,QAAO,oBACL,IAAI,MAAM,0EAA0E,CACrF;AAEH,SAAO,SAAS,OAAO,OAAO;;AAGhC,QAAO;EACL,KAAK,MAAe,cAAiC,EAAE,EAAQ;AAC7D,UAAO,MAAM,WAAW,MAAM,YAAY,CAAC;;EAE7C,MAAM,SAAuB;AAC3B,UAAO,MAAM,QAAQ;;EAEvB,QAAQ;EACR;EACA,OAAO;EACR;;;;;;;AAYH,SAAS,gBAAgB,SAAoD;AAC3E,KAAI,QAAQ,UACV,QAAO,eAAe;EACpB,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,WAAW,QAAQ;EACpB,CAAC;;;;;;;;ACxDN,MAAa,SAAoB,cAAc"}
@@ -1,24 +0,0 @@
1
- import { n as Spinner, t as PromptUtils } from "../types-DFtYg5uZ.js";
2
-
3
- //#region src/lib/prompts/create-prompts.d.ts
4
- /**
5
- * Create a new {@link Spinner} instance backed by @clack/prompts.
6
- */
7
- declare function createSpinner(): Spinner;
8
- /**
9
- * Create a new {@link PromptUtils} instance backed by @clack/prompts.
10
- */
11
- declare function createPromptUtils(): PromptUtils;
12
- //#endregion
13
- //#region src/lib/prompts/defaults.d.ts
14
- /**
15
- * Default spinner instance.
16
- */
17
- declare const spinner: Spinner;
18
- /**
19
- * Default prompt utilities instance.
20
- */
21
- declare const prompts: PromptUtils;
22
- //#endregion
23
- export { type PromptUtils, type Spinner, createPromptUtils, createSpinner, prompts, spinner };
24
- //# sourceMappingURL=prompts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.d.ts","names":[],"sources":["../../src/lib/prompts/create-prompts.ts","../../src/lib/prompts/defaults.ts"],"mappings":";;;;;AAOA;iBAAgB,aAAA,CAAA,GAAiB,OAAA;;;;iBAqBjB,iBAAA,CAAA,GAAqB,WAAA;;;;;AArBrC;cCDa,OAAA,EAAS,OAAA;;;;cAKT,OAAA,EAAS,WAAA"}
@@ -1,3 +0,0 @@
1
- import { i as createSpinner, n as spinner, r as createPromptUtils, t as prompts } from "../prompts-lLfUSgd6.js";
2
-
3
- export { createPromptUtils, createSpinner, prompts, spinner };
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-NPtYX2ZX.js","names":["match"],"sources":["../src/lib/project/root.ts","../src/lib/project/paths.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\n\nimport { attempt } from '@kidd-cli/utils/fp'\n\nimport type { ProjectRoot } from './types.js'\n\nconst MIN_MODULES_PARTS = 2\n\n/**\n * Walk up the directory tree to find the nearest git project root.\n *\n * @param startDir - Directory to start searching from (defaults to cwd).\n * @returns The project root info, or null if no git root is found.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): ProjectRoot | null {\n /**\n * Recursively walk up the directory tree searching for a `.git` marker.\n *\n * @private\n */\n const findRootRecursive = (currentDir: string, visited: Set<string>): ProjectRoot | null => {\n if (visited.has(currentDir)) {\n return null\n }\n const nextVisited = new Set([...visited, currentDir])\n\n const gitPath = join(currentDir, '.git')\n try {\n const result = checkGitPath(gitPath, currentDir)\n if (result) {\n return result\n }\n } catch {\n // Race condition: file may have been deleted between existsSync and statSync\n }\n\n const parent = dirname(currentDir)\n if (parent === currentDir) {\n return null\n }\n return findRootRecursive(parent, nextVisited)\n }\n\n return findRootRecursive(resolve(startDir), new Set())\n}\n\n/**\n * Check whether the current directory is inside a git submodule.\n *\n * @param startDir - Directory to start searching from.\n * @returns True if the directory is inside a submodule.\n */\nexport function isInSubmodule(startDir?: string): boolean {\n const projectRoot = findProjectRoot(startDir)\n if (!projectRoot) {\n return false\n }\n return projectRoot.isSubmodule\n}\n\n/**\n * Resolve the parent repository root when inside a git submodule.\n *\n * @param startDir - Directory to start searching from.\n * @returns The parent repository root path, or null.\n */\nexport function getParentRepoRoot(startDir?: string): string | null {\n const projectRoot = findProjectRoot(startDir)\n if (!projectRoot || !projectRoot.isSubmodule) {\n return null\n }\n\n const gitFilePath = join(projectRoot.path, '.git')\n const gitFileContent = resolveGitDirFromFile(gitFilePath)\n if (gitFileContent === null) {\n return null\n }\n\n return resolveParentGitDir(projectRoot, gitFileContent)\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a `.git` file reference to determine if this is a submodule.\n *\n * @private\n */\nfunction resolveGitFileSubmodule(gitPath: string, currentDir: string): ProjectRoot | null {\n const [readError, gitFileContent] = attempt(() => readFileSync(gitPath, 'utf8').trim())\n if (readError || gitFileContent === null) {\n return { isSubmodule: false, path: currentDir }\n }\n const gitDirMatch = gitFileContent.match(/^gitdir:\\s*(.+)$/)\n if (gitDirMatch && gitDirMatch[1]) {\n const gitDir = resolve(currentDir, gitDirMatch[1])\n const isSubmodule = /[/\\\\]\\.git[/\\\\]modules[/\\\\]/.test(gitDir)\n return { isSubmodule, path: currentDir }\n }\n return null\n}\n\n/**\n * Check whether a `.git` path is a directory or file and resolve accordingly.\n *\n * @private\n */\nfunction checkGitPath(gitPath: string, currentDir: string): ProjectRoot | null {\n if (!existsSync(gitPath)) {\n return null\n }\n\n const stats = statSync(gitPath)\n if (stats.isDirectory()) {\n return { isSubmodule: false, path: currentDir }\n }\n\n if (stats.isFile()) {\n return resolveGitFileSubmodule(gitPath, currentDir)\n }\n\n return null\n}\n\n/**\n * Read a `.git` file and return its raw content.\n *\n * @private\n */\nfunction resolveGitDirFromFile(gitFilePath: string): string | null {\n const [readError, gitFileContent] = attempt(() => readFileSync(gitFilePath, 'utf8').trim())\n if (readError || gitFileContent === null) {\n return null\n }\n return gitFileContent\n}\n\n/**\n * Extract the parent repository root from a resolved git modules path.\n *\n * @private\n */\nfunction resolveParentFromGitDir(resolvedGitDir: string): string | null {\n const gitDirParts = resolvedGitDir.split('/modules/')\n if (gitDirParts.length >= MIN_MODULES_PARTS) {\n const [parentGitDir] = gitDirParts\n if (parentGitDir && parentGitDir.endsWith('.git')) {\n return dirname(parentGitDir)\n }\n }\n return null\n}\n\n/**\n * Resolve the parent repository root from a submodule's gitdir reference.\n *\n * @private\n */\nfunction resolveParentGitDir(projectRoot: ProjectRoot, gitFileContent: string): string | null {\n const gitDirMatch = gitFileContent.match(/^gitdir:\\s*(.+)$/)\n if (!gitDirMatch) {\n return null\n }\n\n const gitDir = gitDirMatch[1] ?? ''\n const resolvedGitDir = resolve(projectRoot.path, gitDir)\n\n if (process.platform === 'win32') {\n return null\n }\n\n return resolveParentFromGitDir(resolvedGitDir)\n}\n","import { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nimport { match } from 'ts-pattern'\n\nimport { findProjectRoot } from './root.js'\nimport type { ResolvePathOptions } from './types.js'\n\n/**\n * Resolve a directory path relative to the project root.\n *\n * @param options - Options containing the directory name and optional start directory.\n * @returns The resolved local path, or null if no project root is found.\n */\nexport function resolveLocalPath(options: {\n readonly dirName: string\n readonly startDir?: string\n}): string | null {\n const projectRoot = findProjectRoot(options.startDir)\n if (!projectRoot) {\n return null\n }\n return join(projectRoot.path, options.dirName)\n}\n\n/**\n * Resolve a directory path relative to the user's home directory.\n *\n * @param options - Options containing the directory name.\n * @returns The resolved global path.\n */\nexport function resolveGlobalPath(options: { readonly dirName: string }): string {\n return join(homedir(), options.dirName)\n}\n\n/**\n * Resolve a directory path using the specified source strategy.\n *\n * When source is 'local', resolves relative to the project root.\n * When source is 'global', resolves relative to the home directory.\n * When source is 'resolve' (default), tries local first, falling back to global.\n *\n * @param options - Resolution options with dirName, source, and startDir.\n * @returns The resolved path, or null if local resolution fails with source='local'.\n */\nexport function resolvePath(options: ResolvePathOptions): string | null {\n const { dirName, source = 'resolve', startDir } = options\n return match(source)\n .with('local', (): string | null => resolveLocalPath({ dirName, startDir }))\n .with('global', (): string => resolveGlobalPath({ dirName }))\n .with('resolve', (): string => {\n const localPath = resolveLocalPath({ dirName, startDir })\n if (localPath) {\n return localPath\n }\n return resolveGlobalPath({ dirName })\n })\n .exhaustive()\n}\n"],"mappings":";;;;;;;AAOA,MAAM,oBAAoB;;;;;;;AAQ1B,SAAgB,gBAAgB,WAAmB,QAAQ,KAAK,EAAsB;;;;;;CAMpF,MAAM,qBAAqB,YAAoB,YAA6C;AAC1F,MAAI,QAAQ,IAAI,WAAW,CACzB,QAAO;EAET,MAAM,cAAc,IAAI,IAAI,CAAC,GAAG,SAAS,WAAW,CAAC;EAErD,MAAM,UAAU,KAAK,YAAY,OAAO;AACxC,MAAI;GACF,MAAM,SAAS,aAAa,SAAS,WAAW;AAChD,OAAI,OACF,QAAO;UAEH;EAIR,MAAM,SAAS,QAAQ,WAAW;AAClC,MAAI,WAAW,WACb,QAAO;AAET,SAAO,kBAAkB,QAAQ,YAAY;;AAG/C,QAAO,kBAAkB,QAAQ,SAAS,kBAAE,IAAI,KAAK,CAAC;;;;;;;;AASxD,SAAgB,cAAc,UAA4B;CACxD,MAAM,cAAc,gBAAgB,SAAS;AAC7C,KAAI,CAAC,YACH,QAAO;AAET,QAAO,YAAY;;;;;;;;AASrB,SAAgB,kBAAkB,UAA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BAAoB,aAA0B,gBAAuC;CAC5F,MAAM,cAAc,eAAe,MAAM,mBAAmB;AAC5D,KAAI,CAAC,YACH,QAAO;CAGT,MAAM,SAAS,YAAY,MAAM;CACjC,MAAM,iBAAiB,QAAQ,YAAY,MAAM,OAAO;AAExD,KAAI,QAAQ,aAAa,QACvB,QAAO;AAGT,QAAO,wBAAwB,eAAe;;;;;;;;;;;AChKhD,SAAgB,iBAAiB,SAGf;CAChB,MAAM,cAAc,gBAAgB,QAAQ,SAAS;AACrD,KAAI,CAAC,YACH,QAAO;AAET,QAAO,KAAK,YAAY,MAAM,QAAQ,QAAQ;;;;;;;;AAShD,SAAgB,kBAAkB,SAA+C;AAC/E,QAAO,KAAK,SAAS,EAAE,QAAQ,QAAQ;;;;;;;;;;;;AAazC,SAAgB,YAAY,SAA4C;CACtE,MAAM,EAAE,SAAS,SAAS,WAAW,aAAa;AAClD,QAAOA,QAAM,OAAO,CACjB,KAAK,eAA8B,iBAAiB;EAAE;EAAS;EAAU,CAAC,CAAC,CAC3E,KAAK,gBAAwB,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAC5D,KAAK,iBAAyB;EAC7B,MAAM,YAAY,iBAAiB;GAAE;GAAS;GAAU,CAAC;AACzD,MAAI,UACF,QAAO;AAET,SAAO,kBAAkB,EAAE,SAAS,CAAC;GACrC,CACD,YAAY"}
@@ -1,63 +0,0 @@
1
- import * as clack from "@clack/prompts";
2
-
3
- //#region src/lib/prompts/create-prompts.ts
4
- /**
5
- * Create a new {@link Spinner} instance backed by @clack/prompts.
6
- */
7
- function createSpinner() {
8
- const spinnerInstance = clack.spinner();
9
- return {
10
- message(msg) {
11
- spinnerInstance.message(msg);
12
- },
13
- start(message) {
14
- spinnerInstance.start(message);
15
- },
16
- stop(message) {
17
- spinnerInstance.stop(message);
18
- }
19
- };
20
- }
21
- /**
22
- * Create a new {@link PromptUtils} instance backed by @clack/prompts.
23
- */
24
- function createPromptUtils() {
25
- return {
26
- cancel(message) {
27
- clack.cancel(message);
28
- },
29
- confirm(opts) {
30
- return clack.confirm(opts);
31
- },
32
- isCancel(value) {
33
- return clack.isCancel(value);
34
- },
35
- multiselect(opts) {
36
- return clack.multiselect(opts);
37
- },
38
- password(opts) {
39
- return clack.password(opts);
40
- },
41
- select(opts) {
42
- return clack.select(opts);
43
- },
44
- text(opts) {
45
- return clack.text(opts);
46
- }
47
- };
48
- }
49
-
50
- //#endregion
51
- //#region src/lib/prompts/defaults.ts
52
- /**
53
- * Default spinner instance.
54
- */
55
- const spinner = createSpinner();
56
- /**
57
- * Default prompt utilities instance.
58
- */
59
- const prompts = createPromptUtils();
60
-
61
- //#endregion
62
- export { createSpinner as i, spinner as n, createPromptUtils as r, prompts as t };
63
- //# sourceMappingURL=prompts-lLfUSgd6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts-lLfUSgd6.js","names":[],"sources":["../src/lib/prompts/create-prompts.ts","../src/lib/prompts/defaults.ts"],"sourcesContent":["import * as clack from '@clack/prompts'\n\nimport type { PromptUtils, Spinner } from './types.js'\n\n/**\n * Create a new {@link Spinner} instance backed by @clack/prompts.\n */\nexport function createSpinner(): Spinner {\n const spinnerInstance = clack.spinner()\n\n return {\n message(msg: string): void {\n spinnerInstance.message(msg)\n },\n\n start(message?: string): void {\n spinnerInstance.start(message)\n },\n\n stop(message?: string): void {\n spinnerInstance.stop(message)\n },\n }\n}\n\n/**\n * Create a new {@link PromptUtils} instance backed by @clack/prompts.\n */\nexport function createPromptUtils(): PromptUtils {\n return {\n cancel(message?: string): void {\n clack.cancel(message)\n },\n\n confirm(\n opts: Omit<Parameters<typeof clack.confirm>[0], 'output'>\n ): ReturnType<typeof clack.confirm> {\n return clack.confirm(opts)\n },\n\n isCancel(value: unknown): value is symbol {\n return clack.isCancel(value)\n },\n\n multiselect<TValue>(\n opts: Omit<Parameters<typeof clack.multiselect<TValue>>[0], 'output'>\n ): ReturnType<typeof clack.multiselect<TValue>> {\n return clack.multiselect(opts)\n },\n\n password(\n opts: Omit<Parameters<typeof clack.password>[0], 'output'>\n ): ReturnType<typeof clack.password> {\n return clack.password(opts)\n },\n\n select<TValue>(\n opts: Omit<Parameters<typeof clack.select<TValue>>[0], 'output'>\n ): ReturnType<typeof clack.select<TValue>> {\n return clack.select(opts)\n },\n\n text(opts: Omit<Parameters<typeof clack.text>[0], 'output'>): ReturnType<typeof clack.text> {\n return clack.text(opts)\n },\n }\n}\n","import { createPromptUtils, createSpinner } from './create-prompts.js'\nimport type { PromptUtils, Spinner } from './types.js'\n\n/**\n * Default spinner instance.\n */\nexport const spinner: Spinner = createSpinner()\n\n/**\n * Default prompt utilities instance.\n */\nexport const prompts: PromptUtils = createPromptUtils()\n"],"mappings":";;;;;;AAOA,SAAgB,gBAAyB;CACvC,MAAM,kBAAkB,MAAM,SAAS;AAEvC,QAAO;EACL,QAAQ,KAAmB;AACzB,mBAAgB,QAAQ,IAAI;;EAG9B,MAAM,SAAwB;AAC5B,mBAAgB,MAAM,QAAQ;;EAGhC,KAAK,SAAwB;AAC3B,mBAAgB,KAAK,QAAQ;;EAEhC;;;;;AAMH,SAAgB,oBAAiC;AAC/C,QAAO;EACL,OAAO,SAAwB;AAC7B,SAAM,OAAO,QAAQ;;EAGvB,QACE,MACkC;AAClC,UAAO,MAAM,QAAQ,KAAK;;EAG5B,SAAS,OAAiC;AACxC,UAAO,MAAM,SAAS,MAAM;;EAG9B,YACE,MAC8C;AAC9C,UAAO,MAAM,YAAY,KAAK;;EAGhC,SACE,MACmC;AACnC,UAAO,MAAM,SAAS,KAAK;;EAG7B,OACE,MACyC;AACzC,UAAO,MAAM,OAAO,KAAK;;EAG3B,KAAK,MAAuF;AAC1F,UAAO,MAAM,KAAK,KAAK;;EAE1B;;;;;;;;AC3DH,MAAa,UAAmB,eAAe;;;;AAK/C,MAAa,UAAuB,mBAAmB"}
@@ -1,135 +0,0 @@
1
- import { AsyncResult } from "@kidd-cli/utils/fp";
2
-
3
- //#region src/middleware/auth/types.d.ts
4
- /**
5
- * Bearer token credential — sends `Authorization: Bearer <token>`.
6
- */
7
- interface BearerCredential {
8
- readonly type: "bearer";
9
- readonly token: string;
10
- }
11
- /**
12
- * Basic auth credential — sends `Authorization: Basic base64(user:pass)`.
13
- */
14
- interface BasicCredential {
15
- readonly type: "basic";
16
- readonly username: string;
17
- readonly password: string;
18
- }
19
- /**
20
- * API key credential — sends the key in a custom header.
21
- */
22
- interface ApiKeyCredential {
23
- readonly type: "api-key";
24
- readonly headerName: string;
25
- readonly key: string;
26
- }
27
- /**
28
- * Custom credential — sends arbitrary headers.
29
- */
30
- interface CustomCredential {
31
- readonly type: "custom";
32
- readonly headers: Readonly<Record<string, string>>;
33
- }
34
- /**
35
- * Discriminated union of all supported auth credential formats.
36
- * The `type` field acts as the discriminator.
37
- */
38
- type AuthCredential = BearerCredential | BasicCredential | ApiKeyCredential | CustomCredential;
39
- /**
40
- * Resolve credentials from environment variables.
41
- */
42
- interface EnvSourceConfig {
43
- readonly source: "env";
44
- readonly tokenVar?: string;
45
- }
46
- /**
47
- * Resolve credentials from a `.env` file parsed with dotenv.
48
- */
49
- interface DotenvSourceConfig {
50
- readonly source: "dotenv";
51
- readonly tokenVar?: string;
52
- readonly path?: string;
53
- }
54
- /**
55
- * Resolve credentials from a JSON file on disk.
56
- */
57
- interface FileSourceConfig {
58
- readonly source: "file";
59
- readonly filename?: string;
60
- readonly dirName?: string;
61
- }
62
- /**
63
- * Resolve credentials via an OAuth browser flow.
64
- */
65
- interface OAuthSourceConfig {
66
- readonly source: "oauth";
67
- readonly authUrl: string;
68
- readonly port?: number;
69
- readonly callbackPath?: string;
70
- readonly timeout?: number;
71
- }
72
- /**
73
- * Resolve credentials by prompting the user interactively.
74
- */
75
- interface PromptSourceConfig {
76
- readonly source: "prompt";
77
- readonly message?: string;
78
- }
79
- /**
80
- * Resolve credentials via a user-supplied function.
81
- */
82
- interface CustomSourceConfig {
83
- readonly source: "custom";
84
- readonly resolver: () => Promise<AuthCredential | null> | AuthCredential | null;
85
- }
86
- /**
87
- * Discriminated union of all supported credential source configurations.
88
- * The `source` field acts as the discriminator.
89
- */
90
- type ResolverConfig = EnvSourceConfig | DotenvSourceConfig | FileSourceConfig | OAuthSourceConfig | PromptSourceConfig | CustomSourceConfig;
91
- /**
92
- * Error returned by {@link AuthContext.authenticate} when interactive auth fails.
93
- */
94
- interface LoginError {
95
- readonly type: "no_credential" | "save_failed";
96
- readonly message: string;
97
- }
98
- /**
99
- * Auth context decorated onto `ctx.auth` by the auth middleware.
100
- *
101
- * No credential data is stored directly on the context. Instead, callers
102
- * use `credential()` to read saved credentials on demand and
103
- * `authenticated()` to check whether a credential exists without exposing it.
104
- *
105
- * `authenticate()` runs the configured interactive resolvers (OAuth, prompt,
106
- * etc.), persists the resulting credential to disk, and returns a
107
- * {@link AsyncResult}.
108
- */
109
- interface AuthContext {
110
- readonly credential: () => AuthCredential | null;
111
- readonly authenticated: () => boolean;
112
- readonly authenticate: () => AsyncResult<AuthCredential, LoginError>;
113
- }
114
- /**
115
- * Options accepted by the `auth()` middleware factory.
116
- *
117
- * @property resolvers - Ordered list of credential sources to try via `authenticate()`.
118
- */
119
- interface AuthOptions {
120
- readonly resolvers: readonly ResolverConfig[];
121
- }
122
- /**
123
- * Augments the base {@link Context} with an optional `auth` property.
124
- *
125
- * When a consumer imports `kidd/auth`, this declaration merges `auth`
126
- * onto `Context` so that `ctx.auth` is typed without manual casting.
127
- */
128
- declare module "@kidd-cli/core" {
129
- interface Context {
130
- readonly auth: AuthContext;
131
- }
132
- }
133
- //#endregion
134
- export { ResolverConfig as a, LoginError as i, AuthCredential as n, AuthOptions as r, AuthContext as t };
135
- //# sourceMappingURL=types-CqKJhsYk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-CqKJhsYk.d.ts","names":[],"sources":["../src/middleware/auth/types.ts"],"mappings":";;;;;;UAmBiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;AAAA;AAeX;;;AAAA,UATiB,eAAA;EAAA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ompts/types.d.ts
4
- /**
5
- * Terminal spinner for indicating long-running operations.
6
- */
7
- interface Spinner {
8
- start(message?: string): void;
9
- stop(message?: string): void;
10
- message(message: string): void;
11
- }
12
- /**
13
- * Interactive prompt methods backed by @clack/prompts.
14
- */
15
- interface PromptUtils {
16
- select<TValue>(opts: Omit<Parameters<typeof clack.select<TValue>>[0], "output">): ReturnType<typeof clack.select<TValue>>;
17
- confirm(opts: Omit<Parameters<typeof clack.confirm>[0], "output">): ReturnType<typeof clack.confirm>;
18
- text(opts: Omit<Parameters<typeof clack.text>[0], "output">): ReturnType<typeof clack.text>;
19
- multiselect<TValue>(opts: Omit<Parameters<typeof clack.multiselect<TValue>>[0], "output">): ReturnType<typeof clack.multiselect<TValue>>;
20
- password(opts: Omit<Parameters<typeof clack.password>[0], "output">): ReturnType<typeof clack.password>;
21
- isCancel(value: unknown): value is symbol;
22
- cancel(message?: string): void;
23
- }
24
- //#endregion
25
- export { Spinner as n, PromptUtils as t };
26
- //# sourceMappingURL=types-DFtYg5uZ.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DFtYg5uZ.d.ts","names":[],"sources":["../src/lib/prompts/types.ts"],"mappings":";;;;;AAKA;UAAiB,OAAA;EACf,KAAA,CAAM,OAAA;EACN,IAAA,CAAK,OAAA;EACL,OAAA,CAAQ,OAAA;AAAA;;;;UAMO,WAAA;EACf,MAAA,SACE,IAAA,EAAM,IAAA,CAAK,UAAA,QAAkB,KAAA,CAAM,MAAA,CAAO,MAAA,mBACzC,UAAA,QAAkB,KAAA,CAAM,MAAA,CAAO,MAAA;EAClC,OAAA,CACE,IAAA,EAAM,IAAA,CAAK,UAAA,QAAkB,KAAA,CAAM,OAAA,kBAClC,UAAA,QAAkB,KAAA,CAAM,OAAA;EAC3B,IAAA,CAAK,IAAA,EAAM,IAAA,CAAK,UAAA,QAAkB,KAAA,CAAM,IAAA,kBAAsB,UAAA,QAAkB,KAAA,CAAM,IAAA;EACtF,WAAA,SACE,IAAA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