@skmtc/core 0.0.792 → 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 (71) 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/parseModuleName.d.ts +175 -0
  23. package/esm/helpers/parseModuleName.d.ts.map +1 -1
  24. package/esm/helpers/parseModuleName.js +153 -0
  25. package/esm/helpers/toResolvedArtifactPath.d.ts +145 -0
  26. package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  27. package/esm/helpers/toResolvedArtifactPath.js +140 -0
  28. package/esm/oas/schema/Schema.d.ts +117 -0
  29. package/esm/oas/schema/Schema.d.ts.map +1 -1
  30. package/esm/typescript/identifiers.d.ts +159 -0
  31. package/esm/typescript/identifiers.d.ts.map +1 -1
  32. package/esm/typescript/identifiers.js +159 -0
  33. package/esm/typescript/withDescription.d.ts +119 -0
  34. package/esm/typescript/withDescription.d.ts.map +1 -1
  35. package/esm/typescript/withDescription.js +119 -0
  36. package/package.json +1 -1
  37. package/script/dsl/GeneratedValueList.d.ts +158 -0
  38. package/script/dsl/GeneratedValueList.d.ts.map +1 -1
  39. package/script/dsl/GeneratedValueList.js +158 -0
  40. package/script/dsl/Stringable.d.ts +76 -0
  41. package/script/dsl/Stringable.d.ts.map +1 -1
  42. package/script/dsl/Stringable.js +75 -0
  43. package/script/helpers/collateExamples.d.ts +150 -0
  44. package/script/helpers/collateExamples.d.ts.map +1 -1
  45. package/script/helpers/collateExamples.js +145 -0
  46. package/script/helpers/formatNumber.d.ts +95 -0
  47. package/script/helpers/formatNumber.d.ts.map +1 -1
  48. package/script/helpers/formatNumber.js +95 -0
  49. package/script/helpers/generationStats.d.ts +287 -1
  50. package/script/helpers/generationStats.d.ts.map +1 -1
  51. package/script/helpers/generationStats.js +266 -0
  52. package/script/helpers/isEmpty.d.ts +62 -0
  53. package/script/helpers/isEmpty.d.ts.map +1 -1
  54. package/script/helpers/isEmpty.js +62 -0
  55. package/script/helpers/isImported.d.ts +80 -0
  56. package/script/helpers/isImported.d.ts.map +1 -1
  57. package/script/helpers/isImported.js +80 -0
  58. package/script/helpers/parseModuleName.d.ts +175 -0
  59. package/script/helpers/parseModuleName.d.ts.map +1 -1
  60. package/script/helpers/parseModuleName.js +153 -0
  61. package/script/helpers/toResolvedArtifactPath.d.ts +145 -0
  62. package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  63. package/script/helpers/toResolvedArtifactPath.js +140 -0
  64. package/script/oas/schema/Schema.d.ts +117 -0
  65. package/script/oas/schema/Schema.d.ts.map +1 -1
  66. package/script/typescript/identifiers.d.ts +159 -0
  67. package/script/typescript/identifiers.d.ts.map +1 -1
  68. package/script/typescript/identifiers.js +159 -0
  69. package/script/typescript/withDescription.d.ts +119 -0
  70. package/script/typescript/withDescription.d.ts.map +1 -1
  71. package/script/typescript/withDescription.js +119 -0
@@ -1,6 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEmpty = void 0;
4
+ /**
5
+ * Checks whether a record/object is empty (has no enumerable properties).
6
+ *
7
+ * This utility function determines if an object contains any enumerable properties
8
+ * by checking the length of its keys array. It's commonly used throughout the
9
+ * SKMTC codebase to validate whether generated objects, configurations, or
10
+ * other data structures contain meaningful content.
11
+ *
12
+ * @param value - The record/object to check for emptiness
13
+ * @returns `true` if the object has no enumerable properties, `false` otherwise
14
+ *
15
+ * @example Basic usage
16
+ * ```typescript
17
+ * import { isEmpty } from '@skmtc/core';
18
+ *
19
+ * console.log(isEmpty({})); // true
20
+ * console.log(isEmpty({ name: 'John' })); // false
21
+ * console.log(isEmpty({ a: undefined })); // false (undefined is still a property)
22
+ * ```
23
+ *
24
+ * @example In conditional logic
25
+ * ```typescript
26
+ * const userPreferences = loadUserPreferences();
27
+ *
28
+ * if (isEmpty(userPreferences)) {
29
+ * // Apply default settings
30
+ * applyDefaults();
31
+ * } else {
32
+ * // Use user's custom settings
33
+ * applyUserSettings(userPreferences);
34
+ * }
35
+ * ```
36
+ *
37
+ * @example Filtering collections
38
+ * ```typescript
39
+ * const configurations = [
40
+ * { api: 'v1', settings: {} },
41
+ * { api: 'v2', settings: { timeout: 5000 } },
42
+ * { api: 'v3', settings: {} }
43
+ * ];
44
+ *
45
+ * const validConfigs = configurations.filter(config => !isEmpty(config.settings));
46
+ * console.log(validConfigs); // [{ api: 'v2', settings: { timeout: 5000 } }]
47
+ * ```
48
+ *
49
+ * @example Code generation usage
50
+ * ```typescript
51
+ * class Generator {
52
+ * generateInterface(properties: Record<string, string>) {
53
+ * if (isEmpty(properties)) {
54
+ * return 'interface EmptyInterface {}';
55
+ * }
56
+ *
57
+ * const props = Object.entries(properties)
58
+ * .map(([name, type]) => ` ${name}: ${type};`)
59
+ * .join('\n');
60
+ *
61
+ * return `interface GeneratedInterface {\n${props}\n}`;
62
+ * }
63
+ * }
64
+ * ```
65
+ */
4
66
  require("../_dnt.polyfills.js");
5
67
  const isEmpty = (value) => {
6
68
  return Object.keys(value).length === 0;
@@ -1,2 +1,82 @@
1
+ /**
2
+ * Determines whether two file paths represent different locations (import required).
3
+ *
4
+ * This utility function normalizes two file paths and compares them to determine
5
+ * if they represent different files. It's used throughout the SKMTC system to
6
+ * decide when import statements are needed - if two paths are different, an
7
+ * import is required to access symbols from one file in another.
8
+ *
9
+ * The function handles path normalization to ensure consistent comparisons
10
+ * across different operating systems and path formats (handling './' vs absolute
11
+ * paths, different separators, etc.).
12
+ *
13
+ * @param pathOne - The first file path to compare
14
+ * @param pathTwo - The second file path to compare
15
+ * @returns `true` if the paths are different (import needed), `false` if they're the same file
16
+ *
17
+ * @example Basic path comparison
18
+ * ```typescript
19
+ * import { isImported } from '@skmtc/core';
20
+ *
21
+ * // Same file, no import needed
22
+ * console.log(isImported('./src/user.ts', './src/user.ts')); // false
23
+ *
24
+ * // Different files, import needed
25
+ * console.log(isImported('./src/user.ts', './src/product.ts')); // true
26
+ * ```
27
+ *
28
+ * @example Path normalization handling
29
+ * ```typescript
30
+ * // These all represent the same file after normalization
31
+ * console.log(isImported('./src/user.ts', 'src/user.ts')); // false
32
+ * console.log(isImported('src/./user.ts', 'src/user.ts')); // false
33
+ * console.log(isImported('src/models/../user.ts', 'src/user.ts')); // false
34
+ * ```
35
+ *
36
+ * @example Usage in import decision logic
37
+ * ```typescript
38
+ * class FileGenerator {
39
+ * addImportIfNeeded(
40
+ * sourceFile: string,
41
+ * targetFile: string,
42
+ * importName: string
43
+ * ) {
44
+ * if (isImported(sourceFile, targetFile)) {
45
+ * // Files are different, add import
46
+ * this.addImport(sourceFile, targetFile, importName);
47
+ * console.log(`Added import: ${importName} from ${targetFile}`);
48
+ * } else {
49
+ * // Same file, no import needed
50
+ * console.log(`No import needed - same file: ${sourceFile}`);
51
+ * }
52
+ * }
53
+ * }
54
+ * ```
55
+ *
56
+ * @example Cross-platform path handling
57
+ * ```typescript
58
+ * // Works consistently across platforms
59
+ * const windowsPath = 'src\\models\\user.ts';
60
+ * const unixPath = 'src/models/user.ts';
61
+ *
62
+ * console.log(isImported(windowsPath, unixPath)); // false (same file)
63
+ * ```
64
+ *
65
+ * @example In generator context
66
+ * ```typescript
67
+ * class ModelGenerator {
68
+ * generateModel(modelPath: string, referencePath: string) {
69
+ * const definition = this.createModelDefinition();
70
+ *
71
+ * if (isImported(modelPath, referencePath)) {
72
+ * // Need to import the referenced model
73
+ * definition.addImport(referencePath, 'ReferencedModel');
74
+ * }
75
+ *
76
+ * return definition;
77
+ * }
78
+ * }
79
+ * ```
80
+ */
1
81
  export declare const isImported: (pathOne: string, pathTwo: string) => boolean;
2
82
  //# sourceMappingURL=isImported.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isImported.d.ts","sourceRoot":"","sources":["../../src/helpers/isImported.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,OAE7D,CAAA"}
1
+ {"version":3,"file":"isImported.d.ts","sourceRoot":"","sources":["../../src/helpers/isImported.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,OAE7D,CAAA"}
@@ -2,6 +2,86 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isImported = void 0;
4
4
  const normalize_js_1 = require("../deps/jsr.io/@std/path/1.1.2/normalize.js");
5
+ /**
6
+ * Determines whether two file paths represent different locations (import required).
7
+ *
8
+ * This utility function normalizes two file paths and compares them to determine
9
+ * if they represent different files. It's used throughout the SKMTC system to
10
+ * decide when import statements are needed - if two paths are different, an
11
+ * import is required to access symbols from one file in another.
12
+ *
13
+ * The function handles path normalization to ensure consistent comparisons
14
+ * across different operating systems and path formats (handling './' vs absolute
15
+ * paths, different separators, etc.).
16
+ *
17
+ * @param pathOne - The first file path to compare
18
+ * @param pathTwo - The second file path to compare
19
+ * @returns `true` if the paths are different (import needed), `false` if they're the same file
20
+ *
21
+ * @example Basic path comparison
22
+ * ```typescript
23
+ * import { isImported } from '@skmtc/core';
24
+ *
25
+ * // Same file, no import needed
26
+ * console.log(isImported('./src/user.ts', './src/user.ts')); // false
27
+ *
28
+ * // Different files, import needed
29
+ * console.log(isImported('./src/user.ts', './src/product.ts')); // true
30
+ * ```
31
+ *
32
+ * @example Path normalization handling
33
+ * ```typescript
34
+ * // These all represent the same file after normalization
35
+ * console.log(isImported('./src/user.ts', 'src/user.ts')); // false
36
+ * console.log(isImported('src/./user.ts', 'src/user.ts')); // false
37
+ * console.log(isImported('src/models/../user.ts', 'src/user.ts')); // false
38
+ * ```
39
+ *
40
+ * @example Usage in import decision logic
41
+ * ```typescript
42
+ * class FileGenerator {
43
+ * addImportIfNeeded(
44
+ * sourceFile: string,
45
+ * targetFile: string,
46
+ * importName: string
47
+ * ) {
48
+ * if (isImported(sourceFile, targetFile)) {
49
+ * // Files are different, add import
50
+ * this.addImport(sourceFile, targetFile, importName);
51
+ * console.log(`Added import: ${importName} from ${targetFile}`);
52
+ * } else {
53
+ * // Same file, no import needed
54
+ * console.log(`No import needed - same file: ${sourceFile}`);
55
+ * }
56
+ * }
57
+ * }
58
+ * ```
59
+ *
60
+ * @example Cross-platform path handling
61
+ * ```typescript
62
+ * // Works consistently across platforms
63
+ * const windowsPath = 'src\\models\\user.ts';
64
+ * const unixPath = 'src/models/user.ts';
65
+ *
66
+ * console.log(isImported(windowsPath, unixPath)); // false (same file)
67
+ * ```
68
+ *
69
+ * @example In generator context
70
+ * ```typescript
71
+ * class ModelGenerator {
72
+ * generateModel(modelPath: string, referencePath: string) {
73
+ * const definition = this.createModelDefinition();
74
+ *
75
+ * if (isImported(modelPath, referencePath)) {
76
+ * // Need to import the referenced model
77
+ * definition.addImport(referencePath, 'ReferencedModel');
78
+ * }
79
+ *
80
+ * return definition;
81
+ * }
82
+ * }
83
+ * ```
84
+ */
5
85
  const isImported = (pathOne, pathTwo) => {
6
86
  return (0, normalize_js_1.normalize)(pathOne) !== (0, normalize_js_1.normalize)(pathTwo);
7
87
  };
@@ -1,8 +1,183 @@
1
+ /**
2
+ * Represents the parsed components of a module name.
3
+ *
4
+ * This type breaks down a module name into its constituent parts,
5
+ * supporting various formats used in different package managers
6
+ * and registries (npm, JSR, Deno, etc.).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // For 'jsr:@std/path@1.0.0'
11
+ * const parsed: ParsedModuleName = {
12
+ * scheme: 'jsr',
13
+ * scopeName: '@std',
14
+ * packageName: 'path',
15
+ * version: '1.0.0'
16
+ * };
17
+ * ```
18
+ */
1
19
  export type ParsedModuleName = {
20
+ /** The module scheme (e.g., 'npm', 'jsr', 'https') */
2
21
  scheme: string | null;
22
+ /** The scope name for scoped packages (e.g., '@std', '@company') */
3
23
  scopeName: string | null;
24
+ /** The package name (the main identifier) */
4
25
  packageName: string;
26
+ /** The version specifier (e.g., '1.0.0', '^2.3.4') */
5
27
  version: string | null;
6
28
  };
29
+ /**
30
+ * Parses a module name string into its component parts.
31
+ *
32
+ * This utility function decomposes module names from various formats into
33
+ * structured components, handling schemes, scopes, versions, and package names.
34
+ * It supports formats used by npm, JSR, Deno, and other package managers.
35
+ *
36
+ * The parser handles complex module name patterns including:
37
+ * - Scheme prefixes (jsr:, npm:, https:)
38
+ * - Scoped packages (@scope/package)
39
+ * - Version specifiers (@version)
40
+ * - Combinations of the above
41
+ *
42
+ * @param moduleName - The module name string to parse
43
+ * @returns Parsed components of the module name
44
+ *
45
+ * @example Basic package names
46
+ * ```typescript
47
+ * import { parseModuleName } from '@skmtc/core';
48
+ *
49
+ * // Simple package name
50
+ * const simple = parseModuleName('lodash');
51
+ * // {
52
+ * // scheme: null,
53
+ * // scopeName: null,
54
+ * // packageName: 'lodash',
55
+ * // version: null
56
+ * // }
57
+ *
58
+ * // Package with version
59
+ * const versioned = parseModuleName('lodash@4.17.21');
60
+ * // {
61
+ * // scheme: null,
62
+ * // scopeName: null,
63
+ * // packageName: 'lodash',
64
+ * // version: '4.17.21'
65
+ * // }
66
+ * ```
67
+ *
68
+ * @example Scoped packages
69
+ * ```typescript
70
+ * // Scoped package
71
+ * const scoped = parseModuleName('@company/utils');
72
+ * // {
73
+ * // scheme: null,
74
+ * // scopeName: '@company',
75
+ * // packageName: 'utils',
76
+ * // version: null
77
+ * // }
78
+ *
79
+ * // Scoped package with version
80
+ * const scopedVersioned = parseModuleName('@company/utils@2.0.0');
81
+ * // {
82
+ * // scheme: null,
83
+ * // scopeName: '@company',
84
+ * // packageName: 'utils',
85
+ * // version: '2.0.0'
86
+ * // }
87
+ * ```
88
+ *
89
+ * @example Scheme-prefixed modules
90
+ * ```typescript
91
+ * // JSR module
92
+ * const jsrModule = parseModuleName('jsr:@std/path@1.0.0');
93
+ * // {
94
+ * // scheme: 'jsr',
95
+ * // scopeName: '@std',
96
+ * // packageName: 'path',
97
+ * // version: '1.0.0'
98
+ * // }
99
+ *
100
+ * // npm module with scheme
101
+ * const npmModule = parseModuleName('npm:lodash@^4.17.0');
102
+ * // {
103
+ * // scheme: 'npm',
104
+ * // scopeName: null,
105
+ * // packageName: 'lodash',
106
+ * // version: '^4.17.0'
107
+ * // }
108
+ *
109
+ * // HTTPS module
110
+ * const httpsModule = parseModuleName('https:example.com/package@v1.2.3');
111
+ * // {
112
+ * // scheme: 'https',
113
+ * // scopeName: null,
114
+ * // packageName: 'example.com/package',
115
+ * // version: 'v1.2.3'
116
+ * // }
117
+ * ```
118
+ *
119
+ * @example Complex parsing scenarios
120
+ * ```typescript
121
+ * // Multiple levels in package name
122
+ * const nested = parseModuleName('npm:@babel/plugin-transform-runtime@^7.0.0');
123
+ * // {
124
+ * // scheme: 'npm',
125
+ * // scopeName: '@babel',
126
+ * // packageName: 'plugin-transform-runtime',
127
+ * // version: '^7.0.0'
128
+ * // }
129
+ *
130
+ * // Version ranges and pre-release versions
131
+ * const prerelease = parseModuleName('jsr:@deno/std@1.0.0-rc.1');
132
+ * // {
133
+ * // scheme: 'jsr',
134
+ * // scopeName: '@deno',
135
+ * // packageName: 'std',
136
+ * // version: '1.0.0-rc.1'
137
+ * // }
138
+ * ```
139
+ *
140
+ * @example Usage in dependency management
141
+ * ```typescript
142
+ * class DependencyManager {
143
+ * processDependency(moduleSpec: string) {
144
+ * const parsed = parseModuleName(moduleSpec);
145
+ *
146
+ * console.log(`Processing ${parsed.packageName}`);
147
+ *
148
+ * if (parsed.scheme) {
149
+ * console.log(`Using ${parsed.scheme} registry`);
150
+ * }
151
+ *
152
+ * if (parsed.scopeName) {
153
+ * console.log(`Scoped package: ${parsed.scopeName}/${parsed.packageName}`);
154
+ * }
155
+ *
156
+ * if (parsed.version) {
157
+ * console.log(`Version constraint: ${parsed.version}`);
158
+ * }
159
+ *
160
+ * return this.resolvePackage(parsed);
161
+ * }
162
+ * }
163
+ * ```
164
+ *
165
+ * @example Building module URLs
166
+ * ```typescript
167
+ * function buildModuleUrl(moduleSpec: string): string {
168
+ * const parsed = parseModuleName(moduleSpec);
169
+ *
170
+ * switch (parsed.scheme) {
171
+ * case 'jsr':
172
+ * return `https://jsr.io/${parsed.scopeName}/${parsed.packageName}`;
173
+ * case 'npm':
174
+ * const scope = parsed.scopeName ? `${parsed.scopeName}/` : '';
175
+ * return `https://npmjs.com/package/${scope}${parsed.packageName}`;
176
+ * default:
177
+ * return `https://deno.land/x/${parsed.packageName}`;
178
+ * }
179
+ * }
180
+ * ```
181
+ */
7
182
  export declare const parseModuleName: (moduleName: string) => ParsedModuleName;
8
183
  //# sourceMappingURL=parseModuleName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseModuleName.d.ts","sourceRoot":"","sources":["../../src/helpers/parseModuleName.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,YAAY,MAAM,KAAG,gBAgCpD,CAAA"}
1
+ {"version":3,"file":"parseModuleName.d.ts","sourceRoot":"","sources":["../../src/helpers/parseModuleName.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sDAAsD;IACtD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAA;IACnB,sDAAsD;IACtD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwJG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,MAAM,KAAG,gBAgCpD,CAAA"}
@@ -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,