@skmtc/core 0.0.782 → 0.0.785

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 (61) hide show
  1. package/esm/context/CoreContext.d.ts +175 -0
  2. package/esm/context/CoreContext.d.ts.map +1 -1
  3. package/esm/context/CoreContext.js +178 -0
  4. package/esm/dsl/ContentBase.d.ts +115 -0
  5. package/esm/dsl/ContentBase.d.ts.map +1 -1
  6. package/esm/dsl/ContentBase.js +110 -0
  7. package/esm/dsl/File.d.ts +208 -0
  8. package/esm/dsl/File.d.ts.map +1 -1
  9. package/esm/dsl/File.js +197 -0
  10. package/esm/dsl/model/ModelBase.d.ts +257 -0
  11. package/esm/dsl/model/ModelBase.d.ts.map +1 -1
  12. package/esm/dsl/model/ModelBase.js +248 -0
  13. package/esm/dsl/operation/OperationBase.d.ts +175 -0
  14. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  15. package/esm/dsl/operation/OperationBase.js +166 -0
  16. package/esm/helpers/strings.d.ts +63 -0
  17. package/esm/helpers/strings.d.ts.map +1 -1
  18. package/esm/helpers/strings.js +59 -0
  19. package/esm/mod.d.ts +66 -0
  20. package/esm/mod.d.ts.map +1 -1
  21. package/esm/mod.js +66 -0
  22. package/esm/run/toArtifacts.d.ts +114 -0
  23. package/esm/run/toArtifacts.d.ts.map +1 -1
  24. package/esm/run/toArtifacts.js +86 -0
  25. package/esm/types/Settings.d.ts +129 -0
  26. package/esm/types/Settings.d.ts.map +1 -1
  27. package/esm/types/Settings.js +3 -0
  28. package/esm/typescript/List.d.ts +111 -0
  29. package/esm/typescript/List.d.ts.map +1 -1
  30. package/esm/typescript/List.js +106 -0
  31. package/package.json +5 -1
  32. package/script/context/CoreContext.d.ts +175 -0
  33. package/script/context/CoreContext.d.ts.map +1 -1
  34. package/script/context/CoreContext.js +178 -0
  35. package/script/dsl/ContentBase.d.ts +115 -0
  36. package/script/dsl/ContentBase.d.ts.map +1 -1
  37. package/script/dsl/ContentBase.js +110 -0
  38. package/script/dsl/File.d.ts +208 -0
  39. package/script/dsl/File.d.ts.map +1 -1
  40. package/script/dsl/File.js +197 -0
  41. package/script/dsl/model/ModelBase.d.ts +257 -0
  42. package/script/dsl/model/ModelBase.d.ts.map +1 -1
  43. package/script/dsl/model/ModelBase.js +248 -0
  44. package/script/dsl/operation/OperationBase.d.ts +175 -0
  45. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  46. package/script/dsl/operation/OperationBase.js +166 -0
  47. package/script/helpers/strings.d.ts +63 -0
  48. package/script/helpers/strings.d.ts.map +1 -1
  49. package/script/helpers/strings.js +59 -0
  50. package/script/mod.d.ts +66 -0
  51. package/script/mod.d.ts.map +1 -1
  52. package/script/mod.js +66 -0
  53. package/script/run/toArtifacts.d.ts +114 -0
  54. package/script/run/toArtifacts.d.ts.map +1 -1
  55. package/script/run/toArtifacts.js +86 -0
  56. package/script/types/Settings.d.ts +129 -0
  57. package/script/types/Settings.d.ts.map +1 -1
  58. package/script/types/Settings.js +3 -0
  59. package/script/typescript/List.d.ts +111 -0
  60. package/script/typescript/List.d.ts.map +1 -1
  61. package/script/typescript/List.js +106 -0
@@ -2,26 +2,132 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EntryList = exports.KeyList = exports.List = void 0;
4
4
  const ts_pattern_1 = require("ts-pattern");
5
+ /**
6
+ * A powerful utility class for building formatted lists of stringable items.
7
+ *
8
+ * The `List` class is a core component of the SKMTC DSL system, providing type-safe
9
+ * construction of formatted lists with customizable separators and bookends. It's
10
+ * extensively used throughout the codebase for generating code constructs like
11
+ * function parameters, object properties, array literals, and more.
12
+ *
13
+ * ## Type Safety
14
+ *
15
+ * The class uses TypeScript's generic system to provide compile-time guarantees
16
+ * about the list structure, separator, and bookend styles. This enables rich
17
+ * type inference and helps prevent formatting errors.
18
+ *
19
+ * ## Common Patterns
20
+ *
21
+ * - **Objects**: `List.toObject()` creates `{key: value, ...}` structures
22
+ * - **Arrays**: `List.toArray()` creates `[item, item, ...]` structures
23
+ * - **Parameters**: `List.toParams()` creates `(param, param, ...)` structures
24
+ * - **Lines**: `List.toLines()` creates newline-separated content
25
+ *
26
+ * @template Values - Array of stringable values
27
+ * @template Separator - String used to separate items
28
+ * @template Bookends - Style of bookends ('[]', '{}', '()', '<>', 'none')
29
+ *
30
+ * @example Basic usage
31
+ * ```typescript
32
+ * import { List } from '@skmtc/core';
33
+ *
34
+ * // Create a comma-separated list
35
+ * const items = new List(['apple', 'banana', 'cherry']);
36
+ * console.log(items.toString()); // "apple, banana, cherry"
37
+ *
38
+ * // Create an array-style list
39
+ * const array = new List(['a', 'b', 'c'], { bookends: '[]' });
40
+ * console.log(array.toString()); // "[a, b, c]"
41
+ *
42
+ * // Create an object-style list
43
+ * const obj = new List(['x: 1', 'y: 2'], { bookends: '{}' });
44
+ * console.log(obj.toString()); // "{x: 1, y: 2}"
45
+ * ```
46
+ *
47
+ * @example Using type aliases
48
+ * ```typescript
49
+ * // Type-safe array construction
50
+ * const params: ListParams<string> = List.toParams(['id', 'name', 'email']);
51
+ * console.log(params.toString()); // "(id, name, email)"
52
+ *
53
+ * // Object properties with filtering
54
+ * const props = List.toObject(['title', undefined, 'author'], { skipEmpty: true });
55
+ * console.log(props.toString()); // "{title, author}"
56
+ *
57
+ * // Line-separated content
58
+ * const lines = List.toLines(['import React from "react"', 'import { useState } from "react"']);
59
+ * console.log(lines.toString());
60
+ * // import React from "react"
61
+ * // import { useState } from "react"
62
+ * ```
63
+ *
64
+ * @example Advanced usage with builders
65
+ * ```typescript
66
+ * // Function signature generation
67
+ * const signature = List.toParams([
68
+ * 'id: string',
69
+ * 'options?: RequestOptions',
70
+ * 'callback?: (result: T) => void'
71
+ * ]);
72
+ *
73
+ * // Interface properties
74
+ * const interfaceProps = List.toObject([
75
+ * 'readonly id: string',
76
+ * 'name: string',
77
+ * 'createdAt: Date',
78
+ * 'updatedAt?: Date'
79
+ * ]);
80
+ *
81
+ * console.log(`interface User ${interfaceProps}`);
82
+ * // interface User {readonly id: string, name: string, createdAt: Date, updatedAt?: Date}
83
+ * ```
84
+ */
5
85
  class List {
86
+ /**
87
+ * Creates a new List instance.
88
+ *
89
+ * @param values - Array of values (undefined values are automatically filtered out)
90
+ * @param options - Configuration options
91
+ * @param options.separator - String to use between items (default: ', ')
92
+ * @param options.bookends - Style of bookends to wrap the list (default: 'none')
93
+ * @param options.skipEmpty - Whether to return empty string for empty lists (default: false)
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * // Basic list with default comma separator
98
+ * const basic = new List(['a', 'b', 'c']);
99
+ *
100
+ * // Custom separator and bookends
101
+ * const custom = new List(['x', 'y', 'z'], {
102
+ * separator: ' | ',
103
+ * bookends: '[]',
104
+ * skipEmpty: true
105
+ * });
106
+ * ```
107
+ */
6
108
  constructor(values, { separator, bookends, skipEmpty } = {}) {
109
+ /** The array of values in this list */
7
110
  Object.defineProperty(this, "values", {
8
111
  enumerable: true,
9
112
  configurable: true,
10
113
  writable: true,
11
114
  value: void 0
12
115
  });
116
+ /** The separator string used between items */
13
117
  Object.defineProperty(this, "separator", {
14
118
  enumerable: true,
15
119
  configurable: true,
16
120
  writable: true,
17
121
  value: void 0
18
122
  });
123
+ /** The bookend style for wrapping the list */
19
124
  Object.defineProperty(this, "bookends", {
20
125
  enumerable: true,
21
126
  configurable: true,
22
127
  writable: true,
23
128
  value: void 0
24
129
  });
130
+ /** Whether to skip rendering when the list is empty */
25
131
  Object.defineProperty(this, "skipEmpty", {
26
132
  enumerable: true,
27
133
  configurable: true,