@forge-ts/core 0.19.4 → 0.19.5
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/dist/index.d.ts +396 -114
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ import { TSDocConfiguration } from '@microsoft/tsdoc';
|
|
|
12
12
|
/**
|
|
13
13
|
* Discriminated event types recorded in the audit trail.
|
|
14
14
|
*
|
|
15
|
+
* @since 0.10.0
|
|
15
16
|
* @public
|
|
16
17
|
*/
|
|
17
18
|
type AuditEventType = "config.lock" | "config.unlock" | "config.drift" | "bypass.create" | "bypass.expire" | "rule.change";
|
|
18
19
|
/**
|
|
19
20
|
* A single audit event recorded in the forge-ts audit trail.
|
|
20
21
|
*
|
|
22
|
+
* @since 0.10.0
|
|
21
23
|
* @public
|
|
22
24
|
*/
|
|
23
25
|
interface AuditEvent {
|
|
@@ -27,7 +29,10 @@ interface AuditEvent {
|
|
|
27
29
|
event: AuditEventType;
|
|
28
30
|
/** OS username of the actor (falls back to "unknown"). */
|
|
29
31
|
user: string;
|
|
30
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Mandatory for lock/unlock/bypass events; optional otherwise.
|
|
34
|
+
* @defaultValue undefined
|
|
35
|
+
*/
|
|
31
36
|
reason?: string;
|
|
32
37
|
/** Event-specific payload. */
|
|
33
38
|
details: Record<string, unknown>;
|
|
@@ -47,6 +52,7 @@ declare function getCurrentUser(): string;
|
|
|
47
52
|
/**
|
|
48
53
|
* Appends a single audit event to the `.forge-audit.jsonl` file.
|
|
49
54
|
*
|
|
55
|
+
* @remarks
|
|
50
56
|
* Creates the file if it does not exist. The file is strictly append-only —
|
|
51
57
|
* existing content is never modified or truncated.
|
|
52
58
|
*
|
|
@@ -55,33 +61,37 @@ declare function getCurrentUser(): string;
|
|
|
55
61
|
* @example
|
|
56
62
|
* ```typescript
|
|
57
63
|
* import { appendAuditEvent } from "@forge-ts/core";
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* event: "config.lock",
|
|
61
|
-
* user: "alice",
|
|
62
|
-
* reason: "Stabilize v2 config",
|
|
63
|
-
* details: { hash: "abc123" },
|
|
64
|
-
* });
|
|
64
|
+
* const event = { timestamp: new Date().toISOString(), event: "config.lock" as const, user: "alice", reason: "Stabilize", details: {} };
|
|
65
|
+
* appendAuditEvent("/path/to/project", event);
|
|
65
66
|
* ```
|
|
67
|
+
* @since 0.10.0
|
|
66
68
|
* @public
|
|
67
69
|
*/
|
|
68
70
|
declare function appendAuditEvent(rootDir: string, event: AuditEvent): void;
|
|
69
71
|
/**
|
|
70
72
|
* Options for reading the audit log.
|
|
71
73
|
*
|
|
74
|
+
* @since 0.10.0
|
|
72
75
|
* @public
|
|
73
76
|
*/
|
|
74
77
|
interface ReadAuditOptions {
|
|
75
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Maximum number of events to return.
|
|
80
|
+
* @defaultValue undefined
|
|
81
|
+
*/
|
|
76
82
|
limit?: number;
|
|
77
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Filter to a single event type.
|
|
85
|
+
* @defaultValue undefined
|
|
86
|
+
*/
|
|
78
87
|
eventType?: AuditEventType;
|
|
79
88
|
}
|
|
80
89
|
/**
|
|
81
90
|
* Reads the `.forge-audit.jsonl` file and returns parsed audit events.
|
|
82
91
|
*
|
|
92
|
+
* @remarks
|
|
83
93
|
* Returns newest events first. If the file does not exist, returns an empty
|
|
84
|
-
* array.
|
|
94
|
+
* array. Invalid JSON lines are silently skipped.
|
|
85
95
|
*
|
|
86
96
|
* @param rootDir - Absolute path to the project root directory.
|
|
87
97
|
* @param options - Optional limit and event type filter.
|
|
@@ -92,27 +102,27 @@ interface ReadAuditOptions {
|
|
|
92
102
|
* const events = readAuditLog("/path/to/project", { limit: 10 });
|
|
93
103
|
* console.log(events.length); // up to 10
|
|
94
104
|
* ```
|
|
105
|
+
* @since 0.10.0
|
|
95
106
|
* @public
|
|
96
107
|
*/
|
|
97
108
|
declare function readAuditLog(rootDir: string, options?: ReadAuditOptions): AuditEvent[];
|
|
98
109
|
/**
|
|
99
110
|
* Formats a single audit event as a human-readable string.
|
|
100
111
|
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* Produces a single-line representation suitable for terminal output or
|
|
114
|
+
* log files. Includes the timestamp, event type, user, reason, and details.
|
|
115
|
+
*
|
|
101
116
|
* @param event - The audit event to format.
|
|
102
117
|
* @returns A single-line human-readable representation.
|
|
103
118
|
* @example
|
|
104
119
|
* ```typescript
|
|
105
120
|
* import { formatAuditEvent } from "@forge-ts/core";
|
|
106
|
-
* const
|
|
107
|
-
*
|
|
108
|
-
* event: "config.lock",
|
|
109
|
-
* user: "alice",
|
|
110
|
-
* reason: "Stabilize v2 config",
|
|
111
|
-
* details: { hash: "abc123" },
|
|
112
|
-
* });
|
|
121
|
+
* const event = { timestamp: "2026-03-21T12:00:00.000Z", event: "config.lock" as const, user: "alice", reason: "Stabilize", details: {} };
|
|
122
|
+
* const line = formatAuditEvent(event);
|
|
113
123
|
* console.log(line);
|
|
114
|
-
* // "[2026-03-21T12:00:00.000Z] config.lock by alice — Stabilize v2 config {hash: abc123}"
|
|
115
124
|
* ```
|
|
125
|
+
* @since 0.10.0
|
|
116
126
|
* @public
|
|
117
127
|
*/
|
|
118
128
|
declare function formatAuditEvent(event: AuditEvent): string;
|
|
@@ -133,6 +143,7 @@ declare function formatAuditEvent(event: AuditEvent): string;
|
|
|
133
143
|
/**
|
|
134
144
|
* Configuration for the bypass budget system.
|
|
135
145
|
*
|
|
146
|
+
* @since 0.10.0
|
|
136
147
|
* @public
|
|
137
148
|
*/
|
|
138
149
|
interface BypassConfig {
|
|
@@ -144,6 +155,7 @@ interface BypassConfig {
|
|
|
144
155
|
/**
|
|
145
156
|
* A single bypass record stored in `.forge-bypass.json`.
|
|
146
157
|
*
|
|
158
|
+
* @since 0.10.0
|
|
147
159
|
* @public
|
|
148
160
|
*/
|
|
149
161
|
interface BypassRecord {
|
|
@@ -164,7 +176,9 @@ interface BypassRecord {
|
|
|
164
176
|
* Creates a new bypass record, writes it to `.forge-bypass.json`, and appends
|
|
165
177
|
* an audit event.
|
|
166
178
|
*
|
|
167
|
-
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* Throws an error if the daily budget is exhausted. Each bypass is recorded
|
|
181
|
+
* in the audit trail for governance traceability.
|
|
168
182
|
*
|
|
169
183
|
* @param rootDir - Absolute path to the project root directory.
|
|
170
184
|
* @param reason - Mandatory justification for the bypass.
|
|
@@ -175,15 +189,20 @@ interface BypassRecord {
|
|
|
175
189
|
* @example
|
|
176
190
|
* ```typescript
|
|
177
191
|
* import { createBypass } from "@forge-ts/core";
|
|
178
|
-
* const bypass = createBypass("/path/to/project", "hotfix for release", "E009");
|
|
179
|
-
* console.log(bypass.id);
|
|
192
|
+
* const bypass = createBypass("/path/to/project", "hotfix for release", "E009", { dailyBudget: 5, durationHours: 12 });
|
|
193
|
+
* console.log(bypass.id);
|
|
180
194
|
* ```
|
|
195
|
+
* @since 0.10.0
|
|
181
196
|
* @public
|
|
182
197
|
*/
|
|
183
198
|
declare function createBypass(rootDir: string, reason: string, rule?: string, config?: Partial<BypassConfig>): BypassRecord;
|
|
184
199
|
/**
|
|
185
200
|
* Returns all currently active (non-expired) bypass records.
|
|
186
201
|
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* Filters bypass records by comparing their `expiresAt` timestamp against
|
|
204
|
+
* the current time. Expired records are not removed by this function.
|
|
205
|
+
*
|
|
187
206
|
* @param rootDir - Absolute path to the project root directory.
|
|
188
207
|
* @returns Array of active bypass records.
|
|
189
208
|
* @example
|
|
@@ -192,12 +211,14 @@ declare function createBypass(rootDir: string, reason: string, rule?: string, co
|
|
|
192
211
|
* const active = getActiveBypasses("/path/to/project");
|
|
193
212
|
* console.log(`${active.length} active bypass(es)`);
|
|
194
213
|
* ```
|
|
214
|
+
* @since 0.10.0
|
|
195
215
|
* @public
|
|
196
216
|
*/
|
|
197
217
|
declare function getActiveBypasses(rootDir: string): BypassRecord[];
|
|
198
218
|
/**
|
|
199
219
|
* Checks whether a specific rule has an active bypass.
|
|
200
220
|
*
|
|
221
|
+
* @remarks
|
|
201
222
|
* A rule is considered bypassed if there is an active bypass with the exact
|
|
202
223
|
* rule code or an "all" bypass.
|
|
203
224
|
*
|
|
@@ -211,13 +232,16 @@ declare function getActiveBypasses(rootDir: string): BypassRecord[];
|
|
|
211
232
|
* console.log("E009 is currently bypassed");
|
|
212
233
|
* }
|
|
213
234
|
* ```
|
|
235
|
+
* @since 0.10.0
|
|
214
236
|
* @public
|
|
215
237
|
*/
|
|
216
238
|
declare function isRuleBypassed(rootDir: string, ruleCode: string): boolean;
|
|
217
239
|
/**
|
|
218
240
|
* Returns the number of bypass budget slots remaining for today.
|
|
219
241
|
*
|
|
242
|
+
* @remarks
|
|
220
243
|
* Counts bypasses created today (UTC) against the configured daily budget.
|
|
244
|
+
* When no config override is provided, the default budget of 3 is used.
|
|
221
245
|
*
|
|
222
246
|
* @param rootDir - Absolute path to the project root directory.
|
|
223
247
|
* @param config - Optional bypass budget configuration overrides.
|
|
@@ -225,16 +249,19 @@ declare function isRuleBypassed(rootDir: string, ruleCode: string): boolean;
|
|
|
225
249
|
* @example
|
|
226
250
|
* ```typescript
|
|
227
251
|
* import { getRemainingBudget } from "@forge-ts/core";
|
|
228
|
-
* const remaining = getRemainingBudget("/path/to/project");
|
|
252
|
+
* const remaining = getRemainingBudget("/path/to/project", { dailyBudget: 5, durationHours: 24 });
|
|
229
253
|
* console.log(`${remaining} bypass(es) remaining today`);
|
|
230
254
|
* ```
|
|
255
|
+
* @since 0.10.0
|
|
231
256
|
* @public
|
|
232
257
|
*/
|
|
233
258
|
declare function getRemainingBudget(rootDir: string, config?: Partial<BypassConfig>): number;
|
|
234
259
|
/**
|
|
235
260
|
* Removes expired bypass records from `.forge-bypass.json`.
|
|
236
261
|
*
|
|
262
|
+
* @remarks
|
|
237
263
|
* Also appends a `bypass.expire` audit event for each expired record removed.
|
|
264
|
+
* Returns 0 without writing the file when no records have expired.
|
|
238
265
|
*
|
|
239
266
|
* @param rootDir - Absolute path to the project root directory.
|
|
240
267
|
* @returns The number of expired records removed.
|
|
@@ -244,13 +271,15 @@ declare function getRemainingBudget(rootDir: string, config?: Partial<BypassConf
|
|
|
244
271
|
* const removed = expireOldBypasses("/path/to/project");
|
|
245
272
|
* console.log(`${removed} expired bypass(es) removed`);
|
|
246
273
|
* ```
|
|
274
|
+
* @since 0.10.0
|
|
247
275
|
* @public
|
|
248
276
|
*/
|
|
249
277
|
declare function expireOldBypasses(rootDir: string): number;
|
|
250
278
|
|
|
251
279
|
/**
|
|
252
280
|
* Visibility levels for exported symbols.
|
|
253
|
-
* Derived from TSDoc release tags (
|
|
281
|
+
* Derived from TSDoc release tags (`@public`, `@beta`, `@internal`).
|
|
282
|
+
* @since 0.1.0
|
|
254
283
|
* @public
|
|
255
284
|
*/
|
|
256
285
|
declare enum Visibility {
|
|
@@ -261,6 +290,7 @@ declare enum Visibility {
|
|
|
261
290
|
}
|
|
262
291
|
/**
|
|
263
292
|
* A single extracted and annotated symbol from the TypeScript AST.
|
|
293
|
+
* @since 0.1.0
|
|
264
294
|
* @public
|
|
265
295
|
*/
|
|
266
296
|
interface ForgeSymbol {
|
|
@@ -276,7 +306,10 @@ interface ForgeSymbol {
|
|
|
276
306
|
line: number;
|
|
277
307
|
/** 0-based column of the declaration. */
|
|
278
308
|
column: number;
|
|
279
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* Parsed TSDoc documentation, if present.
|
|
311
|
+
* @defaultValue undefined
|
|
312
|
+
*/
|
|
280
313
|
documentation?: {
|
|
281
314
|
summary?: string;
|
|
282
315
|
params?: Array<{
|
|
@@ -312,9 +345,15 @@ interface ForgeSymbol {
|
|
|
312
345
|
line: number;
|
|
313
346
|
}>;
|
|
314
347
|
};
|
|
315
|
-
/**
|
|
348
|
+
/**
|
|
349
|
+
* Human-readable type signature of the symbol.
|
|
350
|
+
* @defaultValue undefined
|
|
351
|
+
*/
|
|
316
352
|
signature?: string;
|
|
317
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Child symbols (e.g., class members, enum values).
|
|
355
|
+
* @defaultValue undefined
|
|
356
|
+
*/
|
|
318
357
|
children?: ForgeSymbol[];
|
|
319
358
|
/** Whether this symbol is part of the public module exports. */
|
|
320
359
|
exported: boolean;
|
|
@@ -324,24 +363,26 @@ interface ForgeSymbol {
|
|
|
324
363
|
* - `"error"` — violation fails the build.
|
|
325
364
|
* - `"warn"` — violation is reported but does not fail the build.
|
|
326
365
|
* - `"off"` — rule is disabled entirely.
|
|
366
|
+
* @since 0.1.0
|
|
327
367
|
* @public
|
|
328
368
|
*/
|
|
329
369
|
type RuleSeverity = "error" | "warn" | "off";
|
|
330
370
|
/**
|
|
331
371
|
* Per-rule severity configuration for the TSDoc enforcer.
|
|
332
372
|
* Each key corresponds to one of the E001–E007 rule codes.
|
|
373
|
+
* @since 0.1.0
|
|
333
374
|
* @public
|
|
334
375
|
*/
|
|
335
376
|
interface EnforceRules {
|
|
336
377
|
/** E001: Exported symbol missing TSDoc summary. */
|
|
337
378
|
"require-summary": RuleSeverity;
|
|
338
|
-
/** E002: Function parameter missing
|
|
379
|
+
/** E002: Function parameter missing `\@param` tag. */
|
|
339
380
|
"require-param": RuleSeverity;
|
|
340
|
-
/** E003: Non-void function missing
|
|
381
|
+
/** E003: Non-void function missing `\@returns` tag. */
|
|
341
382
|
"require-returns": RuleSeverity;
|
|
342
|
-
/** E004: Exported function missing
|
|
383
|
+
/** E004: Exported function missing `\@example` block. */
|
|
343
384
|
"require-example": RuleSeverity;
|
|
344
|
-
/** E005: Entry point missing
|
|
385
|
+
/** E005: Entry point missing `\@packageDocumentation`. */
|
|
345
386
|
"require-package-doc": RuleSeverity;
|
|
346
387
|
/** E006: Class member missing documentation. */
|
|
347
388
|
"require-class-member-doc": RuleSeverity;
|
|
@@ -349,42 +390,43 @@ interface EnforceRules {
|
|
|
349
390
|
"require-interface-member-doc": RuleSeverity;
|
|
350
391
|
/** W006: TSDoc syntax parse error (invalid tag, malformed block, etc.). */
|
|
351
392
|
"require-tsdoc-syntax": RuleSeverity;
|
|
352
|
-
/** E013: Exported function/class is missing a
|
|
393
|
+
/** E013: Exported function/class is missing a `\@remarks` block. */
|
|
353
394
|
"require-remarks": RuleSeverity;
|
|
354
|
-
/** E014: Optional property with default is missing
|
|
395
|
+
/** E014: Optional property with default is missing `\@defaultValue`. */
|
|
355
396
|
"require-default-value": RuleSeverity;
|
|
356
|
-
/** E015: Generic symbol is missing
|
|
397
|
+
/** E015: Generic symbol is missing `\@typeParam` for its type parameters. */
|
|
357
398
|
"require-type-param": RuleSeverity;
|
|
358
|
-
/** W005: Symbol references other symbols via
|
|
399
|
+
/** W005: Symbol references other symbols via `\@link` but has no `\@see` tags. */
|
|
359
400
|
"require-see": RuleSeverity;
|
|
360
|
-
/** E016: Exported symbol is missing a release tag (
|
|
401
|
+
/** E016: Exported symbol is missing a release tag (`\@public`, `\@beta`, `\@internal`). */
|
|
361
402
|
"require-release-tag": RuleSeverity;
|
|
362
403
|
/** W007: Guide FORGE:AUTO section references a symbol that no longer exists or has changed. */
|
|
363
404
|
"require-fresh-guides": RuleSeverity;
|
|
364
405
|
/** W008: Exported public symbol is not mentioned in any guide page. */
|
|
365
406
|
"require-guide-coverage": RuleSeverity;
|
|
366
|
-
/** E017:
|
|
407
|
+
/** E017: `\@internal` symbol re-exported through public barrel (index.ts). */
|
|
367
408
|
"require-internal-boundary": RuleSeverity;
|
|
368
|
-
/** E018:
|
|
409
|
+
/** E018: `\@route`-tagged function missing `\@response` tag. */
|
|
369
410
|
"require-route-response": RuleSeverity;
|
|
370
|
-
/** W009:
|
|
411
|
+
/** W009: `\@inheritDoc` references a symbol that does not exist. */
|
|
371
412
|
"require-inheritdoc-source": RuleSeverity;
|
|
372
|
-
/** W010:
|
|
413
|
+
/** W010: `\@breaking` without `\@migration` path. */
|
|
373
414
|
"require-migration-path": RuleSeverity;
|
|
374
|
-
/** W011: New public export missing
|
|
415
|
+
/** W011: New public export missing `\@since` version tag. */
|
|
375
416
|
"require-since": RuleSeverity;
|
|
376
|
-
/** W013:
|
|
417
|
+
/** W013: `\@example` block may be stale — function call arg count mismatches parameter count. */
|
|
377
418
|
"require-fresh-examples": RuleSeverity;
|
|
378
419
|
/** E019: Non-test file contains ts-ignore or ts-expect-error directive. */
|
|
379
420
|
"require-no-ts-ignore": RuleSeverity;
|
|
380
421
|
/** E020: Exported symbol has `any` in its public API signature. */
|
|
381
422
|
"require-no-any-in-api": RuleSeverity;
|
|
382
|
-
/** W012:
|
|
423
|
+
/** W012: `\@link` display text appears stale relative to target summary. */
|
|
383
424
|
"require-fresh-link-text": RuleSeverity;
|
|
384
425
|
}
|
|
385
426
|
/**
|
|
386
427
|
* Full configuration for a forge-ts run.
|
|
387
428
|
* Loaded from forge-ts.config.ts or the "forge-ts" key in package.json.
|
|
429
|
+
* @since 0.1.0
|
|
388
430
|
* @public
|
|
389
431
|
*/
|
|
390
432
|
interface ForgeConfig {
|
|
@@ -542,6 +584,7 @@ interface ForgeConfig {
|
|
|
542
584
|
/**
|
|
543
585
|
* Warnings generated during config loading (e.g., unknown keys).
|
|
544
586
|
* Populated by loadConfig(). Agents should surface these in output.
|
|
587
|
+
* @defaultValue undefined
|
|
545
588
|
* @internal
|
|
546
589
|
*/
|
|
547
590
|
_configWarnings?: string[];
|
|
@@ -567,6 +610,7 @@ interface ForgeConfig {
|
|
|
567
610
|
}
|
|
568
611
|
/**
|
|
569
612
|
* The result of a forge-ts compilation pass.
|
|
613
|
+
* @since 0.1.0
|
|
570
614
|
* @public
|
|
571
615
|
*/
|
|
572
616
|
interface ForgeResult {
|
|
@@ -580,11 +624,15 @@ interface ForgeResult {
|
|
|
580
624
|
warnings: ForgeWarning[];
|
|
581
625
|
/** Wall-clock duration of the run in milliseconds. */
|
|
582
626
|
duration: number;
|
|
583
|
-
/**
|
|
627
|
+
/**
|
|
628
|
+
* Absolute paths of files written during this run (populated by gen).
|
|
629
|
+
* @defaultValue undefined
|
|
630
|
+
*/
|
|
584
631
|
writtenFiles?: string[];
|
|
585
632
|
}
|
|
586
633
|
/**
|
|
587
634
|
* A diagnostic error produced during a forge-ts run.
|
|
635
|
+
* @since 0.1.0
|
|
588
636
|
* @public
|
|
589
637
|
*/
|
|
590
638
|
interface ForgeError {
|
|
@@ -598,15 +646,25 @@ interface ForgeError {
|
|
|
598
646
|
line: number;
|
|
599
647
|
/** 0-based column. */
|
|
600
648
|
column: number;
|
|
601
|
-
/**
|
|
649
|
+
/**
|
|
650
|
+
* Suggested fix for the agent — exact TSDoc block to add.
|
|
651
|
+
* @defaultValue undefined
|
|
652
|
+
*/
|
|
602
653
|
suggestedFix?: string;
|
|
603
|
-
/**
|
|
654
|
+
/**
|
|
655
|
+
* The symbol name that needs fixing.
|
|
656
|
+
* @defaultValue undefined
|
|
657
|
+
*/
|
|
604
658
|
symbolName?: string;
|
|
605
|
-
/**
|
|
659
|
+
/**
|
|
660
|
+
* The symbol kind (function, class, interface, etc.).
|
|
661
|
+
* @defaultValue undefined
|
|
662
|
+
*/
|
|
606
663
|
symbolKind?: string;
|
|
607
664
|
}
|
|
608
665
|
/**
|
|
609
666
|
* A diagnostic warning produced during a forge-ts run.
|
|
667
|
+
* @since 0.1.0
|
|
610
668
|
* @public
|
|
611
669
|
*/
|
|
612
670
|
interface ForgeWarning {
|
|
@@ -630,12 +688,15 @@ interface ForgeWarning {
|
|
|
630
688
|
* - **discretionary**: Release-tag family (`@public`, `@beta`, `@internal`).
|
|
631
689
|
* - Rules not listed here are **guard rules** and are not affected by group settings.
|
|
632
690
|
*
|
|
691
|
+
* @see {@link EnforceRules}
|
|
692
|
+
* @since 0.1.0
|
|
633
693
|
* @public
|
|
634
694
|
*/
|
|
635
695
|
declare const RULE_GROUP_MAP: Partial<Record<keyof EnforceRules, "core" | "extended" | "discretionary">>;
|
|
636
696
|
/**
|
|
637
697
|
* Type-safe helper for defining a partial forge-ts configuration.
|
|
638
698
|
*
|
|
699
|
+
* @remarks
|
|
639
700
|
* Only include the settings you want to override — everything else
|
|
640
701
|
* inherits sensible defaults via `loadConfig()`.
|
|
641
702
|
*
|
|
@@ -645,46 +706,55 @@ declare const RULE_GROUP_MAP: Partial<Record<keyof EnforceRules, "core" | "exten
|
|
|
645
706
|
* ```typescript
|
|
646
707
|
* import { defineConfig } from "@forge-ts/core";
|
|
647
708
|
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
* enforce: { strict: true },
|
|
651
|
-
* gen: { ssgTarget: "mintlify" },
|
|
652
|
-
* });
|
|
709
|
+
* const config = { outDir: "docs", enforce: { strict: true } };
|
|
710
|
+
* export default defineConfig(config);
|
|
653
711
|
* ```
|
|
712
|
+
* @since 0.1.0
|
|
654
713
|
* @public
|
|
655
714
|
*/
|
|
656
715
|
declare function defineConfig(config: Partial<ForgeConfig>): Partial<ForgeConfig>;
|
|
657
716
|
/**
|
|
658
717
|
* Constructs a sensible default {@link ForgeConfig} rooted at `rootDir`.
|
|
659
718
|
*
|
|
719
|
+
* @remarks
|
|
720
|
+
* All configuration fields receive production-ready defaults. The returned
|
|
721
|
+
* object is fully populated and can be used without any further merging.
|
|
722
|
+
*
|
|
660
723
|
* @param rootDir - Absolute path to the project root.
|
|
661
724
|
* @returns A fully-populated default configuration.
|
|
725
|
+
* @see {@link ForgeConfig}
|
|
726
|
+
* @see {@link loadConfig}
|
|
662
727
|
* @example
|
|
663
728
|
* ```typescript
|
|
664
729
|
* import { defaultConfig } from "@forge-ts/core";
|
|
665
730
|
* const config = defaultConfig("/path/to/project");
|
|
666
731
|
* console.log(config.enforce.enabled); // true
|
|
667
732
|
* ```
|
|
733
|
+
* @since 0.1.0
|
|
668
734
|
* @public
|
|
669
735
|
*/
|
|
670
736
|
declare function defaultConfig(rootDir: string): ForgeConfig;
|
|
671
737
|
/**
|
|
672
738
|
* Loads the forge-ts configuration for a project.
|
|
673
739
|
*
|
|
740
|
+
* @remarks
|
|
674
741
|
* Resolution order:
|
|
675
|
-
* 1.
|
|
676
|
-
* 2.
|
|
677
|
-
* 3. `"forge-ts"` key inside
|
|
742
|
+
* 1. `\<rootDir\>/forge-ts.config.ts`
|
|
743
|
+
* 2. `\<rootDir\>/forge-ts.config.js`
|
|
744
|
+
* 3. `"forge-ts"` key inside `\<rootDir\>/package.json`
|
|
678
745
|
* 4. Built-in defaults (returned when none of the above is found)
|
|
679
746
|
*
|
|
680
747
|
* @param rootDir - The project root to search for config. Defaults to `process.cwd()`.
|
|
681
748
|
* @returns A fully-resolved {@link ForgeConfig}.
|
|
749
|
+
* @see {@link ForgeConfig}
|
|
750
|
+
* @see {@link defaultConfig}
|
|
682
751
|
* @example
|
|
683
752
|
* ```typescript
|
|
684
753
|
* import { loadConfig } from "@forge-ts/core";
|
|
685
754
|
* const config = await loadConfig("/path/to/project");
|
|
686
755
|
* // config is fully resolved with defaults
|
|
687
756
|
* ```
|
|
757
|
+
* @since 0.1.0
|
|
688
758
|
* @public
|
|
689
759
|
*/
|
|
690
760
|
declare function loadConfig(rootDir?: string): Promise<ForgeConfig>;
|
|
@@ -704,6 +774,7 @@ declare function loadConfig(rootDir?: string): Promise<ForgeConfig>;
|
|
|
704
774
|
* Captures a point-in-time snapshot of the project's forge-ts configuration
|
|
705
775
|
* so that future runs can detect when settings have been weakened.
|
|
706
776
|
*
|
|
777
|
+
* @since 0.10.0
|
|
707
778
|
* @public
|
|
708
779
|
*/
|
|
709
780
|
interface ForgeLockManifest {
|
|
@@ -726,6 +797,7 @@ interface ForgeLockManifest {
|
|
|
726
797
|
/**
|
|
727
798
|
* A single violation found when comparing current config against the lock.
|
|
728
799
|
*
|
|
800
|
+
* @since 0.10.0
|
|
729
801
|
* @public
|
|
730
802
|
*/
|
|
731
803
|
interface LockViolation {
|
|
@@ -741,6 +813,10 @@ interface LockViolation {
|
|
|
741
813
|
/**
|
|
742
814
|
* Reads the `.forge-lock.json` file from the given project root.
|
|
743
815
|
*
|
|
816
|
+
* @remarks
|
|
817
|
+
* Returns `null` when the file does not exist or contains invalid JSON,
|
|
818
|
+
* so callers can safely use a null check to determine lock state.
|
|
819
|
+
*
|
|
744
820
|
* @param rootDir - Absolute path to the project root.
|
|
745
821
|
* @returns The parsed lock manifest, or `null` if no lock file exists or is invalid.
|
|
746
822
|
* @example
|
|
@@ -751,27 +827,39 @@ interface LockViolation {
|
|
|
751
827
|
* console.log(`Locked at ${lock.lockedAt} by ${lock.lockedBy}`);
|
|
752
828
|
* }
|
|
753
829
|
* ```
|
|
830
|
+
* @since 0.10.0
|
|
754
831
|
* @public
|
|
755
832
|
*/
|
|
756
833
|
declare function readLockFile(rootDir: string): ForgeLockManifest | null;
|
|
757
834
|
/**
|
|
758
835
|
* Writes a {@link ForgeLockManifest} to `.forge-lock.json` in the project root.
|
|
759
836
|
*
|
|
837
|
+
* @remarks
|
|
838
|
+
* Overwrites any existing lock file. The manifest is serialised as
|
|
839
|
+
* pretty-printed JSON with a trailing newline.
|
|
840
|
+
*
|
|
760
841
|
* @param rootDir - Absolute path to the project root.
|
|
761
842
|
* @param manifest - The lock manifest to write.
|
|
843
|
+
* @see {@link ForgeLockManifest}
|
|
844
|
+
* @see {@link createLockManifest}
|
|
762
845
|
* @example
|
|
763
846
|
* ```typescript
|
|
764
847
|
* import { writeLockFile, createLockManifest, loadConfig } from "@forge-ts/core";
|
|
765
848
|
* const config = await loadConfig("/path/to/project");
|
|
766
|
-
* const manifest = createLockManifest(config);
|
|
849
|
+
* const manifest = createLockManifest(config, "alice");
|
|
767
850
|
* writeLockFile("/path/to/project", manifest);
|
|
768
851
|
* ```
|
|
852
|
+
* @since 0.10.0
|
|
769
853
|
* @public
|
|
770
854
|
*/
|
|
771
855
|
declare function writeLockFile(rootDir: string, manifest: ForgeLockManifest): void;
|
|
772
856
|
/**
|
|
773
857
|
* Removes the `.forge-lock.json` file from the project root.
|
|
774
858
|
*
|
|
859
|
+
* @remarks
|
|
860
|
+
* Safe to call even when no lock file exists — returns `false` in that case
|
|
861
|
+
* rather than throwing.
|
|
862
|
+
*
|
|
775
863
|
* @param rootDir - Absolute path to the project root.
|
|
776
864
|
* @returns `true` if the file existed and was removed, `false` otherwise.
|
|
777
865
|
* @example
|
|
@@ -780,31 +868,37 @@ declare function writeLockFile(rootDir: string, manifest: ForgeLockManifest): vo
|
|
|
780
868
|
* const removed = removeLockFile("/path/to/project");
|
|
781
869
|
* console.log(removed ? "Lock removed" : "No lock file found");
|
|
782
870
|
* ```
|
|
871
|
+
* @since 0.10.0
|
|
783
872
|
* @public
|
|
784
873
|
*/
|
|
785
874
|
declare function removeLockFile(rootDir: string): boolean;
|
|
786
875
|
/**
|
|
787
876
|
* Creates a {@link ForgeLockManifest} from the current project config.
|
|
788
877
|
*
|
|
878
|
+
* @remarks
|
|
789
879
|
* Snapshots the enforce rule severities and guard settings so they can
|
|
790
880
|
* be compared on future runs to detect weakening.
|
|
791
881
|
*
|
|
792
882
|
* @param config - The fully-resolved {@link ForgeConfig} to snapshot.
|
|
793
883
|
* @param lockedBy - Identifier of the user or agent creating the lock. Defaults to `"forge-ts lock"`.
|
|
794
884
|
* @returns A new lock manifest ready to be written with {@link writeLockFile}.
|
|
885
|
+
* @see {@link ForgeLockManifest}
|
|
886
|
+
* @see {@link writeLockFile}
|
|
795
887
|
* @example
|
|
796
888
|
* ```typescript
|
|
797
889
|
* import { createLockManifest, loadConfig } from "@forge-ts/core";
|
|
798
890
|
* const config = await loadConfig();
|
|
799
|
-
* const manifest = createLockManifest(config);
|
|
800
|
-
* console.log(manifest.config.rules);
|
|
891
|
+
* const manifest = createLockManifest(config, "alice");
|
|
892
|
+
* console.log(manifest.config.rules);
|
|
801
893
|
* ```
|
|
894
|
+
* @since 0.10.0
|
|
802
895
|
* @public
|
|
803
896
|
*/
|
|
804
897
|
declare function createLockManifest(config: ForgeConfig, lockedBy?: string): ForgeLockManifest;
|
|
805
898
|
/**
|
|
806
899
|
* Validates the current config against a locked manifest.
|
|
807
900
|
*
|
|
901
|
+
* @remarks
|
|
808
902
|
* Returns an array of violations where the current config has weakened
|
|
809
903
|
* settings relative to the locked state. Weakening means:
|
|
810
904
|
* - A rule severity changed from `"error"` to `"warn"` or `"off"`
|
|
@@ -817,6 +911,8 @@ declare function createLockManifest(config: ForgeConfig, lockedBy?: string): For
|
|
|
817
911
|
* @param config - The current fully-resolved {@link ForgeConfig}.
|
|
818
912
|
* @param lock - The lock manifest to validate against.
|
|
819
913
|
* @returns An array of {@link LockViolation} entries. Empty means no weakening detected.
|
|
914
|
+
* @see {@link LockViolation}
|
|
915
|
+
* @see {@link ForgeLockManifest}
|
|
820
916
|
* @example
|
|
821
917
|
* ```typescript
|
|
822
918
|
* import { validateAgainstLock, readLockFile, loadConfig } from "@forge-ts/core";
|
|
@@ -829,6 +925,7 @@ declare function createLockManifest(config: ForgeConfig, lockedBy?: string): For
|
|
|
829
925
|
* }
|
|
830
926
|
* }
|
|
831
927
|
* ```
|
|
928
|
+
* @since 0.10.0
|
|
832
929
|
* @public
|
|
833
930
|
*/
|
|
834
931
|
declare function validateAgainstLock(config: ForgeConfig, lock: ForgeLockManifest): LockViolation[];
|
|
@@ -844,42 +941,89 @@ declare function validateAgainstLock(config: ForgeConfig, lock: ForgeLockManifes
|
|
|
844
941
|
*/
|
|
845
942
|
/**
|
|
846
943
|
* OpenAPI 3.2 schema object.
|
|
944
|
+
* @since 0.1.0
|
|
847
945
|
* @public
|
|
848
946
|
*/
|
|
849
947
|
interface OpenAPISchemaObject {
|
|
850
|
-
/**
|
|
948
|
+
/**
|
|
949
|
+
* The data type of the schema (e.g., "string", "number", "object", "array").
|
|
950
|
+
* @defaultValue undefined
|
|
951
|
+
*/
|
|
851
952
|
type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
852
|
-
/**
|
|
953
|
+
/**
|
|
954
|
+
* A format hint for the data type (e.g., "int32", "date-time", "email", "uuid").
|
|
955
|
+
* @defaultValue undefined
|
|
956
|
+
*/
|
|
853
957
|
format?: string;
|
|
854
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* A human-readable description of the schema's purpose or constraints.
|
|
960
|
+
* @defaultValue undefined
|
|
961
|
+
*/
|
|
855
962
|
description?: string;
|
|
856
|
-
/**
|
|
963
|
+
/**
|
|
964
|
+
* Property definitions for object-type schemas. Maps each property name to its schema.
|
|
965
|
+
* @defaultValue undefined
|
|
966
|
+
*/
|
|
857
967
|
properties?: Record<string, OpenAPISchemaObject>;
|
|
858
|
-
/**
|
|
968
|
+
/**
|
|
969
|
+
* List of property names that must be present on the object.
|
|
970
|
+
* @defaultValue undefined
|
|
971
|
+
*/
|
|
859
972
|
required?: string[];
|
|
860
|
-
/**
|
|
973
|
+
/**
|
|
974
|
+
* Schema definition for the elements of an array-type schema. Required when `type` is "array".
|
|
975
|
+
* @defaultValue undefined
|
|
976
|
+
*/
|
|
861
977
|
items?: OpenAPISchemaObject;
|
|
862
|
-
/**
|
|
978
|
+
/**
|
|
979
|
+
* Controls whether additional properties are allowed (`true`/`false`) or defines their schema.
|
|
980
|
+
* @defaultValue undefined
|
|
981
|
+
*/
|
|
863
982
|
additionalProperties?: boolean | OpenAPISchemaObject;
|
|
864
|
-
/**
|
|
983
|
+
/**
|
|
984
|
+
* Restricts the value to one of the listed constants.
|
|
985
|
+
* @defaultValue undefined
|
|
986
|
+
*/
|
|
865
987
|
enum?: Array<string | number | boolean>;
|
|
866
|
-
/**
|
|
988
|
+
/**
|
|
989
|
+
* Validates the value against exactly one of the listed sub-schemas.
|
|
990
|
+
* @defaultValue undefined
|
|
991
|
+
*/
|
|
867
992
|
oneOf?: OpenAPISchemaObject[];
|
|
868
|
-
/**
|
|
993
|
+
/**
|
|
994
|
+
* Validates the value against all of the listed sub-schemas (intersection).
|
|
995
|
+
* @defaultValue undefined
|
|
996
|
+
*/
|
|
869
997
|
allOf?: OpenAPISchemaObject[];
|
|
870
|
-
/**
|
|
998
|
+
/**
|
|
999
|
+
* Validates the value against at least one of the listed sub-schemas.
|
|
1000
|
+
* @defaultValue undefined
|
|
1001
|
+
*/
|
|
871
1002
|
anyOf?: OpenAPISchemaObject[];
|
|
872
|
-
/**
|
|
1003
|
+
/**
|
|
1004
|
+
* Indicates that the value may be `null` in addition to its declared type.
|
|
1005
|
+
* @defaultValue undefined
|
|
1006
|
+
*/
|
|
873
1007
|
nullable?: boolean;
|
|
874
|
-
/**
|
|
1008
|
+
/**
|
|
1009
|
+
* Marks the schema as deprecated, signalling that it may be removed in a future version.
|
|
1010
|
+
* @defaultValue undefined
|
|
1011
|
+
*/
|
|
875
1012
|
deprecated?: boolean;
|
|
876
|
-
/**
|
|
1013
|
+
/**
|
|
1014
|
+
* The default value to use when the property is absent.
|
|
1015
|
+
* @defaultValue undefined
|
|
1016
|
+
*/
|
|
877
1017
|
default?: string | number | boolean | null;
|
|
878
|
-
/**
|
|
1018
|
+
/**
|
|
1019
|
+
* A JSON Reference (`$ref`) pointing to another schema definition in the document.
|
|
1020
|
+
* @defaultValue undefined
|
|
1021
|
+
*/
|
|
879
1022
|
$ref?: string;
|
|
880
1023
|
}
|
|
881
1024
|
/**
|
|
882
1025
|
* OpenAPI 3.2 info object.
|
|
1026
|
+
* @since 0.1.0
|
|
883
1027
|
* @public
|
|
884
1028
|
*/
|
|
885
1029
|
interface OpenAPIInfoObject {
|
|
@@ -887,11 +1031,20 @@ interface OpenAPIInfoObject {
|
|
|
887
1031
|
title: string;
|
|
888
1032
|
/** The version string for the API (e.g., "1.0.0"). */
|
|
889
1033
|
version: string;
|
|
890
|
-
/**
|
|
1034
|
+
/**
|
|
1035
|
+
* A detailed description of the API, supporting CommonMark markdown.
|
|
1036
|
+
* @defaultValue undefined
|
|
1037
|
+
*/
|
|
891
1038
|
description?: string;
|
|
892
|
-
/**
|
|
1039
|
+
/**
|
|
1040
|
+
* A short summary of the API, intended for display in tooling.
|
|
1041
|
+
* @defaultValue undefined
|
|
1042
|
+
*/
|
|
893
1043
|
summary?: string;
|
|
894
|
-
/**
|
|
1044
|
+
/**
|
|
1045
|
+
* Licensing information for the exposed API, including name, URL, and SPDX identifier.
|
|
1046
|
+
* @defaultValue undefined
|
|
1047
|
+
*/
|
|
895
1048
|
license?: {
|
|
896
1049
|
name: string;
|
|
897
1050
|
url?: string;
|
|
@@ -900,64 +1053,125 @@ interface OpenAPIInfoObject {
|
|
|
900
1053
|
}
|
|
901
1054
|
/**
|
|
902
1055
|
* OpenAPI 3.2 tag object.
|
|
1056
|
+
* @since 0.1.0
|
|
903
1057
|
* @public
|
|
904
1058
|
*/
|
|
905
1059
|
interface OpenAPITagObject {
|
|
906
1060
|
/** The name of the tag, used to group operations in the document. */
|
|
907
1061
|
name: string;
|
|
908
|
-
/**
|
|
1062
|
+
/**
|
|
1063
|
+
* An optional description of the tag, supporting CommonMark markdown.
|
|
1064
|
+
* @defaultValue undefined
|
|
1065
|
+
*/
|
|
909
1066
|
description?: string;
|
|
910
1067
|
}
|
|
911
1068
|
/**
|
|
912
1069
|
* OpenAPI 3.2 path item object.
|
|
1070
|
+
* @since 0.1.0
|
|
913
1071
|
* @public
|
|
914
1072
|
*/
|
|
915
1073
|
interface OpenAPIPathItemObject {
|
|
916
|
-
/**
|
|
1074
|
+
/**
|
|
1075
|
+
* A short summary of the path item, intended for tooling display.
|
|
1076
|
+
* @defaultValue undefined
|
|
1077
|
+
*/
|
|
917
1078
|
summary?: string;
|
|
918
|
-
/**
|
|
1079
|
+
/**
|
|
1080
|
+
* A detailed description of the path item, supporting CommonMark markdown.
|
|
1081
|
+
* @defaultValue undefined
|
|
1082
|
+
*/
|
|
919
1083
|
description?: string;
|
|
920
|
-
/**
|
|
1084
|
+
/**
|
|
1085
|
+
* The operation definition for HTTP GET requests to this path.
|
|
1086
|
+
* @defaultValue undefined
|
|
1087
|
+
*/
|
|
921
1088
|
get?: OpenAPIOperationObject;
|
|
922
|
-
/**
|
|
1089
|
+
/**
|
|
1090
|
+
* The operation definition for HTTP POST requests to this path.
|
|
1091
|
+
* @defaultValue undefined
|
|
1092
|
+
*/
|
|
923
1093
|
post?: OpenAPIOperationObject;
|
|
924
|
-
/**
|
|
1094
|
+
/**
|
|
1095
|
+
* The operation definition for HTTP PUT requests to this path.
|
|
1096
|
+
* @defaultValue undefined
|
|
1097
|
+
*/
|
|
925
1098
|
put?: OpenAPIOperationObject;
|
|
926
|
-
/**
|
|
1099
|
+
/**
|
|
1100
|
+
* The operation definition for HTTP DELETE requests to this path.
|
|
1101
|
+
* @defaultValue undefined
|
|
1102
|
+
*/
|
|
927
1103
|
delete?: OpenAPIOperationObject;
|
|
928
|
-
/**
|
|
1104
|
+
/**
|
|
1105
|
+
* The operation definition for HTTP PATCH requests to this path.
|
|
1106
|
+
* @defaultValue undefined
|
|
1107
|
+
*/
|
|
929
1108
|
patch?: OpenAPIOperationObject;
|
|
930
|
-
/**
|
|
1109
|
+
/**
|
|
1110
|
+
* The operation definition for HTTP OPTIONS requests to this path.
|
|
1111
|
+
* @defaultValue undefined
|
|
1112
|
+
*/
|
|
931
1113
|
options?: OpenAPIOperationObject;
|
|
932
|
-
/**
|
|
1114
|
+
/**
|
|
1115
|
+
* The operation definition for HTTP HEAD requests to this path.
|
|
1116
|
+
* @defaultValue undefined
|
|
1117
|
+
*/
|
|
933
1118
|
head?: OpenAPIOperationObject;
|
|
934
|
-
/**
|
|
1119
|
+
/**
|
|
1120
|
+
* The operation definition for HTTP TRACE requests to this path.
|
|
1121
|
+
* @defaultValue undefined
|
|
1122
|
+
*/
|
|
935
1123
|
trace?: OpenAPIOperationObject;
|
|
936
|
-
/**
|
|
1124
|
+
/**
|
|
1125
|
+
* The operation definition for HTTP QUERY requests to this path (OpenAPI 3.2 extension).
|
|
1126
|
+
* @defaultValue undefined
|
|
1127
|
+
*/
|
|
937
1128
|
query?: OpenAPIOperationObject;
|
|
938
|
-
/**
|
|
1129
|
+
/**
|
|
1130
|
+
* Additional non-standard HTTP method operations keyed by method name.
|
|
1131
|
+
* @defaultValue undefined
|
|
1132
|
+
*/
|
|
939
1133
|
additionalOperations?: Record<string, OpenAPIOperationObject>;
|
|
940
1134
|
}
|
|
941
1135
|
/**
|
|
942
1136
|
* OpenAPI 3.2 operation object.
|
|
1137
|
+
* @since 0.1.0
|
|
943
1138
|
* @public
|
|
944
1139
|
*/
|
|
945
1140
|
interface OpenAPIOperationObject {
|
|
946
|
-
/**
|
|
1141
|
+
/**
|
|
1142
|
+
* A unique string identifier for the operation, used by tooling to reference it.
|
|
1143
|
+
* @defaultValue undefined
|
|
1144
|
+
*/
|
|
947
1145
|
operationId?: string;
|
|
948
|
-
/**
|
|
1146
|
+
/**
|
|
1147
|
+
* A short, human-readable summary of what the operation does.
|
|
1148
|
+
* @defaultValue undefined
|
|
1149
|
+
*/
|
|
949
1150
|
summary?: string;
|
|
950
|
-
/**
|
|
1151
|
+
/**
|
|
1152
|
+
* A detailed description of the operation's behaviour, supporting CommonMark markdown.
|
|
1153
|
+
* @defaultValue undefined
|
|
1154
|
+
*/
|
|
951
1155
|
description?: string;
|
|
952
|
-
/**
|
|
1156
|
+
/**
|
|
1157
|
+
* A list of tag names that logically group this operation in documentation and tooling.
|
|
1158
|
+
* @defaultValue undefined
|
|
1159
|
+
*/
|
|
953
1160
|
tags?: string[];
|
|
954
|
-
/**
|
|
1161
|
+
/**
|
|
1162
|
+
* The list of parameters applicable to this operation.
|
|
1163
|
+
* @defaultValue undefined
|
|
1164
|
+
*/
|
|
955
1165
|
parameters?: OpenAPIParameterObject[];
|
|
956
|
-
/**
|
|
1166
|
+
/**
|
|
1167
|
+
* The possible responses returned by this operation, keyed by HTTP status code or "default".
|
|
1168
|
+
* @defaultValue undefined
|
|
1169
|
+
*/
|
|
957
1170
|
responses?: Record<string, OpenAPIResponseObject>;
|
|
958
1171
|
}
|
|
959
1172
|
/**
|
|
960
1173
|
* OpenAPI 3.2 parameter object.
|
|
1174
|
+
* @since 0.1.0
|
|
961
1175
|
* @public
|
|
962
1176
|
*/
|
|
963
1177
|
interface OpenAPIParameterObject {
|
|
@@ -965,98 +1179,151 @@ interface OpenAPIParameterObject {
|
|
|
965
1179
|
name: string;
|
|
966
1180
|
/** The location of the parameter: path, query, header, cookie, or querystring. */
|
|
967
1181
|
in: "query" | "header" | "path" | "cookie" | "querystring";
|
|
968
|
-
/**
|
|
1182
|
+
/**
|
|
1183
|
+
* A human-readable description of the parameter's purpose, supporting CommonMark markdown.
|
|
1184
|
+
* @defaultValue undefined
|
|
1185
|
+
*/
|
|
969
1186
|
description?: string;
|
|
970
|
-
/**
|
|
1187
|
+
/**
|
|
1188
|
+
* Whether the parameter is mandatory. Required for `in: "path"` parameters.
|
|
1189
|
+
* @defaultValue undefined
|
|
1190
|
+
*/
|
|
971
1191
|
required?: boolean;
|
|
972
|
-
/**
|
|
1192
|
+
/**
|
|
1193
|
+
* The schema defining the type and constraints of the parameter value.
|
|
1194
|
+
* @defaultValue undefined
|
|
1195
|
+
*/
|
|
973
1196
|
schema?: OpenAPISchemaObject;
|
|
974
|
-
/**
|
|
1197
|
+
/**
|
|
1198
|
+
* Marks the parameter as deprecated; clients should avoid using it.
|
|
1199
|
+
* @defaultValue undefined
|
|
1200
|
+
*/
|
|
975
1201
|
deprecated?: boolean;
|
|
976
1202
|
}
|
|
977
1203
|
/**
|
|
978
1204
|
* OpenAPI 3.2 encoding object.
|
|
1205
|
+
* @since 0.1.0
|
|
979
1206
|
* @public
|
|
980
1207
|
*/
|
|
981
1208
|
interface OpenAPIEncodingObject {
|
|
982
|
-
/**
|
|
1209
|
+
/**
|
|
1210
|
+
* The MIME type to use for encoding a specific property (e.g., "application/json").
|
|
1211
|
+
* @defaultValue undefined
|
|
1212
|
+
*/
|
|
983
1213
|
contentType?: string;
|
|
984
|
-
/**
|
|
1214
|
+
/**
|
|
1215
|
+
* Additional headers to send alongside the encoded part, keyed by header name.
|
|
1216
|
+
* @defaultValue undefined
|
|
1217
|
+
*/
|
|
985
1218
|
headers?: Record<string, OpenAPIParameterObject>;
|
|
986
|
-
/**
|
|
1219
|
+
/**
|
|
1220
|
+
* The serialization style for the encoded value (e.g., "form", "spaceDelimited").
|
|
1221
|
+
* @defaultValue undefined
|
|
1222
|
+
*/
|
|
987
1223
|
style?: string;
|
|
988
|
-
/**
|
|
1224
|
+
/**
|
|
1225
|
+
* Whether arrays and objects should be exploded into separate query parameters.
|
|
1226
|
+
* @defaultValue undefined
|
|
1227
|
+
*/
|
|
989
1228
|
explode?: boolean;
|
|
990
|
-
/**
|
|
1229
|
+
/**
|
|
1230
|
+
* Whether reserved characters in the encoded value should be allowed without percent-encoding.
|
|
1231
|
+
* @defaultValue undefined
|
|
1232
|
+
*/
|
|
991
1233
|
allowReserved?: boolean;
|
|
992
1234
|
}
|
|
993
1235
|
/**
|
|
994
1236
|
* OpenAPI 3.2 media type object.
|
|
1237
|
+
* @since 0.1.0
|
|
995
1238
|
* @public
|
|
996
1239
|
*/
|
|
997
1240
|
interface OpenAPIMediaTypeObject {
|
|
998
|
-
/**
|
|
1241
|
+
/**
|
|
1242
|
+
* The schema defining the structure and type of the media type's payload.
|
|
1243
|
+
* @defaultValue undefined
|
|
1244
|
+
*/
|
|
999
1245
|
schema?: OpenAPISchemaObject;
|
|
1000
|
-
/**
|
|
1246
|
+
/**
|
|
1247
|
+
* Encoding information for specific properties of a `multipart` or `application/x-www-form-urlencoded` request body.
|
|
1248
|
+
* @defaultValue undefined
|
|
1249
|
+
*/
|
|
1001
1250
|
encoding?: Record<string, OpenAPIEncodingObject>;
|
|
1002
1251
|
}
|
|
1003
1252
|
/**
|
|
1004
1253
|
* OpenAPI 3.2 response object.
|
|
1254
|
+
* @since 0.1.0
|
|
1005
1255
|
* @public
|
|
1006
1256
|
*/
|
|
1007
1257
|
interface OpenAPIResponseObject {
|
|
1008
1258
|
/** A required human-readable description of the response, supporting CommonMark markdown. */
|
|
1009
1259
|
description: string;
|
|
1010
|
-
/**
|
|
1260
|
+
/**
|
|
1261
|
+
* HTTP headers returned with this response, keyed by header name.
|
|
1262
|
+
* @defaultValue undefined
|
|
1263
|
+
*/
|
|
1011
1264
|
headers?: Record<string, OpenAPIParameterObject>;
|
|
1012
|
-
/**
|
|
1265
|
+
/**
|
|
1266
|
+
* The response body content, keyed by media type (e.g., "application/json").
|
|
1267
|
+
* @defaultValue undefined
|
|
1268
|
+
*/
|
|
1013
1269
|
content?: Record<string, OpenAPIMediaTypeObject>;
|
|
1014
1270
|
}
|
|
1015
1271
|
/**
|
|
1016
1272
|
* Complete OpenAPI 3.2 document.
|
|
1273
|
+
* @since 0.1.0
|
|
1017
1274
|
* @public
|
|
1018
1275
|
*/
|
|
1019
1276
|
interface OpenAPIDocument {
|
|
1020
1277
|
/** The OpenAPI specification version this document conforms to. Must be "3.2.0". */
|
|
1021
1278
|
openapi: "3.2.0";
|
|
1022
|
-
/**
|
|
1279
|
+
/**
|
|
1280
|
+
* An optional self-referencing URL for this document, used for tooling and resolution.
|
|
1281
|
+
* @defaultValue undefined
|
|
1282
|
+
*/
|
|
1023
1283
|
$self?: string;
|
|
1024
1284
|
/** Metadata about the API including title, version, and description. */
|
|
1025
1285
|
info: OpenAPIInfoObject;
|
|
1026
|
-
/** The available paths and their operations, keyed by path template (e.g.,
|
|
1286
|
+
/** The available paths and their operations, keyed by path template (e.g., `/users/\{id\}`). */
|
|
1027
1287
|
paths: Record<string, OpenAPIPathItemObject>;
|
|
1028
1288
|
/** Reusable schema and media type definitions shared across the document. */
|
|
1029
1289
|
components: {
|
|
1030
1290
|
schemas: Record<string, OpenAPISchemaObject>;
|
|
1031
1291
|
mediaTypes?: Record<string, OpenAPIMediaTypeObject>;
|
|
1032
1292
|
};
|
|
1033
|
-
/**
|
|
1293
|
+
/**
|
|
1294
|
+
* A list of tags used to group operations, with optional descriptions.
|
|
1295
|
+
* @defaultValue undefined
|
|
1296
|
+
*/
|
|
1034
1297
|
tags?: OpenAPITagObject[];
|
|
1035
1298
|
}
|
|
1036
1299
|
|
|
1037
1300
|
/**
|
|
1038
1301
|
* Determines the visibility level of a symbol from its TSDoc release tags.
|
|
1039
1302
|
*
|
|
1303
|
+
* @remarks
|
|
1040
1304
|
* The precedence order is:
|
|
1041
|
-
* 1.
|
|
1042
|
-
* 2.
|
|
1043
|
-
* 3.
|
|
1305
|
+
* 1. `\@internal` → {@link Visibility.Internal}
|
|
1306
|
+
* 2. `\@beta` → {@link Visibility.Beta}
|
|
1307
|
+
* 3. `\@public` → {@link Visibility.Public}
|
|
1044
1308
|
* 4. (no tag) → {@link Visibility.Public} (default for exports)
|
|
1045
1309
|
*
|
|
1046
1310
|
* @param tags - The parsed `tags` map from `ForgeSymbol.documentation`.
|
|
1047
1311
|
* @returns The resolved {@link Visibility} value.
|
|
1312
|
+
* @see {@link Visibility}
|
|
1048
1313
|
* @example
|
|
1049
1314
|
* ```typescript
|
|
1050
1315
|
* import { resolveVisibility } from "@forge-ts/core";
|
|
1051
1316
|
* const vis = resolveVisibility({ internal: [] });
|
|
1052
1317
|
* // vis === Visibility.Internal
|
|
1053
1318
|
* ```
|
|
1319
|
+
* @since 0.1.0
|
|
1054
1320
|
* @public
|
|
1055
1321
|
*/
|
|
1056
1322
|
declare function resolveVisibility(tags: Record<string, string[]> | undefined): Visibility;
|
|
1057
1323
|
/**
|
|
1058
1324
|
* Returns whether `candidate` meets or exceeds the required minimum visibility.
|
|
1059
1325
|
*
|
|
1326
|
+
* @remarks
|
|
1060
1327
|
* "Meets" means the symbol is at least as visible as `minVisibility`.
|
|
1061
1328
|
* For example, `Public` meets a minimum of `Public`, but `Internal` does not.
|
|
1062
1329
|
*
|
|
@@ -1066,6 +1333,7 @@ declare function resolveVisibility(tags: Record<string, string[]> | undefined):
|
|
|
1066
1333
|
* @param candidate - The visibility of the symbol being tested.
|
|
1067
1334
|
* @param minVisibility - The minimum visibility threshold.
|
|
1068
1335
|
* @returns `true` if `candidate` is at least as visible as `minVisibility`.
|
|
1336
|
+
* @see {@link Visibility}
|
|
1069
1337
|
* @example
|
|
1070
1338
|
* ```typescript
|
|
1071
1339
|
* import { meetsVisibility, Visibility } from "@forge-ts/core";
|
|
@@ -1073,6 +1341,7 @@ declare function resolveVisibility(tags: Record<string, string[]> | undefined):
|
|
|
1073
1341
|
* meetsVisibility(Visibility.Internal, Visibility.Public); // false
|
|
1074
1342
|
* meetsVisibility("public", "beta"); // true (string literals also accepted)
|
|
1075
1343
|
* ```
|
|
1344
|
+
* @since 0.1.0
|
|
1076
1345
|
* @public
|
|
1077
1346
|
*/
|
|
1078
1347
|
declare function meetsVisibility(candidate: Visibility | "public" | "beta" | "internal" | "private", minVisibility: Visibility | "public" | "beta" | "internal" | "private"): boolean;
|
|
@@ -1080,14 +1349,20 @@ declare function meetsVisibility(candidate: Visibility | "public" | "beta" | "in
|
|
|
1080
1349
|
* Filters an array of {@link ForgeSymbol} objects to only include symbols
|
|
1081
1350
|
* whose visibility meets or exceeds `minVisibility`.
|
|
1082
1351
|
*
|
|
1352
|
+
* @remarks
|
|
1353
|
+
* Returns a new array — the original is not modified.
|
|
1354
|
+
*
|
|
1083
1355
|
* @param symbols - The full list of symbols to filter.
|
|
1084
1356
|
* @param minVisibility - The minimum visibility threshold to keep.
|
|
1085
1357
|
* @returns A new array containing only symbols that pass the visibility check.
|
|
1358
|
+
* @see {@link meetsVisibility}
|
|
1359
|
+
* @see {@link ForgeSymbol}
|
|
1086
1360
|
* @example
|
|
1087
1361
|
* ```typescript
|
|
1088
1362
|
* import { filterByVisibility, Visibility } from "@forge-ts/core";
|
|
1089
1363
|
* const publicOnly = filterByVisibility(symbols, Visibility.Public);
|
|
1090
1364
|
* ```
|
|
1365
|
+
* @since 0.1.0
|
|
1091
1366
|
* @public
|
|
1092
1367
|
*/
|
|
1093
1368
|
declare function filterByVisibility(symbols: ForgeSymbol[], minVisibility: Visibility | "public" | "beta" | "internal" | "private"): ForgeSymbol[];
|
|
@@ -1113,6 +1388,8 @@ declare function clearTSDocConfigCache(): void;
|
|
|
1113
1388
|
declare function loadTSDocConfiguration(folderPath: string): TSDocConfiguration;
|
|
1114
1389
|
/**
|
|
1115
1390
|
* The return type of {@link createWalker}.
|
|
1391
|
+
* @see {@link createWalker}
|
|
1392
|
+
* @since 0.1.0
|
|
1116
1393
|
* @public
|
|
1117
1394
|
*/
|
|
1118
1395
|
interface ASTWalker {
|
|
@@ -1125,6 +1402,7 @@ interface ASTWalker {
|
|
|
1125
1402
|
/**
|
|
1126
1403
|
* Creates an {@link ASTWalker} configured for the given forge config.
|
|
1127
1404
|
*
|
|
1405
|
+
* @remarks
|
|
1128
1406
|
* The walker uses the TypeScript Compiler API to create a `ts.Program` from
|
|
1129
1407
|
* the project's tsconfig, then visits every source file to extract exported
|
|
1130
1408
|
* declarations. TSDoc comments are parsed with `@microsoft/tsdoc` to
|
|
@@ -1132,6 +1410,9 @@ interface ASTWalker {
|
|
|
1132
1410
|
*
|
|
1133
1411
|
* @param config - The resolved {@link ForgeConfig} for the project.
|
|
1134
1412
|
* @returns An {@link ASTWalker} instance whose `walk()` method performs the extraction.
|
|
1413
|
+
* @see {@link ASTWalker}
|
|
1414
|
+
* @see {@link ForgeConfig}
|
|
1415
|
+
* @see {@link ForgeSymbol}
|
|
1135
1416
|
* @example
|
|
1136
1417
|
* ```typescript
|
|
1137
1418
|
* import { loadConfig, createWalker } from "@forge-ts/core";
|
|
@@ -1140,6 +1421,7 @@ interface ASTWalker {
|
|
|
1140
1421
|
* const symbols = walker.walk();
|
|
1141
1422
|
* console.log(`Found ${symbols.length} symbols`);
|
|
1142
1423
|
* ```
|
|
1424
|
+
* @since 0.1.0
|
|
1143
1425
|
* @public
|
|
1144
1426
|
*/
|
|
1145
1427
|
declare function createWalker(config: ForgeConfig): ASTWalker;
|