@kidd-cli/core 0.2.0 → 0.4.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.
- package/README.md +2 -3
- package/dist/{config-Db_sjFU-.js → config-D8e5qxLp.js} +5 -17
- package/dist/config-D8e5qxLp.js.map +1 -0
- package/dist/{create-store-D-fQpCql.js → create-store-OHdkm_Yt.js} +3 -4
- package/dist/{create-store-D-fQpCql.js.map → create-store-OHdkm_Yt.js.map} +1 -1
- package/dist/index.d.ts +36 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +297 -73
- package/dist/index.js.map +1 -1
- package/dist/lib/config.js +3 -4
- package/dist/lib/logger.d.ts +1 -1
- package/dist/lib/logger.js +1 -2
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/project.d.ts +1 -1
- package/dist/lib/project.d.ts.map +1 -1
- package/dist/lib/project.js +2 -3
- package/dist/lib/store.d.ts +1 -1
- package/dist/lib/store.js +3 -4
- package/dist/{logger-BkQQej8h.d.ts → logger-9j49T5da.d.ts} +1 -1
- package/dist/{logger-BkQQej8h.d.ts.map → logger-9j49T5da.d.ts.map} +1 -1
- package/dist/middleware/auth.d.ts +81 -41
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +287 -233
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/http.d.ts +1 -1
- package/dist/middleware/http.js +163 -4
- package/dist/middleware/http.js.map +1 -1
- package/dist/{middleware-BFBKNSPQ.js → middleware-BWnPSRWR.js} +2 -4
- package/dist/{middleware-BFBKNSPQ.js.map → middleware-BWnPSRWR.js.map} +1 -1
- package/dist/{project-DuXgjaa_.js → project-D0g84bZY.js} +4 -8
- package/dist/project-D0g84bZY.js.map +1 -0
- package/dist/{types-C0CYivzY.d.ts → types-D-BxshYM.d.ts} +1 -1
- package/dist/{types-C0CYivzY.d.ts.map → types-D-BxshYM.d.ts.map} +1 -1
- package/dist/{types-BaZ5WqVM.d.ts → types-U73X_oQ_.d.ts} +60 -10
- package/dist/types-U73X_oQ_.d.ts.map +1 -0
- package/package.json +7 -7
- package/dist/config-Db_sjFU-.js.map +0 -1
- package/dist/create-http-client-tZJWlWp1.js +0 -165
- package/dist/create-http-client-tZJWlWp1.js.map +0 -1
- package/dist/project-DuXgjaa_.js.map +0 -1
- package/dist/types-BaZ5WqVM.d.ts.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { withTag } from "@kidd-cli/utils/tag";
|
|
2
|
-
|
|
3
2
|
//#region src/context/decorate.ts
|
|
4
3
|
/**
|
|
5
4
|
* Add a typed, immutable property to a context instance.
|
|
@@ -36,7 +35,6 @@ function decorateContext(ctx, key, value) {
|
|
|
36
35
|
});
|
|
37
36
|
return ctx;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
39
|
//#region src/middleware.ts
|
|
42
40
|
/**
|
|
@@ -59,7 +57,7 @@ function decorateContext(ctx, key, value) {
|
|
|
59
57
|
function middleware(handler) {
|
|
60
58
|
return withTag({ handler }, "Middleware");
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
//#endregion
|
|
64
61
|
export { decorateContext as n, middleware as t };
|
|
65
|
-
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=middleware-BWnPSRWR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-
|
|
1
|
+
{"version":3,"file":"middleware-BWnPSRWR.js","names":[],"sources":["../src/context/decorate.ts","../src/middleware.ts"],"sourcesContent":["import type { Context } from './types.js'\n\n/**\n * Add a typed, immutable property to a context instance.\n *\n * Middleware authors use this to extend ctx with custom properties.\n * Pair with module augmentation on Context for type safety:\n *\n * ```ts\n * declare module '@kidd-cli/core' {\n * interface Context {\n * readonly github: HttpClient\n * }\n * }\n * ```\n *\n * **Note:** This function mutates the context object via\n * `Object.defineProperty`. The added property is non-writable and\n * non-configurable, making it effectively frozen after assignment.\n * Mutation is intentional here — the context is assembled incrementally\n * across middleware, and copying the entire object on each decoration\n * would break the single-reference threading model used by the runner.\n *\n * @param ctx - The context instance to decorate (mutated in place).\n * @param key - The property name.\n * @param value - The property value (frozen after assignment).\n * @returns The same ctx reference, now carrying the new property.\n */\nexport function decorateContext<TKey extends string, TValue>(\n ctx: Context,\n key: TKey,\n value: TValue\n): Context {\n Object.defineProperty(ctx, key, { configurable: false, enumerable: true, value, writable: false })\n return ctx\n}\n","import { withTag } from '@kidd-cli/utils/tag'\n\nimport type { Middleware, MiddlewareEnv, MiddlewareFn } from './types.js'\n\n/**\n * Create a typed middleware that runs before command handlers.\n *\n * Use the generic parameter to declare context variables the middleware provides.\n * The handler's `ctx` type in downstream commands will include these variables.\n *\n * @param handler - The middleware function receiving ctx and next.\n * @returns A Middleware object for use in the cli() or command() middleware stack.\n *\n * @example\n * ```ts\n * const loadUser = middleware<{ Variables: { user: User } }>(async (ctx, next) => {\n * decorateContext(ctx, 'user', await fetchUser())\n * await next()\n * })\n * ```\n */\nexport function middleware<TEnv extends MiddlewareEnv = MiddlewareEnv>(\n handler: MiddlewareFn<TEnv>\n): Middleware<TEnv> {\n return withTag({ handler }, 'Middleware')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,gBACd,KACA,KACA,OACS;AACT,QAAO,eAAe,KAAK,KAAK;EAAE,cAAc;EAAO,YAAY;EAAM;EAAO,UAAU;EAAO,CAAC;AAClG,QAAO;;;;;;;;;;;;;;;;;;;;;ACbT,SAAgB,WACd,SACkB;AAClB,QAAO,QAAQ,EAAE,SAAS,EAAE,aAAa"}
|
|
@@ -3,7 +3,6 @@ import { attempt } from "@kidd-cli/utils/fp";
|
|
|
3
3
|
import { match as match$1 } from "ts-pattern";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
6
|
-
|
|
7
6
|
//#region src/lib/project/root.ts
|
|
8
7
|
const GITDIR_RE = /^gitdir:\s*(.+)$/;
|
|
9
8
|
const MIN_MODULES_PARTS = 2;
|
|
@@ -23,10 +22,8 @@ function findProjectRoot(startDir = process.cwd()) {
|
|
|
23
22
|
if (visited.has(currentDir)) return null;
|
|
24
23
|
const nextVisited = new Set([...visited, currentDir]);
|
|
25
24
|
const gitPath = join(currentDir, ".git");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (result) return result;
|
|
29
|
-
} catch {}
|
|
25
|
+
const [checkError, result] = attempt(() => checkGitPath(gitPath, currentDir));
|
|
26
|
+
if (!checkError && result) return result;
|
|
30
27
|
const parent = dirname(currentDir);
|
|
31
28
|
if (parent === currentDir) return null;
|
|
32
29
|
return findRootRecursive(parent, nextVisited);
|
|
@@ -131,7 +128,6 @@ function resolveParentGitDir(projectRoot, gitFileContent) {
|
|
|
131
128
|
if (process.platform === "win32") return null;
|
|
132
129
|
return resolveParentFromGitDir(resolvedGitDir);
|
|
133
130
|
}
|
|
134
|
-
|
|
135
131
|
//#endregion
|
|
136
132
|
//#region src/lib/project/paths.ts
|
|
137
133
|
/**
|
|
@@ -178,7 +174,7 @@ function resolvePath(options) {
|
|
|
178
174
|
return resolveGlobalPath({ dirName });
|
|
179
175
|
}).exhaustive();
|
|
180
176
|
}
|
|
181
|
-
|
|
182
177
|
//#endregion
|
|
183
178
|
export { getParentRepoRoot as a, findProjectRoot as i, resolveLocalPath as n, isInSubmodule as o, resolvePath as r, resolveGlobalPath as t };
|
|
184
|
-
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=project-D0g84bZY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-D0g84bZY.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 GITDIR_RE = /^gitdir:\\s*(.+)$/\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 // Race condition: file may have been deleted between existsSync and statSync\n const [checkError, result] = attempt(() => checkGitPath(gitPath, currentDir))\n\n if (!checkError && result) {\n return result\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 = readGitFile(gitFilePath)\n if (gitFileContent === null) {\n return null\n }\n\n return resolveParentGitDir(projectRoot, gitFileContent)\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Read and trim the contents of a git-related file.\n *\n * @param filePath - The absolute file path to read.\n * @returns The trimmed file content, or null when the file cannot be read.\n * @private\n */\nfunction readGitFile(filePath: string): string | null {\n const [error, content] = attempt(() => readFileSync(filePath, 'utf8'))\n if (error || content === null) {\n return null\n }\n return content.trim()\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 gitFileContent = readGitFile(gitPath)\n if (gitFileContent === null) {\n return { isSubmodule: false, path: currentDir }\n }\n const gitDirMatch = gitFileContent.match(GITDIR_RE)\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 * 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_RE)\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,YAAY;AAClB,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;EAExC,MAAM,CAAC,YAAY,UAAU,cAAc,aAAa,SAAS,WAAW,CAAC;AAE7E,MAAI,CAAC,cAAc,OAC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iB,WAAA;EAAA,SACN,WAAA;EAAA,SACA,IAAA;AAAA;;;;KAMC,UAAA;AAKZ;;;AAAA,UAAiB,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,MAAA,GAAS,UAAA;EAAA,SACT,QAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as CliLogger } from "./logger-
|
|
2
|
-
import { Tagged } from "@kidd-cli/utils/tag";
|
|
1
|
+
import { t as CliLogger } from "./logger-9j49T5da.js";
|
|
3
2
|
import { z } from "zod";
|
|
3
|
+
import { Tagged } from "@kidd-cli/utils/tag";
|
|
4
4
|
|
|
5
5
|
//#region src/context/types.d.ts
|
|
6
6
|
/**
|
|
@@ -343,6 +343,30 @@ type InferArgs<TDef extends ArgsDef> = TDef extends z.ZodObject<z.ZodRawShape> ?
|
|
|
343
343
|
*/
|
|
344
344
|
type HandlerFn<TArgs extends AnyRecord = AnyRecord, TConfig extends AnyRecord = AnyRecord, TVars = {}> = (ctx: Context<TArgs, TConfig> & Readonly<TVars>) => Promise<void> | void;
|
|
345
345
|
/**
|
|
346
|
+
* Structured configuration for a command's subcommands.
|
|
347
|
+
*
|
|
348
|
+
* Groups the command source (inline map or directory path) alongside display
|
|
349
|
+
* ordering into a single cohesive object.
|
|
350
|
+
*/
|
|
351
|
+
interface CommandsConfig {
|
|
352
|
+
/**
|
|
353
|
+
* Display order for subcommands.
|
|
354
|
+
* Subcommands listed appear first in the specified order; omitted subcommands
|
|
355
|
+
* fall back to alphabetical sort.
|
|
356
|
+
*/
|
|
357
|
+
readonly order?: readonly string[];
|
|
358
|
+
/**
|
|
359
|
+
* Directory path to autoload subcommand files from.
|
|
360
|
+
* Mutually exclusive with `commands` within this config object.
|
|
361
|
+
*/
|
|
362
|
+
readonly path?: string;
|
|
363
|
+
/**
|
|
364
|
+
* Inline subcommand map or a promise from `autoload()`.
|
|
365
|
+
* Mutually exclusive with `path` within this config object.
|
|
366
|
+
*/
|
|
367
|
+
readonly commands?: CommandMap | Promise<CommandMap>;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
346
370
|
* Options passed to `command()`.
|
|
347
371
|
*
|
|
348
372
|
* @typeParam TArgsDef - Arg definitions type.
|
|
@@ -363,9 +387,10 @@ interface CommandDef<TArgsDef extends ArgsDef = ArgsDef, TConfig extends AnyReco
|
|
|
363
387
|
*/
|
|
364
388
|
middleware?: TMiddleware;
|
|
365
389
|
/**
|
|
366
|
-
* Nested subcommands — a static map
|
|
390
|
+
* Nested subcommands — a static map, a promise from `autoload()`, or a
|
|
391
|
+
* structured {@link CommandsConfig} grouping the source with display order.
|
|
367
392
|
*/
|
|
368
|
-
commands?: CommandMap | Promise<CommandMap
|
|
393
|
+
commands?: CommandMap | Promise<CommandMap> | CommandsConfig;
|
|
369
394
|
/**
|
|
370
395
|
* The command handler.
|
|
371
396
|
*/
|
|
@@ -379,6 +404,7 @@ type Command<TArgsDef extends ArgsDef = ArgsDef, TConfig extends AnyRecord = Any
|
|
|
379
404
|
readonly args?: TArgsDef;
|
|
380
405
|
readonly middleware?: TMiddleware;
|
|
381
406
|
readonly commands?: CommandMap | Promise<CommandMap>;
|
|
407
|
+
readonly order?: readonly string[];
|
|
382
408
|
readonly handler?: HandlerFn<TArgsDef extends z.ZodObject<z.ZodRawShape> ? z.infer<TArgsDef> : InferArgs<TArgsDef & ArgsDef>, TConfig, InferVariables<TMiddleware>>;
|
|
383
409
|
}, "Command">;
|
|
384
410
|
/**
|
|
@@ -410,6 +436,21 @@ interface CliConfigOptions<TSchema extends z.ZodType = z.ZodType> {
|
|
|
410
436
|
name?: string;
|
|
411
437
|
}
|
|
412
438
|
/**
|
|
439
|
+
* Help output customization options for the CLI.
|
|
440
|
+
*/
|
|
441
|
+
interface CliHelpOptions {
|
|
442
|
+
/**
|
|
443
|
+
* Header text displayed above help output when the CLI is invoked
|
|
444
|
+
* without a command. Not shown on `--help`.
|
|
445
|
+
*/
|
|
446
|
+
readonly header?: string;
|
|
447
|
+
/**
|
|
448
|
+
* Footer text displayed below help output (e.g., docs URL, bug report link).
|
|
449
|
+
* Shown on all help output.
|
|
450
|
+
*/
|
|
451
|
+
readonly footer?: string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
413
454
|
* Options passed to `cli()`.
|
|
414
455
|
*/
|
|
415
456
|
interface CliOptions<TSchema extends z.ZodType = z.ZodType> {
|
|
@@ -419,8 +460,12 @@ interface CliOptions<TSchema extends z.ZodType = z.ZodType> {
|
|
|
419
460
|
name: string;
|
|
420
461
|
/**
|
|
421
462
|
* CLI version. Enables `--version` flag.
|
|
463
|
+
*
|
|
464
|
+
* When omitted, falls back to the compile-time `__KIDD_VERSION__` constant
|
|
465
|
+
* injected by the kidd bundler. An error is raised at startup if neither
|
|
466
|
+
* an explicit version nor `__KIDD_VERSION__` is available.
|
|
422
467
|
*/
|
|
423
|
-
version
|
|
468
|
+
version?: string;
|
|
424
469
|
/**
|
|
425
470
|
* Human-readable description shown in help text.
|
|
426
471
|
*/
|
|
@@ -437,11 +482,16 @@ interface CliOptions<TSchema extends z.ZodType = z.ZodType> {
|
|
|
437
482
|
* Override the commands source. When omitted, `cli()` loads `kidd.config.ts`
|
|
438
483
|
* and autoloads from its `commands` field (falling back to `'./commands'`).
|
|
439
484
|
*
|
|
440
|
-
* Accepts a directory path string, a static {@link CommandMap},
|
|
441
|
-
* `Promise<CommandMap
|
|
485
|
+
* Accepts a directory path string, a static {@link CommandMap}, a
|
|
486
|
+
* `Promise<CommandMap>`, or a structured {@link CommandsConfig} grouping
|
|
487
|
+
* the source with display ordering.
|
|
488
|
+
*/
|
|
489
|
+
commands?: string | CommandMap | Promise<CommandMap> | CommandsConfig;
|
|
490
|
+
/**
|
|
491
|
+
* Help output customization (header, footer).
|
|
442
492
|
*/
|
|
443
|
-
|
|
493
|
+
help?: CliHelpOptions;
|
|
444
494
|
}
|
|
445
495
|
//#endregion
|
|
446
|
-
export {
|
|
447
|
-
//# sourceMappingURL=types-
|
|
496
|
+
export { Command as a, CommandsConfig as c, MiddlewareEnv as d, MiddlewareFn as f, CliOptions as i, InferVariables as l, AutoloadOptions as n, CommandDef as o, Context as p, CliHelpOptions as r, CommandMap as s, ArgsDef as t, Middleware as u };
|
|
497
|
+
//# sourceMappingURL=types-U73X_oQ_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-U73X_oQ_.d.ts","names":[],"sources":["../src/context/types.ts","../src/types.ts"],"mappings":";;;;;;;;AAuBA;;;;;AAaA;;;;UAbiB,QAAA;EAAA,CAAA,GAAA;AAAA;;;;;;;;;;UAaA,KAAA,cAAmB,SAAA,GAAY,QAAA;EAC9C,GAAA,cAAiB,WAAA,CAAY,IAAA,GAAO,GAAA,EAAK,IAAA,GAAO,IAAA,CAAK,IAAA;EACrD,GAAA,cAAiB,WAAA,CAAY,IAAA,GAAO,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,IAAA,CAAK,IAAA;EAC3D,GAAA,CAAI,GAAA;EACJ,MAAA,CAAO,GAAA;EACP,KAAA;AAAA;;;;UAQe,cAAA;EAAA,SACN,OAAA;EAAA,SACA,YAAA;AAAA;;;;UAMM,WAAA;EAAA,SACN,OAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA;EAAA,SACA,QAAA,IAAY,KAAA,kCAAuC,KAAA;AAAA;;;;;AAZ9D;UAoBiB,YAAA;EAAA,SACN,KAAA,EAAO,MAAA;EAAA,SACP,KAAA;EAAA,SACA,IAAA;AAAA;;;;;;UAQM,aAAA;EAAA,SACN,OAAA;EAAA,SACA,OAAA,EAAS,YAAA,CAAa,MAAA;EAAA,SACtB,YAAA,GAAe,MAAA;AAAA;;AAd1B;;;;UAsBiB,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,OAAA,EAAS,YAAA,CAAa,MAAA;EAAA,SACtB,aAAA,GAAgB,MAAA;EAAA,SAChB,QAAA;AAAA;;AAfX;;;;;UAwBiB,OAAA;EACf,OAAA,CAAQ,IAAA,EAAM,cAAA,GAA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version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "An opinionated CLI framework for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@clack/prompts": "^1.0
|
|
54
|
+
"@clack/prompts": "^1.1.0",
|
|
55
55
|
"@pinojs/redact": "^0.4.0",
|
|
56
56
|
"dotenv": "^17.3.1",
|
|
57
|
-
"es-toolkit": "^1.45.
|
|
57
|
+
"es-toolkit": "^1.45.1",
|
|
58
58
|
"jsonc-parser": "^3.3.1",
|
|
59
59
|
"liquidjs": "^10.25.0",
|
|
60
60
|
"picocolors": "^1.1.1",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"yaml": "^2.8.2",
|
|
63
63
|
"yargs": "^18.0.0",
|
|
64
64
|
"zod": "^4.3.6",
|
|
65
|
-
"@kidd-cli/
|
|
66
|
-
"@kidd-cli/
|
|
65
|
+
"@kidd-cli/config": "0.1.4",
|
|
66
|
+
"@kidd-cli/utils": "0.1.4"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@types/node": "^25.
|
|
69
|
+
"@types/node": "^25.4.0",
|
|
70
70
|
"@types/yargs": "^17.0.35",
|
|
71
|
-
"tsdown": "0.21.
|
|
71
|
+
"tsdown": "0.21.1",
|
|
72
72
|
"typescript": "^5.9.3",
|
|
73
73
|
"vitest": "^4.0.18"
|
|
74
74
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-Db_sjFU-.js","names":["stringifyYaml","parseJsonc","parseYaml"],"sources":["../src/utils/constants.ts","../src/lib/config/constants.ts","../src/lib/config/find.ts","../src/lib/config/parse.ts","../src/lib/config/create-config.ts"],"sourcesContent":["/**\n * Standard JSON indentation level used across the package.\n */\nexport const JSON_INDENT = 2\n\n/**\n * Default process exit code for error conditions.\n */\nexport const DEFAULT_EXIT_CODE = 1\n","/**\n * Supported configuration file formats.\n */\nexport type ConfigFormat = 'json' | 'jsonc' | 'yaml'\n\nexport { JSON_INDENT } from '@/utils/constants.js'\nexport const EMPTY_LENGTH = 0\nexport const CONFIG_EXTENSIONS = ['.jsonc', '.json', '.yaml'] as const\n","import { join } from 'node:path'\n\nimport { fileExists } from '@kidd-cli/utils/fs'\n\nimport { findProjectRoot } from '@/lib/project/index.js'\n\nimport { CONFIG_EXTENSIONS } from './constants.js'\n\n/**\n * Generate the list of config file names to search for based on the CLI name.\n *\n * Produces names like `.myapp.jsonc`, `.myapp.json`, `.myapp.yaml` from the\n * supported extension list.\n *\n * @param name - The CLI name used to derive config file names.\n * @returns An array of config file names to search for.\n */\nexport function getConfigFileNames(name: string): string[] {\n return CONFIG_EXTENSIONS.map((ext) => `.${name}${ext}`)\n}\n\n/**\n * Search for a config file across multiple directories.\n *\n * Searches in order: explicit search paths, the current working directory,\n * and the project root (if different from cwd). Returns the path of the\n * first matching file found.\n *\n * @param options - Search options including cwd, file names, and optional search paths.\n * @returns The full path to the config file, or null if not found.\n */\nexport async function findConfig(options: {\n cwd: string\n fileNames: string[]\n searchPaths?: string[]\n}): Promise<string | null> {\n const { fileNames, cwd, searchPaths } = options\n\n if (searchPaths) {\n const searchResults = await Promise.all(\n searchPaths.map((dir) => findConfigFile(dir, fileNames))\n )\n const found = searchResults.find((result): result is string => result !== null)\n if (found) {\n return found\n }\n }\n\n const fromCwd = await findConfigFile(cwd, fileNames)\n if (fromCwd) {\n return fromCwd\n }\n\n const projectRoot = findProjectRoot(cwd)\n if (projectRoot && projectRoot.path !== cwd) {\n const fromRoot = await findConfigFile(projectRoot.path, fileNames)\n if (fromRoot) {\n return fromRoot\n }\n }\n\n return null\n}\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Search a single directory for the first matching config file name.\n *\n * Checks each candidate file name in order and returns the path of the first\n * one that exists on disk.\n *\n * @param dir - The directory to search in.\n * @param fileNames - Candidate config file names to look for.\n * @returns The full path to the first matching config file, or null if none found.\n * @private\n */\nasync function findConfigFile(\n dir: string,\n fileNames: readonly string[]\n): Promise<string | null> {\n const results = await Promise.all(\n fileNames.map(async (fileName) => {\n const filePath = join(dir, fileName)\n const exists = await fileExists(filePath)\n if (exists) {\n return filePath\n }\n return null\n })\n )\n const found = results.find((result): result is string => result !== null)\n return found ?? null\n}\n","import { extname } from 'node:path'\n\nimport { attempt, err, match } from '@kidd-cli/utils/fp'\nimport { jsonParse, jsonStringify } from '@kidd-cli/utils/json'\nimport type { ParseError } from 'jsonc-parser'\nimport { parse as parseJsonc, printParseErrorCode } from 'jsonc-parser'\nimport { parse as parseYaml, stringify as stringifyYaml } from 'yaml'\n\nimport type { ConfigFormat } from './constants.js'\nimport { EMPTY_LENGTH } from './constants.js'\nimport type { ConfigOperationResult } from './types.js'\n\n/**\n * Determine the config format from a file path's extension.\n *\n * @param filePath - The file path to inspect.\n * @returns The detected config format ('json', 'jsonc', or 'yaml').\n */\nexport function getFormat(filePath: string): ConfigFormat {\n const ext = extname(filePath)\n return match(ext)\n .with('.jsonc', () => 'jsonc' as const)\n .with('.yaml', () => 'yaml' as const)\n .otherwise(() => 'json' as const)\n}\n\n/**\n * Options for parsing config file content.\n */\nexport interface ParseContentOptions {\n readonly content: string\n readonly filePath: string\n readonly format: ConfigFormat\n}\n\n/**\n * Parse config file content using the appropriate parser for the given format.\n *\n * @param options - Parse content options.\n * @returns A ConfigOperationResult with the parsed data or an error.\n */\nexport function parseContent(options: ParseContentOptions): ConfigOperationResult<unknown> {\n const { content, filePath, format } = options\n return match(format)\n .with('json', () => parseJson(content, filePath))\n .with('jsonc', () => parseJsoncContent(content, filePath))\n .with('yaml', () => parseYamlContent(content, filePath))\n .exhaustive()\n}\n\n/**\n * Serialize data to a string in the specified config format.\n *\n * @param data - The data to serialize.\n * @param format - The target config format.\n * @returns The serialized string representation.\n */\nexport function serializeContent(data: unknown, format: ConfigFormat): string {\n return match(format)\n .with('json', () => {\n const [, json] = jsonStringify(data, { pretty: true })\n return `${json}\\n`\n })\n .with('jsonc', () => {\n const [, json] = jsonStringify(data, { pretty: true })\n return `${json}\\n`\n })\n .with('yaml', () => stringifyYaml(data))\n .exhaustive()\n}\n\n/**\n * Get the file extension string for a given config format.\n *\n * @param format - The config format.\n * @returns The file extension including the leading dot (e.g. '.json').\n */\nexport function getExtension(format: ConfigFormat): string {\n return match(format)\n .with('json', () => '.json')\n .with('jsonc', () => '.jsonc')\n .with('yaml', () => '.yaml')\n .exhaustive()\n}\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Parse a JSON string and return the result as a ConfigOperationResult.\n *\n * @param content - The raw JSON string to parse.\n * @param filePath - The file path used in error messages.\n * @returns A ConfigOperationResult with the parsed data or a parse error.\n * @private\n */\nfunction parseJson(content: string, filePath: string): ConfigOperationResult<unknown> {\n const [error, result] = jsonParse(content)\n if (error) {\n return err(`Failed to parse JSON in ${filePath}: ${error.message}`)\n }\n return [null, result]\n}\n\n/**\n * Parse a JSONC (JSON with comments) string and return the result as a ConfigOperationResult.\n *\n * @param content - The raw JSONC string to parse.\n * @param filePath - The file path used in error messages.\n * @returns A ConfigOperationResult with the parsed data or a parse error.\n * @private\n */\nfunction parseJsoncContent(\n content: string,\n filePath: string\n): ConfigOperationResult<unknown> {\n const errors: ParseError[] = []\n const result = parseJsonc(content, errors, {\n allowEmptyContent: false,\n allowTrailingComma: true,\n })\n if (errors.length > EMPTY_LENGTH) {\n const errorMessages = errors\n .map(\n (parseError) =>\n ` - ${printParseErrorCode(parseError.error)} at offset ${parseError.offset}`\n )\n .join('\\n')\n return err(`Failed to parse JSONC in ${filePath}:\\n${errorMessages}`)\n }\n return [null, result]\n}\n\n/**\n * Parse a YAML string and return the result as a ConfigOperationResult.\n *\n * @param content - The raw YAML string to parse.\n * @param filePath - The file path used in error messages.\n * @returns A ConfigOperationResult with the parsed data or a parse error.\n * @private\n */\nfunction parseYamlContent(\n content: string,\n filePath: string\n): ConfigOperationResult<unknown> {\n const [error, result] = attempt(() => parseYaml(content))\n if (error) {\n return err(`Failed to parse YAML in ${filePath}: ${String(error)}`)\n }\n return [null, result]\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\n\nimport { attemptAsync, err, match } from '@kidd-cli/utils/fp'\nimport { formatZodIssues } from '@kidd-cli/utils/validate'\nimport type { ZodTypeAny, output } from 'zod'\n\nimport { findConfig, getConfigFileNames } from './find.js'\nimport { getExtension, getFormat, parseContent, serializeContent } from './parse.js'\nimport type {\n Config,\n ConfigOperationResult,\n ConfigOptions,\n ConfigResult,\n ConfigWriteOptions,\n ConfigWriteResult,\n} from './types.js'\n\n/**\n * Create a typed config client that loads, validates, and writes config files.\n *\n * @param options - Config client options including name and Zod schema.\n * @returns A {@link Config} client instance.\n */\nexport function createConfigClient<TSchema extends ZodTypeAny>(\n options: ConfigOptions<TSchema>\n): Config<output<TSchema>> {\n const { name, schema, searchPaths } = options\n const fileNames = getConfigFileNames(name)\n\n /**\n * Find a config file in the given directory.\n *\n * @private\n * @param cwd - Working directory to search from.\n * @returns The path to the config file, or null if not found.\n */\n async function find(cwd?: string): Promise<string | null> {\n return findConfig({\n cwd: cwd ?? process.cwd(),\n fileNames,\n searchPaths,\n })\n }\n\n /**\n * Load and validate a config file.\n *\n * @private\n * @param cwd - Working directory to search from.\n * @returns A ConfigOperationResult with the loaded config, or [null, null] if not found.\n */\n async function load(\n cwd?: string\n ): Promise<ConfigOperationResult<ConfigResult<output<TSchema>>> | readonly [null, null]> {\n const filePath = await find(cwd)\n if (!filePath) {\n return [null, null]\n }\n\n const [readError, content] = await attemptAsync(() => readFile(filePath, 'utf8'))\n if (readError || content === null) {\n const errorDetail = resolveReadErrorDetail(readError)\n return err(`Failed to read config at ${filePath}: ${errorDetail}`)\n }\n\n const format = getFormat(filePath)\n const parsedResult = parseContent({ content, filePath, format })\n\n if (parsedResult[0]) {\n return [parsedResult[0], null]\n }\n\n const result = schema.safeParse(parsedResult[1])\n if (!result.success) {\n const { message } = formatZodIssues(result.error.issues, '\\n')\n return err(`Invalid config in ${filePath}:\\n${message}`)\n }\n\n return [\n null,\n {\n config: result.data,\n filePath,\n format,\n },\n ]\n }\n\n /**\n * Validate and write config data to a file.\n *\n * @private\n * @param data - The config data to write.\n * @param writeOptions - Write options including path and format.\n * @returns A ConfigOperationResult with the write result.\n */\n async function write(\n data: output<TSchema>,\n writeOptions: ConfigWriteOptions = {}\n ): Promise<ConfigOperationResult<ConfigWriteResult>> {\n const result = schema.safeParse(data)\n if (!result.success) {\n const { message } = formatZodIssues(result.error.issues, '\\n')\n return err(`Invalid config data:\\n${message}`)\n }\n\n const resolvedFormat = match(writeOptions)\n .when(\n (opts) => opts.format !== null && opts.format !== undefined,\n (opts) => opts.format ?? ('jsonc' as const)\n )\n .when(\n (opts) => opts.filePath !== null && opts.filePath !== undefined,\n (opts) => getFormat(opts.filePath ?? '')\n )\n .otherwise(() => 'jsonc' as const)\n\n const resolvedFilePath = match(writeOptions.filePath)\n .when(\n (fp) => fp !== null && fp !== undefined,\n (fp) => fp ?? ''\n )\n .otherwise(() => {\n const dir = writeOptions.dir ?? process.cwd()\n const ext = getExtension(resolvedFormat)\n return join(dir, `.${name}${ext}`)\n })\n\n const serialized = serializeContent(result.data, resolvedFormat)\n\n const [mkdirError] = await attemptAsync(() =>\n mkdir(dirname(resolvedFilePath), { recursive: true })\n )\n if (mkdirError) {\n return err(`Failed to create directory for ${resolvedFilePath}: ${String(mkdirError)}`)\n }\n\n const [writeError] = await attemptAsync(() => writeFile(resolvedFilePath, serialized, 'utf8'))\n if (writeError) {\n return err(`Failed to write config to ${resolvedFilePath}: ${String(writeError)}`)\n }\n\n return [null, { filePath: resolvedFilePath, format: resolvedFormat }]\n }\n\n return { find, load, write }\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the error detail string from a read error.\n *\n * @private\n * @param readError - The error from the read operation, or null.\n * @returns A descriptive error string.\n */\nfunction resolveReadErrorDetail(readError: unknown): string {\n if (readError) {\n return String(readError)\n }\n return 'empty file'\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAa,oBAAoB;;;;ACFjC,MAAa,eAAe;AAC5B,MAAa,oBAAoB;CAAC;CAAU;CAAS;CAAQ;;;;;;;;;;;;;ACU7D,SAAgB,mBAAmB,MAAwB;AACzD,QAAO,kBAAkB,KAAK,QAAQ,IAAI,OAAO,MAAM;;;;;;;;;;;;AAazD,eAAsB,WAAW,SAIN;CACzB,MAAM,EAAE,WAAW,KAAK,gBAAgB;AAExC,KAAI,aAAa;EAIf,MAAM,SAHgB,MAAM,QAAQ,IAClC,YAAY,KAAK,QAAQ,eAAe,KAAK,UAAU,CAAC,CACzD,EAC2B,MAAM,WAA6B,WAAW,KAAK;AAC/E,MAAI,MACF,QAAO;;CAIX,MAAM,UAAU,MAAM,eAAe,KAAK,UAAU;AACpD,KAAI,QACF,QAAO;CAGT,MAAM,cAAc,gBAAgB,IAAI;AACxC,KAAI,eAAe,YAAY,SAAS,KAAK;EAC3C,MAAM,WAAW,MAAM,eAAe,YAAY,MAAM,UAAU;AAClE,MAAI,SACF,QAAO;;AAIX,QAAO;;;;;;;;;;;;;AAkBT,eAAe,eACb,KACA,WACwB;AAYxB,SAXgB,MAAM,QAAQ,IAC5B,UAAU,IAAI,OAAO,aAAa;EAChC,MAAM,WAAW,KAAK,KAAK,SAAS;AAEpC,MADe,MAAM,WAAW,SAAS,CAEvC,QAAO;AAET,SAAO;GACP,CACH,EACqB,MAAM,WAA6B,WAAW,KAAK,IACzD;;;;;;;;;;;AC5ElB,SAAgB,UAAU,UAAgC;AAExD,QAAO,MADK,QAAQ,SAAS,CACZ,CACd,KAAK,gBAAgB,QAAiB,CACtC,KAAK,eAAe,OAAgB,CACpC,gBAAgB,OAAgB;;;;;;;;AAkBrC,SAAgB,aAAa,SAA8D;CACzF,MAAM,EAAE,SAAS,U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B,MAAM,aAAa,CACvC,MACE,SAAS,KAAK,WAAW,QAAQ,KAAK,WAAW,SACjD,SAAS,KAAK,UAAW,QAC3B,CACA,MACE,SAAS,KAAK,aAAa,QAAQ,KAAK,aAAa,SACrD,SAAS,UAAU,KAAK,YAAY,GAAG,CACzC,CACA,gBAAgB,QAAiB;EAEpC,MAAM,mBAAmB,MAAM,aAAa,SAAS,CAClD,MACE,OAAO,OAAO,QAAQ,OAAO,SAC7B,OAAO,MAAM,GACf,CACA,gBAAgB;AAGf,UAAO,KAFK,aAAa,OAAO,QAAQ,KAAK,EAE5B,IAAI,OADT,aAAa,eAAe,GACN;IAClC;EAEJ,MAAM,aAAa,iBAAiB,OAAO,MAAM,eAAe;EAEhE,MAAM,CAAC,cAAc,MAAM,mBACzB,MAAM,QAAQ,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC,CACtD;AACD,MAAI,WACF,QAAO,IAAI,kCAAkC,iBAAiB,IAAI,OAAO,WAAW,GAAG;EAGzF,MAAM,CAAC,cAAc,MAAM,mBAAmB,UAAU,kBAAkB,YAAY,OAAO,CAAC;AAC9F,MAAI,WACF,QAAO,IAAI,6BAA6B,iBAAiB,IAAI,OAAO,WAAW,GAAG;AAGpF,SAAO,CAAC,MAAM;GAAE,UAAU;GAAkB,QAAQ;GAAgB,CAAC;;AAGvE,QAAO;EAAE;EAAM;EAAM;EAAO;;;;;;;;;AAY9B,SAAS,uBAAuB,WAA4B;AAC1D,KAAI,UACF,QAAO,OAAO,UAAU;AAE1B,QAAO"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { attemptAsync } from "@kidd-cli/utils/fp";
|
|
2
|
-
|
|
3
|
-
//#region src/middleware/http/create-http-client.ts
|
|
4
|
-
/**
|
|
5
|
-
* Typed HTTP client factory.
|
|
6
|
-
*
|
|
7
|
-
* Creates a closure-based {@link HttpClient} with pre-configured base URL
|
|
8
|
-
* and default headers. All methods delegate to a shared request executor.
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Create a typed HTTP client with pre-configured base URL and headers.
|
|
14
|
-
*
|
|
15
|
-
* @param options - Client configuration.
|
|
16
|
-
* @returns An HttpClient instance.
|
|
17
|
-
*/
|
|
18
|
-
function createHttpClient(options) {
|
|
19
|
-
const { baseUrl, defaultHeaders, resolveHeaders } = options;
|
|
20
|
-
return {
|
|
21
|
-
delete: (path, requestOptions) => executeRequest(baseUrl, "DELETE", path, defaultHeaders, resolveHeaders, requestOptions),
|
|
22
|
-
get: (path, requestOptions) => executeRequest(baseUrl, "GET", path, defaultHeaders, resolveHeaders, requestOptions),
|
|
23
|
-
patch: (path, requestOptions) => executeRequest(baseUrl, "PATCH", path, defaultHeaders, resolveHeaders, requestOptions),
|
|
24
|
-
post: (path, requestOptions) => executeRequest(baseUrl, "POST", path, defaultHeaders, resolveHeaders, requestOptions),
|
|
25
|
-
put: (path, requestOptions) => executeRequest(baseUrl, "PUT", path, defaultHeaders, resolveHeaders, requestOptions)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Build the full URL from base, path, and optional query params.
|
|
30
|
-
*
|
|
31
|
-
* @private
|
|
32
|
-
* @param baseUrl - The base URL.
|
|
33
|
-
* @param path - The request path.
|
|
34
|
-
* @param params - Optional query parameters.
|
|
35
|
-
* @returns The fully qualified URL string.
|
|
36
|
-
*/
|
|
37
|
-
function buildUrl(baseUrl, path, params) {
|
|
38
|
-
const url = new URL(path, baseUrl);
|
|
39
|
-
if (params !== void 0) url.search = new URLSearchParams(params).toString();
|
|
40
|
-
return url.toString();
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Merge default, dynamic, and per-request headers into a single record.
|
|
44
|
-
*
|
|
45
|
-
* Per-request headers take highest priority, then dynamic headers,
|
|
46
|
-
* then default headers.
|
|
47
|
-
*
|
|
48
|
-
* @private
|
|
49
|
-
* @param defaultHeaders - Optional default headers.
|
|
50
|
-
* @param dynamicHeaders - Optional dynamically resolved headers.
|
|
51
|
-
* @param requestHeaders - Optional per-request headers.
|
|
52
|
-
* @returns The merged headers record.
|
|
53
|
-
*/
|
|
54
|
-
function mergeHeaders(defaultHeaders, dynamicHeaders, requestHeaders) {
|
|
55
|
-
return {
|
|
56
|
-
...defaultHeaders,
|
|
57
|
-
...dynamicHeaders,
|
|
58
|
-
...requestHeaders
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Normalize optional request options into a concrete object with safe defaults.
|
|
63
|
-
*
|
|
64
|
-
* When `options` is `undefined`, returns an empty object so callers can use
|
|
65
|
-
* direct property access without additional nil checks.
|
|
66
|
-
*
|
|
67
|
-
* @private
|
|
68
|
-
* @param options - Optional per-request options.
|
|
69
|
-
* @returns The resolved options object.
|
|
70
|
-
*/
|
|
71
|
-
function resolveRequestOptions(options) {
|
|
72
|
-
if (options !== void 0) return options;
|
|
73
|
-
return {};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Invoke the dynamic header resolver if provided.
|
|
77
|
-
*
|
|
78
|
-
* @private
|
|
79
|
-
* @param resolveHeaders - Optional function to resolve dynamic headers.
|
|
80
|
-
* @returns The resolved headers record, or undefined.
|
|
81
|
-
*/
|
|
82
|
-
function resolveDynamicHeaders(resolveHeaders) {
|
|
83
|
-
if (resolveHeaders !== void 0) return resolveHeaders();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Resolve the serialized body string and content-type header mutation.
|
|
87
|
-
*
|
|
88
|
-
* @private
|
|
89
|
-
* @param options - Optional per-request options.
|
|
90
|
-
* @returns The serialized body string or undefined.
|
|
91
|
-
*/
|
|
92
|
-
function resolveBody(options) {
|
|
93
|
-
if (options !== void 0 && options.body !== void 0) return JSON.stringify(options.body);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Build the fetch init options from resolved values.
|
|
97
|
-
*
|
|
98
|
-
* @private
|
|
99
|
-
* @param method - The HTTP method.
|
|
100
|
-
* @param headers - The merged headers.
|
|
101
|
-
* @param body - The serialized body or undefined.
|
|
102
|
-
* @param signal - The abort signal or undefined.
|
|
103
|
-
* @returns The RequestInit for fetch.
|
|
104
|
-
*/
|
|
105
|
-
function buildFetchInit(method, headers, body, signal) {
|
|
106
|
-
if (body !== void 0) return {
|
|
107
|
-
body,
|
|
108
|
-
headers: {
|
|
109
|
-
...headers,
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
},
|
|
112
|
-
method,
|
|
113
|
-
signal
|
|
114
|
-
};
|
|
115
|
-
return {
|
|
116
|
-
headers,
|
|
117
|
-
method,
|
|
118
|
-
signal
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Execute an HTTP request and wrap the response.
|
|
123
|
-
*
|
|
124
|
-
* @private
|
|
125
|
-
* @param baseUrl - The base URL.
|
|
126
|
-
* @param method - The HTTP method.
|
|
127
|
-
* @param path - The request path.
|
|
128
|
-
* @param defaultHeaders - Optional default headers.
|
|
129
|
-
* @param resolveHeaders - Optional function to resolve dynamic headers per-request.
|
|
130
|
-
* @param options - Optional per-request options.
|
|
131
|
-
* @returns A typed response wrapper.
|
|
132
|
-
*/
|
|
133
|
-
async function executeRequest(baseUrl, method, path, defaultHeaders, resolveHeaders, options) {
|
|
134
|
-
const resolved = resolveRequestOptions(options);
|
|
135
|
-
const url = buildUrl(baseUrl, path, resolved.params);
|
|
136
|
-
const init = buildFetchInit(method, mergeHeaders(defaultHeaders, resolveDynamicHeaders(resolveHeaders), resolved.headers), resolveBody(options), resolved.signal);
|
|
137
|
-
const response = await fetch(url, init);
|
|
138
|
-
return {
|
|
139
|
-
data: await parseResponseBody(response),
|
|
140
|
-
headers: response.headers,
|
|
141
|
-
ok: response.ok,
|
|
142
|
-
raw: response,
|
|
143
|
-
status: response.status
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Parse the response body as JSON, returning null on failure.
|
|
148
|
-
*
|
|
149
|
-
* Wraps `response.json()` with `attemptAsync` so malformed API
|
|
150
|
-
* responses do not crash the command. Returns `null as TResponse`
|
|
151
|
-
* when parsing fails.
|
|
152
|
-
*
|
|
153
|
-
* @private
|
|
154
|
-
* @param response - The fetch Response.
|
|
155
|
-
* @returns The parsed body or null.
|
|
156
|
-
*/
|
|
157
|
-
async function parseResponseBody(response) {
|
|
158
|
-
const [error, data] = await attemptAsync(() => response.json());
|
|
159
|
-
if (error) return null;
|
|
160
|
-
return data;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
export { createHttpClient as t };
|
|
165
|
-
//# sourceMappingURL=create-http-client-tZJWlWp1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-http-client-tZJWlWp1.js","names":[],"sources":["../src/middleware/http/create-http-client.ts"],"sourcesContent":["/**\n * Typed HTTP client factory.\n *\n * Creates a closure-based {@link HttpClient} with pre-configured base URL\n * and default headers. All methods delegate to a shared request executor.\n *\n * @module\n */\n\nimport { attemptAsync } from '@kidd-cli/utils/fp'\n\nimport type { HttpClient, RequestOptions, TypedResponse } from './types.js'\n\n/**\n * Options for creating an HTTP client.\n */\ninterface CreateHttpClientOptions {\n readonly baseUrl: string\n readonly defaultHeaders?: Readonly<Record<string, string>>\n readonly resolveHeaders?: () => Readonly<Record<string, string>>\n}\n\n/**\n * Create a typed HTTP client with pre-configured base URL and headers.\n *\n * @param options - Client configuration.\n * @returns An HttpClient instance.\n */\nexport function createHttpClient(options: CreateHttpClientOptions): HttpClient {\n const { baseUrl, defaultHeaders, resolveHeaders } = options\n\n return {\n delete: <TResponse = unknown>(path: string, requestOptions?: RequestOptions) =>\n executeRequest<TResponse>(baseUrl, 'DELETE', path, defaultHeaders, resolveHeaders, requestOptions),\n\n get: <TResponse = unknown>(path: string, requestOptions?: RequestOptions) =>\n executeRequest<TResponse>(baseUrl, 'GET', path, defaultHeaders, resolveHeaders, requestOptions),\n\n patch: <TResponse = unknown, TBody = unknown>(\n path: string,\n requestOptions?: RequestOptions<TBody>\n ) =>\n executeRequest<TResponse>(baseUrl, 'PATCH', path, defaultHeaders, resolveHeaders, requestOptions),\n\n post: <TResponse = unknown, TBody = unknown>(\n path: string,\n requestOptions?: RequestOptions<TBody>\n ) =>\n executeRequest<TResponse>(baseUrl, 'POST', path, defaultHeaders, resolveHeaders, requestOptions),\n\n put: <TResponse = unknown, TBody = unknown>(\n path: string,\n requestOptions?: RequestOptions<TBody>\n ) =>\n executeRequest<TResponse>(baseUrl, 'PUT', path, defaultHeaders, resolveHeaders, requestOptions),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Build the full URL from base, path, and optional query params.\n *\n * @private\n * @param baseUrl - The base URL.\n * @param path - The request path.\n * @param params - Optional query parameters.\n * @returns The fully qualified URL string.\n */\nfunction buildUrl(\n baseUrl: string,\n path: string,\n params: Readonly<Record<string, string>> | undefined\n): string {\n const url = new URL(path, baseUrl)\n\n if (params !== undefined) {\n const searchParams = new URLSearchParams(params)\n url.search = searchParams.toString()\n }\n\n return url.toString()\n}\n\n/**\n * Merge default, dynamic, and per-request headers into a single record.\n *\n * Per-request headers take highest priority, then dynamic headers,\n * then default headers.\n *\n * @private\n * @param defaultHeaders - Optional default headers.\n * @param dynamicHeaders - Optional dynamically resolved headers.\n * @param requestHeaders - Optional per-request headers.\n * @returns The merged headers record.\n */\nfunction mergeHeaders(\n defaultHeaders: Readonly<Record<string, string>> | undefined,\n dynamicHeaders: Readonly<Record<string, string>> | undefined,\n requestHeaders: Readonly<Record<string, string>> | undefined\n): Readonly<Record<string, string>> {\n return {\n ...defaultHeaders,\n ...dynamicHeaders,\n ...requestHeaders,\n }\n}\n\n/**\n * Normalize optional request options into a concrete object with safe defaults.\n *\n * When `options` is `undefined`, returns an empty object so callers can use\n * direct property access without additional nil checks.\n *\n * @private\n * @param options - Optional per-request options.\n * @returns The resolved options object.\n */\nfunction resolveRequestOptions(options: RequestOptions | undefined): RequestOptions {\n if (options !== undefined) {\n return options\n }\n\n return {}\n}\n\n/**\n * Invoke the dynamic header resolver if provided.\n *\n * @private\n * @param resolveHeaders - Optional function to resolve dynamic headers.\n * @returns The resolved headers record, or undefined.\n */\nfunction resolveDynamicHeaders(\n resolveHeaders: (() => Readonly<Record<string, string>>) | undefined\n): Readonly<Record<string, string>> | undefined {\n if (resolveHeaders !== undefined) {\n return resolveHeaders()\n }\n\n return undefined\n}\n\n/**\n * Resolve the serialized body string and content-type header mutation.\n *\n * @private\n * @param options - Optional per-request options.\n * @returns The serialized body string or undefined.\n */\nfunction resolveBody(options: RequestOptions | undefined): string | undefined {\n if (options !== undefined && options.body !== undefined) {\n return JSON.stringify(options.body)\n }\n\n return undefined\n}\n\n/**\n * Build the fetch init options from resolved values.\n *\n * @private\n * @param method - The HTTP method.\n * @param headers - The merged headers.\n * @param body - The serialized body or undefined.\n * @param signal - The abort signal or undefined.\n * @returns The RequestInit for fetch.\n */\nfunction buildFetchInit(\n method: string,\n headers: Readonly<Record<string, string>>,\n body: string | undefined,\n signal: AbortSignal | undefined\n): RequestInit {\n if (body !== undefined) {\n return {\n body,\n headers: { ...headers, 'Content-Type': 'application/json' },\n method,\n signal,\n }\n }\n\n return {\n headers,\n method,\n signal,\n }\n}\n\n/**\n * Execute an HTTP request and wrap the response.\n *\n * @private\n * @param baseUrl - The base URL.\n * @param method - The HTTP method.\n * @param path - The request path.\n * @param defaultHeaders - Optional default headers.\n * @param resolveHeaders - Optional function to resolve dynamic headers per-request.\n * @param options - Optional per-request options.\n * @returns A typed response wrapper.\n */\nasync function executeRequest<TResponse>(\n baseUrl: string,\n method: string,\n path: string,\n defaultHeaders: Readonly<Record<string, string>> | undefined,\n resolveHeaders: (() => Readonly<Record<string, string>>) | undefined,\n options: RequestOptions | undefined\n): Promise<TypedResponse<TResponse>> {\n const resolved = resolveRequestOptions(options)\n const url = buildUrl(baseUrl, path, resolved.params)\n const dynamicHeaders = resolveDynamicHeaders(resolveHeaders)\n const headers = mergeHeaders(defaultHeaders, dynamicHeaders, resolved.headers)\n const body = resolveBody(options)\n const init = buildFetchInit(method, headers, body, resolved.signal)\n\n const response = await fetch(url, init)\n const data = await parseResponseBody<TResponse>(response)\n\n return {\n data,\n headers: response.headers,\n ok: response.ok,\n raw: response,\n status: response.status,\n }\n}\n\n/**\n * Parse the response body as JSON, returning null on failure.\n *\n * Wraps `response.json()` with `attemptAsync` so malformed API\n * responses do not crash the command. Returns `null as TResponse`\n * when parsing fails.\n *\n * @private\n * @param response - The fetch Response.\n * @returns The parsed body or null.\n */\nasync function parseResponseBody<TResponse>(response: Response): Promise<TResponse> {\n const [error, data] = await attemptAsync(() => response.json() as Promise<TResponse>)\n\n if (error) {\n return null as TResponse\n }\n\n return data as TResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,SAAgB,iBAAiB,SAA8C;CAC7E,MAAM,EAAE,SAAS,gBAAgB,mBAAmB;AAEpD,QAAO;EACL,SAA8B,MAAc,mBAC1C,eAA0B,SAAS,UAAU,MAAM,gBAAgB,gBAAgB,eAAe;EAEpG,MAA2B,MAAc,mBACvC,eAA0B,SAAS,OAAO,MAAM,gBAAgB,gBAAgB,eAAe;EAEjG,QACE,MACA,mBAEA,eAA0B,SAAS,SAAS,MAAM,gBAAgB,gBAAgB,eAAe;EAEnG,OACE,MACA,mBAEA,eAA0B,SAAS,QAAQ,MAAM,gBAAgB,gBAAgB,eAAe;EAElG,MACE,MACA,mBAEA,eAA0B,SAAS,OAAO,MAAM,gBAAgB,gBAAgB,eAAe;EAClG;;;;;;;;;;;AAgBH,SAAS,SACP,SACA,MACA,QACQ;CACR,MAAM,MAAM,IAAI,IAAI,MAAM,QAAQ;AAElC,KAAI,WAAW,OAEb,KAAI,SADiB,IAAI,gBAAgB,OAAO,CACtB,UAAU;AAGtC,QAAO,IAAI,UAAU;;;;;;;;;;;;;;AAevB,SAAS,aACP,gBACA,gBACA,gBACkC;AAClC,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACJ;;;;;;;;;;;;AAaH,SAAS,sBAAsB,SAAqD;AAClF,KAAI,YAAY,OACd,QAAO;AAGT,QAAO,EAAE;;;;;;;;;AAUX,SAAS,sBACP,gBAC8C;AAC9C,KAAI,mBAAmB,OACrB,QAAO,gBAAgB;;;;;;;;;AAa3B,SAAS,YAAY,SAAyD;AAC5E,KAAI,YAAY,UAAa,QAAQ,SAAS,OAC5C,QAAO,KAAK,UAAU,QAAQ,KAAK;;;;;;;;;;;;AAgBvC,SAAS,eACP,QACA,SACA,MACA,QACa;AACb,KAAI,SAAS,OACX,QAAO;EACL;EACA,SAAS;GAAE,GAAG;GAAS,gBAAgB;GAAoB;EAC3D;EACA;EACD;AAGH,QAAO;EACL;EACA;EACA;EACD;;;;;;;;;;;;;;AAeH,eAAe,eACb,SACA,QACA,MACA,gBACA,gBACA,SACmC;CACnC,MAAM,WAAW,sBAAsB,QAAQ;CAC/C,MAAM,MAAM,SAAS,SAAS,MAAM,SAAS,OAAO;CAIpD,MAAM,OAAO,eAAe,QAFZ,aAAa,gBADN,sBAAsB,eAAe,EACC,SAAS,QAAQ,EACjE,YAAY,QAAQ,EACkB,SAAS,OAAO;CAEnE,MAAM,WAAW,MAAM,MAAM,KAAK,KAAK;AAGvC,QAAO;EACL,MAHW,MAAM,kBAA6B,SAAS;EAIvD,SAAS,SAAS;EAClB,IAAI,SAAS;EACb,KAAK;EACL,QAAQ,SAAS;EAClB;;;;;;;;;;;;;AAcH,eAAe,kBAA6B,UAAwC;CAClF,MAAM,CAAC,OAAO,QAAQ,MAAM,mBAAmB,SAAS,MAAM,CAAuB;AAErF,KAAI,MACF,QAAO;AAGT,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-DuXgjaa_.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 GITDIR_RE = /^gitdir:\\s*(.+)$/\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 = readGitFile(gitFilePath)\n if (gitFileContent === null) {\n return null\n }\n\n return resolveParentGitDir(projectRoot, gitFileContent)\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Read and trim the contents of a git-related file.\n *\n * @param filePath - The absolute file path to read.\n * @returns The trimmed file content, or null when the file cannot be read.\n * @private\n */\nfunction readGitFile(filePath: string): string | null {\n const [error, content] = attempt(() => readFileSync(filePath, 'utf8'))\n if (error || content === null) {\n return null\n }\n return content.trim()\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 gitFileContent = readGitFile(gitPath)\n if (gitFileContent === null) {\n return { isSubmodule: false, path: currentDir }\n }\n const gitDirMatch = gitFileContent.match(GITDIR_RE)\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 * 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_RE)\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,YAAY;AAClB,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,M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