@fern-api/go-dynamic-snippets 0.0.7 → 0.0.8
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/cjs/DiscriminatedUnionTypeInstance.cjs +1 -0
- package/cjs/DiscriminatedUnionTypeInstance.d.cts +12 -0
- package/cjs/DynamicSnippetsGenerator.cjs +19 -0
- package/cjs/DynamicSnippetsGenerator.d.cts +20 -0
- package/cjs/DynamicSnippetsGeneratorContext-DuDerGxa.d.cts +143 -0
- package/cjs/EndpointSnippetGenerator.cjs +19 -0
- package/cjs/EndpointSnippetGenerator.d.cts +52 -0
- package/cjs/Result.cjs +1 -0
- package/cjs/Result.d.cts +23 -0
- package/cjs/Scope.cjs +1 -0
- package/cjs/Scope.d.cts +9 -0
- package/cjs/TypeInstance.cjs +1 -0
- package/cjs/TypeInstance.d.cts +15 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +19 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +7 -0
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +19 -0
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +7 -0
- package/cjs/context/DynamicTypeMapper.cjs +19 -0
- package/cjs/context/DynamicTypeMapper.d.cts +7 -0
- package/cjs/context/ErrorReporter.cjs +1 -0
- package/cjs/context/ErrorReporter.d.cts +39 -0
- package/cjs/context/FilePropertyMapper.cjs +19 -0
- package/cjs/context/FilePropertyMapper.d.cts +7 -0
- package/cjs/index.cjs +22 -0
- package/{index.d.ts → cjs/index.d.cts} +1 -1
- package/esm/DiscriminatedUnionTypeInstance.d.ts +12 -0
- package/esm/DiscriminatedUnionTypeInstance.js +0 -0
- package/esm/DynamicSnippetsGenerator.d.ts +20 -0
- package/esm/DynamicSnippetsGenerator.js +1 -0
- package/esm/DynamicSnippetsGeneratorContext-DKWsHJSo.d.ts +143 -0
- package/esm/EndpointSnippetGenerator.d.ts +52 -0
- package/esm/EndpointSnippetGenerator.js +1 -0
- package/esm/Result.d.ts +23 -0
- package/esm/Result.js +1 -0
- package/esm/Scope.d.ts +9 -0
- package/esm/Scope.js +1 -0
- package/esm/TypeInstance.d.ts +15 -0
- package/esm/TypeInstance.js +0 -0
- package/esm/chunk-4PKXKUYU.js +1 -0
- package/esm/chunk-5XUC5IOB.js +1 -0
- package/esm/chunk-6JCPJA27.js +1 -0
- package/esm/chunk-BC35GX6S.js +1 -0
- package/esm/chunk-COBOWL3P.js +1 -0
- package/esm/chunk-IQODEXPX.js +1 -0
- package/esm/chunk-KJOW5AZT.js +1 -0
- package/esm/chunk-UVYC4FWB.js +1 -0
- package/esm/chunk-VAYOWHUI.js +19 -0
- package/esm/chunk-ZQRLKIRW.js +1 -0
- package/esm/chunk-ZYGZ4VN4.js +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +7 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -0
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +7 -0
- package/esm/context/DynamicTypeInstantiationMapper.js +1 -0
- package/esm/context/DynamicTypeMapper.d.ts +7 -0
- package/esm/context/DynamicTypeMapper.js +1 -0
- package/esm/context/ErrorReporter.d.ts +39 -0
- package/esm/context/ErrorReporter.js +1 -0
- package/esm/context/FilePropertyMapper.d.ts +7 -0
- package/esm/context/FilePropertyMapper.js +1 -0
- package/esm/index.d.ts +8 -0
- package/esm/index.js +4 -0
- package/package.json +18 -6
- package/index.cjs +0 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DynamicSnippetsGenerator } from './DynamicSnippetsGenerator.cjs';
|
|
2
2
|
import '@fern-api/browser-compatible-base-generator';
|
|
3
|
-
import './DynamicSnippetsGeneratorContext-
|
|
3
|
+
import './DynamicSnippetsGeneratorContext-DuDerGxa.cjs';
|
|
4
4
|
import '@fern-api/go-ast';
|
|
5
5
|
import '@fern-fern/ir-sdk/api';
|
|
6
6
|
import './TypeInstance.cjs';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NameAndWireValue, dynamic } from '@fern-fern/ir-sdk/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A discriminated union type instance that can be converted into a language-specific AST node.
|
|
5
|
+
*/
|
|
6
|
+
interface DiscriminatedUnionTypeInstance {
|
|
7
|
+
discriminantValue: NameAndWireValue;
|
|
8
|
+
singleDiscriminatedUnionType: dynamic.SingleDiscriminatedUnionType;
|
|
9
|
+
value: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { DiscriminatedUnionTypeInstance };
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-DKWsHJSo.js';
|
|
3
|
+
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
|
+
import '@fern-api/go-ast';
|
|
5
|
+
import './TypeInstance.js';
|
|
6
|
+
import './DiscriminatedUnionTypeInstance.js';
|
|
7
|
+
import './context/ErrorReporter.js';
|
|
8
|
+
|
|
9
|
+
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<dynamic.DynamicIntermediateRepresentation, DynamicSnippetsGeneratorContext, dynamic.EndpointSnippetRequest, dynamic.EndpointSnippetResponse> {
|
|
10
|
+
private formatter;
|
|
11
|
+
constructor({ ir, config, formatter }: {
|
|
12
|
+
ir: dynamic.DynamicIntermediateRepresentation;
|
|
13
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
14
|
+
formatter?: AbstractFormatter;
|
|
15
|
+
});
|
|
16
|
+
generate(request: dynamic.EndpointSnippetRequest): Promise<dynamic.EndpointSnippetResponse>;
|
|
17
|
+
generateSync(request: dynamic.EndpointSnippetRequest): dynamic.EndpointSnippetResponse;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { DynamicSnippetsGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-4PKXKUYU.js";import"./chunk-KJOW5AZT.js";import"./chunk-COBOWL3P.js";import"./chunk-ZYGZ4VN4.js";import"./chunk-UVYC4FWB.js";import"./chunk-IQODEXPX.js";import"./chunk-ZQRLKIRW.js";import"./chunk-BC35GX6S.js";import"./chunk-VAYOWHUI.js";import"./chunk-5XUC5IOB.js";import"./chunk-6JCPJA27.js";export{a as DynamicSnippetsGenerator};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { go, BaseGoCustomConfigSchema } from '@fern-api/go-ast';
|
|
3
|
+
import { dynamic, TypeId, Name, FernFilepath } from '@fern-fern/ir-sdk/api';
|
|
4
|
+
import { TypeInstance } from './TypeInstance.js';
|
|
5
|
+
import { DiscriminatedUnionTypeInstance } from './DiscriminatedUnionTypeInstance.js';
|
|
6
|
+
import { ErrorReporter } from './context/ErrorReporter.js';
|
|
7
|
+
|
|
8
|
+
declare namespace DynamicTypeMapper {
|
|
9
|
+
interface Args {
|
|
10
|
+
typeReference: dynamic.TypeReference;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare class DynamicTypeMapper {
|
|
14
|
+
private context;
|
|
15
|
+
constructor({ context }: {
|
|
16
|
+
context: DynamicSnippetsGeneratorContext;
|
|
17
|
+
});
|
|
18
|
+
convert(args: DynamicTypeMapper.Args): go.Type;
|
|
19
|
+
private convertLiteral;
|
|
20
|
+
private convertNamed;
|
|
21
|
+
private convertUnknown;
|
|
22
|
+
private convertPrimitive;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare namespace DynamicTypeInstantiationMapper {
|
|
26
|
+
interface Args {
|
|
27
|
+
typeReference: dynamic.TypeReference;
|
|
28
|
+
value: unknown;
|
|
29
|
+
as?: ConvertedAs;
|
|
30
|
+
}
|
|
31
|
+
type ConvertedAs = "key";
|
|
32
|
+
}
|
|
33
|
+
declare class DynamicTypeInstantiationMapper {
|
|
34
|
+
private context;
|
|
35
|
+
constructor({ context }: {
|
|
36
|
+
context: DynamicSnippetsGeneratorContext;
|
|
37
|
+
});
|
|
38
|
+
convert(args: DynamicTypeInstantiationMapper.Args): go.TypeInstantiation;
|
|
39
|
+
private convertList;
|
|
40
|
+
private convertMap;
|
|
41
|
+
private convertNamed;
|
|
42
|
+
private convertDiscriminatedUnion;
|
|
43
|
+
private getBaseFields;
|
|
44
|
+
private convertObject;
|
|
45
|
+
private convertEnum;
|
|
46
|
+
private getEnumValueName;
|
|
47
|
+
private convertUndicriminatedUnion;
|
|
48
|
+
private findMatchingUndiscriminatedUnionType;
|
|
49
|
+
private getUndiscriminatedUnionFieldName;
|
|
50
|
+
private getUndiscriminatedUnionFieldNameForList;
|
|
51
|
+
private getUndiscriminatedUnionFieldNameForMap;
|
|
52
|
+
private getUndiscriminatedUnionFieldNameForOptional;
|
|
53
|
+
private getUndiscriminatedUnionFieldNameForSet;
|
|
54
|
+
private getUndiscriminatedUnionFieldNameForLiteral;
|
|
55
|
+
private getUndiscriminatedUnionFieldNameForPrimitive;
|
|
56
|
+
private convertUnknown;
|
|
57
|
+
private convertPrimitive;
|
|
58
|
+
private getValueAsNumber;
|
|
59
|
+
private getValueAsBoolean;
|
|
60
|
+
private getValueAsString;
|
|
61
|
+
private newTypeMismatchError;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface FilePropertyInfo {
|
|
65
|
+
fileFields: go.StructField[];
|
|
66
|
+
bodyPropertyFields: go.StructField[];
|
|
67
|
+
}
|
|
68
|
+
declare class FilePropertyMapper {
|
|
69
|
+
private context;
|
|
70
|
+
constructor({ context }: {
|
|
71
|
+
context: DynamicSnippetsGeneratorContext;
|
|
72
|
+
});
|
|
73
|
+
getFilePropertyInfo({ body, value }: {
|
|
74
|
+
body: dynamic.FileUploadRequestBody;
|
|
75
|
+
value: unknown;
|
|
76
|
+
}): FilePropertyInfo;
|
|
77
|
+
private getSingleFileProperty;
|
|
78
|
+
private getArrayFileProperty;
|
|
79
|
+
private getBodyProperty;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext<dynamic.DynamicIntermediateRepresentation> {
|
|
83
|
+
customConfig: BaseGoCustomConfigSchema | undefined;
|
|
84
|
+
errors: ErrorReporter;
|
|
85
|
+
dynamicTypeMapper: DynamicTypeMapper;
|
|
86
|
+
dynamicTypeInstantiationMapper: DynamicTypeInstantiationMapper;
|
|
87
|
+
filePropertyMapper: FilePropertyMapper;
|
|
88
|
+
rootImportPath: string;
|
|
89
|
+
private httpEndpointReferenceParser;
|
|
90
|
+
constructor({ ir, config }: {
|
|
91
|
+
ir: dynamic.DynamicIntermediateRepresentation;
|
|
92
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
93
|
+
});
|
|
94
|
+
clone(): DynamicSnippetsGeneratorContext;
|
|
95
|
+
associateQueryParametersByWireValue({ parameters, values }: {
|
|
96
|
+
parameters: dynamic.NamedParameter[];
|
|
97
|
+
values: dynamic.Values;
|
|
98
|
+
}): TypeInstance[];
|
|
99
|
+
associateByWireValue({ parameters, values, ignoreMissingParameters }: {
|
|
100
|
+
parameters: dynamic.NamedParameter[];
|
|
101
|
+
values: dynamic.Values;
|
|
102
|
+
ignoreMissingParameters?: boolean;
|
|
103
|
+
}): TypeInstance[];
|
|
104
|
+
isFileUploadRequestBody(body: dynamic.InlinedRequestBody): body is dynamic.InlinedRequestBody.FileUpload;
|
|
105
|
+
needsRequestParameter({ request }: {
|
|
106
|
+
request: dynamic.InlinedRequest;
|
|
107
|
+
}): boolean;
|
|
108
|
+
includePathParametersInWrappedRequest({ request }: {
|
|
109
|
+
request: dynamic.InlinedRequest;
|
|
110
|
+
}): boolean;
|
|
111
|
+
private includeRequestBodyInWrappedRequest;
|
|
112
|
+
private includeFileUploadBodyInWrappedRequest;
|
|
113
|
+
private fileUploadHasBodyProperties;
|
|
114
|
+
private fileUploadHasFileProperties;
|
|
115
|
+
getRecord(value: unknown): Record<string, unknown> | undefined;
|
|
116
|
+
resolveNamedType({ typeId }: {
|
|
117
|
+
typeId: TypeId;
|
|
118
|
+
}): dynamic.NamedType | undefined;
|
|
119
|
+
resolveDiscriminatedUnionTypeInstance({ discriminatedUnion, value }: {
|
|
120
|
+
discriminatedUnion: dynamic.DiscriminatedUnionType;
|
|
121
|
+
value: unknown;
|
|
122
|
+
}): DiscriminatedUnionTypeInstance | undefined;
|
|
123
|
+
getMethodName(name: Name): string;
|
|
124
|
+
getTypeName(name: Name): string;
|
|
125
|
+
getImportPath(fernFilepath: FernFilepath): string;
|
|
126
|
+
getContextTypeReference(): go.TypeReference;
|
|
127
|
+
getContextTodoFunctionInvocation(): go.FuncInvocation;
|
|
128
|
+
getIoReaderTypeReference(): go.TypeReference;
|
|
129
|
+
getNewStringsReaderFunctionInvocation(s: string): go.FuncInvocation;
|
|
130
|
+
getClientConstructorName(): string;
|
|
131
|
+
getClientImportPath(): string;
|
|
132
|
+
getOptionImportPath(): string;
|
|
133
|
+
resolveEndpointOrThrow(rawEndpoint: string): dynamic.Endpoint[];
|
|
134
|
+
resolveEndpointLocationOrThrow(location: dynamic.EndpointLocation): dynamic.Endpoint[];
|
|
135
|
+
getGoTypeReferenceFromDeclaration({ declaration }: {
|
|
136
|
+
declaration: dynamic.Declaration;
|
|
137
|
+
}): go.TypeReference;
|
|
138
|
+
newParameterNotRecognizedError(parameterName: string): Error;
|
|
139
|
+
private isListTypeReference;
|
|
140
|
+
private parsedEndpointMatches;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F, DynamicTypeMapper as a, DynamicTypeInstantiationMapper as b, FilePropertyMapper as c };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AbstractFormatter } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-DKWsHJSo.js';
|
|
3
|
+
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
|
+
import '@fern-api/go-ast';
|
|
5
|
+
import './TypeInstance.js';
|
|
6
|
+
import './DiscriminatedUnionTypeInstance.js';
|
|
7
|
+
import './context/ErrorReporter.js';
|
|
8
|
+
|
|
9
|
+
declare class EndpointSnippetGenerator {
|
|
10
|
+
private context;
|
|
11
|
+
private formatter;
|
|
12
|
+
constructor({ context, formatter }: {
|
|
13
|
+
context: DynamicSnippetsGeneratorContext;
|
|
14
|
+
formatter?: AbstractFormatter;
|
|
15
|
+
});
|
|
16
|
+
generateSnippet({ endpoint, request }: {
|
|
17
|
+
endpoint: dynamic.Endpoint;
|
|
18
|
+
request: dynamic.EndpointSnippetRequest;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
generateSnippetSync({ endpoint, request }: {
|
|
21
|
+
endpoint: dynamic.Endpoint;
|
|
22
|
+
request: dynamic.EndpointSnippetRequest;
|
|
23
|
+
}): string;
|
|
24
|
+
private buildCodeBlock;
|
|
25
|
+
private constructClient;
|
|
26
|
+
private callMethod;
|
|
27
|
+
private getConstructorArgs;
|
|
28
|
+
private getConstructorAuthArg;
|
|
29
|
+
private getConstructorBasicAuthArg;
|
|
30
|
+
private getConstructorBearerAuthArg;
|
|
31
|
+
private getConstructorHeaderAuthArg;
|
|
32
|
+
private getConstructorHeaderArgs;
|
|
33
|
+
private getConstructorHeaderArg;
|
|
34
|
+
private getMethodArgs;
|
|
35
|
+
private getMethodArgsForBodyRequest;
|
|
36
|
+
private getBodyRequestArg;
|
|
37
|
+
private getBytesBodyRequestArg;
|
|
38
|
+
private getMethodArgsForInlinedRequest;
|
|
39
|
+
private getFilePropertyInfo;
|
|
40
|
+
private getInlinedRequestArg;
|
|
41
|
+
private getInlinedRequestBodyStructFields;
|
|
42
|
+
private getFileUploadRequestBodyStructFields;
|
|
43
|
+
private getReferencedRequestBodyPropertyStructField;
|
|
44
|
+
private getReferencedRequestBodyPropertyTypeInstantiation;
|
|
45
|
+
private getInlinedRequestBodyPropertyStructFields;
|
|
46
|
+
private getPathParameters;
|
|
47
|
+
private getMethod;
|
|
48
|
+
private getRootClientFuncInvocation;
|
|
49
|
+
private newAuthMismatchError;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { EndpointSnippetGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-KJOW5AZT.js";import"./chunk-ZYGZ4VN4.js";import"./chunk-VAYOWHUI.js";import"./chunk-5XUC5IOB.js";import"./chunk-6JCPJA27.js";export{a as EndpointSnippetGenerator};
|
package/esm/Result.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-DKWsHJSo.js';
|
|
2
|
+
import { ErrorReporter } from './context/ErrorReporter.js';
|
|
3
|
+
import { dynamic } from '@fern-fern/ir-sdk/api';
|
|
4
|
+
import '@fern-api/browser-compatible-base-generator';
|
|
5
|
+
import '@fern-api/go-ast';
|
|
6
|
+
import './TypeInstance.js';
|
|
7
|
+
import './DiscriminatedUnionTypeInstance.js';
|
|
8
|
+
|
|
9
|
+
declare class Result {
|
|
10
|
+
reporter: ErrorReporter | undefined;
|
|
11
|
+
snippet: string | undefined;
|
|
12
|
+
err: Error | undefined;
|
|
13
|
+
constructor();
|
|
14
|
+
update({ context, snippet }: {
|
|
15
|
+
context: DynamicSnippetsGeneratorContext;
|
|
16
|
+
snippet: string;
|
|
17
|
+
}): void;
|
|
18
|
+
getResponseOrThrow({ endpoint }: {
|
|
19
|
+
endpoint: dynamic.EndpointLocation;
|
|
20
|
+
}): dynamic.EndpointSnippetResponse;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { Result };
|
package/esm/Result.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-COBOWL3P.js";import"./chunk-6JCPJA27.js";export{a as Result};
|
package/esm/Scope.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const Scope: {
|
|
2
|
+
readonly PathParameters: "pathParameters";
|
|
3
|
+
readonly QueryParameters: "queryParameters";
|
|
4
|
+
readonly Headers: "headers";
|
|
5
|
+
readonly RequestBody: "requestBody";
|
|
6
|
+
};
|
|
7
|
+
declare type Scope = typeof Scope[keyof typeof Scope];
|
|
8
|
+
|
|
9
|
+
export { Scope };
|
package/esm/Scope.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-ZYGZ4VN4.js";import"./chunk-6JCPJA27.js";export{a as Scope};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NameAndWireValue, dynamic } from '@fern-fern/ir-sdk/api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A type instance that can be converted into a language-specific AST node.
|
|
5
|
+
*
|
|
6
|
+
* The 'type' and 'value' are used to convert the AST node itself, and the name
|
|
7
|
+
* is (optionally) used within the dynamic snippet, e.g. for named fields.
|
|
8
|
+
*/
|
|
9
|
+
interface TypeInstance {
|
|
10
|
+
name: NameAndWireValue;
|
|
11
|
+
typeReference: dynamic.TypeReference;
|
|
12
|
+
value: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type { TypeInstance };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-KJOW5AZT.js";import{a}from"./chunk-COBOWL3P.js";import{a as m,b as d}from"./chunk-UVYC4FWB.js";import{i as c}from"./chunk-6JCPJA27.js";var f=class extends m{constructor({ir:t,config:r,formatter:n}){super(new d({ir:t,config:r}));c(this,"formatter");this.formatter=n}async generate(t){let r=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let n=new a;for(let i of r){let o=this.context.clone(),p=new s({context:o,formatter:this.formatter});try{let e=await p.generateSnippet({endpoint:i,request:t});if(o.errors.empty())return{snippet:e,errors:void 0};n.update({context:o,snippet:e})}catch(e){n.err==null&&(n.err=e)}}return n.getResponseOrThrow({endpoint:t.endpoint})}generateSync(t){let r=this.context.resolveEndpointLocationOrThrow(t.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${t.endpoint.method} ${t.endpoint.path}"`);let n=new a;for(let i of r){let o=this.context.clone(),p=new s({context:o,formatter:this.formatter});try{let e=p.generateSnippetSync({endpoint:i,request:t});if(o.errors.empty())return{snippet:e,errors:void 0};n.update({context:o,snippet:e})}catch(e){n.err==null&&(n.err=e)}}return n.getResponseOrThrow({endpoint:t.endpoint})}};export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o,b as s,i}from"./chunk-6JCPJA27.js";var n={Critical:"CRITICAL",Warning:"WARNING"},p=class a{constructor(){i(this,"errors");i(this,"path");this.errors=[],this.path=[]}add(r){this.errors.push(s(o({},r),{path:[...this.path]}))}scope(r){this.path.push(r)}unscope(){this.path.pop()}getBySeverity(r){return this.errors.filter(e=>e.severity===r)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let r=new a;return r.errors=[...this.errors],r.path=[...this.path],r}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(r=>({severity:r.severity,path:r.path!=null?this.pathToStringArray(r.path):void 0,message:r.message}))}pathToStringArray(r){let e=[];for(let t of r){if(typeof t=="string"){e.push(t);continue}e[e.length-1]+=`[${t.index}]`}return e}};export{n as a,p as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.create;var g=Object.defineProperty,l=Object.defineProperties,m=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,p=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var h=(a,b,c)=>b in a?g(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,r=(a,b)=>{for(var c in b||(b={}))i.call(b,c)&&h(a,c,b[c]);if(f)for(var c of f(b))j.call(b,c)&&h(a,c,b[c]);return a},s=(a,b)=>l(a,n(b));var t=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var u=a=>typeof a=="symbol"?a:a+"",v=(a,b)=>{var c={};for(var d in a)i.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(a!=null&&f)for(var d of f(a))b.indexOf(d)<0&&j.call(a,d)&&(c[d]=a[d]);return c};var w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),x=(a,b)=>{for(var c in b)g(a,c,{get:b[c],enumerable:!0})},q=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of o(b))!i.call(a,e)&&e!==c&&g(a,e,{get:()=>b[e],enumerable:!(d=m(b,e))||d.enumerable});return a};var y=(a,b,c)=>(c=a!=null?k(p(a)):{},q(b||!a||!a.__esModule?g(c,"default",{value:a,enumerable:!0}):c,a));var z=(a,b,c)=>h(a,typeof b!="symbol"?b+"":b,c);export{r as a,s as b,t as c,u as d,v as e,w as f,x as g,y as h,z as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as y,c as r}from"./chunk-VAYOWHUI.js";import{a as s}from"./chunk-5XUC5IOB.js";import{i as p}from"./chunk-6JCPJA27.js";var l=class{constructor({context:t}){p(this,"context");this.context=t}getFilePropertyInfo({body:t,value:i}){var n;let e={fileFields:[],bodyPropertyFields:[]},a=(n=this.context.getRecord(i))!=null?n:{};for(let o of t.properties)switch(o.type){case"file":e.fileFields.push({name:this.context.getTypeName(o.name),value:this.getSingleFileProperty({property:o,record:a})});break;case"fileArray":e.fileFields.push({name:this.context.getTypeName(o.name),value:this.getArrayFileProperty({property:o,record:a})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getTypeName(o.name.name),value:this.getBodyProperty({property:o,record:a})});break;default:y(o)}return e}getSingleFileProperty({property:t,record:i}){let e=i[t.wireValue];return e==null?r.TypeInstantiation.nop():typeof e!="string"?(this.context.errors.add({severity:s.Critical,message:`Expected file value to be a string, got ${typeof e}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(e))}getArrayFileProperty({property:t,record:i}){let e=i[t.wireValue];if(e==null)return r.TypeInstantiation.nop();if(!Array.isArray(e))return this.context.errors.add({severity:s.Critical,message:`Expected file array value to be an array of strings, got ${typeof e}`}),r.TypeInstantiation.nop();let a=[];for(let n of e)typeof n!="string"&&this.context.errors.add({severity:s.Critical,message:`Expected file array value to be an array of strings, got ${typeof n}`}),a.push(n);return r.TypeInstantiation.slice({valueType:r.Type.reference(this.context.getIoReaderTypeReference()),values:a.map(n=>r.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(n)))})}getBodyProperty({property:t,record:i}){let e=i[t.name.wireValue];return e==null?r.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e})}};export{l as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as t}from"./chunk-6JCPJA27.js";var i=class{constructor(){t(this,"reporter");t(this,"snippet");t(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:r,snippet:e}){(this.reporter==null||this.reporter.size()>r.errors.size())&&(this.reporter=r.errors.clone(),this.snippet=e)}getResponseOrThrow({endpoint:r}){var e;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(e=this.err)!=null?e:new Error(`Failed to generate snippet for endpoint "${r.method} ${r.path}"`)}};export{i as a};
|