@xyd-js/opencli 0.1.0-build.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.
@@ -0,0 +1,522 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+ /**
7
+ * The OpenCLI description
8
+ */
9
+ interface OpencliSpecJson {
10
+ /**
11
+ * The OpenCLI version number
12
+ */
13
+ opencli: string;
14
+ info: CliInfo;
15
+ conventions?: Conventions;
16
+ /**
17
+ * Root command arguments
18
+ */
19
+ arguments?: Argument[];
20
+ /**
21
+ * Root command options
22
+ */
23
+ options?: Option[];
24
+ /**
25
+ * Root command sub commands
26
+ */
27
+ commands?: Command[];
28
+ /**
29
+ * Root command exit codes
30
+ */
31
+ exitCodes?: ExitCode[];
32
+ /**
33
+ * Examples of how to use the CLI
34
+ */
35
+ examples?: string[];
36
+ /**
37
+ * Indicates whether or not the command requires interactive input
38
+ */
39
+ interactive?: boolean;
40
+ /**
41
+ * Custom metadata
42
+ */
43
+ metadata?: Metadata[];
44
+ "x-openapi"?: XOpenApiRoot;
45
+ [k: string]: unknown;
46
+ }
47
+ /**
48
+ * Information about the CLI
49
+ */
50
+ interface CliInfo {
51
+ /**
52
+ * The application title
53
+ */
54
+ title: string;
55
+ /**
56
+ * A short summary of the application
57
+ */
58
+ summary?: string;
59
+ /**
60
+ * A description of the application
61
+ */
62
+ description?: string;
63
+ contact?: Contact;
64
+ license?: License;
65
+ /**
66
+ * The application version
67
+ */
68
+ version: string;
69
+ [k: string]: unknown;
70
+ }
71
+ /**
72
+ * The contact information
73
+ */
74
+ interface Contact {
75
+ /**
76
+ * The identifying name of the contact person/organization
77
+ */
78
+ name?: string;
79
+ /**
80
+ * The URI for the contact information. This MUST be in the form of a URI.
81
+ */
82
+ url?: string;
83
+ /**
84
+ * The email address of the contact person/organization. This MUST be in the form of an email address.
85
+ */
86
+ email?: string;
87
+ [k: string]: unknown;
88
+ }
89
+ /**
90
+ * The application license
91
+ */
92
+ interface License {
93
+ /**
94
+ * The license name
95
+ */
96
+ name?: string;
97
+ /**
98
+ * The SPDX license identifier
99
+ */
100
+ identifier?: string;
101
+ /**
102
+ * The URI for the license. This MUST be in the form of a URI
103
+ */
104
+ url?: string;
105
+ [k: string]: unknown;
106
+ }
107
+ /**
108
+ * The conventions used by the CLI
109
+ */
110
+ interface Conventions {
111
+ /**
112
+ * Whether or not grouping of short options are allowed
113
+ */
114
+ groupOptions?: boolean;
115
+ /**
116
+ * The option argument separator
117
+ */
118
+ optionSeparator?: string;
119
+ [k: string]: unknown;
120
+ }
121
+ interface Argument {
122
+ /**
123
+ * The argument name
124
+ */
125
+ name: string;
126
+ /**
127
+ * Whether or not the argument is required
128
+ */
129
+ required?: boolean;
130
+ arity?: Arity;
131
+ /**
132
+ * A list of accepted values
133
+ */
134
+ acceptedValues?: string[];
135
+ /**
136
+ * The argument group
137
+ */
138
+ group?: string;
139
+ /**
140
+ * The argument description
141
+ */
142
+ description?: string;
143
+ /**
144
+ * Whether or not the argument is hidden
145
+ */
146
+ hidden?: boolean;
147
+ /**
148
+ * Custom metadata
149
+ */
150
+ metadata?: Metadata[];
151
+ [k: string]: unknown;
152
+ }
153
+ /**
154
+ * The argument arity. Arity defines the minimum and maximum number of argument values
155
+ */
156
+ interface Arity {
157
+ /**
158
+ * The minimum number of values allowed
159
+ */
160
+ minimum?: number;
161
+ /**
162
+ * The maximum number of values allowed
163
+ */
164
+ maximum?: number;
165
+ [k: string]: unknown;
166
+ }
167
+ interface Metadata {
168
+ name: string;
169
+ value?: unknown;
170
+ [k: string]: unknown;
171
+ }
172
+ interface Option {
173
+ /**
174
+ * The option name
175
+ */
176
+ name: string;
177
+ /**
178
+ * Whether or not the option is required
179
+ */
180
+ required?: boolean;
181
+ /**
182
+ * The option's aliases
183
+ */
184
+ aliases?: string[];
185
+ /**
186
+ * The option's arguments
187
+ */
188
+ arguments?: Argument[];
189
+ /**
190
+ * The option group
191
+ */
192
+ group?: string;
193
+ /**
194
+ * The option description
195
+ */
196
+ description?: string;
197
+ /**
198
+ * Specifies whether the option is accessible from the immediate parent command and, recursively, from its subcommands
199
+ */
200
+ recursive?: boolean;
201
+ /**
202
+ * Whether or not the option is hidden
203
+ */
204
+ hidden?: boolean;
205
+ /**
206
+ * Custom metadata
207
+ */
208
+ metadata?: Metadata[];
209
+ [k: string]: unknown;
210
+ }
211
+ interface Command {
212
+ /**
213
+ * The command name
214
+ */
215
+ name: string;
216
+ /**
217
+ * The command aliases
218
+ */
219
+ aliases?: string[];
220
+ /**
221
+ * The command options
222
+ */
223
+ options?: Option[];
224
+ /**
225
+ * The command arguments
226
+ */
227
+ arguments?: Argument[];
228
+ /**
229
+ * The command's sub commands
230
+ */
231
+ commands?: Command[];
232
+ /**
233
+ * The command's exit codes
234
+ */
235
+ exitCodes?: ExitCode[];
236
+ /**
237
+ * The command description
238
+ */
239
+ description?: string;
240
+ /**
241
+ * Whether or not the command is hidden
242
+ */
243
+ hidden?: boolean;
244
+ /**
245
+ * Examples of how to use the command
246
+ */
247
+ examples?: string[];
248
+ /**
249
+ * Indicate whether or not the command requires interactive input
250
+ */
251
+ interactive?: boolean;
252
+ /**
253
+ * Custom metadata
254
+ */
255
+ metadata?: Metadata[];
256
+ "x-openapi"?: XOpenApiCommand;
257
+ [k: string]: unknown;
258
+ }
259
+ interface ExitCode {
260
+ /**
261
+ * The exit code
262
+ */
263
+ code: number;
264
+ /**
265
+ * The exit code description
266
+ */
267
+ description?: string;
268
+ [k: string]: unknown;
269
+ }
270
+ /**
271
+ * xyd extension: OpenAPI/HTTP binding for this command's operation (method, path, params, body). Consumed by the opencli2* code generators to build real API requests.
272
+ */
273
+ interface XOpenApiCommand {
274
+ /**
275
+ * The source OpenAPI operationId, when present
276
+ */
277
+ operationId?: string;
278
+ /**
279
+ * HTTP method (lowercase)
280
+ */
281
+ method: string;
282
+ /**
283
+ * HTTP path template (e.g. /chat/completions/{completion_id})
284
+ */
285
+ path: string;
286
+ /**
287
+ * Override base URL for this operation, if any
288
+ */
289
+ server?: string;
290
+ /**
291
+ * Request body content type
292
+ */
293
+ contentType?: string;
294
+ /**
295
+ * Per-operation security requirements (overrides root)
296
+ */
297
+ security?: XOpenApiSecurity[];
298
+ /**
299
+ * How CLI arguments/options map to HTTP parameters
300
+ */
301
+ params?: XOpenApiParam[];
302
+ body?: XOpenApiBody;
303
+ [k: string]: unknown;
304
+ }
305
+ /**
306
+ * A single security scheme mapped from the OpenAPI securitySchemes.
307
+ */
308
+ interface XOpenApiSecurity {
309
+ /**
310
+ * Normalized scheme a generator branches on: bearer | apiKey-header | apiKey-query | apiKey-cookie | basic | other
311
+ */
312
+ kind?: string;
313
+ /**
314
+ * The OpenAPI security scheme type (e.g. http, apiKey, oauth2)
315
+ */
316
+ type: string;
317
+ /**
318
+ * The HTTP auth scheme (e.g. bearer, basic) when type is http
319
+ */
320
+ scheme?: string;
321
+ /**
322
+ * Location for an apiKey scheme (header, query or cookie)
323
+ */
324
+ in?: string;
325
+ /**
326
+ * Header/query/cookie name for an apiKey scheme
327
+ */
328
+ name?: string;
329
+ /**
330
+ * The bearer token format hint (e.g. JWT)
331
+ */
332
+ bearerFormat?: string;
333
+ /**
334
+ * Environment variable a generated CLI reads the credential from (e.g. OPENAI_API_KEY)
335
+ */
336
+ envVar?: string;
337
+ [k: string]: unknown;
338
+ }
339
+ /**
340
+ * Maps one CLI argument/option onto an HTTP parameter.
341
+ */
342
+ interface XOpenApiParam {
343
+ /**
344
+ * Parameter location (path, query, header or cookie)
345
+ */
346
+ in: string;
347
+ /**
348
+ * The wire name of the HTTP parameter
349
+ */
350
+ name: string;
351
+ /**
352
+ * Source CLI token: 'argument:<name>' or 'option:<name>'
353
+ */
354
+ from: string;
355
+ /**
356
+ * Whether the HTTP parameter is required
357
+ */
358
+ required?: boolean;
359
+ /**
360
+ * OpenAPI explode flag for array/object serialization
361
+ */
362
+ explode?: boolean;
363
+ /**
364
+ * OpenAPI serialization style
365
+ */
366
+ style?: string;
367
+ [k: string]: unknown;
368
+ }
369
+ /**
370
+ * How CLI options map to the request body
371
+ */
372
+ interface XOpenApiBody {
373
+ /**
374
+ * How the body is assembled: 'flatten' (per-property flags), 'json' (single JSON flag) or 'multipart'
375
+ */
376
+ style: string;
377
+ /**
378
+ * Body content type
379
+ */
380
+ contentType?: string;
381
+ /**
382
+ * Source CLI token when the whole body comes from one option (style=json)
383
+ */
384
+ from?: string;
385
+ /**
386
+ * Per-property body field mappings (style=flatten/multipart)
387
+ */
388
+ properties?: XOpenApiBodyProp[];
389
+ [k: string]: unknown;
390
+ }
391
+ /**
392
+ * Maps one CLI option onto a request body field.
393
+ */
394
+ interface XOpenApiBodyProp {
395
+ /**
396
+ * The wire name of the body field
397
+ */
398
+ name: string;
399
+ /**
400
+ * Source CLI token: 'option:<name>'
401
+ */
402
+ from: string;
403
+ /**
404
+ * Dot path of the field within the JSON body
405
+ */
406
+ jsonPath?: string;
407
+ /**
408
+ * How the CLI value is encoded into the field: 'string', 'number', 'integer', 'boolean', 'json' (parse as JSON), 'array' or 'file'
409
+ */
410
+ encoding?: string;
411
+ /**
412
+ * Whether the body field is required
413
+ */
414
+ required?: boolean;
415
+ [k: string]: unknown;
416
+ }
417
+ /**
418
+ * xyd extension: OpenAPI/HTTP binding for the CLI as a whole (servers + security). Emitted by @xyd-js/openapi2opencli and consumed by the opencli2* code generators to build real API requests.
419
+ */
420
+ interface XOpenApiRoot {
421
+ /**
422
+ * Available API base URLs (from the OpenAPI servers list)
423
+ */
424
+ servers?: string[];
425
+ /**
426
+ * Default security requirements for the CLI
427
+ */
428
+ security?: XOpenApiSecurity[];
429
+ [k: string]: unknown;
430
+ }
431
+
432
+ interface LoadOpencliSpecOptions {
433
+ /**
434
+ * Base directory used to resolve a relative file `source`.
435
+ * Defaults to `process.cwd()`. (The remark plugin passes the markdown file's dirname.)
436
+ */
437
+ cwd?: string;
438
+ }
439
+ /**
440
+ * Load an OpenCLI spec from a file path or an HTTP(S) URL.
441
+ *
442
+ * Returns `null` (and logs) on any failure so callers can leave placeholders
443
+ * untouched rather than throwing.
444
+ */
445
+ declare function loadOpencliSpec(source: string, opts?: LoadOpencliSpecOptions): Promise<OpencliSpecJson | null>;
446
+ /**
447
+ * Find a command in the spec by path (e.g., "spice install").
448
+ * If the path is empty, returns a synthetic root command built from the spec root.
449
+ */
450
+ declare function findCommand(spec: OpencliSpecJson, commandPath: string): Command | null;
451
+
452
+ type IndentStyle = 'code' | 'list';
453
+ /**
454
+ * Generate usage line for a command (like: "shadcn init [options] [components...]")
455
+ */
456
+ declare function generateUsage(_spec: OpencliSpecJson, command: Command, commandPath: string): string;
457
+ /**
458
+ * Generate description for a command
459
+ */
460
+ declare function generateDescription(command: Command): string;
461
+ /**
462
+ * Generate arguments documentation
463
+ * @param indentStyle - 'code' for tab-indented CLI style, 'list' for markdown list style
464
+ */
465
+ declare function generateArguments(command: Command, indentStyle?: IndentStyle): string;
466
+ /**
467
+ * Generate options documentation
468
+ * @param indentStyle - 'code' for tab-indented CLI style, 'list' for markdown list style
469
+ */
470
+ declare function generateOptions(command: Command, indentStyle?: IndentStyle): string;
471
+ /**
472
+ * TODO: OPTIONS DO ALMOST THE SAME
473
+ * Generate flags/options documentation
474
+ */
475
+ declare function generateFlags(command: Command): string;
476
+ /**
477
+ * Generate subcommands documentation
478
+ */
479
+ declare function generateCommands(command: Command): string;
480
+
481
+ interface OpencliRefProperty {
482
+ name: string;
483
+ type: string;
484
+ description: string;
485
+ meta?: {
486
+ name: string;
487
+ value: unknown;
488
+ }[];
489
+ }
490
+ interface OpencliRefDefinition {
491
+ title: string;
492
+ properties: OpencliRefProperty[];
493
+ }
494
+ interface OpencliReference {
495
+ title: string;
496
+ canonical: string;
497
+ description: string;
498
+ context: {
499
+ path: string;
500
+ fullPath: string;
501
+ group: string[];
502
+ };
503
+ examples: {
504
+ groups: never[];
505
+ };
506
+ definitions: OpencliRefDefinition[];
507
+ }
508
+ interface OpencliToReferencesOptions {
509
+ /**
510
+ * Restrict output to specific commands. Each region is a command path,
511
+ * space-joined from the CLI root (e.g. `"install"`, `"remote add"`).
512
+ */
513
+ regions?: string[];
514
+ }
515
+ /**
516
+ * Convert an OpenCLI document to uniform `Reference[]` — one Reference per
517
+ * command — so the docs engine can render CLI reference pages the same way it
518
+ * renders OpenAPI/GraphQL (`api.cli`). Mirrors `oapSchemaToReferences`.
519
+ */
520
+ declare function opencliToReferences(spec: OpencliSpecJson | null | undefined, options?: OpencliToReferencesOptions): OpencliReference[];
521
+
522
+ export { type Argument, type Arity, type CliInfo, type Command, type Contact, type Conventions, type ExitCode, type IndentStyle, type License, type LoadOpencliSpecOptions, type Metadata, type OpencliReference, type OpencliSpecJson, type OpencliToReferencesOptions, type Option, type XOpenApiBody, type XOpenApiBodyProp, type XOpenApiCommand, type XOpenApiParam, type XOpenApiRoot, type XOpenApiSecurity, findCommand, generateArguments, generateCommands, generateDescription, generateFlags, generateOptions, generateUsage, loadOpencliSpec, opencliToReferences };