@skmtc/core 0.0.800 → 0.0.803
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/CoreContext.d.ts +2 -2
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.d.ts +16 -3
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/ParseContext.d.ts +3 -3
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/RenderContext.d.ts +153 -1
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +179 -0
- package/esm/context/types.d.ts +30 -0
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/model/ModelBase.d.ts +1 -1
- package/esm/dsl/model/ModelBase.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.d.ts +62 -0
- package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.js +63 -1
- package/esm/dsl/model/toModelBase.d.ts +66 -0
- package/esm/dsl/model/toModelBase.d.ts.map +1 -1
- package/esm/dsl/model/toModelBase.js +46 -0
- package/esm/dsl/model/toModelEntry.d.ts +63 -0
- package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
- package/esm/dsl/model/toModelEntry.js +63 -0
- package/esm/dsl/operation/OperationBase.d.ts +3 -3
- package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.d.ts +84 -0
- package/esm/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.js +85 -1
- package/esm/dsl/operation/toOperationBase.d.ts +58 -0
- package/esm/dsl/operation/toOperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationBase.js +46 -0
- package/esm/dsl/operation/toOperationEntry.d.ts +37 -0
- package/esm/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationEntry.js +28 -0
- package/esm/helpers/isEmpty.d.ts +1 -1
- package/esm/helpers/isEmpty.d.ts.map +1 -1
- package/esm/helpers/tracer.d.ts +1 -1
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +1 -1
- package/esm/mod.d.ts +52 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +52 -0
- package/esm/oas/array/Array.d.ts +26 -0
- package/esm/oas/array/Array.d.ts.map +1 -1
- package/esm/oas/array/Array.js +26 -0
- package/esm/oas/array/array-types.d.ts +32 -11
- package/esm/oas/array/array-types.d.ts.map +1 -1
- package/esm/oas/array/array-types.js +16 -0
- package/esm/oas/array/toArray.d.ts +111 -0
- package/esm/oas/array/toArray.d.ts.map +1 -1
- package/esm/oas/array/toArray.js +115 -3
- package/esm/oas/boolean/Boolean.d.ts +26 -0
- package/esm/oas/boolean/Boolean.d.ts.map +1 -1
- package/esm/oas/boolean/Boolean.js +26 -0
- package/esm/oas/boolean/boolean-types.d.ts +1 -7
- package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
- package/esm/oas/boolean/toBoolean.d.ts +57 -0
- package/esm/oas/boolean/toBoolean.d.ts.map +1 -1
- package/esm/oas/boolean/toBoolean.js +57 -0
- package/esm/oas/components/components-types.d.ts +19 -0
- package/esm/oas/components/components-types.d.ts.map +1 -0
- package/esm/oas/components/components-types.js +21 -0
- package/esm/oas/contact/contact-types.d.ts +9 -0
- package/esm/oas/contact/contact-types.d.ts.map +1 -0
- package/esm/oas/contact/contact-types.js +7 -0
- package/esm/oas/discriminator/discriminator-types.d.ts +1 -5
- package/esm/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/esm/oas/document/document-types.d.ts +16 -0
- package/esm/oas/document/document-types.d.ts.map +1 -0
- package/esm/oas/document/document-types.js +18 -0
- package/esm/oas/example/example-types.d.ts +1 -6
- package/esm/oas/example/example-types.d.ts.map +1 -1
- package/esm/oas/header/header-types.d.ts +50 -0
- package/esm/oas/header/header-types.d.ts.map +1 -0
- package/esm/oas/header/header-types.js +30 -0
- package/esm/oas/info/info-types.d.ts +14 -0
- package/esm/oas/info/info-types.d.ts.map +1 -0
- package/esm/oas/info/info-types.js +13 -0
- package/esm/oas/integer/integer-types.d.ts +3 -17
- package/esm/oas/integer/integer-types.d.ts.map +1 -1
- package/esm/oas/license/license-types.d.ts +9 -0
- package/esm/oas/license/license-types.d.ts.map +1 -0
- package/esm/oas/license/license-types.js +7 -0
- package/esm/oas/mediaType/mediaType-types.d.ts +1 -11
- package/esm/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/esm/oas/number/number-types.d.ts +2 -16
- package/esm/oas/number/number-types.d.ts.map +1 -1
- package/esm/oas/number/toNumber.d.ts +62 -0
- package/esm/oas/number/toNumber.d.ts.map +1 -1
- package/esm/oas/number/toNumber.js +62 -0
- package/esm/oas/operation/operation-types.d.ts +22 -0
- package/esm/oas/operation/operation-types.d.ts.map +1 -0
- package/esm/oas/operation/operation-types.js +35 -0
- package/esm/oas/parameter/Parameter.d.ts +47 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +47 -0
- package/esm/oas/parameter/parameter-types.d.ts +3 -58
- package/esm/oas/parameter/parameter-types.d.ts.map +1 -1
- package/esm/oas/pathItem/pathItem-types.d.ts +12 -0
- package/esm/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/esm/oas/pathItem/pathItem-types.js +12 -0
- package/esm/oas/requestBody/requestBody-types.d.ts +10 -0
- package/esm/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/esm/oas/requestBody/requestBody-types.js +9 -0
- package/esm/oas/response/response-types.d.ts +12 -0
- package/esm/oas/response/response-types.d.ts.map +1 -0
- package/esm/oas/response/response-types.js +11 -0
- package/esm/oas/schema/toSchemasV3.js +2 -2
- package/esm/oas/server/toServerV3.d.ts.map +1 -1
- package/esm/oas/string/string-types.d.ts +2 -29
- package/esm/oas/string/string-types.d.ts.map +1 -1
- package/esm/oas/string/toString.d.ts +125 -1
- package/esm/oas/string/toString.d.ts.map +1 -1
- package/esm/oas/string/toString.js +119 -0
- package/esm/oas/tag/tag-types.d.ts +8 -0
- package/esm/oas/tag/tag-types.d.ts.map +1 -0
- package/esm/oas/tag/tag-types.js +8 -0
- package/esm/oas/union/union-types.d.ts +1 -12
- package/esm/oas/union/union-types.d.ts.map +1 -1
- package/esm/oas/unknown/unknown-types.d.ts +1 -7
- package/esm/oas/unknown/unknown-types.d.ts.map +1 -1
- package/esm/types/CustomValue.d.ts +58 -0
- package/esm/types/CustomValue.d.ts.map +1 -1
- package/esm/types/CustomValue.js +58 -0
- package/esm/types/DenoJson.d.ts +24 -0
- package/esm/types/DenoJson.d.ts.map +1 -1
- package/esm/types/DenoJson.js +12 -0
- package/esm/types/Enrichments.d.ts +103 -0
- package/esm/types/Enrichments.d.ts.map +1 -1
- package/esm/types/Enrichments.js +52 -0
- package/esm/types/GeneratedValue.d.ts +17 -0
- package/esm/types/GeneratedValue.d.ts.map +1 -1
- package/esm/types/Logger.d.ts +9 -0
- package/esm/types/Logger.d.ts.map +1 -0
- package/esm/types/Logger.js +1 -0
- package/esm/types/Preview.d.ts +37 -0
- package/esm/types/Preview.d.ts.map +1 -1
- package/esm/types/Preview.js +37 -0
- package/esm/types/Settings.d.ts +35 -0
- package/esm/types/Settings.d.ts.map +1 -1
- package/esm/types/Settings.js +27 -0
- package/esm/typescript/FunctionParameter.d.ts +4 -4
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/List.d.ts +40 -2
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +32 -0
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +2 -2
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/GenerateContext.d.ts +16 -3
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/ParseContext.d.ts +3 -3
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/RenderContext.d.ts +153 -1
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +179 -0
- package/script/context/types.d.ts +30 -0
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/model/ModelBase.d.ts +1 -1
- package/script/dsl/model/ModelBase.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.d.ts +62 -0
- package/script/dsl/model/ModelDriver.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.js +63 -1
- package/script/dsl/model/toModelBase.d.ts +66 -0
- package/script/dsl/model/toModelBase.d.ts.map +1 -1
- package/script/dsl/model/toModelBase.js +46 -0
- package/script/dsl/model/toModelEntry.d.ts +63 -0
- package/script/dsl/model/toModelEntry.d.ts.map +1 -1
- package/script/dsl/model/toModelEntry.js +63 -0
- package/script/dsl/operation/OperationBase.d.ts +3 -3
- package/script/dsl/operation/OperationBase.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.d.ts +84 -0
- package/script/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.js +85 -1
- package/script/dsl/operation/toOperationBase.d.ts +58 -0
- package/script/dsl/operation/toOperationBase.d.ts.map +1 -1
- package/script/dsl/operation/toOperationBase.js +46 -0
- package/script/dsl/operation/toOperationEntry.d.ts +37 -0
- package/script/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/script/dsl/operation/toOperationEntry.js +28 -0
- package/script/helpers/isEmpty.d.ts +1 -1
- package/script/helpers/isEmpty.d.ts.map +1 -1
- package/script/helpers/tracer.d.ts +1 -1
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +1 -1
- package/script/mod.d.ts +52 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +52 -0
- package/script/oas/array/Array.d.ts +26 -0
- package/script/oas/array/Array.d.ts.map +1 -1
- package/script/oas/array/Array.js +26 -0
- package/script/oas/array/array-types.d.ts +32 -11
- package/script/oas/array/array-types.d.ts.map +1 -1
- package/script/oas/array/array-types.js +17 -1
- package/script/oas/array/toArray.d.ts +111 -0
- package/script/oas/array/toArray.d.ts.map +1 -1
- package/script/oas/array/toArray.js +114 -2
- package/script/oas/boolean/Boolean.d.ts +26 -0
- package/script/oas/boolean/Boolean.d.ts.map +1 -1
- package/script/oas/boolean/Boolean.js +26 -0
- package/script/oas/boolean/boolean-types.d.ts +1 -7
- package/script/oas/boolean/boolean-types.d.ts.map +1 -1
- package/script/oas/boolean/toBoolean.d.ts +57 -0
- package/script/oas/boolean/toBoolean.d.ts.map +1 -1
- package/script/oas/boolean/toBoolean.js +57 -0
- package/script/oas/components/components-types.d.ts +19 -0
- package/script/oas/components/components-types.d.ts.map +1 -0
- package/script/oas/components/components-types.js +57 -0
- package/script/oas/contact/contact-types.d.ts +9 -0
- package/script/oas/contact/contact-types.d.ts.map +1 -0
- package/script/oas/contact/contact-types.js +43 -0
- package/script/oas/discriminator/discriminator-types.d.ts +1 -5
- package/script/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/script/oas/document/document-types.d.ts +16 -0
- package/script/oas/document/document-types.d.ts.map +1 -0
- package/script/oas/document/document-types.js +54 -0
- package/script/oas/example/example-types.d.ts +1 -6
- package/script/oas/example/example-types.d.ts.map +1 -1
- package/script/oas/header/header-types.d.ts +50 -0
- package/script/oas/header/header-types.d.ts.map +1 -0
- package/script/oas/header/header-types.js +66 -0
- package/script/oas/info/info-types.d.ts +14 -0
- package/script/oas/info/info-types.d.ts.map +1 -0
- package/script/oas/info/info-types.js +49 -0
- package/script/oas/integer/integer-types.d.ts +3 -17
- package/script/oas/integer/integer-types.d.ts.map +1 -1
- package/script/oas/license/license-types.d.ts +9 -0
- package/script/oas/license/license-types.d.ts.map +1 -0
- package/script/oas/license/license-types.js +43 -0
- package/script/oas/mediaType/mediaType-types.d.ts +1 -11
- package/script/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/script/oas/number/number-types.d.ts +2 -16
- package/script/oas/number/number-types.d.ts.map +1 -1
- package/script/oas/number/toNumber.d.ts +62 -0
- package/script/oas/number/toNumber.d.ts.map +1 -1
- package/script/oas/number/toNumber.js +62 -0
- package/script/oas/operation/operation-types.d.ts +22 -0
- package/script/oas/operation/operation-types.d.ts.map +1 -0
- package/script/oas/operation/operation-types.js +71 -0
- package/script/oas/parameter/Parameter.d.ts +47 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +47 -0
- package/script/oas/parameter/parameter-types.d.ts +3 -58
- package/script/oas/parameter/parameter-types.d.ts.map +1 -1
- package/script/oas/pathItem/pathItem-types.d.ts +12 -0
- package/script/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/script/oas/pathItem/pathItem-types.js +48 -0
- package/script/oas/requestBody/requestBody-types.d.ts +10 -0
- package/script/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/script/oas/requestBody/requestBody-types.js +45 -0
- package/script/oas/response/response-types.d.ts +12 -0
- package/script/oas/response/response-types.d.ts.map +1 -0
- package/script/oas/response/response-types.js +47 -0
- package/script/oas/schema/toSchemasV3.js +2 -2
- package/script/oas/server/toServerV3.d.ts.map +1 -1
- package/script/oas/string/string-types.d.ts +2 -29
- package/script/oas/string/string-types.d.ts.map +1 -1
- package/script/oas/string/toString.d.ts +125 -1
- package/script/oas/string/toString.d.ts.map +1 -1
- package/script/oas/string/toString.js +119 -0
- package/script/oas/tag/tag-types.d.ts +8 -0
- package/script/oas/tag/tag-types.d.ts.map +1 -0
- package/script/oas/tag/tag-types.js +44 -0
- package/script/oas/union/union-types.d.ts +1 -12
- package/script/oas/union/union-types.d.ts.map +1 -1
- package/script/oas/unknown/unknown-types.d.ts +1 -7
- package/script/oas/unknown/unknown-types.d.ts.map +1 -1
- package/script/types/CustomValue.d.ts +58 -0
- package/script/types/CustomValue.d.ts.map +1 -1
- package/script/types/CustomValue.js +58 -0
- package/script/types/DenoJson.d.ts +24 -0
- package/script/types/DenoJson.d.ts.map +1 -1
- package/script/types/DenoJson.js +12 -0
- package/script/types/Enrichments.d.ts +103 -0
- package/script/types/Enrichments.d.ts.map +1 -1
- package/script/types/Enrichments.js +52 -0
- package/script/types/GeneratedValue.d.ts +17 -0
- package/script/types/GeneratedValue.d.ts.map +1 -1
- package/script/types/Logger.d.ts +9 -0
- package/script/types/Logger.d.ts.map +1 -0
- package/script/types/Logger.js +2 -0
- package/script/types/Preview.d.ts +37 -0
- package/script/types/Preview.d.ts.map +1 -1
- package/script/types/Preview.js +37 -0
- package/script/types/Settings.d.ts +35 -0
- package/script/types/Settings.d.ts.map +1 -1
- package/script/types/Settings.js +27 -0
- package/script/typescript/FunctionParameter.d.ts +4 -4
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/List.d.ts +40 -2
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +32 -0
|
@@ -1,11 +1,75 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { ParseContext } from '../../context/ParseContext.js';
|
|
3
3
|
import { OasString } from './String.js';
|
|
4
|
+
/**
|
|
5
|
+
* Arguments for transforming an OpenAPI string schema into OAS representation.
|
|
6
|
+
*/
|
|
4
7
|
type ToStringArgs = {
|
|
8
|
+
/** The OpenAPI v3 schema object to transform (must be type 'string') */
|
|
5
9
|
value: OpenAPIV3.SchemaObject;
|
|
10
|
+
/** Parse context providing utilities and tracing capabilities */
|
|
6
11
|
context: ParseContext;
|
|
7
12
|
};
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Transforms an OpenAPI v3 string schema object into an internal OAS string representation.
|
|
15
|
+
*
|
|
16
|
+
* This function processes OpenAPI string schemas by extracting and parsing nullable values,
|
|
17
|
+
* examples, enumerations, and default values. It handles the complete transformation from
|
|
18
|
+
* raw OpenAPI JSON to the SKMTC internal string representation with proper validation
|
|
19
|
+
* of string formats and constraints.
|
|
20
|
+
*
|
|
21
|
+
* The transformation follows a pipeline approach:
|
|
22
|
+
* 1. Parse nullable flag and extract base value
|
|
23
|
+
* 2. Parse example values with nullable support
|
|
24
|
+
* 3. Parse enumeration constraints
|
|
25
|
+
* 4. Parse default values
|
|
26
|
+
* 5. Create final OasString instance with format validation
|
|
27
|
+
*
|
|
28
|
+
* @param args - Transformation arguments
|
|
29
|
+
* @param args.context - Parse context providing utilities and tracing
|
|
30
|
+
* @param args.value - The OpenAPI v3 string schema object to transform
|
|
31
|
+
* @returns Transformed OAS string object with parsed properties
|
|
32
|
+
*
|
|
33
|
+
* @example Basic string transformation
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { toString } from '@skmtc/core';
|
|
36
|
+
*
|
|
37
|
+
* const openApiString = {
|
|
38
|
+
* type: 'string',
|
|
39
|
+
* format: 'email',
|
|
40
|
+
* maxLength: 255,
|
|
41
|
+
* pattern: '^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,}$'
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* const oasString = toString({
|
|
45
|
+
* context: parseContext,
|
|
46
|
+
* value: openApiString
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* console.log(oasString.format); // 'email'
|
|
50
|
+
* console.log(oasString.maxLength); // 255
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example String with nullable and enums
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const statusString = {
|
|
56
|
+
* type: 'string',
|
|
57
|
+
* nullable: true,
|
|
58
|
+
* enum: ['active', 'inactive', 'pending', null],
|
|
59
|
+
* default: 'active',
|
|
60
|
+
* example: 'pending'
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* const oasString = toString({
|
|
64
|
+
* context: parseContext,
|
|
65
|
+
* value: statusString
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* console.log(oasString.nullable); // true
|
|
69
|
+
* console.log(oasString.enums); // ['active', 'inactive', 'pending', null]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const toString: ({ context, value }: ToStringArgs) => OasString;
|
|
9
73
|
type ToParsedStringArgs<Nullable extends boolean | undefined> = {
|
|
10
74
|
value: Omit<OpenAPIV3.SchemaObject, 'nullable' | 'example' | 'enums' | 'default'>;
|
|
11
75
|
context: ParseContext;
|
|
@@ -14,6 +78,66 @@ type ToParsedStringArgs<Nullable extends boolean | undefined> = {
|
|
|
14
78
|
enums: Nullable extends true ? (string | null)[] | undefined : string[] | undefined;
|
|
15
79
|
defaultValue: Nullable extends true ? string | null | undefined : string | undefined;
|
|
16
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Creates an OAS string instance from pre-parsed string schema components.
|
|
83
|
+
*
|
|
84
|
+
* This function is the final step in the string transformation pipeline, taking
|
|
85
|
+
* already-parsed nullable, example, enum, and default values and combining them
|
|
86
|
+
* with the remaining string properties to create the complete OasString instance.
|
|
87
|
+
*
|
|
88
|
+
* The function handles format validation against known OpenAPI string formats,
|
|
89
|
+
* length constraints parsing, pattern validation, and specification extension
|
|
90
|
+
* processing. It logs warnings for unrecognized formats while still preserving
|
|
91
|
+
* them in the output.
|
|
92
|
+
*
|
|
93
|
+
* @template Nullable - Boolean type indicating if the string can be null
|
|
94
|
+
* @param args - Pre-parsed string components
|
|
95
|
+
* @param args.context - Parse context for tracing and issue logging
|
|
96
|
+
* @param args.nullable - Parsed nullable flag
|
|
97
|
+
* @param args.example - Parsed example value (type-safe with nullable)
|
|
98
|
+
* @param args.enums - Parsed enumeration constraints (type-safe with nullable)
|
|
99
|
+
* @param args.defaultValue - Parsed default value (type-safe with nullable)
|
|
100
|
+
* @param args.value - OpenAPI string object without parsed fields
|
|
101
|
+
* @returns Complete OAS string instance with all properties and validation
|
|
102
|
+
*
|
|
103
|
+
* @example Date-time string with validation
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const dateTimeString = toParsedString({
|
|
106
|
+
* context: parseContext,
|
|
107
|
+
* nullable: false,
|
|
108
|
+
* example: '2023-12-25T10:00:00Z',
|
|
109
|
+
* enums: undefined,
|
|
110
|
+
* defaultValue: undefined,
|
|
111
|
+
* value: {
|
|
112
|
+
* type: 'string',
|
|
113
|
+
* format: 'date-time',
|
|
114
|
+
* title: 'Event Date',
|
|
115
|
+
* description: 'When the event occurs'
|
|
116
|
+
* }
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* console.log(dateTimeString.format); // 'date-time'
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example String with custom format (generates warning)
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const customFormatString = toParsedString({
|
|
125
|
+
* context: parseContext,
|
|
126
|
+
* nullable: false,
|
|
127
|
+
* example: 'ABC123',
|
|
128
|
+
* enums: undefined,
|
|
129
|
+
* defaultValue: undefined,
|
|
130
|
+
* value: {
|
|
131
|
+
* type: 'string',
|
|
132
|
+
* format: 'custom-id', // Unknown format, will log warning
|
|
133
|
+
* pattern: '^[A-Z]{3}[0-9]{3}$'
|
|
134
|
+
* }
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* // Logs: "Unexpected format: custom-id"
|
|
138
|
+
* console.log(customFormatString.format); // 'custom-id' (still preserved)
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
17
141
|
export declare const toParsedString: <Nullable extends boolean | undefined>({ context, nullable, example, enums, defaultValue, value }: ToParsedStringArgs<Nullable>) => OasString<Nullable>;
|
|
18
142
|
export {};
|
|
19
143
|
//# sourceMappingURL=toString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toString.d.ts","sourceRoot":"","sources":["../../../src/oas/string/toString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAQvC,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,SAAS,CAAC,YAAY,CAAA;IAC7B,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,oBA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,cAAc,GAAI,QAAQ,SAAS,OAAO,GAAG,SAAS,EAAE,4DAOlE,kBAAkB,CAAC,QAAQ,CAAC,KAAG,SAAS,CAAC,QAAQ,CA0CnD,CAAA"}
|
|
@@ -6,6 +6,65 @@ import { parseNullable } from '../_helpers/parseNullable.js';
|
|
|
6
6
|
import { parseExample } from '../_helpers/parseExample.js';
|
|
7
7
|
import { parseEnum } from '../_helpers/parseEnum.js';
|
|
8
8
|
import { parseDefault } from '../_helpers/parseDefault.js';
|
|
9
|
+
/**
|
|
10
|
+
* Transforms an OpenAPI v3 string schema object into an internal OAS string representation.
|
|
11
|
+
*
|
|
12
|
+
* This function processes OpenAPI string schemas by extracting and parsing nullable values,
|
|
13
|
+
* examples, enumerations, and default values. It handles the complete transformation from
|
|
14
|
+
* raw OpenAPI JSON to the SKMTC internal string representation with proper validation
|
|
15
|
+
* of string formats and constraints.
|
|
16
|
+
*
|
|
17
|
+
* The transformation follows a pipeline approach:
|
|
18
|
+
* 1. Parse nullable flag and extract base value
|
|
19
|
+
* 2. Parse example values with nullable support
|
|
20
|
+
* 3. Parse enumeration constraints
|
|
21
|
+
* 4. Parse default values
|
|
22
|
+
* 5. Create final OasString instance with format validation
|
|
23
|
+
*
|
|
24
|
+
* @param args - Transformation arguments
|
|
25
|
+
* @param args.context - Parse context providing utilities and tracing
|
|
26
|
+
* @param args.value - The OpenAPI v3 string schema object to transform
|
|
27
|
+
* @returns Transformed OAS string object with parsed properties
|
|
28
|
+
*
|
|
29
|
+
* @example Basic string transformation
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { toString } from '@skmtc/core';
|
|
32
|
+
*
|
|
33
|
+
* const openApiString = {
|
|
34
|
+
* type: 'string',
|
|
35
|
+
* format: 'email',
|
|
36
|
+
* maxLength: 255,
|
|
37
|
+
* pattern: '^[\\w.-]+@[\\w.-]+\\.[a-zA-Z]{2,}$'
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const oasString = toString({
|
|
41
|
+
* context: parseContext,
|
|
42
|
+
* value: openApiString
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* console.log(oasString.format); // 'email'
|
|
46
|
+
* console.log(oasString.maxLength); // 255
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example String with nullable and enums
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const statusString = {
|
|
52
|
+
* type: 'string',
|
|
53
|
+
* nullable: true,
|
|
54
|
+
* enum: ['active', 'inactive', 'pending', null],
|
|
55
|
+
* default: 'active',
|
|
56
|
+
* example: 'pending'
|
|
57
|
+
* };
|
|
58
|
+
*
|
|
59
|
+
* const oasString = toString({
|
|
60
|
+
* context: parseContext,
|
|
61
|
+
* value: statusString
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* console.log(oasString.nullable); // true
|
|
65
|
+
* console.log(oasString.enums); // ['active', 'inactive', 'pending', null]
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
9
68
|
export const toString = ({ context, value }) => {
|
|
10
69
|
const { nullable, value: valueWithoutNullable } = parseNullable({
|
|
11
70
|
value,
|
|
@@ -38,6 +97,66 @@ export const toString = ({ context, value }) => {
|
|
|
38
97
|
value: valueWithoutDefault
|
|
39
98
|
});
|
|
40
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Creates an OAS string instance from pre-parsed string schema components.
|
|
102
|
+
*
|
|
103
|
+
* This function is the final step in the string transformation pipeline, taking
|
|
104
|
+
* already-parsed nullable, example, enum, and default values and combining them
|
|
105
|
+
* with the remaining string properties to create the complete OasString instance.
|
|
106
|
+
*
|
|
107
|
+
* The function handles format validation against known OpenAPI string formats,
|
|
108
|
+
* length constraints parsing, pattern validation, and specification extension
|
|
109
|
+
* processing. It logs warnings for unrecognized formats while still preserving
|
|
110
|
+
* them in the output.
|
|
111
|
+
*
|
|
112
|
+
* @template Nullable - Boolean type indicating if the string can be null
|
|
113
|
+
* @param args - Pre-parsed string components
|
|
114
|
+
* @param args.context - Parse context for tracing and issue logging
|
|
115
|
+
* @param args.nullable - Parsed nullable flag
|
|
116
|
+
* @param args.example - Parsed example value (type-safe with nullable)
|
|
117
|
+
* @param args.enums - Parsed enumeration constraints (type-safe with nullable)
|
|
118
|
+
* @param args.defaultValue - Parsed default value (type-safe with nullable)
|
|
119
|
+
* @param args.value - OpenAPI string object without parsed fields
|
|
120
|
+
* @returns Complete OAS string instance with all properties and validation
|
|
121
|
+
*
|
|
122
|
+
* @example Date-time string with validation
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const dateTimeString = toParsedString({
|
|
125
|
+
* context: parseContext,
|
|
126
|
+
* nullable: false,
|
|
127
|
+
* example: '2023-12-25T10:00:00Z',
|
|
128
|
+
* enums: undefined,
|
|
129
|
+
* defaultValue: undefined,
|
|
130
|
+
* value: {
|
|
131
|
+
* type: 'string',
|
|
132
|
+
* format: 'date-time',
|
|
133
|
+
* title: 'Event Date',
|
|
134
|
+
* description: 'When the event occurs'
|
|
135
|
+
* }
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* console.log(dateTimeString.format); // 'date-time'
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @example String with custom format (generates warning)
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const customFormatString = toParsedString({
|
|
144
|
+
* context: parseContext,
|
|
145
|
+
* nullable: false,
|
|
146
|
+
* example: 'ABC123',
|
|
147
|
+
* enums: undefined,
|
|
148
|
+
* defaultValue: undefined,
|
|
149
|
+
* value: {
|
|
150
|
+
* type: 'string',
|
|
151
|
+
* format: 'custom-id', // Unknown format, will log warning
|
|
152
|
+
* pattern: '^[A-Z]{3}[0-9]{3}$'
|
|
153
|
+
* }
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* // Logs: "Unexpected format: custom-id"
|
|
157
|
+
* console.log(customFormatString.format); // 'custom-id' (still preserved)
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
41
160
|
export const toParsedString = ({ context, nullable, example, enums, defaultValue, value }) => {
|
|
42
161
|
const { type: _type, title, description, format, maxLength, minLength, pattern, ...skipped } = v.parse(oasStringData, value);
|
|
43
162
|
const extensionFields = toSpecificationExtensionsV3({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-types.d.ts","sourceRoot":"","sources":["../../../src/oas/tag/tag-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,KAAK,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CAKjD,CAAA"}
|
|
@@ -30,16 +30,5 @@ export type OasUnionData = {
|
|
|
30
30
|
* discriminator properties. Uses lazy evaluation to handle recursive
|
|
31
31
|
* schema references in union members.
|
|
32
32
|
*/
|
|
33
|
-
export declare const oasUnionData: v.
|
|
34
|
-
readonly oasType: v.LiteralSchema<"schema", undefined>;
|
|
35
|
-
readonly type: v.LiteralSchema<"union", undefined>;
|
|
36
|
-
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
37
|
-
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
38
|
-
readonly members: v.LazySchema<v.ArraySchema<v.UnionSchema<[v.GenericSchema<OasSchemaData>, v.GenericSchema<OasSchemaRefData>], undefined>, undefined>>;
|
|
39
|
-
readonly discriminator: v.OptionalSchema<v.ObjectSchema<{
|
|
40
|
-
readonly oasType: v.LiteralSchema<"discriminator", undefined>;
|
|
41
|
-
readonly propertyName: v.StringSchema<undefined>;
|
|
42
|
-
readonly mapping: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
|
|
43
|
-
}, undefined>, undefined>;
|
|
44
|
-
}, undefined>;
|
|
33
|
+
export declare const oasUnionData: v.GenericSchema<OasUnionData>;
|
|
45
34
|
//# sourceMappingURL=union-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-types.d.ts","sourceRoot":"","sources":["../../../src/oas/union/union-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,yCAAyC,CAAA;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,kDAAkD;IAClD,OAAO,EAAE,QAAQ,CAAA;IACjB,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+CAA+C;IAC/C,OAAO,EAAE,CAAC,aAAa,GAAG,gBAAgB,CAAC,EAAE,CAAA;IAC7C,2DAA2D;IAC3D,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"union-types.d.ts","sourceRoot":"","sources":["../../../src/oas/union/union-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,yCAAyC,CAAA;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,kDAAkD;IAClD,OAAO,EAAE,QAAQ,CAAA;IACjB,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+CAA+C;IAC/C,OAAO,EAAE,CAAC,aAAa,GAAG,gBAAgB,CAAC,EAAE,CAAA;IAC7C,2DAA2D;IAC3D,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAOrD,CAAA"}
|
|
@@ -5,13 +5,7 @@ import * as v from 'valibot';
|
|
|
5
5
|
* Validates unknown/unspecified schemas used as fallbacks when
|
|
6
6
|
* schema types cannot be determined or for flexible data handling.
|
|
7
7
|
*/
|
|
8
|
-
export declare const oasUnknownData: v.
|
|
9
|
-
readonly oasType: v.LiteralSchema<"schema", undefined>;
|
|
10
|
-
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11
|
-
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
12
|
-
readonly default: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
13
|
-
readonly type: v.LiteralSchema<"unknown", undefined>;
|
|
14
|
-
}, undefined>;
|
|
8
|
+
export declare const oasUnknownData: v.GenericSchema<OasUnknownData>;
|
|
15
9
|
/**
|
|
16
10
|
* Data type for OpenAPI unknown schema objects.
|
|
17
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown-types.d.ts","sourceRoot":"","sources":["../../../src/oas/unknown/unknown-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"unknown-types.d.ts","sourceRoot":"","sources":["../../../src/oas/unknown/unknown-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,aAAa,CAAC,cAAc,CAMzD,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,kDAAkD;IAClD,OAAO,EAAE,QAAQ,CAAA;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yCAAyC;IACzC,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA"}
|
|
@@ -9,15 +9,73 @@ type CreateArgs = {
|
|
|
9
9
|
value: Stringable;
|
|
10
10
|
generatorKey?: GeneratorKey;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Represents a custom value in the SKMTC generation pipeline.
|
|
14
|
+
*
|
|
15
|
+
* CustomValue allows generators to create arbitrary content that doesn't fit
|
|
16
|
+
* standard schema types. Used for injecting custom code, templates, or specialized
|
|
17
|
+
* content during the generation process.
|
|
18
|
+
*
|
|
19
|
+
* @example Creating custom content
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const customValue = new CustomValue({
|
|
22
|
+
* context: generateContext,
|
|
23
|
+
* value: 'const customCode = "generated";',
|
|
24
|
+
* generatorKey: 'my-generator'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* console.log(customValue.toString()); // "const customCode = "generated";"
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
12
30
|
export declare class CustomValue extends ContentBase {
|
|
31
|
+
/** Type identifier for this custom value */
|
|
13
32
|
type: "custom";
|
|
33
|
+
/** The underlying value content that can be converted to string */
|
|
14
34
|
value: Stringable;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new CustomValue instance.
|
|
37
|
+
*
|
|
38
|
+
* @param args - Creation arguments including context, value, and optional generator key
|
|
39
|
+
*/
|
|
15
40
|
constructor({ context, value, generatorKey }: CreateArgs);
|
|
41
|
+
/**
|
|
42
|
+
* Determines if this custom value is a reference.
|
|
43
|
+
*
|
|
44
|
+
* @returns Always false since custom values are concrete content, not references
|
|
45
|
+
*/
|
|
16
46
|
isRef(): this is OasRef<'schema'>;
|
|
47
|
+
/**
|
|
48
|
+
* Resolves this custom value.
|
|
49
|
+
*
|
|
50
|
+
* @returns The custom value itself since it's already resolved
|
|
51
|
+
*/
|
|
17
52
|
resolve(): CustomValue;
|
|
53
|
+
/**
|
|
54
|
+
* Resolves this custom value one level.
|
|
55
|
+
*
|
|
56
|
+
* @returns The custom value itself since it's already resolved
|
|
57
|
+
*/
|
|
18
58
|
resolveOnce(): CustomValue;
|
|
59
|
+
/**
|
|
60
|
+
* Converts the custom value to its string representation.
|
|
61
|
+
*
|
|
62
|
+
* @returns String representation of the underlying value
|
|
63
|
+
*/
|
|
19
64
|
toString(): string;
|
|
20
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Type guard function to check if a value is a CustomValue instance.
|
|
68
|
+
*
|
|
69
|
+
* @param value - Value to check
|
|
70
|
+
* @returns True if the value is a CustomValue, false otherwise
|
|
71
|
+
*
|
|
72
|
+
* @example Type checking
|
|
73
|
+
* ```typescript
|
|
74
|
+
* if (isCustomValue(someValue)) {
|
|
75
|
+
* console.log(someValue.value); // TypeScript knows it's a CustomValue
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
21
79
|
export declare const isCustomValue: (value: unknown) => value is CustomValue;
|
|
22
80
|
export {};
|
|
23
81
|
//# sourceMappingURL=CustomValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomValue.d.ts","sourceRoot":"","sources":["../../src/types/CustomValue.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAu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AC;IAIjC;;;;OAIG;IACH,OAAO,IAAI,WAAW;IAItB;;;;OAIG;IACH,WAAW,IAAI,WAAW;IAI1B;;;;OAIG;IACM,QAAQ,IAAI,MAAM;CAG5B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAEvD,CAAA"}
|
package/esm/types/CustomValue.js
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import { ContentBase } from '../dsl/ContentBase.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a custom value in the SKMTC generation pipeline.
|
|
5
|
+
*
|
|
6
|
+
* CustomValue allows generators to create arbitrary content that doesn't fit
|
|
7
|
+
* standard schema types. Used for injecting custom code, templates, or specialized
|
|
8
|
+
* content during the generation process.
|
|
9
|
+
*
|
|
10
|
+
* @example Creating custom content
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const customValue = new CustomValue({
|
|
13
|
+
* context: generateContext,
|
|
14
|
+
* value: 'const customCode = "generated";',
|
|
15
|
+
* generatorKey: 'my-generator'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* console.log(customValue.toString()); // "const customCode = "generated";"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
3
21
|
export class CustomValue extends ContentBase {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new CustomValue instance.
|
|
24
|
+
*
|
|
25
|
+
* @param args - Creation arguments including context, value, and optional generator key
|
|
26
|
+
*/
|
|
4
27
|
constructor({ context, value, generatorKey }) {
|
|
5
28
|
super({ context, generatorKey });
|
|
29
|
+
/** Type identifier for this custom value */
|
|
6
30
|
Object.defineProperty(this, "type", {
|
|
7
31
|
enumerable: true,
|
|
8
32
|
configurable: true,
|
|
9
33
|
writable: true,
|
|
10
34
|
value: 'custom'
|
|
11
35
|
});
|
|
36
|
+
/** The underlying value content that can be converted to string */
|
|
12
37
|
Object.defineProperty(this, "value", {
|
|
13
38
|
enumerable: true,
|
|
14
39
|
configurable: true,
|
|
@@ -17,19 +42,52 @@ export class CustomValue extends ContentBase {
|
|
|
17
42
|
});
|
|
18
43
|
this.value = value;
|
|
19
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Determines if this custom value is a reference.
|
|
47
|
+
*
|
|
48
|
+
* @returns Always false since custom values are concrete content, not references
|
|
49
|
+
*/
|
|
20
50
|
isRef() {
|
|
21
51
|
return false;
|
|
22
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolves this custom value.
|
|
55
|
+
*
|
|
56
|
+
* @returns The custom value itself since it's already resolved
|
|
57
|
+
*/
|
|
23
58
|
resolve() {
|
|
24
59
|
return this;
|
|
25
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves this custom value one level.
|
|
63
|
+
*
|
|
64
|
+
* @returns The custom value itself since it's already resolved
|
|
65
|
+
*/
|
|
26
66
|
resolveOnce() {
|
|
27
67
|
return this;
|
|
28
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Converts the custom value to its string representation.
|
|
71
|
+
*
|
|
72
|
+
* @returns String representation of the underlying value
|
|
73
|
+
*/
|
|
29
74
|
toString() {
|
|
30
75
|
return `${this.value}`;
|
|
31
76
|
}
|
|
32
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard function to check if a value is a CustomValue instance.
|
|
80
|
+
*
|
|
81
|
+
* @param value - Value to check
|
|
82
|
+
* @returns True if the value is a CustomValue, false otherwise
|
|
83
|
+
*
|
|
84
|
+
* @example Type checking
|
|
85
|
+
* ```typescript
|
|
86
|
+
* if (isCustomValue(someValue)) {
|
|
87
|
+
* console.log(someValue.value); // TypeScript knows it's a CustomValue
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
33
91
|
export const isCustomValue = (value) => {
|
|
34
92
|
return Boolean(value && typeof value === 'object' && 'type' in value && value.type === 'custom');
|
|
35
93
|
};
|
package/esm/types/DenoJson.d.ts
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
/**
|
|
4
|
+
* Valibot schema for root-level deno.json configuration files.
|
|
5
|
+
*
|
|
6
|
+
* Validates workspace-level deno.json files that manage multiple packages
|
|
7
|
+
* and define workspace-wide imports and exports.
|
|
8
|
+
*/
|
|
3
9
|
export declare const rootDenoJson: v.GenericSchema<RootDenoJson>;
|
|
10
|
+
/**
|
|
11
|
+
* Type definition for root-level deno.json configuration.
|
|
12
|
+
*
|
|
13
|
+
* Represents the structure of workspace-level deno.json files that coordinate
|
|
14
|
+
* multiple packages within a Deno workspace.
|
|
15
|
+
*/
|
|
4
16
|
export type RootDenoJson = {
|
|
5
17
|
imports?: Record<string, string>;
|
|
6
18
|
exports?: Record<string, string>;
|
|
7
19
|
workspace?: string[];
|
|
8
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Valibot schema for package-level deno.json configuration files.
|
|
23
|
+
*
|
|
24
|
+
* Validates individual package deno.json files that define package-specific
|
|
25
|
+
* metadata, dependencies, and export configurations.
|
|
26
|
+
*/
|
|
9
27
|
export declare const packageDenoJson: v.GenericSchema<PackageDenoJson>;
|
|
28
|
+
/**
|
|
29
|
+
* Type definition for package-level deno.json configuration.
|
|
30
|
+
*
|
|
31
|
+
* Represents the structure of individual package deno.json files with
|
|
32
|
+
* required name/version fields and optional import/export configurations.
|
|
33
|
+
*/
|
|
10
34
|
export type PackageDenoJson = {
|
|
11
35
|
name: string;
|
|
12
36
|
version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoJson.d.ts","sourceRoot":"","sources":["../../src/types/DenoJson.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAIrD,CAAA;AAEF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C,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CACzC,CAAA"}
|
package/esm/types/DenoJson.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
/**
|
|
4
|
+
* Valibot schema for root-level deno.json configuration files.
|
|
5
|
+
*
|
|
6
|
+
* Validates workspace-level deno.json files that manage multiple packages
|
|
7
|
+
* and define workspace-wide imports and exports.
|
|
8
|
+
*/
|
|
3
9
|
export const rootDenoJson = v.looseObject({
|
|
4
10
|
imports: v.optional(v.record(v.string(), v.string())),
|
|
5
11
|
exports: v.optional(v.record(v.string(), v.string())),
|
|
6
12
|
workspace: v.optional(v.array(v.string()))
|
|
7
13
|
});
|
|
14
|
+
/**
|
|
15
|
+
* Valibot schema for package-level deno.json configuration files.
|
|
16
|
+
*
|
|
17
|
+
* Validates individual package deno.json files that define package-specific
|
|
18
|
+
* metadata, dependencies, and export configurations.
|
|
19
|
+
*/
|
|
8
20
|
export const packageDenoJson = v.looseObject({
|
|
9
21
|
name: v.string(),
|
|
10
22
|
version: v.string(),
|