@skmtc/core 0.0.789 → 0.0.790

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.
@@ -1 +1 @@
1
- {"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAA;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,cAAc,CAAC,EAAE,kBAAkB,CAAA;IACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,oBA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkLG;AACH,qBAAa,aAAa;;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAA;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAEjD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAElB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;gBACtC,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,MAAM,EACN,UAAU,EACV,oBAAoB,EACrB,EAAE,eAAe;IAWZ,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAiBhD,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAuC3C,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ;IAU1C,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAO7D"}
@@ -56,6 +56,185 @@ const toResolvedArtifactPath_js_1 = require("../helpers/toResolvedArtifactPath.j
56
56
  const tracer_js_1 = require("../helpers/tracer.js");
57
57
  const File_js_1 = require("../dsl/File.js");
58
58
  const prettier = __importStar(require("prettier"));
59
+ /**
60
+ * The rendering context for the final phase of the SKMTC transformation pipeline.
61
+ *
62
+ * `RenderContext` is responsible for taking the generated artifacts from the generation
63
+ * phase and rendering them into their final form with proper formatting, path resolution,
64
+ * and file preparation. It handles code formatting via Prettier, path normalization,
65
+ * and produces the final artifacts ready for writing to the filesystem.
66
+ *
67
+ * This context represents the culmination of the three-phase SKMTC pipeline, transforming
68
+ * generator outputs into production-ready code files with proper formatting and structure.
69
+ *
70
+ * ## Key Features
71
+ *
72
+ * - **Code Formatting**: Automatic Prettier formatting for generated TypeScript/JavaScript code
73
+ * - **Path Resolution**: Intelligent path resolution with base path support
74
+ * - **Content Collation**: Combines all generated content into organized file structures
75
+ * - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
76
+ * - **Error Tracking**: Comprehensive error handling with Sentry integration
77
+ * - **Performance Monitoring**: Built-in tracing and performance measurement
78
+ *
79
+ * @example Basic rendering usage
80
+ * ```typescript
81
+ * import { RenderContext } from '@skmtc/core';
82
+ *
83
+ * const renderContext = new RenderContext({
84
+ * files: generatedFiles,
85
+ * previews: previewData,
86
+ * mappings: mappingData,
87
+ * prettierConfig: {
88
+ * semi: false,
89
+ * singleQuote: true,
90
+ * trailingComma: 'all'
91
+ * },
92
+ * basePath: './src/generated',
93
+ * stackTrail: traceStack,
94
+ * logger: myLogger,
95
+ * captureCurrentResult: (result) => console.log(result)
96
+ * });
97
+ *
98
+ * const rendered = await renderContext.render();
99
+ *
100
+ * // Access rendered files
101
+ * Object.entries(rendered.artifacts).forEach(([path, content]) => {
102
+ * console.log(`Rendered ${path}: ${rendered.files[path].lines} lines`);
103
+ * // Write to filesystem
104
+ * await Deno.writeTextFile(path, content);
105
+ * });
106
+ * ```
107
+ *
108
+ * @example With custom Prettier configuration
109
+ * ```typescript
110
+ * const renderContext = new RenderContext({
111
+ * files: generatedFiles,
112
+ * previews: {},
113
+ * mappings: {},
114
+ * prettierConfig: {
115
+ * parser: 'typescript',
116
+ * printWidth: 120,
117
+ * tabWidth: 2,
118
+ * semi: true,
119
+ * singleQuote: true,
120
+ * trailingComma: 'es5',
121
+ * bracketSpacing: true,
122
+ * arrowParens: 'avoid'
123
+ * },
124
+ * basePath: './packages/api-client/src',
125
+ * stackTrail: stack,
126
+ * logger: logger,
127
+ * captureCurrentResult: resultHandler
128
+ * });
129
+ *
130
+ * const result = await renderContext.render();
131
+ *
132
+ * // All TypeScript files are automatically formatted
133
+ * console.log('Formatted files:', Object.keys(result.artifacts).length);
134
+ * ```
135
+ *
136
+ * @example Processing render results
137
+ * ```typescript
138
+ * const rendered = await renderContext.render();
139
+ *
140
+ * // Analyze file statistics
141
+ * const totalLines = Object.values(rendered.files)
142
+ * .reduce((sum, file) => sum + file.lines, 0);
143
+ * const totalChars = Object.values(rendered.files)
144
+ * .reduce((sum, file) => sum + file.characters, 0);
145
+ *
146
+ * console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
147
+ * console.log(`Total lines: ${totalLines}`);
148
+ * console.log(`Total characters: ${totalChars}`);
149
+ *
150
+ * // Check for large files
151
+ * const largeFiles = Object.entries(rendered.files)
152
+ * .filter(([_, metadata]) => metadata.lines > 1000)
153
+ * .map(([path, metadata]) => ({ path, lines: metadata.lines }));
154
+ *
155
+ * if (largeFiles.length > 0) {
156
+ * console.log('Large files detected:', largeFiles);
157
+ * }
158
+ *
159
+ * // Access preview and mapping data
160
+ * console.log('Previews available:', Object.keys(rendered.previews));
161
+ * console.log('Mappings available:', Object.keys(rendered.mappings));
162
+ * ```
163
+ *
164
+ * @example Integration with CoreContext
165
+ * ```typescript
166
+ * // Typically used within CoreContext.toArtifacts()
167
+ * class CustomCoreContext extends CoreContext {
168
+ * async renderWithPostProcessing(
169
+ * files: Map<string, File | JsonFile>,
170
+ * previews: Record<string, Record<string, Preview>>,
171
+ * mappings: Record<string, Record<string, Mapping>>
172
+ * ) {
173
+ * const renderContext = new RenderContext({
174
+ * files,
175
+ * previews,
176
+ * mappings,
177
+ * prettierConfig: this.prettierConfig,
178
+ * basePath: this.settings?.basePath,
179
+ * stackTrail: this.stackTrail,
180
+ * logger: this.logger,
181
+ * captureCurrentResult: this.captureCurrentResult.bind(this)
182
+ * });
183
+ *
184
+ * const rendered = await renderContext.render();
185
+ *
186
+ * // Post-process rendered files
187
+ * const processedArtifacts: Record<string, string> = {};
188
+ *
189
+ * for (const [path, content] of Object.entries(rendered.artifacts)) {
190
+ * // Add file headers, license notices, etc.
191
+ * const processedContent = this.addFileHeader(content, path);
192
+ * processedArtifacts[path] = processedContent;
193
+ * }
194
+ *
195
+ * return {
196
+ * ...rendered,
197
+ * artifacts: processedArtifacts
198
+ * };
199
+ * }
200
+ * }
201
+ * ```
202
+ *
203
+ * @example Error handling during rendering
204
+ * ```typescript
205
+ * try {
206
+ * const renderContext = new RenderContext({
207
+ * files: generatedFiles,
208
+ * previews: {},
209
+ * mappings: {},
210
+ * prettierConfig: prettierConfig,
211
+ * basePath: './invalid-path', // This might cause issues
212
+ * stackTrail: stack,
213
+ * logger: logger,
214
+ * captureCurrentResult: (result) => {
215
+ * if (result === 'error') {
216
+ * console.error('Render error detected');
217
+ * }
218
+ * }
219
+ * });
220
+ *
221
+ * const result = await renderContext.render();
222
+ *
223
+ * // Check if any files failed to render
224
+ * const failedFiles = Object.entries(result.files)
225
+ * .filter(([path, metadata]) => metadata.lines === 0)
226
+ * .map(([path]) => path);
227
+ *
228
+ * if (failedFiles.length > 0) {
229
+ * console.warn('Files with no content:', failedFiles);
230
+ * }
231
+ *
232
+ * } catch (error) {
233
+ * console.error('Render operation failed:', error);
234
+ * // Sentry automatically captures the error
235
+ * }
236
+ * ```
237
+ */
59
238
  class RenderContext {
60
239
  constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
61
240
  Object.defineProperty(this, "files", {
@@ -2,17 +2,158 @@ import "../../_dnt.polyfills.js";
2
2
  import type { OpenAPIV3 } from 'openapi-types';
3
3
  import type { OasRef } from '../ref/Ref.js';
4
4
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
5
+ /**
6
+ * Constructor fields for {@link OasBoolean}.
7
+ *
8
+ * @template Nullable - Whether the boolean can be null (affects type unions)
9
+ */
5
10
  export type BooleanFields<Nullable extends boolean | undefined> = {
11
+ /** A short summary of the boolean schema */
6
12
  title?: string;
13
+ /** A description of the boolean schema */
7
14
  description?: string;
15
+ /** Whether the boolean value can be null */
8
16
  nullable?: Nullable;
17
+ /** Custom extension fields (x-* properties) */
9
18
  extensionFields?: Record<string, unknown>;
19
+ /** Example value for the boolean (null allowed if Nullable is true) */
10
20
  example?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
21
+ /** Array of valid enum values for the boolean (null allowed if Nullable is true) */
11
22
  enums?: Nullable extends true ? (boolean | null)[] | undefined : boolean[] | undefined;
23
+ /** Default value for the boolean (null allowed if Nullable is true) */
12
24
  default?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
13
25
  };
14
26
  /**
15
- * Object representing a boolean in the OpenAPI Specification.
27
+ * Represents a boolean schema in the OpenAPI Specification.
28
+ *
29
+ * The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
30
+ * both simple true/false values and more complex boolean schemas with constraints,
31
+ * enumerations, and nullable types. This class provides type-safe boolean handling
32
+ * with optional null value support through generic typing.
33
+ *
34
+ * ## Key Features
35
+ *
36
+ * - **Type Safety**: Generic nullable type support with proper TypeScript inference
37
+ * - **Enum Support**: Constrain boolean values to specific true/false combinations
38
+ * - **Null Handling**: Optional null value support for nullable boolean types
39
+ * - **Validation**: Default values and example validation
40
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
41
+ * - **Documentation**: Rich metadata support for API documentation
42
+ *
43
+ * @template Nullable - Whether the boolean value itself can be null
44
+ *
45
+ * @example Basic boolean schema
46
+ * ```typescript
47
+ * import { OasBoolean } from '@skmtc/core';
48
+ *
49
+ * const isActiveSchema = new OasBoolean({
50
+ * title: 'Active Status',
51
+ * description: 'Whether the user account is active',
52
+ * default: true,
53
+ * example: true
54
+ * });
55
+ *
56
+ * // This represents: boolean with default true
57
+ * ```
58
+ *
59
+ * @example Nullable boolean schema
60
+ * ```typescript
61
+ * const nullableFlag = new OasBoolean<true>({
62
+ * title: 'Optional Flag',
63
+ * description: 'An optional boolean flag that can be null',
64
+ * nullable: true,
65
+ * default: null,
66
+ * example: true
67
+ * });
68
+ *
69
+ * // This represents: boolean | null
70
+ * ```
71
+ *
72
+ * @example Boolean with enum constraints
73
+ * ```typescript
74
+ * const strictBoolean = new OasBoolean({
75
+ * title: 'Confirmation',
76
+ * description: 'Must explicitly be true to confirm action',
77
+ * enums: [true], // Only true is allowed
78
+ * example: true
79
+ * });
80
+ *
81
+ * // This only accepts true, effectively making it required
82
+ * ```
83
+ *
84
+ * @example Boolean with null in enum
85
+ * ```typescript
86
+ * const triStateBoolean = new OasBoolean<true>({
87
+ * title: 'Approval Status',
88
+ * description: 'Approval can be true (approved), false (denied), or null (pending)',
89
+ * nullable: true,
90
+ * enums: [true, false, null],
91
+ * default: null,
92
+ * example: null
93
+ * });
94
+ *
95
+ * // This represents: true | false | null (tri-state logic)
96
+ * ```
97
+ *
98
+ * @example Feature flag schema
99
+ * ```typescript
100
+ * const featureFlag = new OasBoolean({
101
+ * title: 'Feature Enabled',
102
+ * description: 'Whether the new feature is enabled for this user',
103
+ * default: false,
104
+ * example: false
105
+ * });
106
+ *
107
+ * // Used in configuration objects
108
+ * const userConfig = new OasObject({
109
+ * properties: {
110
+ * darkMode: featureFlag,
111
+ * notifications: featureFlag,
112
+ * betaFeatures: featureFlag
113
+ * }
114
+ * });
115
+ * ```
116
+ *
117
+ * @example Consent and agreement booleans
118
+ * ```typescript
119
+ * const consentSchema = new OasBoolean({
120
+ * title: 'Terms Accepted',
121
+ * description: 'User has accepted the terms and conditions',
122
+ * enums: [true], // Must be true to be valid
123
+ * example: true
124
+ * });
125
+ *
126
+ * const privacyConsent = new OasBoolean({
127
+ * title: 'Privacy Policy Accepted',
128
+ * description: 'User has accepted the privacy policy',
129
+ * default: false,
130
+ * example: true
131
+ * });
132
+ *
133
+ * // Used in registration forms where consent is required
134
+ * ```
135
+ *
136
+ * @example Optional settings with nullable booleans
137
+ * ```typescript
138
+ * const userPreferences = new OasObject({
139
+ * properties: {
140
+ * emailNotifications: new OasBoolean<true>({
141
+ * title: 'Email Notifications',
142
+ * description: 'Enable email notifications (null means use default)',
143
+ * nullable: true,
144
+ * default: null
145
+ * }),
146
+ * smsNotifications: new OasBoolean<true>({
147
+ * title: 'SMS Notifications',
148
+ * description: 'Enable SMS notifications (null means not set)',
149
+ * nullable: true,
150
+ * default: null
151
+ * })
152
+ * }
153
+ * });
154
+ *
155
+ * // Allows: { emailNotifications: true, smsNotifications: null }
156
+ * ```
16
157
  */
17
158
  export declare class OasBoolean<Nullable extends boolean | undefined = boolean | undefined> {
18
159
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,OAAO,GAAG,SAAS,IAAI;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IAClF,KAAK,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;IACtF,OAAO,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AO,EAAG,QAAQ,CAAS;IAC3B;;OAEG;IACH,IAAI,EAAG,SAAS,CAAS;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;IAE9B,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IAEjF;;OAEG;IACH,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;IACrF;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;gBAErE,MAAM,GAAE,aAAa,CAAC,QAAQ,CAAM;IAUhD,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,UAAU,CAAC,QAAQ,CAAC;IAI/B,WAAW,IAAI,UAAU,CAAC,QAAQ,CAAC;IAKnC,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAW5E"}
@@ -3,7 +3,136 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OasBoolean = void 0;
4
4
  require("../../_dnt.polyfills.js");
5
5
  /**
6
- * Object representing a boolean in the OpenAPI Specification.
6
+ * Represents a boolean schema in the OpenAPI Specification.
7
+ *
8
+ * The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
9
+ * both simple true/false values and more complex boolean schemas with constraints,
10
+ * enumerations, and nullable types. This class provides type-safe boolean handling
11
+ * with optional null value support through generic typing.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Type Safety**: Generic nullable type support with proper TypeScript inference
16
+ * - **Enum Support**: Constrain boolean values to specific true/false combinations
17
+ * - **Null Handling**: Optional null value support for nullable boolean types
18
+ * - **Validation**: Default values and example validation
19
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
20
+ * - **Documentation**: Rich metadata support for API documentation
21
+ *
22
+ * @template Nullable - Whether the boolean value itself can be null
23
+ *
24
+ * @example Basic boolean schema
25
+ * ```typescript
26
+ * import { OasBoolean } from '@skmtc/core';
27
+ *
28
+ * const isActiveSchema = new OasBoolean({
29
+ * title: 'Active Status',
30
+ * description: 'Whether the user account is active',
31
+ * default: true,
32
+ * example: true
33
+ * });
34
+ *
35
+ * // This represents: boolean with default true
36
+ * ```
37
+ *
38
+ * @example Nullable boolean schema
39
+ * ```typescript
40
+ * const nullableFlag = new OasBoolean<true>({
41
+ * title: 'Optional Flag',
42
+ * description: 'An optional boolean flag that can be null',
43
+ * nullable: true,
44
+ * default: null,
45
+ * example: true
46
+ * });
47
+ *
48
+ * // This represents: boolean | null
49
+ * ```
50
+ *
51
+ * @example Boolean with enum constraints
52
+ * ```typescript
53
+ * const strictBoolean = new OasBoolean({
54
+ * title: 'Confirmation',
55
+ * description: 'Must explicitly be true to confirm action',
56
+ * enums: [true], // Only true is allowed
57
+ * example: true
58
+ * });
59
+ *
60
+ * // This only accepts true, effectively making it required
61
+ * ```
62
+ *
63
+ * @example Boolean with null in enum
64
+ * ```typescript
65
+ * const triStateBoolean = new OasBoolean<true>({
66
+ * title: 'Approval Status',
67
+ * description: 'Approval can be true (approved), false (denied), or null (pending)',
68
+ * nullable: true,
69
+ * enums: [true, false, null],
70
+ * default: null,
71
+ * example: null
72
+ * });
73
+ *
74
+ * // This represents: true | false | null (tri-state logic)
75
+ * ```
76
+ *
77
+ * @example Feature flag schema
78
+ * ```typescript
79
+ * const featureFlag = new OasBoolean({
80
+ * title: 'Feature Enabled',
81
+ * description: 'Whether the new feature is enabled for this user',
82
+ * default: false,
83
+ * example: false
84
+ * });
85
+ *
86
+ * // Used in configuration objects
87
+ * const userConfig = new OasObject({
88
+ * properties: {
89
+ * darkMode: featureFlag,
90
+ * notifications: featureFlag,
91
+ * betaFeatures: featureFlag
92
+ * }
93
+ * });
94
+ * ```
95
+ *
96
+ * @example Consent and agreement booleans
97
+ * ```typescript
98
+ * const consentSchema = new OasBoolean({
99
+ * title: 'Terms Accepted',
100
+ * description: 'User has accepted the terms and conditions',
101
+ * enums: [true], // Must be true to be valid
102
+ * example: true
103
+ * });
104
+ *
105
+ * const privacyConsent = new OasBoolean({
106
+ * title: 'Privacy Policy Accepted',
107
+ * description: 'User has accepted the privacy policy',
108
+ * default: false,
109
+ * example: true
110
+ * });
111
+ *
112
+ * // Used in registration forms where consent is required
113
+ * ```
114
+ *
115
+ * @example Optional settings with nullable booleans
116
+ * ```typescript
117
+ * const userPreferences = new OasObject({
118
+ * properties: {
119
+ * emailNotifications: new OasBoolean<true>({
120
+ * title: 'Email Notifications',
121
+ * description: 'Enable email notifications (null means use default)',
122
+ * nullable: true,
123
+ * default: null
124
+ * }),
125
+ * smsNotifications: new OasBoolean<true>({
126
+ * title: 'SMS Notifications',
127
+ * description: 'Enable SMS notifications (null means not set)',
128
+ * nullable: true,
129
+ * default: null
130
+ * })
131
+ * }
132
+ * });
133
+ *
134
+ * // Allows: { emailNotifications: true, smsNotifications: null }
135
+ * ```
7
136
  */
8
137
  class OasBoolean {
9
138
  constructor(fields = {}) {
@@ -6,21 +6,181 @@ import type { OasExample } from '../example/Example.js';
6
6
  import type { OasSchema } from '../schema/Schema.js';
7
7
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
8
8
  import type { OpenAPIV3 } from 'openapi-types';
9
+ /**
10
+ * Constructor fields for {@link OasParameter}.
11
+ */
9
12
  export type ParameterFields = {
13
+ /** The name of the parameter */
10
14
  name: string;
15
+ /** The location of the parameter (path, query, header, cookie) */
11
16
  location: OasParameterLocation;
17
+ /** A brief description of the parameter */
12
18
  description?: string | undefined;
19
+ /** Determines whether this parameter is mandatory */
13
20
  required?: boolean | undefined;
21
+ /** Specifies that the parameter is deprecated */
14
22
  deprecated?: boolean | undefined;
23
+ /** Whether to allow empty values for the parameter */
15
24
  allowEmptyValue?: boolean | undefined;
25
+ /** Whether reserved characters are allowed in the parameter value */
16
26
  allowReserved?: boolean | undefined;
27
+ /** The schema defining the parameter's data type */
17
28
  schema?: OasSchema | OasRef<'schema'> | undefined;
29
+ /** Example values for the parameter */
18
30
  examples?: Record<string, OasExample | OasRef<'example'>> | undefined;
31
+ /** Media type definitions for the parameter content */
19
32
  content?: Record<string, OasMediaType> | undefined;
33
+ /** The serialization style for the parameter */
20
34
  style: OasParameterStyle;
35
+ /** Whether to explode parameter values */
21
36
  explode: boolean;
37
+ /** Custom extension fields (x-* properties) */
22
38
  extensionFields?: Record<string, unknown>;
23
39
  };
40
+ /**
41
+ * Represents a Parameter Object in the OpenAPI Specification.
42
+ *
43
+ * The `OasParameter` class encapsulates the definition of a single operation parameter,
44
+ * including its location, data type, validation rules, and serialization behavior.
45
+ * Parameters can be located in the path, query string, headers, or cookies.
46
+ *
47
+ * This class provides comprehensive support for parameter validation, serialization
48
+ * styles, and complex data types through schema definitions or content specifications.
49
+ *
50
+ * ## Key Features
51
+ *
52
+ * - **Location Support**: Path, query, header, and cookie parameters
53
+ * - **Schema Validation**: Comprehensive data type validation through schemas
54
+ * - **Serialization Styles**: Various parameter serialization formats
55
+ * - **Content Types**: Support for complex parameter content with media types
56
+ * - **Examples & Documentation**: Parameter examples and descriptive documentation
57
+ * - **Advanced Options**: Empty values, reserved characters, and explode behavior
58
+ *
59
+ * @example Basic path parameter
60
+ * ```typescript
61
+ * import { OasParameter, OasString } from '@skmtc/core';
62
+ *
63
+ * const userIdParam = new OasParameter({
64
+ * name: 'userId',
65
+ * location: 'path',
66
+ * description: 'Unique identifier for the user',
67
+ * required: true,
68
+ * schema: new OasString({
69
+ * pattern: '^[0-9a-f]{24}$',
70
+ * example: '507f1f77bcf86cd799439011'
71
+ * }),
72
+ * style: 'simple',
73
+ * explode: false
74
+ * });
75
+ *
76
+ * // Used in path: /users/{userId}
77
+ * ```
78
+ *
79
+ * @example Query parameter with validation
80
+ * ```typescript
81
+ * const pageSizeParam = new OasParameter({
82
+ * name: 'pageSize',
83
+ * location: 'query',
84
+ * description: 'Number of items to return per page',
85
+ * required: false,
86
+ * schema: new OasInteger({
87
+ * minimum: 1,
88
+ * maximum: 100,
89
+ * default: 20
90
+ * }),
91
+ * style: 'form',
92
+ * explode: true,
93
+ * examples: {
94
+ * small: new OasExample({ value: 10 }),
95
+ * medium: new OasExample({ value: 25 }),
96
+ * large: new OasExample({ value: 50 })
97
+ * }
98
+ * });
99
+ *
100
+ * // Used in query: ?pageSize=20
101
+ * ```
102
+ *
103
+ * @example Header parameter
104
+ * ```typescript
105
+ * const authHeaderParam = new OasParameter({
106
+ * name: 'Authorization',
107
+ * location: 'header',
108
+ * description: 'Bearer token for authentication',
109
+ * required: true,
110
+ * schema: new OasString({
111
+ * pattern: '^Bearer [A-Za-z0-9+/=]+$',
112
+ * example: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
113
+ * }),
114
+ * style: 'simple',
115
+ * explode: false
116
+ * });
117
+ * ```
118
+ *
119
+ * @example Complex parameter with content
120
+ * ```typescript
121
+ * const filterParam = new OasParameter({
122
+ * name: 'filter',
123
+ * location: 'query',
124
+ * description: 'Complex filter object',
125
+ * required: false,
126
+ * content: {
127
+ * 'application/json': new OasMediaType({
128
+ * schema: new OasObject({
129
+ * properties: {
130
+ * category: new OasString(),
131
+ * priceRange: new OasObject({
132
+ * properties: {
133
+ * min: new OasNumber(),
134
+ * max: new OasNumber()
135
+ * }
136
+ * })
137
+ * }
138
+ * })
139
+ * })
140
+ * },
141
+ * style: 'deepObject',
142
+ * explode: true
143
+ * });
144
+ *
145
+ * // Used as: ?filter[category]=electronics&filter[priceRange][min]=100
146
+ * ```
147
+ *
148
+ * @example Array parameter with explode
149
+ * ```typescript
150
+ * const tagsParam = new OasParameter({
151
+ * name: 'tags',
152
+ * location: 'query',
153
+ * description: 'Filter by multiple tags',
154
+ * required: false,
155
+ * schema: new OasArray({
156
+ * items: new OasString(),
157
+ * minItems: 1,
158
+ * maxItems: 10
159
+ * }),
160
+ * style: 'form',
161
+ * explode: true // Results in: ?tags=tech&tags=api&tags=rest
162
+ * });
163
+ *
164
+ * // Without explode: ?tags=tech,api,rest
165
+ * // With explode: ?tags=tech&tags=api&tags=rest
166
+ * ```
167
+ *
168
+ * @example Cookie parameter
169
+ * ```typescript
170
+ * const sessionParam = new OasParameter({
171
+ * name: 'sessionId',
172
+ * location: 'cookie',
173
+ * description: 'Session identifier cookie',
174
+ * required: false,
175
+ * schema: new OasString({
176
+ * minLength: 32,
177
+ * maxLength: 128
178
+ * }),
179
+ * style: 'form',
180
+ * explode: false
181
+ * });
182
+ * ```
183
+ */
24
184
  export declare class OasParameter {
25
185
  oasType: 'parameter';
26
186
  name: string;