@outfitter/cli 0.5.2 → 1.0.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 (110) hide show
  1. package/README.md +179 -60
  2. package/dist/actions.d.ts +5 -2
  3. package/dist/actions.js +2 -2
  4. package/dist/cli.d.ts +1 -1
  5. package/dist/cli.js +8 -1
  6. package/dist/colors/index.js +1 -17
  7. package/dist/command.d.ts +3 -43
  8. package/dist/command.js +241 -13
  9. package/dist/envelope.d.ts +5 -0
  10. package/dist/envelope.js +160 -0
  11. package/dist/flags.d.ts +5 -189
  12. package/dist/flags.js +5 -1
  13. package/dist/hints.d.ts +34 -0
  14. package/dist/hints.js +26 -0
  15. package/dist/index.d.ts +3 -2
  16. package/dist/index.js +2 -17
  17. package/dist/input.d.ts +3 -124
  18. package/dist/input.js +14 -359
  19. package/dist/internal/envelope-helpers.d.ts +4 -0
  20. package/dist/internal/envelope-helpers.js +24 -0
  21. package/dist/internal/envelope-types.d.ts +3 -0
  22. package/dist/internal/flag-builders.d.ts +3 -0
  23. package/dist/internal/flag-builders.js +155 -0
  24. package/dist/internal/flag-types.d.ts +3 -0
  25. package/dist/internal/flag-types.js +13 -0
  26. package/dist/internal/hint-action-graph.d.ts +5 -0
  27. package/dist/internal/hint-action-graph.js +11 -0
  28. package/dist/internal/hint-command-tree.d.ts +5 -0
  29. package/dist/internal/hint-command-tree.js +9 -0
  30. package/dist/internal/hint-error-recovery.d.ts +2 -0
  31. package/dist/internal/hint-error-recovery.js +7 -0
  32. package/dist/internal/hint-types.d.ts +4 -0
  33. package/dist/internal/hint-types.js +1 -0
  34. package/dist/internal/input-helpers.d.ts +18 -0
  35. package/dist/internal/input-helpers.js +11 -0
  36. package/dist/internal/input-normalization.d.ts +3 -0
  37. package/dist/internal/input-normalization.js +9 -0
  38. package/dist/internal/input-parsers.d.ts +3 -0
  39. package/dist/internal/input-parsers.js +19 -0
  40. package/dist/internal/input-security.d.ts +22 -0
  41. package/dist/internal/input-security.js +11 -0
  42. package/dist/internal/output-formatting.d.ts +3 -0
  43. package/dist/internal/output-formatting.js +21 -0
  44. package/dist/internal/presets.d.ts +3 -0
  45. package/dist/{shared/@outfitter/cli-pdb7znbq.js → internal/presets.js} +49 -223
  46. package/dist/internal/schema-commands.d.ts +3 -0
  47. package/dist/{shared/@outfitter/cli-0cjts94k.js → internal/schema-commands.js} +12 -100
  48. package/dist/internal/schema-formatting.d.ts +2 -0
  49. package/dist/internal/schema-formatting.js +7 -0
  50. package/dist/internal/schema-types.d.ts +2 -0
  51. package/dist/internal/schema-types.js +1 -0
  52. package/dist/output.d.ts +4 -3
  53. package/dist/output.js +10 -2
  54. package/dist/pagination.d.ts +1 -1
  55. package/dist/query.d.ts +84 -2
  56. package/dist/query.js +8 -45
  57. package/dist/schema-input.d.ts +80 -0
  58. package/dist/schema-input.js +15 -0
  59. package/dist/schema.d.ts +4 -1
  60. package/dist/schema.js +1 -1
  61. package/dist/shared/@outfitter/cli-10wxfc78.d.ts +45 -0
  62. package/dist/shared/@outfitter/cli-16wg5mka.d.ts +71 -0
  63. package/dist/shared/@outfitter/cli-1q5redaj.js +267 -0
  64. package/dist/shared/@outfitter/cli-2dfxs239.js +98 -0
  65. package/dist/shared/@outfitter/cli-30mt7c5w.d.ts +112 -0
  66. package/dist/shared/@outfitter/cli-3jta1h1h.js +134 -0
  67. package/dist/shared/@outfitter/cli-4h85mpth.js +76 -0
  68. package/dist/shared/@outfitter/cli-6shkwxdc.js +28 -0
  69. package/dist/shared/@outfitter/cli-89335n9a.js +16 -0
  70. package/dist/shared/@outfitter/cli-8999qjdd.js +3 -0
  71. package/dist/shared/@outfitter/cli-8cfxdady.js +60 -0
  72. package/dist/shared/@outfitter/cli-bcajqy33.d.ts +25 -0
  73. package/dist/shared/@outfitter/cli-c09332vm.d.ts +39 -0
  74. package/dist/shared/@outfitter/cli-cgha038c.d.ts +3 -0
  75. package/dist/shared/@outfitter/{cli-zahqsaby.js → cli-d40m2x1d.js} +19 -3
  76. package/dist/shared/@outfitter/{cli-7wp5nj0s.js → cli-dg0cz7rw.js} +39 -81
  77. package/dist/shared/@outfitter/cli-dv8kk4jw.d.ts +24 -0
  78. package/dist/shared/@outfitter/cli-g43887b7.js +20 -0
  79. package/dist/shared/@outfitter/cli-gqtkhgw4.js +52 -0
  80. package/dist/shared/@outfitter/cli-h4ejpmjs.d.ts +104 -0
  81. package/dist/shared/@outfitter/cli-htzez8v2.js +70 -0
  82. package/dist/shared/@outfitter/cli-hvg2m5gf.js +79 -0
  83. package/dist/shared/@outfitter/cli-n54zs151.d.ts +78 -0
  84. package/dist/shared/@outfitter/cli-nbpgw7z7.d.ts +15 -0
  85. package/dist/shared/@outfitter/cli-nkt399zf.d.ts +94 -0
  86. package/dist/shared/@outfitter/cli-pmd04gtv.d.ts +60 -0
  87. package/dist/shared/@outfitter/{cli-xy3gs50c.d.ts → cli-q6csxmeh.d.ts} +19 -12
  88. package/dist/shared/@outfitter/cli-qcskd96y.d.ts +11 -0
  89. package/dist/shared/@outfitter/cli-ry7btmy4.js +118 -0
  90. package/dist/shared/@outfitter/cli-sy99pjyj.js +32 -0
  91. package/dist/shared/@outfitter/cli-tm2fzngs.d.ts +23 -0
  92. package/dist/shared/@outfitter/cli-vvvhjwks.js +106 -0
  93. package/dist/shared/@outfitter/cli-wjv7g1aq.d.ts +16 -0
  94. package/dist/shared/@outfitter/{cli-98aa9104.d.ts → cli-x6qr7bnd.d.ts} +338 -16
  95. package/dist/shared/@outfitter/cli-xde45xcc.d.ts +53 -0
  96. package/dist/shared/@outfitter/cli-xw8ys1je.d.ts +123 -0
  97. package/dist/shared/@outfitter/cli-yfewnyc2.d.ts +43 -0
  98. package/dist/shared/@outfitter/cli-zkzj0q4q.js +99 -0
  99. package/dist/shared/@outfitter/cli-zv3ah6f0.js +3 -0
  100. package/dist/streaming.d.ts +47 -0
  101. package/dist/streaming.js +13 -0
  102. package/dist/terminal/index.js +1 -19
  103. package/dist/truncation.d.ts +104 -0
  104. package/dist/truncation.js +111 -0
  105. package/dist/types.d.ts +2 -2
  106. package/dist/types.js +0 -5
  107. package/dist/verbs.d.ts +1 -1
  108. package/package.json +66 -36
  109. package/dist/shared/@outfitter/cli-n1k0d23k.d.ts +0 -33
  110. /package/dist/{shared/@outfitter/cli-zw75pdk8.js → internal/envelope-types.js} +0 -0
@@ -0,0 +1,155 @@
1
+ // @bun
2
+ import {
3
+ createPreset
4
+ } from "../shared/@outfitter/cli-8cfxdady.js";
5
+
6
+ // packages/cli/src/internal/flag-builders.ts
7
+ function resolveSourceKeys(key, sources) {
8
+ return sources && sources.length > 0 ? sources : [key];
9
+ }
10
+ function normalizeStringListInput(value, separator) {
11
+ if (Array.isArray(value)) {
12
+ const items2 = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
13
+ return items2.length > 0 ? items2 : undefined;
14
+ }
15
+ if (typeof value !== "string")
16
+ return;
17
+ const items = value.split(separator).map((item) => item.trim()).filter(Boolean);
18
+ return items.length > 0 ? items : undefined;
19
+ }
20
+ function booleanFlagPreset(config) {
21
+ const sources = resolveSourceKeys(config.key, config.sources);
22
+ const defaultValue = config.defaultValue ?? false;
23
+ const isNegatedFlag = config.flags.includes("--no-");
24
+ const optionDefault = isNegatedFlag && config.defaultValue === undefined ? {} : { defaultValue };
25
+ return createPreset({
26
+ id: config.id,
27
+ options: [
28
+ {
29
+ flags: config.flags,
30
+ description: config.description,
31
+ ...optionDefault,
32
+ ...config.required === true ? { required: true } : {}
33
+ }
34
+ ],
35
+ resolve: (flags) => {
36
+ for (const source of sources) {
37
+ const value = flags[source];
38
+ if (typeof value === "boolean") {
39
+ return { [config.key]: value };
40
+ }
41
+ }
42
+ if (config.negatedSources) {
43
+ for (const source of config.negatedSources) {
44
+ const value = flags[source];
45
+ if (typeof value === "boolean") {
46
+ return { [config.key]: !value };
47
+ }
48
+ }
49
+ }
50
+ return { [config.key]: defaultValue };
51
+ }
52
+ });
53
+ }
54
+ function enumFlagPreset(config) {
55
+ const sources = resolveSourceKeys(config.key, config.sources);
56
+ const allowed = new Set(config.values);
57
+ return createPreset({
58
+ id: config.id,
59
+ options: [
60
+ {
61
+ flags: config.flags,
62
+ description: config.description,
63
+ ...config.required === true ? { required: true } : {}
64
+ }
65
+ ],
66
+ resolve: (flags) => {
67
+ for (const source of sources) {
68
+ const value = flags[source];
69
+ if (typeof value === "string" && allowed.has(value)) {
70
+ return { [config.key]: value };
71
+ }
72
+ }
73
+ return {
74
+ [config.key]: config.defaultValue
75
+ };
76
+ }
77
+ });
78
+ }
79
+ function numberFlagPreset(config) {
80
+ const sources = resolveSourceKeys(config.key, config.sources);
81
+ return createPreset({
82
+ id: config.id,
83
+ options: [
84
+ {
85
+ flags: config.flags,
86
+ description: config.description,
87
+ ...config.required === true ? { required: true } : {}
88
+ }
89
+ ],
90
+ resolve: (flags) => {
91
+ let parsed;
92
+ for (const source of sources) {
93
+ const value = flags[source];
94
+ if (value === "" || value == null || typeof value === "boolean") {
95
+ continue;
96
+ }
97
+ const numeric = Number(value);
98
+ if (Number.isFinite(numeric)) {
99
+ parsed = config.integer === false ? numeric : Math.floor(numeric);
100
+ break;
101
+ }
102
+ }
103
+ if (parsed === undefined) {
104
+ parsed = config.defaultValue;
105
+ }
106
+ if (typeof config.min === "number" && Number.isFinite(config.min)) {
107
+ parsed = Math.max(parsed, config.min);
108
+ }
109
+ if (typeof config.max === "number" && Number.isFinite(config.max)) {
110
+ parsed = Math.min(parsed, config.max);
111
+ }
112
+ return { [config.key]: parsed };
113
+ }
114
+ });
115
+ }
116
+ function stringListFlagPreset(config) {
117
+ const sources = resolveSourceKeys(config.key, config.sources);
118
+ const separator = config.separator ?? ",";
119
+ const fallback = config.defaultValue === undefined ? undefined : [...config.defaultValue];
120
+ return createPreset({
121
+ id: config.id,
122
+ options: [
123
+ {
124
+ flags: config.flags,
125
+ description: config.description,
126
+ ...config.required === true ? { required: true } : {}
127
+ }
128
+ ],
129
+ resolve: (flags) => {
130
+ let resolved;
131
+ for (const source of sources) {
132
+ const parsed = normalizeStringListInput(flags[source], separator);
133
+ if (parsed !== undefined) {
134
+ resolved = parsed;
135
+ break;
136
+ }
137
+ }
138
+ if (resolved === undefined) {
139
+ resolved = fallback === undefined ? undefined : [...fallback];
140
+ }
141
+ if (resolved && config.dedupe) {
142
+ resolved = [...new Set(resolved)];
143
+ }
144
+ return {
145
+ [config.key]: resolved
146
+ };
147
+ }
148
+ });
149
+ }
150
+ export {
151
+ stringListFlagPreset,
152
+ numberFlagPreset,
153
+ enumFlagPreset,
154
+ booleanFlagPreset
155
+ };
@@ -0,0 +1,3 @@
1
+ import { composePresets, createPreset, createSchemaPreset, isSchemaPreset } from "../shared/@outfitter/cli-n54zs151.js";
2
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
3
+ export { isSchemaPreset, createSchemaPreset, createPreset, composePresets };
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ import {
3
+ composePresets,
4
+ createPreset,
5
+ createSchemaPreset,
6
+ isSchemaPreset
7
+ } from "../shared/@outfitter/cli-8cfxdady.js";
8
+ export {
9
+ isSchemaPreset,
10
+ createSchemaPreset,
11
+ createPreset,
12
+ composePresets
13
+ };
@@ -0,0 +1,5 @@
1
+ import { buildActionGraph, graphErrorHints, graphSuccessHints } from "../shared/@outfitter/cli-pmd04gtv.js";
2
+ import "../shared/@outfitter/cli-16wg5mka.js";
3
+ import "../shared/@outfitter/cli-xde45xcc.js";
4
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
5
+ export { graphSuccessHints, graphErrorHints, buildActionGraph };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ buildActionGraph,
4
+ graphErrorHints,
5
+ graphSuccessHints
6
+ } from "../shared/@outfitter/cli-hvg2m5gf.js";
7
+ export {
8
+ graphSuccessHints,
9
+ graphErrorHints,
10
+ buildActionGraph
11
+ };
@@ -0,0 +1,5 @@
1
+ import { buildCommandTree, commandTreeHints } from "../shared/@outfitter/cli-yfewnyc2.js";
2
+ import "../shared/@outfitter/cli-16wg5mka.js";
3
+ import "../shared/@outfitter/cli-xde45xcc.js";
4
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
5
+ export { commandTreeHints, buildCommandTree };
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ buildCommandTree,
4
+ commandTreeHints
5
+ } from "../shared/@outfitter/cli-htzez8v2.js";
6
+ export {
7
+ commandTreeHints,
8
+ buildCommandTree
9
+ };
@@ -0,0 +1,2 @@
1
+ import { errorRecoveryHints } from "../shared/@outfitter/cli-tm2fzngs.js";
2
+ export { errorRecoveryHints };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ errorRecoveryHints
4
+ } from "../shared/@outfitter/cli-2dfxs239.js";
5
+ export {
6
+ errorRecoveryHints
7
+ };
@@ -0,0 +1,4 @@
1
+ import { ActionGraph, ActionGraphEdge, CommandTree, CommandTreeNode, CommandTreeOption } from "../shared/@outfitter/cli-16wg5mka.js";
2
+ import "../shared/@outfitter/cli-xde45xcc.js";
3
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
4
+ export { CommandTreeOption, CommandTreeNode, CommandTree, ActionGraphEdge, ActionGraph };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Basic I/O and validation helpers for CLI input.
3
+ *
4
+ * @internal
5
+ */
6
+ /**
7
+ * Reads stdin content using async iteration.
8
+ */
9
+ declare function readStdin(): Promise<string>;
10
+ /**
11
+ * Splits a string by comma and/or space, trimming each part.
12
+ */
13
+ declare function splitIds(input: string): string[];
14
+ /**
15
+ * Checks if a path is a directory using Bun shell.
16
+ */
17
+ declare function isDirectory(dirPath: string): Promise<boolean>;
18
+ export { splitIds, readStdin, isDirectory };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ isDirectory,
4
+ readStdin,
5
+ splitIds
6
+ } from "../shared/@outfitter/cli-6shkwxdc.js";
7
+ export {
8
+ splitIds,
9
+ readStdin,
10
+ isDirectory
11
+ };
@@ -0,0 +1,3 @@
1
+ import { collectIds } from "../shared/@outfitter/cli-bcajqy33.js";
2
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
3
+ export { collectIds };
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ collectIds
4
+ } from "../shared/@outfitter/cli-gqtkhgw4.js";
5
+ import"../shared/@outfitter/cli-sy99pjyj.js";
6
+ import"../shared/@outfitter/cli-6shkwxdc.js";
7
+ export {
8
+ collectIds
9
+ };
@@ -0,0 +1,3 @@
1
+ import { expandFileArg, parseFilter, parseGlob, parseKeyValue, parseRange, parseSortSpec } from "../shared/@outfitter/cli-h4ejpmjs.js";
2
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
3
+ export { parseSortSpec, parseRange, parseKeyValue, parseGlob, parseFilter, expandFileArg };
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import {
3
+ expandFileArg,
4
+ parseFilter,
5
+ parseGlob,
6
+ parseKeyValue,
7
+ parseRange,
8
+ parseSortSpec
9
+ } from "../shared/@outfitter/cli-1q5redaj.js";
10
+ import"../shared/@outfitter/cli-sy99pjyj.js";
11
+ import"../shared/@outfitter/cli-6shkwxdc.js";
12
+ export {
13
+ parseSortSpec,
14
+ parseRange,
15
+ parseKeyValue,
16
+ parseGlob,
17
+ parseFilter,
18
+ expandFileArg
19
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Validates that a path doesn't contain traversal patterns.
3
+ *
4
+ * Rejects paths that:
5
+ * - Start with .. or contain /.. or \..
6
+ * - Contain null bytes
7
+ * - Are absolute paths (unless explicitly allowed)
8
+ */
9
+ declare function isSecurePath(filePath: string, allowAbsolute?: boolean): boolean;
10
+ /**
11
+ * Validates that a glob pattern doesn't escape the workspace.
12
+ *
13
+ * Rejects patterns that:
14
+ * - Start with ..
15
+ * - Contain /../
16
+ */
17
+ declare function isSecureGlobPattern(pattern: string): boolean;
18
+ /**
19
+ * Validates that a resolved path is within the workspace boundary.
20
+ */
21
+ declare function isWithinWorkspace(resolvedPath: string, workspaceRoot: string): boolean;
22
+ export { isWithinWorkspace, isSecurePath, isSecureGlobPattern };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ isSecureGlobPattern,
4
+ isSecurePath,
5
+ isWithinWorkspace
6
+ } from "../shared/@outfitter/cli-sy99pjyj.js";
7
+ export {
8
+ isWithinWorkspace,
9
+ isSecurePath,
10
+ isSecureGlobPattern
11
+ };
@@ -0,0 +1,3 @@
1
+ import { applyOutputTruncation, cliStringify, detectMode, formatErrorHuman, formatHuman, getExitCode, serializeErrorToJson, writeWithBackpressure } from "../shared/@outfitter/cli-10wxfc78.js";
2
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
3
+ export { writeWithBackpressure, serializeErrorToJson, getExitCode, formatHuman, formatErrorHuman, detectMode, cliStringify, applyOutputTruncation };
@@ -0,0 +1,21 @@
1
+ // @bun
2
+ import {
3
+ applyOutputTruncation,
4
+ cliStringify,
5
+ detectMode,
6
+ formatErrorHuman,
7
+ formatHuman,
8
+ getExitCode,
9
+ serializeErrorToJson,
10
+ writeWithBackpressure
11
+ } from "../shared/@outfitter/cli-dg0cz7rw.js";
12
+ export {
13
+ writeWithBackpressure,
14
+ serializeErrorToJson,
15
+ getExitCode,
16
+ formatHuman,
17
+ formatErrorHuman,
18
+ detectMode,
19
+ cliStringify,
20
+ applyOutputTruncation
21
+ };
@@ -0,0 +1,3 @@
1
+ import { colorPreset, cwdPreset, dryRunPreset, executionPreset, forcePreset, interactionPreset, paginationPreset, projectionPreset, strictPreset, timeWindowPreset, verbosePreset } from "../shared/@outfitter/cli-xw8ys1je.js";
2
+ import "../shared/@outfitter/cli-x6qr7bnd.js";
3
+ export { verbosePreset, timeWindowPreset, strictPreset, projectionPreset, paginationPreset, interactionPreset, forcePreset, executionPreset, dryRunPreset, cwdPreset, colorPreset };
@@ -1,193 +1,20 @@
1
1
  // @bun
2
- // packages/cli/src/flags.ts
3
- function createPreset(config) {
4
- const preset = {
5
- id: config.id,
6
- options: config.options,
7
- resolve: config.resolve
8
- };
9
- preset[PRESET_IDS] = [config.id];
10
- return preset;
11
- }
12
- var PRESET_IDS = Symbol("presetIds");
13
- function getPresetIds(preset) {
14
- const ids = preset[PRESET_IDS];
15
- return ids && ids.length > 0 ? ids : [preset.id];
16
- }
17
- function composePresets(...presets) {
18
- const seen = new Set;
19
- const mergedIds = [];
20
- const mergedOptions = [];
21
- const resolvers = [];
22
- for (const preset of presets) {
23
- const presetIds = getPresetIds(preset);
24
- if (presetIds.every((id) => seen.has(id)))
25
- continue;
26
- for (const id of presetIds) {
27
- if (seen.has(id))
28
- continue;
29
- seen.add(id);
30
- mergedIds.push(id);
31
- }
32
- mergedOptions.push(...preset.options);
33
- resolvers.push(preset.resolve);
34
- }
35
- const composed = {
36
- id: mergedIds.join("+"),
37
- options: mergedOptions,
38
- resolve: (flags) => {
39
- let result = {};
40
- for (const resolver of resolvers) {
41
- result = { ...result, ...resolver(flags) };
42
- }
43
- return result;
44
- }
45
- };
46
- composed[PRESET_IDS] = mergedIds;
47
- return composed;
48
- }
49
- function resolveSourceKeys(key, sources) {
50
- return sources && sources.length > 0 ? sources : [key];
51
- }
52
- function booleanFlagPreset(config) {
53
- const sources = resolveSourceKeys(config.key, config.sources);
54
- const defaultValue = config.defaultValue ?? false;
55
- const isNegatedFlag = config.flags.includes("--no-");
56
- const optionDefault = isNegatedFlag && config.defaultValue === undefined ? {} : { defaultValue };
57
- return createPreset({
58
- id: config.id,
59
- options: [
60
- {
61
- flags: config.flags,
62
- description: config.description,
63
- ...optionDefault,
64
- ...config.required === true ? { required: true } : {}
65
- }
66
- ],
67
- resolve: (flags) => {
68
- for (const source of sources) {
69
- const value = flags[source];
70
- if (typeof value === "boolean") {
71
- return { [config.key]: value };
72
- }
73
- }
74
- if (config.negatedSources) {
75
- for (const source of config.negatedSources) {
76
- const value = flags[source];
77
- if (typeof value === "boolean") {
78
- return { [config.key]: !value };
79
- }
80
- }
81
- }
82
- return { [config.key]: defaultValue };
83
- }
84
- });
85
- }
86
- function enumFlagPreset(config) {
87
- const sources = resolveSourceKeys(config.key, config.sources);
88
- const allowed = new Set(config.values);
89
- return createPreset({
90
- id: config.id,
91
- options: [
92
- {
93
- flags: config.flags,
94
- description: config.description,
95
- ...config.required === true ? { required: true } : {}
96
- }
97
- ],
98
- resolve: (flags) => {
99
- for (const source of sources) {
100
- const value = flags[source];
101
- if (typeof value === "string" && allowed.has(value)) {
102
- return { [config.key]: value };
103
- }
104
- }
105
- return {
106
- [config.key]: config.defaultValue
107
- };
108
- }
109
- });
110
- }
111
- function numberFlagPreset(config) {
112
- const sources = resolveSourceKeys(config.key, config.sources);
113
- return createPreset({
114
- id: config.id,
115
- options: [
116
- {
117
- flags: config.flags,
118
- description: config.description,
119
- ...config.required === true ? { required: true } : {}
120
- }
121
- ],
122
- resolve: (flags) => {
123
- let parsed;
124
- for (const source of sources) {
125
- const value = flags[source];
126
- if (value === "" || value == null || typeof value === "boolean") {
127
- continue;
128
- }
129
- const numeric = Number(value);
130
- if (Number.isFinite(numeric)) {
131
- parsed = config.integer === false ? numeric : Math.floor(numeric);
132
- break;
133
- }
134
- }
135
- if (parsed === undefined) {
136
- parsed = config.defaultValue;
137
- }
138
- if (typeof config.min === "number" && Number.isFinite(config.min)) {
139
- parsed = Math.max(parsed, config.min);
140
- }
141
- if (typeof config.max === "number" && Number.isFinite(config.max)) {
142
- parsed = Math.min(parsed, config.max);
143
- }
144
- return { [config.key]: parsed };
145
- }
146
- });
147
- }
148
- function normalizeStringListInput(value, separator) {
149
- if (Array.isArray(value)) {
150
- const items2 = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
151
- return items2.length > 0 ? items2 : undefined;
152
- }
2
+ import {
3
+ createPreset
4
+ } from "../shared/@outfitter/cli-8cfxdady.js";
5
+
6
+ // packages/cli/src/internal/presets.ts
7
+ function parseCommaSeparated(value) {
153
8
  if (typeof value !== "string")
154
9
  return;
155
- const items = value.split(separator).map((item) => item.trim()).filter(Boolean);
10
+ const items = value.split(",").map((s) => s.trim()).filter(Boolean);
156
11
  return items.length > 0 ? items : undefined;
157
12
  }
158
- function stringListFlagPreset(config) {
159
- const sources = resolveSourceKeys(config.key, config.sources);
160
- const separator = config.separator ?? ",";
161
- const fallback = config.defaultValue === undefined ? undefined : [...config.defaultValue];
162
- return createPreset({
163
- id: config.id,
164
- options: [
165
- {
166
- flags: config.flags,
167
- description: config.description,
168
- ...config.required === true ? { required: true } : {}
169
- }
170
- ],
171
- resolve: (flags) => {
172
- let resolved;
173
- for (const source of sources) {
174
- const parsed = normalizeStringListInput(flags[source], separator);
175
- if (parsed !== undefined) {
176
- resolved = parsed;
177
- break;
178
- }
179
- }
180
- if (resolved === undefined) {
181
- resolved = fallback === undefined ? undefined : [...fallback];
182
- }
183
- if (resolved && config.dedupe) {
184
- resolved = [...new Set(resolved)];
185
- }
186
- return {
187
- [config.key]: resolved
188
- };
189
- }
190
- });
13
+ function sanitizePositiveInteger(value, fallback) {
14
+ const parsed = Number(value);
15
+ if (!Number.isFinite(parsed) || parsed <= 0)
16
+ return fallback;
17
+ return Math.floor(parsed);
191
18
  }
192
19
  function verbosePreset() {
193
20
  return createPreset({
@@ -319,12 +146,6 @@ function colorPreset() {
319
146
  }
320
147
  });
321
148
  }
322
- function parseCommaSeparated(value) {
323
- if (typeof value !== "string")
324
- return;
325
- const items = value.split(",").map((s) => s.trim()).filter(Boolean);
326
- return items.length > 0 ? items : undefined;
327
- }
328
149
  function projectionPreset() {
329
150
  return createPreset({
330
151
  id: "projection",
@@ -350,36 +171,6 @@ function projectionPreset() {
350
171
  })
351
172
  });
352
173
  }
353
- var DURATION_SUFFIXES = {
354
- w: 7 * 24 * 60 * 60 * 1000,
355
- d: 24 * 60 * 60 * 1000,
356
- h: 60 * 60 * 1000,
357
- m: 60 * 1000
358
- };
359
- function parseDate(value, nowMs = Date.now()) {
360
- if (typeof value !== "string" || value === "")
361
- return;
362
- const durationMatch = value.match(/^(\d+(?:\.\d+)?)(w|d|h|m)$/);
363
- if (durationMatch) {
364
- const amount = Number(durationMatch[1]);
365
- const suffix = durationMatch[2];
366
- const multiplier = suffix ? DURATION_SUFFIXES[suffix] : undefined;
367
- if (amount > 0 && multiplier !== undefined) {
368
- return new Date(nowMs - amount * multiplier);
369
- }
370
- return;
371
- }
372
- const date = new Date(value);
373
- if (Number.isNaN(date.getTime()))
374
- return;
375
- return date;
376
- }
377
- function sanitizePositiveInteger(value, fallback) {
378
- const parsed = Number(value);
379
- if (!Number.isFinite(parsed) || parsed <= 0)
380
- return fallback;
381
- return Math.floor(parsed);
382
- }
383
174
  function timeWindowPreset(config) {
384
175
  return createPreset({
385
176
  id: "timeWindow",
@@ -496,5 +287,40 @@ function paginationPreset(config) {
496
287
  }
497
288
  });
498
289
  }
499
-
500
- export { createPreset, composePresets, booleanFlagPreset, enumFlagPreset, numberFlagPreset, stringListFlagPreset, verbosePreset, cwdPreset, dryRunPreset, forcePreset, interactionPreset, strictPreset, colorPreset, projectionPreset, timeWindowPreset, executionPreset, paginationPreset };
290
+ var DURATION_SUFFIXES = {
291
+ w: 7 * 24 * 60 * 60 * 1000,
292
+ d: 24 * 60 * 60 * 1000,
293
+ h: 60 * 60 * 1000,
294
+ m: 60 * 1000
295
+ };
296
+ function parseDate(value, nowMs = Date.now()) {
297
+ if (typeof value !== "string" || value === "")
298
+ return;
299
+ const durationMatch = value.match(/^(\d+(?:\.\d+)?)(w|d|h|m)$/);
300
+ if (durationMatch) {
301
+ const amount = Number(durationMatch[1]);
302
+ const suffix = durationMatch[2];
303
+ const multiplier = suffix ? DURATION_SUFFIXES[suffix] : undefined;
304
+ if (amount > 0 && multiplier !== undefined) {
305
+ return new Date(nowMs - amount * multiplier);
306
+ }
307
+ return;
308
+ }
309
+ const date = new Date(value);
310
+ if (Number.isNaN(date.getTime()))
311
+ return;
312
+ return date;
313
+ }
314
+ export {
315
+ verbosePreset,
316
+ timeWindowPreset,
317
+ strictPreset,
318
+ projectionPreset,
319
+ paginationPreset,
320
+ interactionPreset,
321
+ forcePreset,
322
+ executionPreset,
323
+ dryRunPreset,
324
+ cwdPreset,
325
+ colorPreset
326
+ };
@@ -0,0 +1,3 @@
1
+ import { createSchemaCommand } from "../shared/@outfitter/cli-nbpgw7z7.js";
2
+ import "../shared/@outfitter/cli-wjv7g1aq.js";
3
+ export { createSchemaCommand };