@skmtc/core 0.0.791 → 0.0.793

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 (113) hide show
  1. package/esm/dsl/GeneratedValueList.d.ts +158 -0
  2. package/esm/dsl/GeneratedValueList.d.ts.map +1 -1
  3. package/esm/dsl/GeneratedValueList.js +158 -0
  4. package/esm/dsl/Stringable.d.ts +76 -0
  5. package/esm/dsl/Stringable.d.ts.map +1 -1
  6. package/esm/dsl/Stringable.js +75 -0
  7. package/esm/helpers/collateExamples.d.ts +150 -0
  8. package/esm/helpers/collateExamples.d.ts.map +1 -1
  9. package/esm/helpers/collateExamples.js +145 -0
  10. package/esm/helpers/formatNumber.d.ts +95 -0
  11. package/esm/helpers/formatNumber.d.ts.map +1 -1
  12. package/esm/helpers/formatNumber.js +95 -0
  13. package/esm/helpers/generationStats.d.ts +287 -1
  14. package/esm/helpers/generationStats.d.ts.map +1 -1
  15. package/esm/helpers/generationStats.js +266 -0
  16. package/esm/helpers/isEmpty.d.ts +62 -0
  17. package/esm/helpers/isEmpty.d.ts.map +1 -1
  18. package/esm/helpers/isEmpty.js +62 -0
  19. package/esm/helpers/isImported.d.ts +80 -0
  20. package/esm/helpers/isImported.d.ts.map +1 -1
  21. package/esm/helpers/isImported.js +80 -0
  22. package/esm/helpers/naming.d.ts +65 -1
  23. package/esm/helpers/naming.d.ts.map +1 -1
  24. package/esm/helpers/naming.js +65 -1
  25. package/esm/helpers/parseModuleName.d.ts +175 -0
  26. package/esm/helpers/parseModuleName.d.ts.map +1 -1
  27. package/esm/helpers/parseModuleName.js +153 -0
  28. package/esm/helpers/toResolvedArtifactPath.d.ts +145 -0
  29. package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  30. package/esm/helpers/toResolvedArtifactPath.js +140 -0
  31. package/esm/oas/example/Example.d.ts +81 -1
  32. package/esm/oas/example/Example.d.ts.map +1 -1
  33. package/esm/oas/example/Example.js +74 -1
  34. package/esm/oas/header/Header.d.ts +217 -1
  35. package/esm/oas/header/Header.d.ts.map +1 -1
  36. package/esm/oas/header/Header.js +207 -1
  37. package/esm/oas/info/Info.d.ts +72 -0
  38. package/esm/oas/info/Info.d.ts.map +1 -1
  39. package/esm/oas/info/Info.js +62 -0
  40. package/esm/oas/mediaType/MediaType.d.ts +85 -0
  41. package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
  42. package/esm/oas/mediaType/MediaType.js +77 -0
  43. package/esm/oas/pathItem/PathItem.d.ts +92 -0
  44. package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
  45. package/esm/oas/pathItem/PathItem.js +85 -0
  46. package/esm/oas/requestBody/RequestBody.d.ts +264 -0
  47. package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
  48. package/esm/oas/requestBody/RequestBody.js +257 -0
  49. package/esm/oas/schema/Schema.d.ts +117 -0
  50. package/esm/oas/schema/Schema.d.ts.map +1 -1
  51. package/esm/typescript/identifiers.d.ts +159 -0
  52. package/esm/typescript/identifiers.d.ts.map +1 -1
  53. package/esm/typescript/identifiers.js +159 -0
  54. package/esm/typescript/withDescription.d.ts +119 -0
  55. package/esm/typescript/withDescription.d.ts.map +1 -1
  56. package/esm/typescript/withDescription.js +119 -0
  57. package/package.json +1 -1
  58. package/script/dsl/GeneratedValueList.d.ts +158 -0
  59. package/script/dsl/GeneratedValueList.d.ts.map +1 -1
  60. package/script/dsl/GeneratedValueList.js +158 -0
  61. package/script/dsl/Stringable.d.ts +76 -0
  62. package/script/dsl/Stringable.d.ts.map +1 -1
  63. package/script/dsl/Stringable.js +75 -0
  64. package/script/helpers/collateExamples.d.ts +150 -0
  65. package/script/helpers/collateExamples.d.ts.map +1 -1
  66. package/script/helpers/collateExamples.js +145 -0
  67. package/script/helpers/formatNumber.d.ts +95 -0
  68. package/script/helpers/formatNumber.d.ts.map +1 -1
  69. package/script/helpers/formatNumber.js +95 -0
  70. package/script/helpers/generationStats.d.ts +287 -1
  71. package/script/helpers/generationStats.d.ts.map +1 -1
  72. package/script/helpers/generationStats.js +266 -0
  73. package/script/helpers/isEmpty.d.ts +62 -0
  74. package/script/helpers/isEmpty.d.ts.map +1 -1
  75. package/script/helpers/isEmpty.js +62 -0
  76. package/script/helpers/isImported.d.ts +80 -0
  77. package/script/helpers/isImported.d.ts.map +1 -1
  78. package/script/helpers/isImported.js +80 -0
  79. package/script/helpers/naming.d.ts +65 -1
  80. package/script/helpers/naming.d.ts.map +1 -1
  81. package/script/helpers/naming.js +65 -1
  82. package/script/helpers/parseModuleName.d.ts +175 -0
  83. package/script/helpers/parseModuleName.d.ts.map +1 -1
  84. package/script/helpers/parseModuleName.js +153 -0
  85. package/script/helpers/toResolvedArtifactPath.d.ts +145 -0
  86. package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  87. package/script/helpers/toResolvedArtifactPath.js +140 -0
  88. package/script/oas/example/Example.d.ts +81 -1
  89. package/script/oas/example/Example.d.ts.map +1 -1
  90. package/script/oas/example/Example.js +74 -1
  91. package/script/oas/header/Header.d.ts +217 -1
  92. package/script/oas/header/Header.d.ts.map +1 -1
  93. package/script/oas/header/Header.js +207 -1
  94. package/script/oas/info/Info.d.ts +72 -0
  95. package/script/oas/info/Info.d.ts.map +1 -1
  96. package/script/oas/info/Info.js +62 -0
  97. package/script/oas/mediaType/MediaType.d.ts +85 -0
  98. package/script/oas/mediaType/MediaType.d.ts.map +1 -1
  99. package/script/oas/mediaType/MediaType.js +77 -0
  100. package/script/oas/pathItem/PathItem.d.ts +92 -0
  101. package/script/oas/pathItem/PathItem.d.ts.map +1 -1
  102. package/script/oas/pathItem/PathItem.js +85 -0
  103. package/script/oas/requestBody/RequestBody.d.ts +264 -0
  104. package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
  105. package/script/oas/requestBody/RequestBody.js +257 -0
  106. package/script/oas/schema/Schema.d.ts +117 -0
  107. package/script/oas/schema/Schema.d.ts.map +1 -1
  108. package/script/typescript/identifiers.d.ts +159 -0
  109. package/script/typescript/identifiers.d.ts.map +1 -1
  110. package/script/typescript/identifiers.js +159 -0
  111. package/script/typescript/withDescription.d.ts +119 -0
  112. package/script/typescript/withDescription.d.ts.map +1 -1
  113. package/script/typescript/withDescription.js +119 -0
@@ -1,6 +1,159 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseModuleName = void 0;
4
+ /**
5
+ * Parses a module name string into its component parts.
6
+ *
7
+ * This utility function decomposes module names from various formats into
8
+ * structured components, handling schemes, scopes, versions, and package names.
9
+ * It supports formats used by npm, JSR, Deno, and other package managers.
10
+ *
11
+ * The parser handles complex module name patterns including:
12
+ * - Scheme prefixes (jsr:, npm:, https:)
13
+ * - Scoped packages (@scope/package)
14
+ * - Version specifiers (@version)
15
+ * - Combinations of the above
16
+ *
17
+ * @param moduleName - The module name string to parse
18
+ * @returns Parsed components of the module name
19
+ *
20
+ * @example Basic package names
21
+ * ```typescript
22
+ * import { parseModuleName } from '@skmtc/core';
23
+ *
24
+ * // Simple package name
25
+ * const simple = parseModuleName('lodash');
26
+ * // {
27
+ * // scheme: null,
28
+ * // scopeName: null,
29
+ * // packageName: 'lodash',
30
+ * // version: null
31
+ * // }
32
+ *
33
+ * // Package with version
34
+ * const versioned = parseModuleName('lodash@4.17.21');
35
+ * // {
36
+ * // scheme: null,
37
+ * // scopeName: null,
38
+ * // packageName: 'lodash',
39
+ * // version: '4.17.21'
40
+ * // }
41
+ * ```
42
+ *
43
+ * @example Scoped packages
44
+ * ```typescript
45
+ * // Scoped package
46
+ * const scoped = parseModuleName('@company/utils');
47
+ * // {
48
+ * // scheme: null,
49
+ * // scopeName: '@company',
50
+ * // packageName: 'utils',
51
+ * // version: null
52
+ * // }
53
+ *
54
+ * // Scoped package with version
55
+ * const scopedVersioned = parseModuleName('@company/utils@2.0.0');
56
+ * // {
57
+ * // scheme: null,
58
+ * // scopeName: '@company',
59
+ * // packageName: 'utils',
60
+ * // version: '2.0.0'
61
+ * // }
62
+ * ```
63
+ *
64
+ * @example Scheme-prefixed modules
65
+ * ```typescript
66
+ * // JSR module
67
+ * const jsrModule = parseModuleName('jsr:@std/path@1.0.0');
68
+ * // {
69
+ * // scheme: 'jsr',
70
+ * // scopeName: '@std',
71
+ * // packageName: 'path',
72
+ * // version: '1.0.0'
73
+ * // }
74
+ *
75
+ * // npm module with scheme
76
+ * const npmModule = parseModuleName('npm:lodash@^4.17.0');
77
+ * // {
78
+ * // scheme: 'npm',
79
+ * // scopeName: null,
80
+ * // packageName: 'lodash',
81
+ * // version: '^4.17.0'
82
+ * // }
83
+ *
84
+ * // HTTPS module
85
+ * const httpsModule = parseModuleName('https:example.com/package@v1.2.3');
86
+ * // {
87
+ * // scheme: 'https',
88
+ * // scopeName: null,
89
+ * // packageName: 'example.com/package',
90
+ * // version: 'v1.2.3'
91
+ * // }
92
+ * ```
93
+ *
94
+ * @example Complex parsing scenarios
95
+ * ```typescript
96
+ * // Multiple levels in package name
97
+ * const nested = parseModuleName('npm:@babel/plugin-transform-runtime@^7.0.0');
98
+ * // {
99
+ * // scheme: 'npm',
100
+ * // scopeName: '@babel',
101
+ * // packageName: 'plugin-transform-runtime',
102
+ * // version: '^7.0.0'
103
+ * // }
104
+ *
105
+ * // Version ranges and pre-release versions
106
+ * const prerelease = parseModuleName('jsr:@deno/std@1.0.0-rc.1');
107
+ * // {
108
+ * // scheme: 'jsr',
109
+ * // scopeName: '@deno',
110
+ * // packageName: 'std',
111
+ * // version: '1.0.0-rc.1'
112
+ * // }
113
+ * ```
114
+ *
115
+ * @example Usage in dependency management
116
+ * ```typescript
117
+ * class DependencyManager {
118
+ * processDependency(moduleSpec: string) {
119
+ * const parsed = parseModuleName(moduleSpec);
120
+ *
121
+ * console.log(`Processing ${parsed.packageName}`);
122
+ *
123
+ * if (parsed.scheme) {
124
+ * console.log(`Using ${parsed.scheme} registry`);
125
+ * }
126
+ *
127
+ * if (parsed.scopeName) {
128
+ * console.log(`Scoped package: ${parsed.scopeName}/${parsed.packageName}`);
129
+ * }
130
+ *
131
+ * if (parsed.version) {
132
+ * console.log(`Version constraint: ${parsed.version}`);
133
+ * }
134
+ *
135
+ * return this.resolvePackage(parsed);
136
+ * }
137
+ * }
138
+ * ```
139
+ *
140
+ * @example Building module URLs
141
+ * ```typescript
142
+ * function buildModuleUrl(moduleSpec: string): string {
143
+ * const parsed = parseModuleName(moduleSpec);
144
+ *
145
+ * switch (parsed.scheme) {
146
+ * case 'jsr':
147
+ * return `https://jsr.io/${parsed.scopeName}/${parsed.packageName}`;
148
+ * case 'npm':
149
+ * const scope = parsed.scopeName ? `${parsed.scopeName}/` : '';
150
+ * return `https://npmjs.com/package/${scope}${parsed.packageName}`;
151
+ * default:
152
+ * return `https://deno.land/x/${parsed.packageName}`;
153
+ * }
154
+ * }
155
+ * ```
156
+ */
4
157
  const parseModuleName = (moduleName) => {
5
158
  const result = {
6
159
  scheme: null,
@@ -1,8 +1,153 @@
1
1
  import "../_dnt.polyfills.js";
2
+ /**
3
+ * Arguments for resolving artifact file paths.
4
+ */
2
5
  type ToResolvedArtifactPathArgs = {
6
+ /** The base directory path for resolving relative paths */
3
7
  basePath: string | undefined;
8
+ /** The destination path for the artifact file */
4
9
  destinationPath: string;
5
10
  };
11
+ /**
12
+ * Resolves artifact destination paths relative to a base directory.
13
+ *
14
+ * This utility function combines a base path with a destination path to create
15
+ * the final resolved file path for generated artifacts. It handles special path
16
+ * prefixes (like '@/') and provides sensible defaults when no base path is specified.
17
+ *
18
+ * The function is used throughout the rendering pipeline to determine the final
19
+ * file system locations for generated code artifacts, ensuring consistent path
20
+ * resolution across different operating systems and deployment scenarios.
21
+ *
22
+ * @param args - Path resolution configuration
23
+ * @param args.basePath - Base directory path (defaults to './' if undefined)
24
+ * @param args.destinationPath - Destination path for the artifact
25
+ * @returns The resolved absolute or relative path for the artifact
26
+ *
27
+ * @example Basic path resolution
28
+ * ```typescript
29
+ * import { toResolvedArtifactPath } from '@skmtc/core';
30
+ *
31
+ * // With explicit base path
32
+ * const resolved1 = toResolvedArtifactPath({
33
+ * basePath: './src/generated',
34
+ * destinationPath: 'models/User.ts'
35
+ * });
36
+ * console.log(resolved1); // './src/generated/models/User.ts'
37
+ *
38
+ * // With undefined base path (uses default)
39
+ * const resolved2 = toResolvedArtifactPath({
40
+ * basePath: undefined,
41
+ * destinationPath: 'types.ts'
42
+ * });
43
+ * console.log(resolved2); // './types.ts'
44
+ * ```
45
+ *
46
+ * @example Special path prefix handling
47
+ * ```typescript
48
+ * // '@/' prefix gets stripped and resolved relative to base
49
+ * const resolved = toResolvedArtifactPath({
50
+ * basePath: './output',
51
+ * destinationPath: '@/api/models.ts'
52
+ * });
53
+ * console.log(resolved); // './output/api/models.ts'
54
+ *
55
+ * // Regular paths work normally
56
+ * const normal = toResolvedArtifactPath({
57
+ * basePath: './build',
58
+ * destinationPath: 'components/Button.tsx'
59
+ * });
60
+ * console.log(normal); // './build/components/Button.tsx'
61
+ * ```
62
+ *
63
+ * @example Cross-platform path resolution
64
+ * ```typescript
65
+ * // Works consistently across platforms
66
+ * const windowsPath = toResolvedArtifactPath({
67
+ * basePath: 'C:\\projects\\app\\dist',
68
+ * destinationPath: 'utils/helpers.js'
69
+ * });
70
+ *
71
+ * const unixPath = toResolvedArtifactPath({
72
+ * basePath: '/home/user/projects/app/dist',
73
+ * destinationPath: 'utils/helpers.js'
74
+ * });
75
+ * ```
76
+ *
77
+ * @example Usage in file generation
78
+ * ```typescript
79
+ * class ArtifactWriter {
80
+ * writeArtifact(
81
+ * content: string,
82
+ * destination: string,
83
+ * baseDir?: string
84
+ * ) {
85
+ * const resolvedPath = toResolvedArtifactPath({
86
+ * basePath: baseDir,
87
+ * destinationPath: destination
88
+ * });
89
+ *
90
+ * console.log(`Writing to: ${resolvedPath}`);
91
+ * return Deno.writeTextFile(resolvedPath, content);
92
+ * }
93
+ * }
94
+ *
95
+ * const writer = new ArtifactWriter();
96
+ * await writer.writeArtifact(
97
+ * 'export const greeting = "Hello";',
98
+ * '@/constants.ts',
99
+ * './src/generated'
100
+ * );
101
+ * // Writes to: ./src/generated/constants.ts
102
+ * ```
103
+ *
104
+ * @example Integration with rendering pipeline
105
+ * ```typescript
106
+ * class FileRenderer {
107
+ * renderFiles(
108
+ * files: Map<string, File>,
109
+ * outputDir: string
110
+ * ): Record<string, string> {
111
+ * const artifacts: Record<string, string> = {};
112
+ *
113
+ * for (const [destPath, file] of files) {
114
+ * const resolvedPath = toResolvedArtifactPath({
115
+ * basePath: outputDir,
116
+ * destinationPath: destPath
117
+ * });
118
+ *
119
+ * artifacts[resolvedPath] = file.toString();
120
+ * }
121
+ *
122
+ * return artifacts;
123
+ * }
124
+ * }
125
+ * ```
126
+ *
127
+ * @example Dynamic base path resolution
128
+ * ```typescript
129
+ * function resolveForEnvironment(
130
+ * destination: string,
131
+ * env: 'development' | 'production'
132
+ * ): string {
133
+ * const basePaths = {
134
+ * development: './dev-output',
135
+ * production: './dist'
136
+ * };
137
+ *
138
+ * return toResolvedArtifactPath({
139
+ * basePath: basePaths[env],
140
+ * destinationPath: destination
141
+ * });
142
+ * }
143
+ *
144
+ * const devPath = resolveForEnvironment('api.ts', 'development');
145
+ * const prodPath = resolveForEnvironment('api.ts', 'production');
146
+ *
147
+ * console.log(devPath); // './dev-output/api.ts'
148
+ * console.log(prodPath); // './dist/api.ts'
149
+ * ```
150
+ */
6
151
  export declare const toResolvedArtifactPath: ({ basePath, destinationPath }: ToResolvedArtifactPathArgs) => string;
7
152
  export {};
8
153
  //# sourceMappingURL=toResolvedArtifactPath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toResolvedArtifactPath.d.ts","sourceRoot":"","sources":["../../src/helpers/toResolvedArtifactPath.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,KAAK,0BAA0B,GAAG;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,+BAGpC,0BAA0B,KAAG,MAE/B,CAAA"}
1
+ {"version":3,"file":"toResolvedArtifactPath.d.ts","sourceRoot":"","sources":["../../src/helpers/toResolvedArtifactPath.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAG9B;;GAEG;AACH,KAAK,0BAA0B,GAAG;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,iDAAiD;IACjD,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2IG;AACH,eAAO,MAAM,sBAAsB,GAAI,+BAGpC,0BAA0B,KAAG,MAE/B,CAAA"}
@@ -3,6 +3,146 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toResolvedArtifactPath = void 0;
4
4
  require("../_dnt.polyfills.js");
5
5
  const join_js_1 = require("../deps/jsr.io/@std/path/1.1.2/join.js");
6
+ /**
7
+ * Resolves artifact destination paths relative to a base directory.
8
+ *
9
+ * This utility function combines a base path with a destination path to create
10
+ * the final resolved file path for generated artifacts. It handles special path
11
+ * prefixes (like '@/') and provides sensible defaults when no base path is specified.
12
+ *
13
+ * The function is used throughout the rendering pipeline to determine the final
14
+ * file system locations for generated code artifacts, ensuring consistent path
15
+ * resolution across different operating systems and deployment scenarios.
16
+ *
17
+ * @param args - Path resolution configuration
18
+ * @param args.basePath - Base directory path (defaults to './' if undefined)
19
+ * @param args.destinationPath - Destination path for the artifact
20
+ * @returns The resolved absolute or relative path for the artifact
21
+ *
22
+ * @example Basic path resolution
23
+ * ```typescript
24
+ * import { toResolvedArtifactPath } from '@skmtc/core';
25
+ *
26
+ * // With explicit base path
27
+ * const resolved1 = toResolvedArtifactPath({
28
+ * basePath: './src/generated',
29
+ * destinationPath: 'models/User.ts'
30
+ * });
31
+ * console.log(resolved1); // './src/generated/models/User.ts'
32
+ *
33
+ * // With undefined base path (uses default)
34
+ * const resolved2 = toResolvedArtifactPath({
35
+ * basePath: undefined,
36
+ * destinationPath: 'types.ts'
37
+ * });
38
+ * console.log(resolved2); // './types.ts'
39
+ * ```
40
+ *
41
+ * @example Special path prefix handling
42
+ * ```typescript
43
+ * // '@/' prefix gets stripped and resolved relative to base
44
+ * const resolved = toResolvedArtifactPath({
45
+ * basePath: './output',
46
+ * destinationPath: '@/api/models.ts'
47
+ * });
48
+ * console.log(resolved); // './output/api/models.ts'
49
+ *
50
+ * // Regular paths work normally
51
+ * const normal = toResolvedArtifactPath({
52
+ * basePath: './build',
53
+ * destinationPath: 'components/Button.tsx'
54
+ * });
55
+ * console.log(normal); // './build/components/Button.tsx'
56
+ * ```
57
+ *
58
+ * @example Cross-platform path resolution
59
+ * ```typescript
60
+ * // Works consistently across platforms
61
+ * const windowsPath = toResolvedArtifactPath({
62
+ * basePath: 'C:\\projects\\app\\dist',
63
+ * destinationPath: 'utils/helpers.js'
64
+ * });
65
+ *
66
+ * const unixPath = toResolvedArtifactPath({
67
+ * basePath: '/home/user/projects/app/dist',
68
+ * destinationPath: 'utils/helpers.js'
69
+ * });
70
+ * ```
71
+ *
72
+ * @example Usage in file generation
73
+ * ```typescript
74
+ * class ArtifactWriter {
75
+ * writeArtifact(
76
+ * content: string,
77
+ * destination: string,
78
+ * baseDir?: string
79
+ * ) {
80
+ * const resolvedPath = toResolvedArtifactPath({
81
+ * basePath: baseDir,
82
+ * destinationPath: destination
83
+ * });
84
+ *
85
+ * console.log(`Writing to: ${resolvedPath}`);
86
+ * return Deno.writeTextFile(resolvedPath, content);
87
+ * }
88
+ * }
89
+ *
90
+ * const writer = new ArtifactWriter();
91
+ * await writer.writeArtifact(
92
+ * 'export const greeting = "Hello";',
93
+ * '@/constants.ts',
94
+ * './src/generated'
95
+ * );
96
+ * // Writes to: ./src/generated/constants.ts
97
+ * ```
98
+ *
99
+ * @example Integration with rendering pipeline
100
+ * ```typescript
101
+ * class FileRenderer {
102
+ * renderFiles(
103
+ * files: Map<string, File>,
104
+ * outputDir: string
105
+ * ): Record<string, string> {
106
+ * const artifacts: Record<string, string> = {};
107
+ *
108
+ * for (const [destPath, file] of files) {
109
+ * const resolvedPath = toResolvedArtifactPath({
110
+ * basePath: outputDir,
111
+ * destinationPath: destPath
112
+ * });
113
+ *
114
+ * artifacts[resolvedPath] = file.toString();
115
+ * }
116
+ *
117
+ * return artifacts;
118
+ * }
119
+ * }
120
+ * ```
121
+ *
122
+ * @example Dynamic base path resolution
123
+ * ```typescript
124
+ * function resolveForEnvironment(
125
+ * destination: string,
126
+ * env: 'development' | 'production'
127
+ * ): string {
128
+ * const basePaths = {
129
+ * development: './dev-output',
130
+ * production: './dist'
131
+ * };
132
+ *
133
+ * return toResolvedArtifactPath({
134
+ * basePath: basePaths[env],
135
+ * destinationPath: destination
136
+ * });
137
+ * }
138
+ *
139
+ * const devPath = resolveForEnvironment('api.ts', 'development');
140
+ * const prodPath = resolveForEnvironment('api.ts', 'production');
141
+ *
142
+ * console.log(devPath); // './dev-output/api.ts'
143
+ * console.log(prodPath); // './dist/api.ts'
144
+ * ```
145
+ */
6
146
  const toResolvedArtifactPath = ({ basePath, destinationPath }) => {
7
147
  return (0, join_js_1.join)(basePath ?? './', destinationPath.replace(/^@\//, ''));
8
148
  };
@@ -1,13 +1,93 @@
1
1
  import type { OasRef } from '../ref/Ref.js';
2
2
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
3
3
  import type { OpenAPIV3 } from 'openapi-types';
4
+ /**
5
+ * Constructor fields for {@link OasExample}.
6
+ */
4
7
  export type ExampleFields = {
8
+ /** Short summary of the example */
5
9
  summary: string | undefined;
10
+ /** Longer description of the example */
6
11
  description: string | undefined;
12
+ /** The example value */
7
13
  value: unknown;
14
+ /** Custom extension fields (x-* properties) */
8
15
  extensionFields?: Record<string, unknown>;
9
16
  };
10
- /** Provides example data represented by schema */
17
+ /**
18
+ * Represents an Example Object in the OpenAPI Specification.
19
+ *
20
+ * The `OasExample` class provides sample data for parameters, request bodies,
21
+ * responses, and other components in an OpenAPI document. Examples are crucial
22
+ * for API documentation, testing, and helping developers understand expected
23
+ * data formats and structures.
24
+ *
25
+ * This class supports rich example definitions with metadata, making API
26
+ * documentation more informative and interactive for developers.
27
+ *
28
+ * ## Key Features
29
+ *
30
+ * - **Sample Data**: Concrete examples of API inputs and outputs
31
+ * - **Documentation**: Summary and description for context
32
+ * - **Type Flexibility**: Supports any data type as example values
33
+ * - **Reference Support**: Can be referenced from multiple locations
34
+ * - **Markdown Support**: Rich text descriptions with CommonMark
35
+ *
36
+ * @example Simple string example
37
+ * ```typescript
38
+ * import { OasExample } from '@skmtc/core';
39
+ *
40
+ * const nameExample = new OasExample({
41
+ * summary: 'Typical user name',
42
+ * description: 'A common first and last name combination',
43
+ * value: 'John Doe'
44
+ * });
45
+ * ```
46
+ *
47
+ * @example JSON object example
48
+ * ```typescript
49
+ * const userExample = new OasExample({
50
+ * summary: 'Complete user profile',
51
+ * description: 'Example user with all profile fields populated',
52
+ * value: {
53
+ * id: 12345,
54
+ * name: 'Jane Smith',
55
+ * email: 'jane.smith@example.com',
56
+ * active: true,
57
+ * createdAt: '2023-01-15T10:30:00Z'
58
+ * }
59
+ * });
60
+ * ```
61
+ *
62
+ * @example Array example with multiple items
63
+ * ```typescript
64
+ * const productsExample = new OasExample({
65
+ * summary: 'Product list sample',
66
+ * description: 'Typical response for product catalog endpoint',
67
+ * value: [
68
+ * { id: 1, name: 'Laptop', price: 999.99, category: 'Electronics' },
69
+ * { id: 2, name: 'Book', price: 19.99, category: 'Education' },
70
+ * { id: 3, name: 'Coffee Mug', price: 12.50, category: 'Home' }
71
+ * ]
72
+ * });
73
+ * ```
74
+ *
75
+ * @example Error response example
76
+ * ```typescript
77
+ * const errorExample = new OasExample({
78
+ * summary: 'Validation error',
79
+ * description: 'Response when request validation fails',
80
+ * value: {
81
+ * error: 'Validation failed',
82
+ * code: 'INVALID_INPUT',
83
+ * details: [
84
+ * { field: 'email', message: 'Invalid email format' },
85
+ * { field: 'age', message: 'Must be between 18 and 120' }
86
+ * ]
87
+ * }
88
+ * });
89
+ * ```
90
+ */
11
91
  export declare class OasExample {
12
92
  #private;
13
93
  /** Static identifier property for OasExample */
@@ -1 +1 @@
1
- {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,kDAAkD;AAClD,qBAAa,UAAU;;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;gBAIlB,MAAM,EAAE,aAAa;IAIjC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,2EAA2E;IAC3E,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,6BAA6B;IAC7B,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEzD;IAED,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAOrE"}
1
+ {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mCAAmC;IACnC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,wCAAwC;IACxC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,qBAAa,UAAU;;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;gBAIlB,MAAM,EAAE,aAAa;IAIjC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,2EAA2E;IAC3E,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,6BAA6B;IAC7B,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEzD;IAED,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAOrE"}
@@ -13,7 +13,80 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _OasExample_fields;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.OasExample = void 0;
16
- /** Provides example data represented by schema */
16
+ /**
17
+ * Represents an Example Object in the OpenAPI Specification.
18
+ *
19
+ * The `OasExample` class provides sample data for parameters, request bodies,
20
+ * responses, and other components in an OpenAPI document. Examples are crucial
21
+ * for API documentation, testing, and helping developers understand expected
22
+ * data formats and structures.
23
+ *
24
+ * This class supports rich example definitions with metadata, making API
25
+ * documentation more informative and interactive for developers.
26
+ *
27
+ * ## Key Features
28
+ *
29
+ * - **Sample Data**: Concrete examples of API inputs and outputs
30
+ * - **Documentation**: Summary and description for context
31
+ * - **Type Flexibility**: Supports any data type as example values
32
+ * - **Reference Support**: Can be referenced from multiple locations
33
+ * - **Markdown Support**: Rich text descriptions with CommonMark
34
+ *
35
+ * @example Simple string example
36
+ * ```typescript
37
+ * import { OasExample } from '@skmtc/core';
38
+ *
39
+ * const nameExample = new OasExample({
40
+ * summary: 'Typical user name',
41
+ * description: 'A common first and last name combination',
42
+ * value: 'John Doe'
43
+ * });
44
+ * ```
45
+ *
46
+ * @example JSON object example
47
+ * ```typescript
48
+ * const userExample = new OasExample({
49
+ * summary: 'Complete user profile',
50
+ * description: 'Example user with all profile fields populated',
51
+ * value: {
52
+ * id: 12345,
53
+ * name: 'Jane Smith',
54
+ * email: 'jane.smith@example.com',
55
+ * active: true,
56
+ * createdAt: '2023-01-15T10:30:00Z'
57
+ * }
58
+ * });
59
+ * ```
60
+ *
61
+ * @example Array example with multiple items
62
+ * ```typescript
63
+ * const productsExample = new OasExample({
64
+ * summary: 'Product list sample',
65
+ * description: 'Typical response for product catalog endpoint',
66
+ * value: [
67
+ * { id: 1, name: 'Laptop', price: 999.99, category: 'Electronics' },
68
+ * { id: 2, name: 'Book', price: 19.99, category: 'Education' },
69
+ * { id: 3, name: 'Coffee Mug', price: 12.50, category: 'Home' }
70
+ * ]
71
+ * });
72
+ * ```
73
+ *
74
+ * @example Error response example
75
+ * ```typescript
76
+ * const errorExample = new OasExample({
77
+ * summary: 'Validation error',
78
+ * description: 'Response when request validation fails',
79
+ * value: {
80
+ * error: 'Validation failed',
81
+ * code: 'INVALID_INPUT',
82
+ * details: [
83
+ * { field: 'email', message: 'Invalid email format' },
84
+ * { field: 'age', message: 'Must be between 18 and 120' }
85
+ * ]
86
+ * }
87
+ * });
88
+ * ```
89
+ */
17
90
  class OasExample {
18
91
  constructor(fields) {
19
92
  /** Static identifier property for OasExample */