@skmtc/core 0.0.781 → 0.0.783
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.
- package/esm/app/validate.d.ts +1 -1
- package/esm/app/validate.d.ts.map +1 -1
- package/esm/context/CoreContext.d.ts +177 -8
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +178 -0
- package/esm/context/ParseContext.d.ts +1 -1
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/StackTrail.d.ts +2 -2
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/types.d.ts +2 -2
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/ContentBase.d.ts +115 -0
- package/esm/dsl/ContentBase.d.ts.map +1 -1
- package/esm/dsl/ContentBase.js +110 -0
- package/esm/dsl/File.d.ts.map +1 -1
- package/esm/dsl/JsonFile.d.ts.map +1 -1
- package/esm/dsl/model/toModelBase.d.ts +2 -23
- package/esm/dsl/model/toModelBase.d.ts.map +1 -1
- package/esm/dsl/model/toModelEntry.d.ts +5 -5
- package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationBase.d.ts +2 -25
- package/esm/dsl/operation/toOperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationEntry.d.ts +5 -5
- package/esm/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/esm/helpers/formatNumber.d.ts.map +1 -1
- package/esm/helpers/generationStats.d.ts.map +1 -1
- package/esm/helpers/strings.d.ts +63 -0
- package/esm/helpers/strings.d.ts.map +1 -1
- package/esm/helpers/strings.js +59 -0
- package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
- package/esm/mod.d.ts +66 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +66 -0
- package/esm/oas/document/Document.d.ts +1 -9
- package/esm/oas/document/Document.d.ts.map +1 -1
- package/esm/oas/operation/Operation.d.ts +2 -12
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/ref/Ref.d.ts +1 -3
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/server/Server.d.ts.map +1 -1
- package/esm/oas/serverVariable/ServerVariable.d.ts.map +1 -1
- package/esm/run/toArtifacts.d.ts +114 -0
- package/esm/run/toArtifacts.d.ts.map +1 -1
- package/esm/run/toArtifacts.js +86 -0
- package/esm/types/DenoJson.d.ts +2 -11
- package/esm/types/DenoJson.d.ts.map +1 -1
- package/esm/types/Enrichments.d.ts +9 -207
- package/esm/types/Enrichments.d.ts.map +1 -1
- package/esm/types/Manifest.d.ts +3 -59
- package/esm/types/Manifest.d.ts.map +1 -1
- package/esm/types/Method.d.ts +11 -2
- package/esm/types/Method.d.ts.map +1 -1
- package/esm/types/Method.js +4 -3
- package/esm/types/ModuleExport.d.ts +1 -4
- package/esm/types/ModuleExport.d.ts.map +1 -1
- package/esm/types/PrettierConfig.d.ts +1 -24
- package/esm/types/PrettierConfig.d.ts.map +1 -1
- package/esm/types/Preview.d.ts +17 -52
- package/esm/types/Preview.d.ts.map +1 -1
- package/esm/types/Preview.js +3 -2
- package/esm/types/Results.d.ts +1 -1
- package/esm/types/Results.d.ts.map +1 -1
- package/esm/types/Settings.d.ts +135 -102
- package/esm/types/Settings.d.ts.map +1 -1
- package/esm/types/Settings.js +3 -0
- package/esm/typescript/List.d.ts +112 -1
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +106 -0
- package/package.json +1 -1
- package/script/app/validate.d.ts +1 -1
- package/script/app/validate.d.ts.map +1 -1
- package/script/context/CoreContext.d.ts +177 -8
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +178 -0
- package/script/context/ParseContext.d.ts +1 -1
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/StackTrail.d.ts +2 -2
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/types.d.ts +2 -2
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/ContentBase.d.ts +115 -0
- package/script/dsl/ContentBase.d.ts.map +1 -1
- package/script/dsl/ContentBase.js +110 -0
- package/script/dsl/File.d.ts.map +1 -1
- package/script/dsl/JsonFile.d.ts.map +1 -1
- package/script/dsl/model/toModelBase.d.ts +2 -23
- package/script/dsl/model/toModelBase.d.ts.map +1 -1
- package/script/dsl/model/toModelEntry.d.ts +5 -5
- package/script/dsl/model/toModelEntry.d.ts.map +1 -1
- package/script/dsl/operation/toOperationBase.d.ts +2 -25
- package/script/dsl/operation/toOperationBase.d.ts.map +1 -1
- package/script/dsl/operation/toOperationEntry.d.ts +5 -5
- package/script/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/script/helpers/formatNumber.d.ts.map +1 -1
- package/script/helpers/generationStats.d.ts.map +1 -1
- package/script/helpers/strings.d.ts +63 -0
- package/script/helpers/strings.d.ts.map +1 -1
- package/script/helpers/strings.js +59 -0
- package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
- package/script/mod.d.ts +66 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +66 -0
- package/script/oas/document/Document.d.ts +1 -9
- package/script/oas/document/Document.d.ts.map +1 -1
- package/script/oas/operation/Operation.d.ts +2 -12
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/ref/Ref.d.ts +1 -3
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/server/Server.d.ts.map +1 -1
- package/script/oas/serverVariable/ServerVariable.d.ts.map +1 -1
- package/script/run/toArtifacts.d.ts +114 -0
- package/script/run/toArtifacts.d.ts.map +1 -1
- package/script/run/toArtifacts.js +86 -0
- package/script/types/DenoJson.d.ts +2 -11
- package/script/types/DenoJson.d.ts.map +1 -1
- package/script/types/Enrichments.d.ts +9 -207
- package/script/types/Enrichments.d.ts.map +1 -1
- package/script/types/Manifest.d.ts +3 -59
- package/script/types/Manifest.d.ts.map +1 -1
- package/script/types/Method.d.ts +11 -2
- package/script/types/Method.d.ts.map +1 -1
- package/script/types/Method.js +4 -3
- package/script/types/ModuleExport.d.ts +1 -4
- package/script/types/ModuleExport.d.ts.map +1 -1
- package/script/types/PrettierConfig.d.ts +1 -24
- package/script/types/PrettierConfig.d.ts.map +1 -1
- package/script/types/Preview.d.ts +17 -52
- package/script/types/Preview.d.ts.map +1 -1
- package/script/types/Preview.js +3 -2
- package/script/types/Results.d.ts +1 -1
- package/script/types/Results.d.ts.map +1 -1
- package/script/types/Settings.d.ts +135 -102
- package/script/types/Settings.d.ts.map +1 -1
- package/script/types/Settings.js +3 -0
- package/script/typescript/List.d.ts +112 -1
- package/script/typescript/List.d.ts.map +1 -1
- 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,
|