Skip to content

Commit ec77659

Browse files
authored
Merge pull request #32 from cesarParra/async-endpoint
Async endpoint
2 parents d29f355 + 8fc2595 commit ec77659

File tree

10 files changed

+3016
-2361
lines changed

10 files changed

+3016
-2361
lines changed

js/apex-reflection-node/__tests__/end-to-end.test.ts

Lines changed: 432 additions & 272 deletions
Large diffs are not rendered by default.

js/apex-reflection-node/index.ts

Lines changed: 117 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,198 @@
1-
require('./out.js');
1+
require("./out.js");
22

33
export function reflect(declarationBody: string): ReflectionResult {
4-
// @ts-expect-error "reflect" is added to self by the "out" module
5-
return JSON.parse(self.reflect(declarationBody)) as ReflectionResult;
4+
// @ts-expect-error "reflect" is added to self by the "out" module
5+
return JSON.parse(self.reflect(declarationBody)) as ReflectionResult;
6+
}
7+
8+
export async function reflectAsync(declarationBody: string): Promise<ReflectionResult> {
9+
// @ts-expect-error "reflectAsync" is added to self by the "out" module
10+
const result = await self.reflectAsync(declarationBody) as string;
11+
return JSON.parse(result) as ReflectionResult;
612
}
713

814
export interface ParamAnnotation {
9-
bodyLines: string[];
10-
paramName: string;
15+
bodyLines: string[];
16+
paramName: string;
1117
}
1218

1319
export interface ReturnAnnotation {
14-
bodyLines: string[];
20+
bodyLines: string[];
1521
}
1622

1723
export interface ExampleAnnotation {
18-
bodyLines: string[];
24+
bodyLines: string[];
1925
}
2026

2127
export interface ThrowsAnnotation {
22-
bodyLines: string[];
23-
exceptionName: string;
28+
bodyLines: string[];
29+
exceptionName: string;
2430
}
2531

2632
export interface DocCommentAnnotation {
27-
name: string;
28-
bodyLines: string[];
29-
body: string;
33+
name: string;
34+
bodyLines: string[];
35+
body: string;
3036
}
3137

3238
export interface DocComment {
33-
rawDeclaration?: string;
34-
paramAnnotations: ParamAnnotation[];
35-
returnAnnotation: ReturnAnnotation | null;
36-
exampleAnnotation: ExampleAnnotation | null;
37-
throwsAnnotations: ThrowsAnnotation[];
38-
annotations: DocCommentAnnotation[];
39-
descriptionLines: string[];
40-
description: string;
41-
error?: string;
39+
rawDeclaration?: string;
40+
paramAnnotations: ParamAnnotation[];
41+
returnAnnotation: ReturnAnnotation | null;
42+
exampleAnnotation: ExampleAnnotation | null;
43+
throwsAnnotations: ThrowsAnnotation[];
44+
annotations: DocCommentAnnotation[];
45+
descriptionLines: string[];
46+
description: string;
47+
error?: string;
4248
}
4349

4450
export interface AnnotationElementValue {
45-
key: string;
46-
value: string;
51+
key: string;
52+
value: string;
4753
}
4854

4955
export interface Annotation {
50-
rawDeclaration: string;
51-
name: string;
52-
type: string;
53-
elementValues?: AnnotationElementValue[];
56+
rawDeclaration: string;
57+
name: string;
58+
type: string;
59+
elementValues?: AnnotationElementValue[];
5460
}
5561

5662
export type ReferencedType = ReferenceObjectType | ListObjectType | SetObjectType | MapObjectType | GenericObjectType;
5763

5864
export interface ReferenceObjectType {
59-
type: string;
60-
rawDeclaration: string;
65+
type: string;
66+
rawDeclaration: string;
6167
}
6268

6369
export interface ListObjectType extends ReferenceObjectType {
64-
ofType: ReferenceObjectType;
70+
ofType: ReferenceObjectType;
6571
}
6672

6773
export interface SetObjectType extends ReferenceObjectType {
68-
ofType: ReferenceObjectType;
74+
ofType: ReferenceObjectType;
6975
}
7076

7177
export interface MapObjectType extends ReferenceObjectType {
72-
keyType: ReferenceObjectType;
73-
valueType: ReferenceObjectType;
78+
keyType: ReferenceObjectType;
79+
valueType: ReferenceObjectType;
7480
}
7581

7682
export interface GenericObjectType extends ReferenceObjectType {
77-
ofType: ReferenceObjectType;
83+
ofType: ReferenceObjectType;
7884
}
7985

8086
export interface EnumValue {
81-
name: string;
82-
docComment?: DocComment;
87+
name: string;
88+
docComment?: DocComment;
8389
}
8490

8591
export interface ParameterMirror {
86-
memberModifiers: string[];
87-
name: string;
88-
typeReference: ReferencedType;
89-
docComment?: DocComment;
92+
memberModifiers: string[];
93+
name: string;
94+
typeReference: ReferencedType;
95+
docComment?: DocComment;
9096
}
9197

9298
export interface MethodMirror {
93-
access_modifier: string;
94-
annotations: Annotation[];
95-
name: string;
96-
memberModifiers: string[];
97-
typeReference: ReferencedType;
98-
parameters: ParameterMirror[];
99-
docComment?: DocComment;
100-
group?: string;
101-
groupDescription?: string;
99+
access_modifier: string;
100+
annotations: Annotation[];
101+
name: string;
102+
memberModifiers: string[];
103+
typeReference: ReferencedType;
104+
parameters: ParameterMirror[];
105+
docComment?: DocComment;
106+
group?: string;
107+
groupDescription?: string;
102108
}
103109

104110
export interface PropertyMirror {
105-
access_modifier: string;
106-
annotations: Annotation[];
107-
name: string;
108-
memberModifiers: string[];
109-
typeReference: ReferencedType;
110-
docComment?: DocComment;
111-
group?: string;
112-
groupDescription?: string;
111+
access_modifier: string;
112+
annotations: Annotation[];
113+
name: string;
114+
memberModifiers: string[];
115+
typeReference: ReferencedType;
116+
docComment?: DocComment;
117+
group?: string;
118+
groupDescription?: string;
113119
}
114120

115121
export interface FieldMirror {
116-
access_modifier: string;
117-
annotations: Annotation[];
118-
name: string;
119-
memberModifiers: string[];
120-
typeReference: ReferencedType;
121-
docComment?: DocComment;
122-
group?: string;
123-
groupDescription?: string;
122+
access_modifier: string;
123+
annotations: Annotation[];
124+
name: string;
125+
memberModifiers: string[];
126+
typeReference: ReferencedType;
127+
docComment?: DocComment;
128+
group?: string;
129+
groupDescription?: string;
124130
}
125131

126132
export interface ConstructorMirror {
127-
access_modifier: string;
128-
annotations: Annotation[];
129-
parameters: ParameterMirror[];
130-
docComment?: DocComment;
131-
group?: string;
132-
groupDescription?: string;
133+
access_modifier: string;
134+
annotations: Annotation[];
135+
parameters: ParameterMirror[];
136+
docComment?: DocComment;
137+
group?: string;
138+
groupDescription?: string;
133139
}
134140

135141
export interface ReflectionResult {
136-
typeMirror?: Type;
137-
error?: ParsingError;
142+
typeMirror?: Type;
143+
error?: ParsingError;
138144
}
139145

140146
export interface ParsingError {
141-
message: string;
147+
message: string;
142148
}
143149

144150
// Types
145151

146-
type TypeName = 'class' | 'interface' | 'enum';
152+
type TypeName = "class" | "interface" | "enum";
147153
export type Type = InterfaceMirror | ClassMirror | EnumMirror;
148154

149155
export interface EnumMirror {
150-
annotations: Annotation[];
151-
name: string;
152-
type_name: TypeName;
153-
access_modifier: string;
154-
docComment?: DocComment;
155-
group?: string;
156-
groupDescription?: string;
157-
values: EnumValue[];
156+
annotations: Annotation[];
157+
name: string;
158+
type_name: TypeName;
159+
access_modifier: string;
160+
docComment?: DocComment;
161+
group?: string;
162+
groupDescription?: string;
163+
values: EnumValue[];
158164
}
159165

160166
export interface InterfaceMirror {
161-
annotations: Annotation[];
162-
name: string;
163-
type_name: TypeName;
164-
methods: MethodMirror[];
165-
extended_interfaces: string[];
166-
access_modifier: string;
167-
docComment?: DocComment;
168-
sharingModifier?: string;
169-
group?: string;
170-
groupDescription?: string;
167+
annotations: Annotation[];
168+
name: string;
169+
type_name: TypeName;
170+
methods: MethodMirror[];
171+
extended_interfaces: string[];
172+
access_modifier: string;
173+
docComment?: DocComment;
174+
sharingModifier?: string;
175+
group?: string;
176+
groupDescription?: string;
171177
}
172178

173179
export interface ClassMirror {
174-
annotations: Annotation[];
175-
name: string;
176-
type_name: TypeName;
177-
methods: MethodMirror[];
178-
sharingModifier?: string;
179-
classModifier?: string;
180-
extended_class?: string;
181-
implemented_interfaces: string[];
182-
properties: PropertyMirror[];
183-
fields: FieldMirror[];
184-
constructors: ConstructorMirror[];
185-
enums: EnumMirror[];
186-
interfaces: InterfaceMirror[];
187-
classes: ClassMirror[];
188-
access_modifier: string;
189-
docComment?: DocComment;
190-
group?: string;
191-
groupDescription?: string;
180+
annotations: Annotation[];
181+
name: string;
182+
type_name: TypeName;
183+
methods: MethodMirror[];
184+
sharingModifier?: string;
185+
classModifier?: string;
186+
extended_class?: string;
187+
implemented_interfaces: string[];
188+
properties: PropertyMirror[];
189+
fields: FieldMirror[];
190+
constructors: ConstructorMirror[];
191+
enums: EnumMirror[];
192+
interfaces: InterfaceMirror[];
193+
classes: ClassMirror[];
194+
access_modifier: string;
195+
docComment?: DocComment;
196+
group?: string;
197+
groupDescription?: string;
192198
}

0 commit comments

Comments
 (0)