@skmtc/core 0.0.785 → 0.0.787

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 (93) hide show
  1. package/esm/dsl/ContentSettings.d.ts +164 -0
  2. package/esm/dsl/ContentSettings.d.ts.map +1 -1
  3. package/esm/dsl/ContentSettings.js +151 -0
  4. package/esm/dsl/Definition.d.ts +199 -0
  5. package/esm/dsl/Definition.d.ts.map +1 -1
  6. package/esm/dsl/Definition.js +189 -0
  7. package/esm/dsl/EntityType.d.ts +83 -0
  8. package/esm/dsl/EntityType.d.ts.map +1 -1
  9. package/esm/dsl/EntityType.js +83 -0
  10. package/esm/dsl/Identifier.d.ts +152 -0
  11. package/esm/dsl/Identifier.d.ts.map +1 -1
  12. package/esm/dsl/Identifier.js +152 -0
  13. package/esm/dsl/Import.d.ts +221 -0
  14. package/esm/dsl/Import.d.ts.map +1 -1
  15. package/esm/dsl/Import.js +202 -0
  16. package/esm/dsl/operation/OperationBase.d.ts +181 -1
  17. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  18. package/esm/dsl/operation/OperationBase.js +181 -1
  19. package/esm/oas/array/Array.d.ts +109 -1
  20. package/esm/oas/array/Array.d.ts.map +1 -1
  21. package/esm/oas/array/Array.js +93 -1
  22. package/esm/oas/document/Document.d.ts +155 -1
  23. package/esm/oas/document/Document.d.ts.map +1 -1
  24. package/esm/oas/document/Document.js +141 -2
  25. package/esm/oas/integer/Integer.d.ts +98 -0
  26. package/esm/oas/integer/Integer.d.ts.map +1 -1
  27. package/esm/oas/integer/Integer.js +80 -0
  28. package/esm/oas/object/Object.d.ts +255 -10
  29. package/esm/oas/object/Object.d.ts.map +1 -1
  30. package/esm/oas/object/Object.js +229 -10
  31. package/esm/oas/string/String.d.ts +103 -1
  32. package/esm/oas/string/String.d.ts.map +1 -1
  33. package/esm/oas/string/String.js +87 -1
  34. package/esm/types/Brand.d.ts +74 -0
  35. package/esm/types/Brand.d.ts.map +1 -1
  36. package/esm/types/Brand.js +9 -0
  37. package/esm/types/GeneratorKeys.d.ts +336 -0
  38. package/esm/types/GeneratorKeys.d.ts.map +1 -1
  39. package/esm/types/GeneratorKeys.js +243 -0
  40. package/esm/types/GeneratorType.d.ts +119 -0
  41. package/esm/types/GeneratorType.d.ts.map +1 -1
  42. package/esm/types/Method.d.ts +109 -0
  43. package/esm/types/Method.d.ts.map +1 -1
  44. package/esm/types/Method.js +84 -0
  45. package/esm/types/RefName.d.ts +61 -0
  46. package/esm/types/RefName.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/script/dsl/ContentSettings.d.ts +164 -0
  49. package/script/dsl/ContentSettings.d.ts.map +1 -1
  50. package/script/dsl/ContentSettings.js +151 -0
  51. package/script/dsl/Definition.d.ts +199 -0
  52. package/script/dsl/Definition.d.ts.map +1 -1
  53. package/script/dsl/Definition.js +189 -0
  54. package/script/dsl/EntityType.d.ts +83 -0
  55. package/script/dsl/EntityType.d.ts.map +1 -1
  56. package/script/dsl/EntityType.js +83 -0
  57. package/script/dsl/Identifier.d.ts +152 -0
  58. package/script/dsl/Identifier.d.ts.map +1 -1
  59. package/script/dsl/Identifier.js +152 -0
  60. package/script/dsl/Import.d.ts +221 -0
  61. package/script/dsl/Import.d.ts.map +1 -1
  62. package/script/dsl/Import.js +202 -0
  63. package/script/dsl/operation/OperationBase.d.ts +181 -1
  64. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  65. package/script/dsl/operation/OperationBase.js +181 -1
  66. package/script/oas/array/Array.d.ts +109 -1
  67. package/script/oas/array/Array.d.ts.map +1 -1
  68. package/script/oas/array/Array.js +93 -1
  69. package/script/oas/document/Document.d.ts +155 -1
  70. package/script/oas/document/Document.d.ts.map +1 -1
  71. package/script/oas/document/Document.js +141 -2
  72. package/script/oas/integer/Integer.d.ts +98 -0
  73. package/script/oas/integer/Integer.d.ts.map +1 -1
  74. package/script/oas/integer/Integer.js +80 -0
  75. package/script/oas/object/Object.d.ts +255 -10
  76. package/script/oas/object/Object.d.ts.map +1 -1
  77. package/script/oas/object/Object.js +229 -10
  78. package/script/oas/string/String.d.ts +103 -1
  79. package/script/oas/string/String.d.ts.map +1 -1
  80. package/script/oas/string/String.js +87 -1
  81. package/script/types/Brand.d.ts +74 -0
  82. package/script/types/Brand.d.ts.map +1 -1
  83. package/script/types/Brand.js +9 -0
  84. package/script/types/GeneratorKeys.d.ts +336 -0
  85. package/script/types/GeneratorKeys.d.ts.map +1 -1
  86. package/script/types/GeneratorKeys.js +243 -0
  87. package/script/types/GeneratorType.d.ts +119 -0
  88. package/script/types/GeneratorType.d.ts.map +1 -1
  89. package/script/types/Method.d.ts +109 -0
  90. package/script/types/Method.d.ts.map +1 -1
  91. package/script/types/Method.js +84 -0
  92. package/script/types/RefName.d.ts +61 -0
  93. package/script/types/RefName.d.ts.map +1 -1
@@ -8,23 +8,156 @@ import type { OasSecurityRequirement } from '../securityRequirement/SecurityRequ
8
8
  import type { StackTrail } from '../../context/StackTrail.js';
9
9
  import type { OasSchema } from '../schema/Schema.js';
10
10
  import type { OasRef } from '../ref/Ref.js';
11
+ /**
12
+ * Fields that define the structure of an OpenAPI v3 document.
13
+ *
14
+ * This type represents the normalized structure of an OpenAPI document after
15
+ * parsing, with operations flattened from the nested paths structure into
16
+ * a simple array for easier processing.
17
+ */
11
18
  export type DocumentFields = {
19
+ /** OpenAPI specification version (e.g., '3.0.0', '3.1.0') */
12
20
  openapi: string;
21
+ /** API metadata including title, version, description */
13
22
  info: OasInfo;
23
+ /** Array of server objects providing connectivity information */
14
24
  servers?: OasServer[] | undefined;
25
+ /** Flattened array of all operations from all paths */
15
26
  operations: OasOperation[];
27
+ /** Container for reusable components (schemas, responses, etc.) */
16
28
  components?: OasComponents | undefined;
29
+ /** List of tags used by operations with additional metadata */
17
30
  tags?: OasTag[] | undefined;
31
+ /** Default security requirements that apply to all operations */
18
32
  security?: OasSecurityRequirement[] | undefined;
33
+ /** Custom extension fields (x-* properties) */
19
34
  extensionFields?: Record<string, unknown>;
20
35
  };
21
- /** Top level document object describing the API */
36
+ /**
37
+ * Represents a complete OpenAPI v3 document in the SKMTC OAS processing system.
38
+ *
39
+ * The `OasDocument` class is the root object in the OAS hierarchy, containing all
40
+ * the information needed to describe a complete REST API. It provides normalized
41
+ * access to document properties with built-in validation and error handling.
42
+ *
43
+ * ## Key Features
44
+ *
45
+ * - **Normalized Structure**: Operations are flattened from nested paths for easier processing
46
+ * - **Lazy Initialization**: Fields are set after construction during parsing
47
+ * - **Type Safety**: All properties are typed and validated on access
48
+ * - **Extensibility**: Supports OpenAPI extension fields (x-* properties)
49
+ * - **JSON Serialization**: Can be converted back to standard OpenAPI JSON format
50
+ *
51
+ * @example Basic document access
52
+ * ```typescript
53
+ * import { OasDocument } from '@skmtc/core';
54
+ *
55
+ * // Document is typically created during parsing
56
+ * const document = new OasDocument();
57
+ * document.fields = {
58
+ * openapi: '3.0.0',
59
+ * info: { title: 'My API', version: '1.0.0' },
60
+ * operations: [
61
+ * // ... parsed operations
62
+ * ],
63
+ * components: {
64
+ * schemas: {
65
+ * User: { type: 'object', properties: { id: { type: 'string' } } }
66
+ * }
67
+ * }
68
+ * };
69
+ *
70
+ * console.log(document.info.title); // 'My API'
71
+ * console.log(document.operations.length); // Number of operations
72
+ * ```
73
+ *
74
+ * @example Iterating over operations
75
+ * ```typescript
76
+ * // Process all operations in the document
77
+ * for (const operation of document.operations) {
78
+ * console.log(`${operation.method.toUpperCase()} ${operation.path}`);
79
+ *
80
+ * if (operation.operationId) {
81
+ * console.log(`Operation ID: ${operation.operationId}`);
82
+ * }
83
+ * }
84
+ * ```
85
+ *
86
+ * @example Working with components
87
+ * ```typescript
88
+ * if (document.components?.schemas) {
89
+ * const userSchema = document.components.schemas.get('User');
90
+ * if (userSchema) {
91
+ * console.log('User schema found:', userSchema);
92
+ * }
93
+ * }
94
+ * ```
95
+ */
22
96
  export declare class OasDocument {
23
97
  #private;
24
98
  /** Static identifier property for OasDocument */
25
99
  oasType: 'openapi';
100
+ /**
101
+ * Creates a new OasDocument instance.
102
+ *
103
+ * The document is typically created with undefined fields and populated
104
+ * later during the parsing process. This allows for lazy initialization
105
+ * and proper error handling during document processing.
106
+ *
107
+ * @param fields - Optional document fields (usually set later during parsing)
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Usually created without fields during parsing
112
+ * const document = new OasDocument();
113
+ *
114
+ * // Fields are set later by the parser
115
+ * document.fields = parsedDocumentFields;
116
+ * ```
117
+ */
26
118
  constructor(fields?: DocumentFields);
119
+ /**
120
+ * Removes an item from the document based on a stack trail path.
121
+ *
122
+ * This method is used internally during document processing to remove
123
+ * specific operations or schema components. The stack trail indicates
124
+ * the path to the item within the document structure.
125
+ *
126
+ * @param stackTrail - Path to the item to remove
127
+ * @returns The removed item, or undefined if not found
128
+ *
129
+ * @internal This method is primarily used by the processing pipeline
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * // Remove an operation at /users POST
134
+ * const removed = document.removeItem(new StackTrail(['paths', '/users', 'post']));
135
+ *
136
+ * // Remove a schema component
137
+ * const removedSchema = document.removeItem(new StackTrail(['components', 'schemas', 'User']));
138
+ * ```
139
+ */
27
140
  removeItem(stackTrail: StackTrail): OasOperation | OasSchema | OasRef<'schema'> | undefined;
141
+ /**
142
+ * Sets the document fields after parsing.
143
+ *
144
+ * This setter is called by the parsing pipeline to populate the document
145
+ * with parsed OpenAPI data. It enables lazy initialization and proper
146
+ * error handling during document processing.
147
+ *
148
+ * @param fields - The parsed document fields
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const document = new OasDocument();
153
+ * document.fields = {
154
+ * openapi: '3.0.0',
155
+ * info: { title: 'API', version: '1.0' },
156
+ * operations: [],
157
+ * // ... other fields
158
+ * };
159
+ * ```
160
+ */
28
161
  set fields(fields: DocumentFields);
29
162
  /** OpenAPI specification version */
30
163
  get openapi(): string;
@@ -41,6 +174,27 @@ export declare class OasDocument {
41
174
  get security(): OasSecurityRequirement[] | undefined;
42
175
  /** Specification Extension fields */
43
176
  get extensionFields(): Record<string, unknown> | undefined;
177
+ /**
178
+ * Converts the document back to a JSON-serializable OpenAPI object.
179
+ *
180
+ * This method serializes the document to a standard OpenAPI v3 format,
181
+ * which can be used for output, validation, or further processing. The
182
+ * resulting object follows the OpenAPI specification structure.
183
+ *
184
+ * @returns A JSON-serializable object representing the OpenAPI document
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * // Convert document back to standard OpenAPI format
189
+ * const openApiJson = document.toJSON();
190
+ *
191
+ * // Can be stringified for output
192
+ * const yamlString = JSON.stringify(openApiJson, null, 2);
193
+ *
194
+ * // Or used with OpenAPI tools
195
+ * await validateOpenApiDocument(openApiJson);
196
+ * ```
197
+ */
44
198
  toJSON(): object;
45
199
  }
46
200
  //# sourceMappingURL=Document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../../src/oas/document/Document.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAG7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,C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;;;;;;;OAiBG;gBACS,MAAM,CAAC,EAAE,cAAc;IAInC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IA6B3F;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,EAEhC;IAED,oCAAoC;IACpC,IAAI,OAAO,IAAI,MAAM,CAMpB;IAED,mBAAmB;IACnB,IAAI,IAAI,IAAI,OAAO,CAMlB;IAED,IAAI,OAAO,IAAI,SAAS,EAAE,GAAG,SAAS,CAMrC;IAED,yCAAyC;IACzC,IAAI,UAAU,IAAI,YAAY,EAAE,CAM/B;IAED,iEAAiE;IACjE,IAAI,UAAU,IAAI,aAAa,GAAG,SAAS,CAM1C;IAED,wDAAwD;IACxD,IAAI,IAAI,IAAI,MAAM,EAAE,GAAG,SAAS,CAM/B;IAED,gDAAgD;IAChD,IAAI,QAAQ,IAAI,sBAAsB,EAAE,GAAG,SAAS,CAMnD;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAMzD;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,IAAI,MAAM;CAYjB"}
@@ -12,8 +12,85 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _OasDocument_fields;
13
13
  import "../../_dnt.polyfills.js";
14
14
  import { match } from 'ts-pattern';
15
- /** Top level document object describing the API */
15
+ /**
16
+ * Represents a complete OpenAPI v3 document in the SKMTC OAS processing system.
17
+ *
18
+ * The `OasDocument` class is the root object in the OAS hierarchy, containing all
19
+ * the information needed to describe a complete REST API. It provides normalized
20
+ * access to document properties with built-in validation and error handling.
21
+ *
22
+ * ## Key Features
23
+ *
24
+ * - **Normalized Structure**: Operations are flattened from nested paths for easier processing
25
+ * - **Lazy Initialization**: Fields are set after construction during parsing
26
+ * - **Type Safety**: All properties are typed and validated on access
27
+ * - **Extensibility**: Supports OpenAPI extension fields (x-* properties)
28
+ * - **JSON Serialization**: Can be converted back to standard OpenAPI JSON format
29
+ *
30
+ * @example Basic document access
31
+ * ```typescript
32
+ * import { OasDocument } from '@skmtc/core';
33
+ *
34
+ * // Document is typically created during parsing
35
+ * const document = new OasDocument();
36
+ * document.fields = {
37
+ * openapi: '3.0.0',
38
+ * info: { title: 'My API', version: '1.0.0' },
39
+ * operations: [
40
+ * // ... parsed operations
41
+ * ],
42
+ * components: {
43
+ * schemas: {
44
+ * User: { type: 'object', properties: { id: { type: 'string' } } }
45
+ * }
46
+ * }
47
+ * };
48
+ *
49
+ * console.log(document.info.title); // 'My API'
50
+ * console.log(document.operations.length); // Number of operations
51
+ * ```
52
+ *
53
+ * @example Iterating over operations
54
+ * ```typescript
55
+ * // Process all operations in the document
56
+ * for (const operation of document.operations) {
57
+ * console.log(`${operation.method.toUpperCase()} ${operation.path}`);
58
+ *
59
+ * if (operation.operationId) {
60
+ * console.log(`Operation ID: ${operation.operationId}`);
61
+ * }
62
+ * }
63
+ * ```
64
+ *
65
+ * @example Working with components
66
+ * ```typescript
67
+ * if (document.components?.schemas) {
68
+ * const userSchema = document.components.schemas.get('User');
69
+ * if (userSchema) {
70
+ * console.log('User schema found:', userSchema);
71
+ * }
72
+ * }
73
+ * ```
74
+ */
16
75
  export class OasDocument {
76
+ /**
77
+ * Creates a new OasDocument instance.
78
+ *
79
+ * The document is typically created with undefined fields and populated
80
+ * later during the parsing process. This allows for lazy initialization
81
+ * and proper error handling during document processing.
82
+ *
83
+ * @param fields - Optional document fields (usually set later during parsing)
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * // Usually created without fields during parsing
88
+ * const document = new OasDocument();
89
+ *
90
+ * // Fields are set later by the parser
91
+ * document.fields = parsedDocumentFields;
92
+ * ```
93
+ */
17
94
  constructor(fields) {
18
95
  /** Static identifier property for OasDocument */
19
96
  Object.defineProperty(this, "oasType", {
@@ -22,10 +99,31 @@ export class OasDocument {
22
99
  writable: true,
23
100
  value: 'openapi'
24
101
  });
25
- /** @internal */
102
+ /** @internal Private fields storage */
26
103
  _OasDocument_fields.set(this, void 0);
27
104
  __classPrivateFieldSet(this, _OasDocument_fields, fields, "f");
28
105
  }
106
+ /**
107
+ * Removes an item from the document based on a stack trail path.
108
+ *
109
+ * This method is used internally during document processing to remove
110
+ * specific operations or schema components. The stack trail indicates
111
+ * the path to the item within the document structure.
112
+ *
113
+ * @param stackTrail - Path to the item to remove
114
+ * @returns The removed item, or undefined if not found
115
+ *
116
+ * @internal This method is primarily used by the processing pipeline
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Remove an operation at /users POST
121
+ * const removed = document.removeItem(new StackTrail(['paths', '/users', 'post']));
122
+ *
123
+ * // Remove a schema component
124
+ * const removedSchema = document.removeItem(new StackTrail(['components', 'schemas', 'User']));
125
+ * ```
126
+ */
29
127
  removeItem(stackTrail) {
30
128
  const [first, second, third] = stackTrail.stackTrail;
31
129
  return match(first)
@@ -47,6 +145,26 @@ export class OasDocument {
47
145
  throw new Error(`Unexpected stack trail: ${stackTrail}`);
48
146
  });
49
147
  }
148
+ /**
149
+ * Sets the document fields after parsing.
150
+ *
151
+ * This setter is called by the parsing pipeline to populate the document
152
+ * with parsed OpenAPI data. It enables lazy initialization and proper
153
+ * error handling during document processing.
154
+ *
155
+ * @param fields - The parsed document fields
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const document = new OasDocument();
160
+ * document.fields = {
161
+ * openapi: '3.0.0',
162
+ * info: { title: 'API', version: '1.0' },
163
+ * operations: [],
164
+ * // ... other fields
165
+ * };
166
+ * ```
167
+ */
50
168
  set fields(fields) {
51
169
  __classPrivateFieldSet(this, _OasDocument_fields, fields, "f");
52
170
  }
@@ -105,6 +223,27 @@ export class OasDocument {
105
223
  }
106
224
  return __classPrivateFieldGet(this, _OasDocument_fields, "f").extensionFields;
107
225
  }
226
+ /**
227
+ * Converts the document back to a JSON-serializable OpenAPI object.
228
+ *
229
+ * This method serializes the document to a standard OpenAPI v3 format,
230
+ * which can be used for output, validation, or further processing. The
231
+ * resulting object follows the OpenAPI specification structure.
232
+ *
233
+ * @returns A JSON-serializable object representing the OpenAPI document
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * // Convert document back to standard OpenAPI format
238
+ * const openApiJson = document.toJSON();
239
+ *
240
+ * // Can be stringified for output
241
+ * const yamlString = JSON.stringify(openApiJson, null, 2);
242
+ *
243
+ * // Or used with OpenAPI tools
244
+ * await validateOpenApiDocument(openApiJson);
245
+ * ```
246
+ */
108
247
  toJSON() {
109
248
  return {
110
249
  openapi: this.openapi,
@@ -2,21 +2,119 @@ import "../../_dnt.polyfills.js";
2
2
  import type { OasRef } from '../ref/Ref.js';
3
3
  import type { OpenAPIV3 } from 'openapi-types';
4
4
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
5
+ /**
6
+ * Constructor fields for {@link OasInteger}.
7
+ *
8
+ * @template Nullable - Whether the integer value can be null
9
+ */
5
10
  export type IntegerFields<Nullable extends boolean | undefined> = {
11
+ /** A short summary of the integer schema */
6
12
  title?: string;
13
+ /** A description of the integer schema */
7
14
  description?: string;
15
+ /** Whether the integer value can be null */
8
16
  nullable?: Nullable;
17
+ /** Integer format specification (int32 or int64) */
9
18
  format?: 'int32' | 'int64';
19
+ /** Default value for the integer */
10
20
  default?: Nullable extends true ? number | null | undefined : number | undefined;
21
+ /** Array of allowed enum values */
11
22
  enums?: Nullable extends true ? (number | null)[] | undefined : number[] | undefined;
23
+ /** Custom extension fields (x-* properties) */
12
24
  extensionFields?: Record<string, unknown>;
25
+ /** Example value for the integer */
13
26
  example?: Nullable extends true ? number | null | undefined : number | undefined;
27
+ /** Number must be a multiple of this value */
14
28
  multipleOf?: number;
29
+ /** Maximum value (inclusive) */
15
30
  maximum?: number;
31
+ /** Whether maximum is exclusive */
16
32
  exclusiveMaximum?: boolean;
33
+ /** Minimum value (inclusive) */
17
34
  minimum?: number;
35
+ /** Whether minimum is exclusive */
18
36
  exclusiveMinimum?: boolean;
19
37
  };
38
+ /**
39
+ * Represents an integer schema in the OpenAPI Specification.
40
+ *
41
+ * `OasInteger` handles integer type definitions with comprehensive validation
42
+ * constraints including range limits, multiple-of validation, format specifications,
43
+ * and enum restrictions. It supports both 32-bit and 64-bit integer formats
44
+ * and provides nullable type support.
45
+ *
46
+ * This class is used throughout the OAS processing pipeline to represent
47
+ * integer fields in API schemas, including IDs, counts, timestamps, and
48
+ * other numeric values that must be whole numbers.
49
+ *
50
+ * ## Key Features
51
+ *
52
+ * - **Format Support**: int32 and int64 format specifications
53
+ * - **Range Validation**: Minimum and maximum value constraints
54
+ * - **Multiple Validation**: Ensure values are multiples of specified numbers
55
+ * - **Enum Values**: Restricted sets of allowed integer values
56
+ * - **Nullable Support**: Type-safe nullable integer handling
57
+ * - **JSON Schema**: Conversion to standard JSON Schema format
58
+ *
59
+ * @template Nullable - Whether the integer value can be null
60
+ *
61
+ * @example Basic integer schema
62
+ * ```typescript
63
+ * import { OasInteger } from '@skmtc/core';
64
+ *
65
+ * const ageInteger = new OasInteger({
66
+ * title: 'Age',
67
+ * description: 'Person age in years',
68
+ * minimum: 0,
69
+ * maximum: 150,
70
+ * example: 25
71
+ * });
72
+ * ```
73
+ *
74
+ * @example ID with int64 format
75
+ * ```typescript
76
+ * const userIdInteger = new OasInteger({
77
+ * title: 'User ID',
78
+ * description: 'Unique user identifier',
79
+ * format: 'int64',
80
+ * minimum: 1,
81
+ * example: 1234567890123
82
+ * });
83
+ * ```
84
+ *
85
+ * @example Count with multiple-of validation
86
+ * ```typescript
87
+ * const batchSizeInteger = new OasInteger({
88
+ * title: 'Batch Size',
89
+ * description: 'Number of items to process',
90
+ * minimum: 10,
91
+ * maximum: 1000,
92
+ * multipleOf: 10, // Must be multiple of 10
93
+ * default: 50
94
+ * });
95
+ * ```
96
+ *
97
+ * @example Status code enum
98
+ * ```typescript
99
+ * const statusCodeInteger = new OasInteger({
100
+ * title: 'HTTP Status Code',
101
+ * description: 'Valid HTTP response status codes',
102
+ * enums: [200, 201, 400, 401, 404, 500],
103
+ * example: 200
104
+ * });
105
+ * ```
106
+ *
107
+ * @example Nullable integer
108
+ * ```typescript
109
+ * const optionalCountInteger = new OasInteger<true>({
110
+ * title: 'Optional Count',
111
+ * description: 'Count value that can be null',
112
+ * nullable: true,
113
+ * minimum: 0,
114
+ * default: null
115
+ * });
116
+ * ```
117
+ */
20
118
  export declare class OasInteger<Nullable extends boolean | undefined = boolean | undefined> {
21
119
  /**
22
120
  * Object is part the 'schema' set which is used
@@ -1 +1 @@
1
- {"version":3,"file":"Integer.d.ts","sourceRoot":"","sources":["../../../src/oas/integer/Integer.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,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,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAChF,KAAK,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC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F,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAC/E;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;gBACnE,MAAM,GAAE,aAAa,CAAC,QAAQ,CAAM;IAgBhD,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;CAiB5E"}
@@ -1,4 +1,84 @@
1
1
  import "../../_dnt.polyfills.js";
2
+ /**
3
+ * Represents an integer schema in the OpenAPI Specification.
4
+ *
5
+ * `OasInteger` handles integer type definitions with comprehensive validation
6
+ * constraints including range limits, multiple-of validation, format specifications,
7
+ * and enum restrictions. It supports both 32-bit and 64-bit integer formats
8
+ * and provides nullable type support.
9
+ *
10
+ * This class is used throughout the OAS processing pipeline to represent
11
+ * integer fields in API schemas, including IDs, counts, timestamps, and
12
+ * other numeric values that must be whole numbers.
13
+ *
14
+ * ## Key Features
15
+ *
16
+ * - **Format Support**: int32 and int64 format specifications
17
+ * - **Range Validation**: Minimum and maximum value constraints
18
+ * - **Multiple Validation**: Ensure values are multiples of specified numbers
19
+ * - **Enum Values**: Restricted sets of allowed integer values
20
+ * - **Nullable Support**: Type-safe nullable integer handling
21
+ * - **JSON Schema**: Conversion to standard JSON Schema format
22
+ *
23
+ * @template Nullable - Whether the integer value can be null
24
+ *
25
+ * @example Basic integer schema
26
+ * ```typescript
27
+ * import { OasInteger } from '@skmtc/core';
28
+ *
29
+ * const ageInteger = new OasInteger({
30
+ * title: 'Age',
31
+ * description: 'Person age in years',
32
+ * minimum: 0,
33
+ * maximum: 150,
34
+ * example: 25
35
+ * });
36
+ * ```
37
+ *
38
+ * @example ID with int64 format
39
+ * ```typescript
40
+ * const userIdInteger = new OasInteger({
41
+ * title: 'User ID',
42
+ * description: 'Unique user identifier',
43
+ * format: 'int64',
44
+ * minimum: 1,
45
+ * example: 1234567890123
46
+ * });
47
+ * ```
48
+ *
49
+ * @example Count with multiple-of validation
50
+ * ```typescript
51
+ * const batchSizeInteger = new OasInteger({
52
+ * title: 'Batch Size',
53
+ * description: 'Number of items to process',
54
+ * minimum: 10,
55
+ * maximum: 1000,
56
+ * multipleOf: 10, // Must be multiple of 10
57
+ * default: 50
58
+ * });
59
+ * ```
60
+ *
61
+ * @example Status code enum
62
+ * ```typescript
63
+ * const statusCodeInteger = new OasInteger({
64
+ * title: 'HTTP Status Code',
65
+ * description: 'Valid HTTP response status codes',
66
+ * enums: [200, 201, 400, 401, 404, 500],
67
+ * example: 200
68
+ * });
69
+ * ```
70
+ *
71
+ * @example Nullable integer
72
+ * ```typescript
73
+ * const optionalCountInteger = new OasInteger<true>({
74
+ * title: 'Optional Count',
75
+ * description: 'Count value that can be null',
76
+ * nullable: true,
77
+ * minimum: 0,
78
+ * default: null
79
+ * });
80
+ * ```
81
+ */
2
82
  export class OasInteger {
3
83
  constructor(fields = {}) {
4
84
  /**