@skmtc/core 0.0.799 → 0.0.800
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/context/GenerateContext.d.ts +21 -1
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +21 -1
- package/esm/context/ParseContext.d.ts +64 -3
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +61 -0
- package/esm/context/ResultsHandler.d.ts +10 -3
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/dsl/model/types.d.ts +51 -4
- package/esm/dsl/model/types.d.ts.map +1 -1
- package/esm/dsl/operation/types.d.ts +61 -3
- package/esm/dsl/operation/types.d.ts.map +1 -1
- package/esm/oas/operation/Operation.d.ts +47 -2
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +43 -0
- package/esm/oas/ref/Ref.d.ts +49 -2
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +28 -0
- package/esm/typescript/List.d.ts +64 -3
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +43 -0
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +21 -1
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +21 -1
- package/script/context/ParseContext.d.ts +64 -3
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +61 -0
- package/script/context/ResultsHandler.d.ts +10 -3
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/dsl/model/types.d.ts +51 -4
- package/script/dsl/model/types.d.ts.map +1 -1
- package/script/dsl/operation/types.d.ts +61 -3
- package/script/dsl/operation/types.d.ts.map +1 -1
- package/script/oas/operation/Operation.d.ts +47 -2
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +43 -0
- package/script/oas/ref/Ref.d.ts +49 -2
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +28 -0
- package/script/typescript/List.d.ts +64 -3
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +43 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operation.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/Operation.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAC3F;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAA;IACjC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,qCAAqC;IACrC,OAAO,CAAC,EAAE,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AAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IAEpD;;;;OAIG;gBACS,MAAM,EAAE,eAAe;IAgBnC;;;;;;OAMG;IACH,iBAAiB,IAAI,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS;IAMjE;;;;;;OAMG;IACH,qBAAqB,IAAI,MAAM,GAAG,SAAS;IAiB3C;;;;;;OAMG;IACH,aAAa,CAAC,CAAC,EACb,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,oBAAoB,KAAK,CAAC,EACzD,SAAS,SAAqB,GAC7B,CAAC,GAAG,SAAS;IAOhB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,GAAG,YAAY,EAAE;IAQzD;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,GAAG,SAAS;IAY9D;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,eAAe;IAiBrE;;;;OAIG;IACH,MAAM,IAAI,MAAM;CAcjB"}
|
|
@@ -111,6 +111,11 @@ const Object_js_1 = require("../object/Object.js");
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
class OasOperation {
|
|
114
|
+
/**
|
|
115
|
+
* Creates a new OasOperation instance from operation field data.
|
|
116
|
+
*
|
|
117
|
+
* @param fields - Operation field data from OpenAPI specification
|
|
118
|
+
*/
|
|
114
119
|
constructor(fields) {
|
|
115
120
|
/** Type identifier for OAS operation objects */
|
|
116
121
|
Object.defineProperty(this, "oasType", {
|
|
@@ -224,10 +229,24 @@ class OasOperation {
|
|
|
224
229
|
this.deprecated = fields.deprecated;
|
|
225
230
|
this.extensionFields = fields.extensionFields;
|
|
226
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns the successful response definition for this operation.
|
|
234
|
+
*
|
|
235
|
+
* Looks for the lowest numbered 2xx response code and returns its response definition.
|
|
236
|
+
*
|
|
237
|
+
* @returns Success response object or undefined if none found
|
|
238
|
+
*/
|
|
227
239
|
toSuccessResponse() {
|
|
228
240
|
const successCode = this.toSuccessResponseCode();
|
|
229
241
|
return successCode ? this.responses[successCode] : undefined;
|
|
230
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns the HTTP status code for the primary success response.
|
|
245
|
+
*
|
|
246
|
+
* Finds the lowest numbered 2xx status code in the responses.
|
|
247
|
+
*
|
|
248
|
+
* @returns Success status code as string or undefined if none found
|
|
249
|
+
*/
|
|
231
250
|
toSuccessResponseCode() {
|
|
232
251
|
const successCode = Object.keys(this.responses)
|
|
233
252
|
.map(httpCode => parseInt(httpCode))
|
|
@@ -241,6 +260,13 @@ class OasOperation {
|
|
|
241
260
|
}
|
|
242
261
|
return undefined;
|
|
243
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Maps the request body schema to a custom value using the provided mapping function.
|
|
265
|
+
*
|
|
266
|
+
* @param map - Function to transform the request body schema and metadata
|
|
267
|
+
* @param mediaType - Media type to extract schema from (default: 'application/json')
|
|
268
|
+
* @returns Mapped value or undefined if no request body schema found
|
|
269
|
+
*/
|
|
244
270
|
toRequestBody(map, mediaType = 'application/json') {
|
|
245
271
|
const requestBody = this.requestBody?.resolve();
|
|
246
272
|
const schema = requestBody?.content[mediaType]?.schema;
|
|
@@ -257,6 +283,12 @@ class OasOperation {
|
|
|
257
283
|
?.map(param => param.resolve())
|
|
258
284
|
.filter(param => (filter?.length ? filter.includes(param.location) : true)) ?? []);
|
|
259
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Creates an OAS object representation of operation parameters.
|
|
288
|
+
*
|
|
289
|
+
* @param filter - Optional array of parameter locations to include
|
|
290
|
+
* @returns OAS object with parameter properties
|
|
291
|
+
*/
|
|
260
292
|
toParametersObject(filter) {
|
|
261
293
|
const parameters = this.toParams(filter);
|
|
262
294
|
return parameters.reduce((acc, parameter) => {
|
|
@@ -267,6 +299,12 @@ class OasOperation {
|
|
|
267
299
|
});
|
|
268
300
|
}, Object_js_1.OasObject.empty());
|
|
269
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Converts the operation to OpenAPI v3 JSON schema format.
|
|
304
|
+
*
|
|
305
|
+
* @param options - Conversion options for nested components
|
|
306
|
+
* @returns OpenAPI v3 operation object
|
|
307
|
+
*/
|
|
270
308
|
toJsonSchema(options) {
|
|
271
309
|
return {
|
|
272
310
|
tags: this.tags,
|
|
@@ -281,6 +319,11 @@ class OasOperation {
|
|
|
281
319
|
...this.extensionFields
|
|
282
320
|
};
|
|
283
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Serializes the operation to a plain JavaScript object.
|
|
324
|
+
*
|
|
325
|
+
* @returns Plain object representation of the operation
|
|
326
|
+
*/
|
|
284
327
|
toJSON() {
|
|
285
328
|
return {
|
|
286
329
|
tags: this.tags,
|
package/script/oas/ref/Ref.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ import type { OasDocument } from '../document/Document.js';
|
|
|
10
10
|
import type { RefName } from '../../types/RefName.js';
|
|
11
11
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
12
12
|
import type { OasSecurityScheme } from '../securitySchemes/SecurityScheme.js';
|
|
13
|
+
/**
|
|
14
|
+
* Field data for creating OAS reference objects.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The type of component being referenced (e.g., 'schema', 'response')
|
|
17
|
+
*/
|
|
13
18
|
export type RefFields<T extends OasRefData['refType']> = {
|
|
14
19
|
refType: T;
|
|
15
20
|
$ref: string;
|
|
@@ -102,11 +107,39 @@ export type RefFields<T extends OasRefData['refType']> = {
|
|
|
102
107
|
*/
|
|
103
108
|
export declare class OasRef<T extends OasRefData['refType']> {
|
|
104
109
|
#private;
|
|
110
|
+
/** OAS type identifier */
|
|
105
111
|
oasType: 'ref';
|
|
112
|
+
/** Type identifier */
|
|
106
113
|
type: 'ref';
|
|
114
|
+
/**
|
|
115
|
+
* Creates a new OAS reference instance.
|
|
116
|
+
*
|
|
117
|
+
* @param fields - Reference field data including refType and $ref
|
|
118
|
+
* @param oasDocument - Document containing the referenced component
|
|
119
|
+
*/
|
|
107
120
|
constructor(fields: RefFields<T>, oasDocument: OasDocument);
|
|
121
|
+
/**
|
|
122
|
+
* Type guard to check if this instance is a reference.
|
|
123
|
+
*
|
|
124
|
+
* @returns Always true for OasRef instances
|
|
125
|
+
*/
|
|
108
126
|
isRef(): this is OasRef<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Recursively resolves this reference to its final target component.
|
|
129
|
+
*
|
|
130
|
+
* Follows reference chains until reaching a non-reference component,
|
|
131
|
+
* with protection against infinite loops.
|
|
132
|
+
*
|
|
133
|
+
* @param lookupsPerformed - Internal counter to prevent infinite recursion
|
|
134
|
+
* @returns The resolved component
|
|
135
|
+
* @throws Error if maximum lookup depth is exceeded
|
|
136
|
+
*/
|
|
109
137
|
resolve(lookupsPerformed?: number): ResolvedRef<T>;
|
|
138
|
+
/**
|
|
139
|
+
* Resolves this reference one level, potentially returning another reference.
|
|
140
|
+
*
|
|
141
|
+
* @returns Either the resolved component or another reference in the chain
|
|
142
|
+
*/
|
|
110
143
|
resolveOnce(): OasRef<T> | ResolvedRef<T>;
|
|
111
144
|
toRefName(): RefName;
|
|
112
145
|
get $ref(): string;
|
|
@@ -115,10 +148,24 @@ export declare class OasRef<T extends OasRefData['refType']> {
|
|
|
115
148
|
toJsonSchema({ resolve }: ToJsonSchemaOptions): OpenAPIV3.ReferenceObject | ResolvedRefJsonType<T>;
|
|
116
149
|
toJSON(): object;
|
|
117
150
|
}
|
|
118
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Type representing the JSON schema result from resolving a reference.
|
|
153
|
+
*
|
|
154
|
+
* @template T - The type of component being referenced
|
|
155
|
+
*/
|
|
156
|
+
export type ResolvedRefJsonType<T extends OasRefData['refType']> = ReturnType<ResolvedRef<T>['toJsonSchema']>;
|
|
157
|
+
/**
|
|
158
|
+
* Union type of all OAS component types that can be referenced.
|
|
159
|
+
*
|
|
160
|
+
* Includes all OpenAPI component types that support $ref resolution.
|
|
161
|
+
*/
|
|
119
162
|
export type OasComponentType = OasSchema | OasResponse | OasParameter | OasExample | OasRequestBody | OasHeader | OasSecurityScheme;
|
|
163
|
+
/**
|
|
164
|
+
* Type representing a resolved reference to a specific component type.
|
|
165
|
+
*
|
|
166
|
+
* @template T - The type of component being referenced (e.g., 'schema', 'response')
|
|
167
|
+
*/
|
|
120
168
|
export type ResolvedRef<T extends OasRefData['refType']> = Extract<OasComponentType, {
|
|
121
169
|
oasType: T;
|
|
122
170
|
}>;
|
|
123
|
-
export {};
|
|
124
171
|
//# sourceMappingURL=Ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../../src/oas/ref/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAI7E,MAAM,MAA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AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,CAAA"}
|
package/script/oas/ref/Ref.js
CHANGED
|
@@ -104,13 +104,21 @@ const MAX_LOOKUPS = 10;
|
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
class OasRef {
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new OAS reference instance.
|
|
109
|
+
*
|
|
110
|
+
* @param fields - Reference field data including refType and $ref
|
|
111
|
+
* @param oasDocument - Document containing the referenced component
|
|
112
|
+
*/
|
|
107
113
|
constructor(fields, oasDocument) {
|
|
114
|
+
/** OAS type identifier */
|
|
108
115
|
Object.defineProperty(this, "oasType", {
|
|
109
116
|
enumerable: true,
|
|
110
117
|
configurable: true,
|
|
111
118
|
writable: true,
|
|
112
119
|
value: 'ref'
|
|
113
120
|
});
|
|
121
|
+
/** Type identifier */
|
|
114
122
|
Object.defineProperty(this, "type", {
|
|
115
123
|
enumerable: true,
|
|
116
124
|
configurable: true,
|
|
@@ -122,9 +130,24 @@ class OasRef {
|
|
|
122
130
|
__classPrivateFieldSet(this, _OasRef_fields, fields, "f");
|
|
123
131
|
__classPrivateFieldSet(this, _OasRef_oasDocument, oasDocument, "f");
|
|
124
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Type guard to check if this instance is a reference.
|
|
135
|
+
*
|
|
136
|
+
* @returns Always true for OasRef instances
|
|
137
|
+
*/
|
|
125
138
|
isRef() {
|
|
126
139
|
return true;
|
|
127
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Recursively resolves this reference to its final target component.
|
|
143
|
+
*
|
|
144
|
+
* Follows reference chains until reaching a non-reference component,
|
|
145
|
+
* with protection against infinite loops.
|
|
146
|
+
*
|
|
147
|
+
* @param lookupsPerformed - Internal counter to prevent infinite recursion
|
|
148
|
+
* @returns The resolved component
|
|
149
|
+
* @throws Error if maximum lookup depth is exceeded
|
|
150
|
+
*/
|
|
128
151
|
resolve(lookupsPerformed = 0) {
|
|
129
152
|
if (lookupsPerformed >= MAX_LOOKUPS) {
|
|
130
153
|
throw new Error('Max lookups reached');
|
|
@@ -132,6 +155,11 @@ class OasRef {
|
|
|
132
155
|
const resolved = this.resolveOnce();
|
|
133
156
|
return resolved.isRef() ? resolved.resolve(lookupsPerformed + 1) : resolved;
|
|
134
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Resolves this reference one level, potentially returning another reference.
|
|
160
|
+
*
|
|
161
|
+
* @returns Either the resolved component or another reference in the chain
|
|
162
|
+
*/
|
|
135
163
|
resolveOnce() {
|
|
136
164
|
const c = this.oasDocument.components;
|
|
137
165
|
const refName = (0, refFns_js_1.toRefName)(this.$ref);
|
|
@@ -11,17 +11,32 @@ export type ListParams<V extends Stringable> = List<V[], ', ', '()'>;
|
|
|
11
11
|
export type SkipEmptyOption = {
|
|
12
12
|
skipEmpty?: boolean;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Type alias for creating key-value pair lists.
|
|
16
|
+
*
|
|
17
|
+
* Creates a List specialized for key-value pairs with colon separator
|
|
18
|
+
* and no bookends (e.g., "key1: value1, key2: value2").
|
|
19
|
+
*
|
|
20
|
+
* @template Key - Type of the keys (must be stringable)
|
|
21
|
+
* @template Value - Type of the values (must be stringable)
|
|
22
|
+
*/
|
|
14
23
|
export type ListKeyValue<Key extends Stringable, Value extends Stringable> = List<[
|
|
15
24
|
Key,
|
|
16
25
|
Value
|
|
17
26
|
], ': ', 'none'>;
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Type representing the different bookend styles for lists.
|
|
29
|
+
*/
|
|
30
|
+
export type BookendsType = '[]' | '{}' | '()' | '<>' | 'none';
|
|
19
31
|
type ConstructorOptions<Separator extends string = ', ', Bookends extends BookendsType = 'none'> = {
|
|
20
32
|
separator?: Separator;
|
|
21
33
|
bookends?: Bookends;
|
|
22
34
|
skipEmpty?: boolean;
|
|
23
35
|
};
|
|
24
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Utility type to extract the item type from an array type.
|
|
38
|
+
*/
|
|
39
|
+
export type ExtractArrayItem<ArrayOf> = ArrayOf extends Array<infer Item> ? Item : never;
|
|
25
40
|
type ToFilteredKeyValueReturn<Value extends undefined | Stringable | Stringable[] | List> = Value extends undefined ? undefined : List<[string, Stringable | Stringable[] | List], ': ', 'none'>;
|
|
26
41
|
type ToConditionalReturn<Value extends Stringable, Condition extends boolean> = Condition extends true ? List<[Value], ', ', 'none'> : List<never[], ', ', 'none'>;
|
|
27
42
|
/**
|
|
@@ -136,6 +151,14 @@ export declare class List<Values extends Stringable[] = Stringable[], Separator
|
|
|
136
151
|
* ```
|
|
137
152
|
*/
|
|
138
153
|
constructor(values: (ExtractArrayItem<Values> | undefined)[], { separator, bookends, skipEmpty }?: ConstructorOptions<Separator, Bookends>);
|
|
154
|
+
/**
|
|
155
|
+
* Converts the list to its string representation.
|
|
156
|
+
*
|
|
157
|
+
* Joins all values with the configured separator and wraps with bookends.
|
|
158
|
+
* Returns empty string if skipEmpty is enabled and list is empty.
|
|
159
|
+
*
|
|
160
|
+
* @returns Formatted string representation of the list
|
|
161
|
+
*/
|
|
139
162
|
toString(): string;
|
|
140
163
|
/**
|
|
141
164
|
* Create an empty List that will render as an empty string ''
|
|
@@ -241,13 +264,51 @@ export declare class List<Values extends Stringable[] = Stringable[], Separator
|
|
|
241
264
|
*/
|
|
242
265
|
static hasValue: (value: undefined | Stringable | Stringable[] | List) => value is Stringable | Stringable[] | List;
|
|
243
266
|
}
|
|
244
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Mapping function type for transforming keys into values.
|
|
269
|
+
*/
|
|
270
|
+
export type KeyMapFn<V extends Stringable> = (key: string, index: number) => V;
|
|
271
|
+
/**
|
|
272
|
+
* Utility class for working with arrays of string keys.
|
|
273
|
+
*
|
|
274
|
+
* Provides methods for transforming key arrays into objects and lists
|
|
275
|
+
* with custom mapping functions.
|
|
276
|
+
*/
|
|
245
277
|
export declare class KeyList {
|
|
278
|
+
/** Array of string keys */
|
|
246
279
|
keys: string[];
|
|
280
|
+
/**
|
|
281
|
+
* Creates a new KeyList instance.
|
|
282
|
+
*
|
|
283
|
+
* @param keys - Array of string keys to work with
|
|
284
|
+
*/
|
|
247
285
|
constructor(keys: string[]);
|
|
286
|
+
/**
|
|
287
|
+
* Transforms keys into an object using a mapping function.
|
|
288
|
+
*
|
|
289
|
+
* @param mapFn - Function to transform each key into a value
|
|
290
|
+
* @param options - Options for handling empty values
|
|
291
|
+
* @returns Object with keys mapped to transformed values
|
|
292
|
+
*/
|
|
248
293
|
toObject<V extends Stringable>(mapFn: KeyMapFn<V>, { skipEmpty }?: SkipEmptyOption): ListObject<V>;
|
|
294
|
+
/**
|
|
295
|
+
* Creates a plain object with keys as both keys and values.
|
|
296
|
+
*
|
|
297
|
+
* @returns Object where each key maps to itself
|
|
298
|
+
*/
|
|
249
299
|
toObjectPlain(): ListObject<string>;
|
|
300
|
+
/**
|
|
301
|
+
* Transforms keys into a List using a mapping function.
|
|
302
|
+
*
|
|
303
|
+
* @param mapFn - Function to transform each key into a value
|
|
304
|
+
* @returns List containing the transformed values
|
|
305
|
+
*/
|
|
250
306
|
toLines<V extends Stringable>(mapFn: KeyMapFn<V>): ListLines<V>;
|
|
307
|
+
/**
|
|
308
|
+
* Creates a List with keys as the values.
|
|
309
|
+
*
|
|
310
|
+
* @returns List containing the original keys
|
|
311
|
+
*/
|
|
251
312
|
toLinesPlain(): ListLines<string>;
|
|
252
313
|
}
|
|
253
314
|
type Entry<T extends Stringable> = [key: string, value: T];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../src/typescript/List.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGtD,4EAA4E;AAC5E,MAAM,MAAM,UAA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
* Converts the list to its string representation.
|
|
144
|
+
*
|
|
145
|
+
* Joins all values with the configured separator and wraps with bookends.
|
|
146
|
+
* Returns empty string if skipEmpty is enabled and list is empty.
|
|
147
|
+
*
|
|
148
|
+
* @returns Formatted string representation of the list
|
|
149
|
+
*/
|
|
142
150
|
toString() {
|
|
143
151
|
if (this.skipEmpty && this.values.length === 0) {
|
|
144
152
|
return '';
|
|
@@ -381,8 +389,20 @@ Object.defineProperty(List, "hasValue", {
|
|
|
381
389
|
return true;
|
|
382
390
|
}
|
|
383
391
|
});
|
|
392
|
+
/**
|
|
393
|
+
* Utility class for working with arrays of string keys.
|
|
394
|
+
*
|
|
395
|
+
* Provides methods for transforming key arrays into objects and lists
|
|
396
|
+
* with custom mapping functions.
|
|
397
|
+
*/
|
|
384
398
|
class KeyList {
|
|
399
|
+
/**
|
|
400
|
+
* Creates a new KeyList instance.
|
|
401
|
+
*
|
|
402
|
+
* @param keys - Array of string keys to work with
|
|
403
|
+
*/
|
|
385
404
|
constructor(keys) {
|
|
405
|
+
/** Array of string keys */
|
|
386
406
|
Object.defineProperty(this, "keys", {
|
|
387
407
|
enumerable: true,
|
|
388
408
|
configurable: true,
|
|
@@ -391,15 +411,38 @@ class KeyList {
|
|
|
391
411
|
});
|
|
392
412
|
this.keys = keys;
|
|
393
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Transforms keys into an object using a mapping function.
|
|
416
|
+
*
|
|
417
|
+
* @param mapFn - Function to transform each key into a value
|
|
418
|
+
* @param options - Options for handling empty values
|
|
419
|
+
* @returns Object with keys mapped to transformed values
|
|
420
|
+
*/
|
|
394
421
|
toObject(mapFn, { skipEmpty } = {}) {
|
|
395
422
|
return List.toObject(this.keys.map((key, index) => mapFn(key, index)), { skipEmpty });
|
|
396
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Creates a plain object with keys as both keys and values.
|
|
426
|
+
*
|
|
427
|
+
* @returns Object where each key maps to itself
|
|
428
|
+
*/
|
|
397
429
|
toObjectPlain() {
|
|
398
430
|
return List.toObject(this.keys);
|
|
399
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Transforms keys into a List using a mapping function.
|
|
434
|
+
*
|
|
435
|
+
* @param mapFn - Function to transform each key into a value
|
|
436
|
+
* @returns List containing the transformed values
|
|
437
|
+
*/
|
|
400
438
|
toLines(mapFn) {
|
|
401
439
|
return List.toLines(this.keys.map((key, index) => mapFn(key, index)));
|
|
402
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a List with keys as the values.
|
|
443
|
+
*
|
|
444
|
+
* @returns List containing the original keys
|
|
445
|
+
*/
|
|
403
446
|
toLinesPlain() {
|
|
404
447
|
return List.toLines(this.keys);
|
|
405
448
|
}
|