@skmtc/core 0.0.786 → 0.0.788

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/context/GenerateContext.d.ts +95 -0
  2. package/esm/context/GenerateContext.d.ts.map +1 -1
  3. package/esm/context/GenerateContext.js +95 -0
  4. package/esm/dsl/ContentSettings.d.ts +164 -0
  5. package/esm/dsl/ContentSettings.d.ts.map +1 -1
  6. package/esm/dsl/ContentSettings.js +151 -0
  7. package/esm/dsl/Definition.d.ts +199 -0
  8. package/esm/dsl/Definition.d.ts.map +1 -1
  9. package/esm/dsl/Definition.js +189 -0
  10. package/esm/dsl/EntityType.d.ts +83 -0
  11. package/esm/dsl/EntityType.d.ts.map +1 -1
  12. package/esm/dsl/EntityType.js +83 -0
  13. package/esm/dsl/JsonFile.d.ts +162 -0
  14. package/esm/dsl/JsonFile.d.ts.map +1 -1
  15. package/esm/dsl/JsonFile.js +157 -0
  16. package/esm/oas/array/Array.d.ts +109 -1
  17. package/esm/oas/array/Array.d.ts.map +1 -1
  18. package/esm/oas/array/Array.js +93 -1
  19. package/esm/oas/integer/Integer.d.ts +98 -0
  20. package/esm/oas/integer/Integer.d.ts.map +1 -1
  21. package/esm/oas/integer/Integer.js +80 -0
  22. package/esm/oas/operation/Operation.d.ts +107 -1
  23. package/esm/oas/operation/Operation.d.ts.map +1 -1
  24. package/esm/oas/operation/Operation.js +107 -1
  25. package/esm/oas/ref/Ref.d.ts +86 -0
  26. package/esm/oas/ref/Ref.d.ts.map +1 -1
  27. package/esm/oas/ref/Ref.js +86 -0
  28. package/esm/oas/string/String.d.ts +103 -1
  29. package/esm/oas/string/String.d.ts.map +1 -1
  30. package/esm/oas/string/String.js +87 -1
  31. package/esm/types/Brand.d.ts +74 -0
  32. package/esm/types/Brand.d.ts.map +1 -1
  33. package/esm/types/Brand.js +9 -0
  34. package/esm/types/RefName.d.ts +61 -0
  35. package/esm/types/RefName.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/script/context/GenerateContext.d.ts +95 -0
  38. package/script/context/GenerateContext.d.ts.map +1 -1
  39. package/script/context/GenerateContext.js +95 -0
  40. package/script/dsl/ContentSettings.d.ts +164 -0
  41. package/script/dsl/ContentSettings.d.ts.map +1 -1
  42. package/script/dsl/ContentSettings.js +151 -0
  43. package/script/dsl/Definition.d.ts +199 -0
  44. package/script/dsl/Definition.d.ts.map +1 -1
  45. package/script/dsl/Definition.js +189 -0
  46. package/script/dsl/EntityType.d.ts +83 -0
  47. package/script/dsl/EntityType.d.ts.map +1 -1
  48. package/script/dsl/EntityType.js +83 -0
  49. package/script/dsl/JsonFile.d.ts +162 -0
  50. package/script/dsl/JsonFile.d.ts.map +1 -1
  51. package/script/dsl/JsonFile.js +157 -0
  52. package/script/oas/array/Array.d.ts +109 -1
  53. package/script/oas/array/Array.d.ts.map +1 -1
  54. package/script/oas/array/Array.js +93 -1
  55. package/script/oas/integer/Integer.d.ts +98 -0
  56. package/script/oas/integer/Integer.d.ts.map +1 -1
  57. package/script/oas/integer/Integer.js +80 -0
  58. package/script/oas/operation/Operation.d.ts +107 -1
  59. package/script/oas/operation/Operation.d.ts.map +1 -1
  60. package/script/oas/operation/Operation.js +107 -1
  61. package/script/oas/ref/Ref.d.ts +86 -0
  62. package/script/oas/ref/Ref.d.ts.map +1 -1
  63. package/script/oas/ref/Ref.js +86 -0
  64. package/script/oas/string/String.d.ts +103 -1
  65. package/script/oas/string/String.d.ts.map +1 -1
  66. package/script/oas/string/String.js +87 -1
  67. package/script/types/Brand.d.ts +74 -0
  68. package/script/types/Brand.d.ts.map +1 -1
  69. package/script/types/Brand.js +9 -0
  70. package/script/types/RefName.d.ts +61 -0
  71. package/script/types/RefName.d.ts.map +1 -1
@@ -1,5 +1,79 @@
1
+ /**
2
+ * Unique symbol used for branding types.
3
+ *
4
+ * This symbol is used internally by the {@link Brand} type to create
5
+ * unique branded types that are structurally identical but nominally
6
+ * distinct from their base types.
7
+ *
8
+ * @internal
9
+ */
1
10
  import "../_dnt.polyfills.js";
2
11
  declare const brand: unique symbol;
12
+ /**
13
+ * Creates a branded type from a base type.
14
+ *
15
+ * Brand types (also known as nominal types or opaque types) are TypeScript
16
+ * types that are structurally identical to their base type but are treated
17
+ * as distinct types by the type system. This prevents accidental mixing of
18
+ * values that should be kept separate.
19
+ *
20
+ * The SKMTC system uses branded types extensively to ensure type safety
21
+ * when working with identifiers, keys, and other string-based values that
22
+ * have specific semantic meaning.
23
+ *
24
+ * @template T - The base type to brand
25
+ * @template TBrand - The brand identifier (usually a string literal)
26
+ *
27
+ * @example Basic branded type usage
28
+ * ```typescript
29
+ * import { Brand } from '@skmtc/core';
30
+ *
31
+ * type UserId = Brand<string, 'UserId'>;
32
+ * type ProductId = Brand<string, 'ProductId'>;
33
+ *
34
+ * const userId: UserId = 'user-123' as UserId;
35
+ * const productId: ProductId = 'prod-456' as ProductId;
36
+ *
37
+ * function getUser(id: UserId) {
38
+ * // Function expects a UserId, not just any string
39
+ * return `User with ID: ${id}`;
40
+ * }
41
+ *
42
+ * getUser(userId); // ✅ Works - correct type
43
+ * getUser(productId); // ❌ TypeScript error - ProductId is not UserId
44
+ * getUser('user-789'); // ❌ TypeScript error - string is not UserId
45
+ * ```
46
+ *
47
+ * @example SKMTC branded types
48
+ * ```typescript
49
+ * // RefName ensures schema reference safety
50
+ * type RefName = Brand<string, 'RefName'>;
51
+ * const schemaRef: RefName = 'User' as RefName;
52
+ *
53
+ * // GeneratorKey ensures generator identification safety
54
+ * type OperationGeneratorKey = Brand<string, 'OperationGeneratorKey'>;
55
+ * const opKey: OperationGeneratorKey = 'api-client|/users|get' as OperationGeneratorKey;
56
+ * ```
57
+ *
58
+ * @example Runtime behavior
59
+ * ```typescript
60
+ * type EmailAddress = Brand<string, 'EmailAddress'>;
61
+ *
62
+ * const email: EmailAddress = 'user@example.com' as EmailAddress;
63
+ *
64
+ * // At runtime, branded types are just their base type
65
+ * console.log(typeof email); // 'string'
66
+ * console.log(email); // 'user@example.com'
67
+ *
68
+ * // But TypeScript enforces the brand at compile time
69
+ * function sendEmail(to: EmailAddress) {
70
+ * // Implementation
71
+ * }
72
+ *
73
+ * sendEmail(email); // ✅ Works
74
+ * sendEmail('test@example.com'); // ❌ Error - needs EmailAddress brand
75
+ * ```
76
+ */
3
77
  export type Brand<T, TBrand> = T & {
4
78
  [brand]: TBrand;
5
79
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAA;AAElC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
1
+ {"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -1,3 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Unique symbol used for branding types.
5
+ *
6
+ * This symbol is used internally by the {@link Brand} type to create
7
+ * unique branded types that are structurally identical but nominally
8
+ * distinct from their base types.
9
+ *
10
+ * @internal
11
+ */
3
12
  require("../_dnt.polyfills.js");
@@ -1,4 +1,65 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  import type { Brand } from './Brand.js';
3
+ /**
4
+ * Branded type representing a reference name for OpenAPI schemas.
5
+ *
6
+ * `RefName` is a branded string type that ensures type safety when working
7
+ * with schema reference names throughout the SKMTC system. It prevents
8
+ * accidental mixing of regular strings with schema reference identifiers.
9
+ *
10
+ * Reference names typically correspond to keys in the OpenAPI `components.schemas`
11
+ * section and are used to create cross-references between different parts
12
+ * of the schema definition.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { RefName } from '@skmtc/core';
17
+ *
18
+ * // RefName is extracted from OpenAPI schema references
19
+ * const userRefName: RefName = 'User' as RefName;
20
+ * const productRefName: RefName = 'Product' as RefName;
21
+ *
22
+ * // Used in schema references
23
+ * const userRef = new OasRef({
24
+ * refName: userRefName, // Type-safe reference name
25
+ * ref: '#/components/schemas/User'
26
+ * });
27
+ * ```
28
+ *
29
+ * @example In generator contexts
30
+ * ```typescript
31
+ * class ModelGenerator extends ModelBase {
32
+ * constructor(args: { refName: RefName; ... }) {
33
+ * super(args);
34
+ * // this.refName is guaranteed to be a valid schema reference
35
+ * }
36
+ *
37
+ * toDefinition(): Definition {
38
+ * // RefName ensures we're working with valid schema identifiers
39
+ * const schemaName = this.refName; // Type: RefName
40
+ * return new Definition({
41
+ * identifier: Identifier.createType(schemaName),
42
+ * // ...
43
+ * });
44
+ * }
45
+ * }
46
+ * ```
47
+ *
48
+ * @example Type safety benefits
49
+ * ```typescript
50
+ * function processSchema(refName: RefName) {
51
+ * // RefName brand ensures this is a valid schema reference
52
+ * console.log(`Processing schema: ${refName}`);
53
+ * }
54
+ *
55
+ * const validRef: RefName = 'User' as RefName;
56
+ * const regularString = 'just a string';
57
+ *
58
+ * processSchema(validRef); // ✅ Works - RefName type
59
+ * processSchema(regularString); // ❌ TypeScript error - string is not RefName
60
+ * ```
61
+ *
62
+ * @see {@link Brand} for the underlying branding mechanism
63
+ */
3
64
  export type RefName = Brand<string, 'RefName'>;
4
65
  //# sourceMappingURL=RefName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RefName.d.ts","sourceRoot":"","sources":["../../src/types/RefName.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}
1
+ {"version":3,"file":"RefName.d.ts","sourceRoot":"","sources":["../../src/types/RefName.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}