@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
@@ -1,6 +1,89 @@
1
+ /**
2
+ * Represents the type of a TypeScript entity for code generation.
3
+ *
4
+ * `EntityType` encapsulates the distinction between different kinds of
5
+ * TypeScript entities, specifically variables (which become `const` declarations)
6
+ * and types (which become `type` or `interface` declarations).
7
+ *
8
+ * This class is used by the {@link Identifier} system to ensure that
9
+ * generated code uses the correct TypeScript keywords and syntax patterns.
10
+ *
11
+ * @example Variable entity type
12
+ * ```typescript
13
+ * import { EntityType } from '@skmtc/core';
14
+ *
15
+ * const variableEntity = new EntityType('variable');
16
+ * console.log(variableEntity.toString()); // 'const'
17
+ *
18
+ * // Used in code generation:
19
+ * // const API_URL = 'https://api.example.com';
20
+ * ```
21
+ *
22
+ * @example Type entity type
23
+ * ```typescript
24
+ * const typeEntity = new EntityType('type');
25
+ * console.log(typeEntity.toString()); // 'type'
26
+ *
27
+ * // Used in code generation:
28
+ * // type User = { id: string; name: string; };
29
+ * ```
30
+ *
31
+ * @example Integration with Identifier
32
+ * ```typescript
33
+ * import { Identifier, EntityType } from '@skmtc/core';
34
+ *
35
+ * // Create a variable identifier (uses 'const' keyword)
36
+ * const varId = Identifier.createVariable('API_KEY', 'string');
37
+ * console.log(varId.entityType.toString()); // 'const'
38
+ *
39
+ * // Create a type identifier (uses 'type' keyword)
40
+ * const typeId = Identifier.createType('UserStatus');
41
+ * console.log(typeId.entityType.toString()); // 'type'
42
+ * ```
43
+ */
1
44
  export declare class EntityType {
45
+ /** The entity type discriminator */
2
46
  type: 'variable' | 'type';
47
+ /**
48
+ * Creates a new EntityType instance.
49
+ *
50
+ * @param type - The type of entity ('variable' for const declarations, 'type' for type declarations)
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // For generating const declarations
55
+ * const constEntity = new EntityType('variable');
56
+ *
57
+ * // For generating type declarations
58
+ * const typeEntity = new EntityType('type');
59
+ * ```
60
+ */
3
61
  constructor(type: 'variable' | 'type');
62
+ /**
63
+ * Returns the appropriate TypeScript keyword for this entity type.
64
+ *
65
+ * This method maps the entity type to the correct TypeScript declaration
66
+ * keyword that should be used in generated code:
67
+ * - 'variable' entities become 'const' declarations
68
+ * - 'type' entities become 'type' declarations
69
+ *
70
+ * @returns The TypeScript keyword string ('const' or 'type')
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const varEntity = new EntityType('variable');
75
+ * console.log(varEntity.toString()); // 'const'
76
+ *
77
+ * const typeEntity = new EntityType('type');
78
+ * console.log(typeEntity.toString()); // 'type'
79
+ *
80
+ * // Used in code generation:
81
+ * const keyword = entityType.toString();
82
+ * const declaration = `${keyword} ${identifier} = ${value};`;
83
+ * // Results in: "const API_URL = 'https://example.com';" or
84
+ * // Results in: "type Status = 'active' | 'inactive';"
85
+ * ```
86
+ */
4
87
  toString(): string;
5
88
  }
6
89
  //# sourceMappingURL=EntityType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityType.d.ts","sourceRoot":"","sources":["../../src/dsl/EntityType.ts"],"names":[],"mappings":"AAEA,qBAAa,UAAU;IACrB,IAAI,EAAE,UAAU,GAAG,MAAM,CAAA;gBACb,IAAI,EAAE,UAAU,GAAG,MAAM;IAIrC,QAAQ,IAAI,MAAM;CAMnB"}
1
+ {"version":3,"file":"EntityType.d.ts","sourceRoot":"","sources":["../../src/dsl/EntityType.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBAAa,UAAU;IACrB,oCAAoC;IACpC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAA;IAEzB;;;;;;;;;;;;;OAaG;gBACS,IAAI,EAAE,UAAU,GAAG,MAAM;IAIrC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,IAAI,MAAM;CAMnB"}
@@ -2,8 +2,66 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EntityType = void 0;
4
4
  const ts_pattern_1 = require("ts-pattern");
5
+ /**
6
+ * Represents the type of a TypeScript entity for code generation.
7
+ *
8
+ * `EntityType` encapsulates the distinction between different kinds of
9
+ * TypeScript entities, specifically variables (which become `const` declarations)
10
+ * and types (which become `type` or `interface` declarations).
11
+ *
12
+ * This class is used by the {@link Identifier} system to ensure that
13
+ * generated code uses the correct TypeScript keywords and syntax patterns.
14
+ *
15
+ * @example Variable entity type
16
+ * ```typescript
17
+ * import { EntityType } from '@skmtc/core';
18
+ *
19
+ * const variableEntity = new EntityType('variable');
20
+ * console.log(variableEntity.toString()); // 'const'
21
+ *
22
+ * // Used in code generation:
23
+ * // const API_URL = 'https://api.example.com';
24
+ * ```
25
+ *
26
+ * @example Type entity type
27
+ * ```typescript
28
+ * const typeEntity = new EntityType('type');
29
+ * console.log(typeEntity.toString()); // 'type'
30
+ *
31
+ * // Used in code generation:
32
+ * // type User = { id: string; name: string; };
33
+ * ```
34
+ *
35
+ * @example Integration with Identifier
36
+ * ```typescript
37
+ * import { Identifier, EntityType } from '@skmtc/core';
38
+ *
39
+ * // Create a variable identifier (uses 'const' keyword)
40
+ * const varId = Identifier.createVariable('API_KEY', 'string');
41
+ * console.log(varId.entityType.toString()); // 'const'
42
+ *
43
+ * // Create a type identifier (uses 'type' keyword)
44
+ * const typeId = Identifier.createType('UserStatus');
45
+ * console.log(typeId.entityType.toString()); // 'type'
46
+ * ```
47
+ */
5
48
  class EntityType {
49
+ /**
50
+ * Creates a new EntityType instance.
51
+ *
52
+ * @param type - The type of entity ('variable' for const declarations, 'type' for type declarations)
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // For generating const declarations
57
+ * const constEntity = new EntityType('variable');
58
+ *
59
+ * // For generating type declarations
60
+ * const typeEntity = new EntityType('type');
61
+ * ```
62
+ */
6
63
  constructor(type) {
64
+ /** The entity type discriminator */
7
65
  Object.defineProperty(this, "type", {
8
66
  enumerable: true,
9
67
  configurable: true,
@@ -12,6 +70,31 @@ class EntityType {
12
70
  });
13
71
  this.type = type;
14
72
  }
73
+ /**
74
+ * Returns the appropriate TypeScript keyword for this entity type.
75
+ *
76
+ * This method maps the entity type to the correct TypeScript declaration
77
+ * keyword that should be used in generated code:
78
+ * - 'variable' entities become 'const' declarations
79
+ * - 'type' entities become 'type' declarations
80
+ *
81
+ * @returns The TypeScript keyword string ('const' or 'type')
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const varEntity = new EntityType('variable');
86
+ * console.log(varEntity.toString()); // 'const'
87
+ *
88
+ * const typeEntity = new EntityType('type');
89
+ * console.log(typeEntity.toString()); // 'type'
90
+ *
91
+ * // Used in code generation:
92
+ * const keyword = entityType.toString();
93
+ * const declaration = `${keyword} ${identifier} = ${value};`;
94
+ * // Results in: "const API_URL = 'https://example.com';" or
95
+ * // Results in: "type Status = 'active' | 'inactive';"
96
+ * ```
97
+ */
15
98
  toString() {
16
99
  return (0, ts_pattern_1.match)(this.type)
17
100
  .with('variable', () => 'const')
@@ -1,11 +1,163 @@
1
1
  import { EntityType } from './EntityType.js';
2
+ /**
3
+ * Represents a TypeScript identifier in the SKMTC DSL system.
4
+ *
5
+ * The `Identifier` class encapsulates named entities in generated code,
6
+ * providing type-safe creation and management of variables, types, and other
7
+ * identifiers. It distinguishes between different kinds of identifiers and
8
+ * optionally tracks type information.
9
+ *
10
+ * This class uses factory methods instead of direct construction to ensure
11
+ * proper entity type classification and to provide a cleaner API.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Type Safety**: Distinguishes between variables, types, and other entities
16
+ * - **Factory Methods**: Provides semantic constructors for different identifier types
17
+ * - **Optional Typing**: Can associate type information with variable identifiers
18
+ * - **String Conversion**: Clean string representation for code generation
19
+ *
20
+ * @example Creating variable identifiers
21
+ * ```typescript
22
+ * import { Identifier } from '@skmtc/core';
23
+ *
24
+ * // Simple variable without type
25
+ * const userName = Identifier.createVariable('userName');
26
+ * console.log(userName.toString()); // 'userName'
27
+ *
28
+ * // Typed variable
29
+ * const userId = Identifier.createVariable('userId', 'string');
30
+ * console.log(userId.name); // 'userId'
31
+ * console.log(userId.typeName); // 'string'
32
+ * ```
33
+ *
34
+ * @example Creating type identifiers
35
+ * ```typescript
36
+ * // Type identifier
37
+ * const userType = Identifier.createType('User');
38
+ * console.log(userType.toString()); // 'User'
39
+ * console.log(userType.entityType.value); // 'type'
40
+ * ```
41
+ *
42
+ * @example Using in code generation
43
+ * ```typescript
44
+ * import { Definition, Identifier } from '@skmtc/core';
45
+ *
46
+ * class ApiGenerator {
47
+ * generateFunction(name: string) {
48
+ * const funcId = Identifier.createVariable(name);
49
+ * const requestType = Identifier.createType('RequestType');
50
+ *
51
+ * return new Definition({
52
+ * name: funcId.name,
53
+ * content: `function ${funcId}(data: ${requestType}) {
54
+ * // Implementation
55
+ * }`
56
+ * });
57
+ * }
58
+ * }
59
+ * ```
60
+ */
2
61
  export declare class Identifier {
62
+ /** The identifier name */
3
63
  name: string;
64
+ /** The entity type (variable, type, etc.) */
4
65
  entityType: EntityType;
66
+ /** Optional type name for typed variables */
5
67
  typeName?: string;
68
+ /**
69
+ * Creates a new Identifier instance.
70
+ *
71
+ * This constructor is private to enforce the use of factory methods
72
+ * that provide better semantic clarity and type safety.
73
+ *
74
+ * @param args - Identifier configuration
75
+ */
6
76
  private constructor();
77
+ /**
78
+ * Creates a variable identifier with optional type information.
79
+ *
80
+ * This factory method creates an identifier for variables, constants,
81
+ * function parameters, and other value-based entities. Optionally
82
+ * associates type information for typed variables.
83
+ *
84
+ * @param name - The variable name
85
+ * @param typeName - Optional type name for the variable
86
+ * @returns A new variable Identifier instance
87
+ *
88
+ * @example Untyped variable
89
+ * ```typescript
90
+ * const count = Identifier.createVariable('count');
91
+ * console.log(count.name); // 'count'
92
+ * console.log(count.typeName); // undefined
93
+ * ```
94
+ *
95
+ * @example Typed variable
96
+ * ```typescript
97
+ * const userId = Identifier.createVariable('userId', 'string');
98
+ * console.log(userId.name); // 'userId'
99
+ * console.log(userId.typeName); // 'string'
100
+ * ```
101
+ *
102
+ * @example In function generation
103
+ * ```typescript
104
+ * const param = Identifier.createVariable('data', 'RequestData');
105
+ * const funcDef = `function processRequest(${param.name}: ${param.typeName}) {}`;
106
+ * ```
107
+ */
7
108
  static createVariable(name: string, typeName?: string): Identifier;
109
+ /**
110
+ * Creates a type identifier for TypeScript types.
111
+ *
112
+ * This factory method creates an identifier for type entities like
113
+ * interfaces, type aliases, classes, and other type-level constructs.
114
+ * Type identifiers don't have associated type information since they
115
+ * represent types themselves.
116
+ *
117
+ * @param name - The type name
118
+ * @returns A new type Identifier instance
119
+ *
120
+ * @example Interface type
121
+ * ```typescript
122
+ * const userInterface = Identifier.createType('User');
123
+ * console.log(userInterface.name); // 'User'
124
+ * console.log(userInterface.entityType.value); // 'type'
125
+ * ```
126
+ *
127
+ * @example Type alias
128
+ * ```typescript
129
+ * const statusType = Identifier.createType('Status');
130
+ * const typeDef = `type ${statusType} = 'pending' | 'complete'`;
131
+ * ```
132
+ *
133
+ * @example Generic type
134
+ * ```typescript
135
+ * const responseType = Identifier.createType('ApiResponse');
136
+ * const genericDef = `interface ${responseType}<T> { data: T; success: boolean; }`;
137
+ * ```
138
+ */
8
139
  static createType(name: string): Identifier;
140
+ /**
141
+ * Returns the string representation of the identifier.
142
+ *
143
+ * This method simply returns the identifier name, which is the most
144
+ * common usage when generating code. The name can be used directly
145
+ * in code generation contexts.
146
+ *
147
+ * @returns The identifier name as a string
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const variable = Identifier.createVariable('userName');
152
+ * const typeId = Identifier.createType('User');
153
+ *
154
+ * console.log(variable.toString()); // 'userName'
155
+ * console.log(typeId.toString()); // 'User'
156
+ *
157
+ * // Can be used directly in template strings
158
+ * const code = `const ${variable}: ${typeId} = getUserData();`;
159
+ * ```
160
+ */
9
161
  toString(): string;
10
162
  }
11
163
  //# sourceMappingURL=Identifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Identifier.d.ts","sourceRoot":"","sources":["../../src/dsl/Identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQ5C,qBAAa,UAAU;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,OAAO;IAMP,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU;IAelE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAO3C,QAAQ,IAAI,MAAM;CAGnB"}
1
+ {"version":3,"file":"Identifier.d.ts","sourceRoot":"","sources":["../../src/dsl/Identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAc5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,qBAAa,UAAU;IACrB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IAEZ,6CAA6C;IAC7C,UAAU,EAAE,UAAU,CAAA;IAEtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;;;;OAOG;IACH,OAAO;IAMP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU;IAelE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAO3C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
@@ -2,20 +2,90 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Identifier = void 0;
4
4
  const EntityType_js_1 = require("./EntityType.js");
5
+ /**
6
+ * Represents a TypeScript identifier in the SKMTC DSL system.
7
+ *
8
+ * The `Identifier` class encapsulates named entities in generated code,
9
+ * providing type-safe creation and management of variables, types, and other
10
+ * identifiers. It distinguishes between different kinds of identifiers and
11
+ * optionally tracks type information.
12
+ *
13
+ * This class uses factory methods instead of direct construction to ensure
14
+ * proper entity type classification and to provide a cleaner API.
15
+ *
16
+ * ## Key Features
17
+ *
18
+ * - **Type Safety**: Distinguishes between variables, types, and other entities
19
+ * - **Factory Methods**: Provides semantic constructors for different identifier types
20
+ * - **Optional Typing**: Can associate type information with variable identifiers
21
+ * - **String Conversion**: Clean string representation for code generation
22
+ *
23
+ * @example Creating variable identifiers
24
+ * ```typescript
25
+ * import { Identifier } from '@skmtc/core';
26
+ *
27
+ * // Simple variable without type
28
+ * const userName = Identifier.createVariable('userName');
29
+ * console.log(userName.toString()); // 'userName'
30
+ *
31
+ * // Typed variable
32
+ * const userId = Identifier.createVariable('userId', 'string');
33
+ * console.log(userId.name); // 'userId'
34
+ * console.log(userId.typeName); // 'string'
35
+ * ```
36
+ *
37
+ * @example Creating type identifiers
38
+ * ```typescript
39
+ * // Type identifier
40
+ * const userType = Identifier.createType('User');
41
+ * console.log(userType.toString()); // 'User'
42
+ * console.log(userType.entityType.value); // 'type'
43
+ * ```
44
+ *
45
+ * @example Using in code generation
46
+ * ```typescript
47
+ * import { Definition, Identifier } from '@skmtc/core';
48
+ *
49
+ * class ApiGenerator {
50
+ * generateFunction(name: string) {
51
+ * const funcId = Identifier.createVariable(name);
52
+ * const requestType = Identifier.createType('RequestType');
53
+ *
54
+ * return new Definition({
55
+ * name: funcId.name,
56
+ * content: `function ${funcId}(data: ${requestType}) {
57
+ * // Implementation
58
+ * }`
59
+ * });
60
+ * }
61
+ * }
62
+ * ```
63
+ */
5
64
  class Identifier {
65
+ /**
66
+ * Creates a new Identifier instance.
67
+ *
68
+ * This constructor is private to enforce the use of factory methods
69
+ * that provide better semantic clarity and type safety.
70
+ *
71
+ * @param args - Identifier configuration
72
+ */
6
73
  constructor({ name, typeName, entityType }) {
74
+ /** The identifier name */
7
75
  Object.defineProperty(this, "name", {
8
76
  enumerable: true,
9
77
  configurable: true,
10
78
  writable: true,
11
79
  value: void 0
12
80
  });
81
+ /** The entity type (variable, type, etc.) */
13
82
  Object.defineProperty(this, "entityType", {
14
83
  enumerable: true,
15
84
  configurable: true,
16
85
  writable: true,
17
86
  value: void 0
18
87
  });
88
+ /** Optional type name for typed variables */
19
89
  Object.defineProperty(this, "typeName", {
20
90
  enumerable: true,
21
91
  configurable: true,
@@ -26,6 +96,37 @@ class Identifier {
26
96
  this.typeName = typeName;
27
97
  this.entityType = entityType;
28
98
  }
99
+ /**
100
+ * Creates a variable identifier with optional type information.
101
+ *
102
+ * This factory method creates an identifier for variables, constants,
103
+ * function parameters, and other value-based entities. Optionally
104
+ * associates type information for typed variables.
105
+ *
106
+ * @param name - The variable name
107
+ * @param typeName - Optional type name for the variable
108
+ * @returns A new variable Identifier instance
109
+ *
110
+ * @example Untyped variable
111
+ * ```typescript
112
+ * const count = Identifier.createVariable('count');
113
+ * console.log(count.name); // 'count'
114
+ * console.log(count.typeName); // undefined
115
+ * ```
116
+ *
117
+ * @example Typed variable
118
+ * ```typescript
119
+ * const userId = Identifier.createVariable('userId', 'string');
120
+ * console.log(userId.name); // 'userId'
121
+ * console.log(userId.typeName); // 'string'
122
+ * ```
123
+ *
124
+ * @example In function generation
125
+ * ```typescript
126
+ * const param = Identifier.createVariable('data', 'RequestData');
127
+ * const funcDef = `function processRequest(${param.name}: ${param.typeName}) {}`;
128
+ * ```
129
+ */
29
130
  static createVariable(name, typeName) {
30
131
  if (typeName) {
31
132
  return new Identifier({
@@ -39,12 +140,63 @@ class Identifier {
39
140
  entityType: new EntityType_js_1.EntityType('variable')
40
141
  });
41
142
  }
143
+ /**
144
+ * Creates a type identifier for TypeScript types.
145
+ *
146
+ * This factory method creates an identifier for type entities like
147
+ * interfaces, type aliases, classes, and other type-level constructs.
148
+ * Type identifiers don't have associated type information since they
149
+ * represent types themselves.
150
+ *
151
+ * @param name - The type name
152
+ * @returns A new type Identifier instance
153
+ *
154
+ * @example Interface type
155
+ * ```typescript
156
+ * const userInterface = Identifier.createType('User');
157
+ * console.log(userInterface.name); // 'User'
158
+ * console.log(userInterface.entityType.value); // 'type'
159
+ * ```
160
+ *
161
+ * @example Type alias
162
+ * ```typescript
163
+ * const statusType = Identifier.createType('Status');
164
+ * const typeDef = `type ${statusType} = 'pending' | 'complete'`;
165
+ * ```
166
+ *
167
+ * @example Generic type
168
+ * ```typescript
169
+ * const responseType = Identifier.createType('ApiResponse');
170
+ * const genericDef = `interface ${responseType}<T> { data: T; success: boolean; }`;
171
+ * ```
172
+ */
42
173
  static createType(name) {
43
174
  return new Identifier({
44
175
  name,
45
176
  entityType: new EntityType_js_1.EntityType('type')
46
177
  });
47
178
  }
179
+ /**
180
+ * Returns the string representation of the identifier.
181
+ *
182
+ * This method simply returns the identifier name, which is the most
183
+ * common usage when generating code. The name can be used directly
184
+ * in code generation contexts.
185
+ *
186
+ * @returns The identifier name as a string
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const variable = Identifier.createVariable('userName');
191
+ * const typeId = Identifier.createType('User');
192
+ *
193
+ * console.log(variable.toString()); // 'userName'
194
+ * console.log(typeId.toString()); // 'User'
195
+ *
196
+ * // Can be used directly in template strings
197
+ * const code = `const ${variable}: ${typeId} = getUserData();`;
198
+ * ```
199
+ */
48
200
  toString() {
49
201
  return this.name;
50
202
  }