@flock/wirespec 0.16.3 → 0.16.5
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/fetch.ts +0 -0
- package/kotlin-kotlin-stdlib.mjs +37 -37
- package/kotlin-kotlin-stdlib.mjs.map +1 -1
- package/kotlinx-io-kotlinx-io-core.mjs +2 -2
- package/package.json +11 -1
- package/wirespec-fetch.d.ts +6 -0
- package/wirespec-fetch.mjs +33 -0
- package/wirespec-src-compiler-core.mjs +1052 -4723
- package/wirespec-src-compiler-core.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-java.mjs +1003 -0
- package/wirespec-src-compiler-emitters-java.mjs.map +1 -0
- package/wirespec-src-compiler-emitters-kotlin.mjs +844 -0
- package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -0
- package/wirespec-src-compiler-emitters-python.mjs +1004 -0
- package/wirespec-src-compiler-emitters-python.mjs.map +1 -0
- package/wirespec-src-compiler-emitters-typescript.mjs +812 -0
- package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -0
- package/wirespec-src-compiler-emitters-wirespec.mjs +390 -0
- package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -0
- package/wirespec-src-compiler-lib.mjs +67 -67
- package/wirespec-src-compiler-lib.mjs.map +1 -1
- package/wirespec-src-converter-avro.mjs +34 -34
- package/wirespec-src-converter-avro.mjs.map +1 -1
- package/wirespec-src-converter-openapi.mjs +201 -201
- package/wirespec-src-converter-openapi.mjs.map +1 -1
- package/wirespec-src-plugin-arguments.mjs +60 -22
- package/wirespec-src-plugin-arguments.mjs.map +1 -1
- package/wirespec-src-plugin-cli.mjs +25 -59
- package/wirespec-src-plugin-cli.mjs.map +1 -1
- package/wirespec-src-plugin-npm.d.ts +6 -2
- package/wirespec-src-plugin-npm.mjs +40 -22
- package/wirespec-src-plugin-npm.mjs.map +1 -1
- package/wirespec-src-tools-generator.mjs +23 -23
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrayList_init_$Create$2rimpp4x9tjd3 as ArrayList_init_$Create$,
|
|
3
|
+
Unit_instanceat14thlj150z as Unit_instance,
|
|
4
|
+
VOID7hggqo3abtya as VOID,
|
|
5
|
+
joinToString1cxrrlmo0chqs as joinToString,
|
|
6
|
+
trimMarginhyd3fsmh8iev as trimMargin,
|
|
7
|
+
noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
|
|
8
|
+
first58ocm7j58k3q as first,
|
|
9
|
+
listOfNotNull2woi2boe01ub4 as listOfNotNull,
|
|
10
|
+
isBlank1dvkhjjvox3p0 as isBlank,
|
|
11
|
+
split2bvyvnrlcifjv as split,
|
|
12
|
+
collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
|
|
13
|
+
ArrayList_init_$Create$3m1kyiqequwm5 as ArrayList_init_$Create$_0,
|
|
14
|
+
checkIndexOverflow3frtmheghr0th as checkIndexOverflow,
|
|
15
|
+
StringBuilder_init_$Create$zzhi687lupah as StringBuilder_init_$Create$,
|
|
16
|
+
charSequenceLength3278n89t01tmv as charSequenceLength,
|
|
17
|
+
charSequenceGet1vxk1y5n17t1z as charSequenceGet,
|
|
18
|
+
isLetterOrDigit2kuxd9e198haf as isLetterOrDigit,
|
|
19
|
+
_Char___init__impl__6a9atx367vrx0avsvbg as _Char___init__impl__6a9atx,
|
|
20
|
+
firstOrNulltrxqttxfxqju as firstOrNull,
|
|
21
|
+
isDigit3mimrri4wkzop as isDigit,
|
|
22
|
+
Char19o2r8palgjof as Char,
|
|
23
|
+
setOf45ia9pnfhe90 as setOf,
|
|
24
|
+
protoOf180f3jzyo7rfj as protoOf,
|
|
25
|
+
initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion,
|
|
26
|
+
equals2au1ep9vhcato as equals,
|
|
27
|
+
FunctionAdapter3lcrrz3moet5b as FunctionAdapter,
|
|
28
|
+
isInterface3d6p8outrmvmk as isInterface,
|
|
29
|
+
Comparator2b3maoeh98xtg as Comparator,
|
|
30
|
+
hashCodeq5arwsb9dgti as hashCode,
|
|
31
|
+
initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
|
|
32
|
+
compareValues1n2ayl87ihzfk as compareValues,
|
|
33
|
+
sortedWith2csnbbb21k0lg as sortedWith,
|
|
34
|
+
ensureNotNull1e947j3ixpazm as ensureNotNull,
|
|
35
|
+
THROW_CCE2g6jy02ryeudk as THROW_CCE,
|
|
36
|
+
isCharSequence1ju9jr1w86plq as isCharSequence,
|
|
37
|
+
trimStart5ewg8zf6cs5u as trimStart,
|
|
38
|
+
toString1pkumu07cwy4m as toString,
|
|
39
|
+
initMetadataForObject1cxne3s9w65el as initMetadataForObject,
|
|
40
|
+
} from './kotlin-kotlin-stdlib.mjs';
|
|
41
|
+
import {
|
|
42
|
+
ParamType_PATH_getInstance30h8xah12rwcj as ParamType_PATH_getInstance,
|
|
43
|
+
ParamType_QUERY_getInstance2okqpz15zml34 as ParamType_QUERY_getInstance,
|
|
44
|
+
ParamType_HEADER_getInstance2vvrdca9hqed5 as ParamType_HEADER_getInstance,
|
|
45
|
+
Primitivexjb7c0cm123a as Primitive,
|
|
46
|
+
Custom37hvrfgd6b0uj as Custom,
|
|
47
|
+
Any268baxyo9do19 as Any,
|
|
48
|
+
Unit3rie819ih39bz as Unit,
|
|
49
|
+
Iterablerto606wd057m as Iterable,
|
|
50
|
+
Dict3l6tdihpke4rr as Dict,
|
|
51
|
+
Spacer_instancel9yep7i0q3er as Spacer_instance,
|
|
52
|
+
orNull2zq556ke3x99j as orNull,
|
|
53
|
+
Companion_instanceb7vsmblp2jf7 as Companion_instance,
|
|
54
|
+
Param33sus5zaarsk0 as Param,
|
|
55
|
+
Literal32wmkquj6qapn as Literal,
|
|
56
|
+
Emitterpslsvv25okcl as Emitter,
|
|
57
|
+
Companion_instance2ag0h5twtdral as Companion_instance_0,
|
|
58
|
+
Companion_instance26a9xkw31611z as Companion_instance_1,
|
|
59
|
+
FileExtension_Python_getInstancenly5nzbfq5gh as FileExtension_Python_getInstance,
|
|
60
|
+
Channel2rnyzzgwpojjq as Channel,
|
|
61
|
+
Endpoint1dn4dd2eg1gxz as Endpoint,
|
|
62
|
+
Union171cmlm23mwcq as Union,
|
|
63
|
+
Type11a5scrd50tqk as Type,
|
|
64
|
+
Refined3fn8nn8ume24i as Refined,
|
|
65
|
+
Enum13738b9tl6w6v as Enum,
|
|
66
|
+
Emitted12h24rpo4uifw as Emitted,
|
|
67
|
+
Model25ic6t0badh93 as Model,
|
|
68
|
+
plus2csvv9vgnno78 as plus,
|
|
69
|
+
Bytes2moci2lqqzua3 as Bytes,
|
|
70
|
+
Boolean1v54w5v4qjba1 as Boolean_0,
|
|
71
|
+
Number3i05nlui0wcz8 as Number_0,
|
|
72
|
+
Integeryrcje1s9u7kr as Integer,
|
|
73
|
+
String23kqvhe3sk098 as String_0,
|
|
74
|
+
FieldIdentifier2fnn30qixmpf as FieldIdentifier,
|
|
75
|
+
DefinitionIdentifier21mzme854zakh as DefinitionIdentifier,
|
|
76
|
+
Bytes_instance1at7binw0nl40 as Bytes_instance,
|
|
77
|
+
Boolean_instance3qnzv8pgzox40 as Boolean_instance,
|
|
78
|
+
RegExp1kvu7kxwy7td5 as RegExp_0,
|
|
79
|
+
Bound1dotva4vah4jp as Bound,
|
|
80
|
+
_RegExp___get_value__impl__7o761828ey0cgsx2afa as _RegExp___get_value__impl__7o7618,
|
|
81
|
+
} from './wirespec-src-compiler-core.mjs';
|
|
82
|
+
import { toNonEmptyListOrNull2ovnnazjb3msz as toNonEmptyListOrNull } from './arrow-arrow-core.mjs';
|
|
83
|
+
//region block: imports
|
|
84
|
+
//endregion
|
|
85
|
+
//region block: pre-declaration
|
|
86
|
+
initMetadataForCompanion(Companion);
|
|
87
|
+
initMetadataForClass(sam$kotlin_Comparator$0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
|
|
88
|
+
initMetadataForClass(PythonEmitter, 'PythonEmitter', PythonEmitter, Emitter);
|
|
89
|
+
initMetadataForObject(PythonShared, 'PythonShared');
|
|
90
|
+
//endregion
|
|
91
|
+
function emitReferenceCustomImports(_this__u8e3s4, $this) {
|
|
92
|
+
return 'from ..model.' + _this__u8e3s4.x28_1 + ' import ' + _this__u8e3s4.x28_1;
|
|
93
|
+
}
|
|
94
|
+
function emit(_this__u8e3s4, $this) {
|
|
95
|
+
return $this.d25(_this__u8e3s4.e24_1) + ': ' + $this.n2a(_this__u8e3s4.f24_1);
|
|
96
|
+
}
|
|
97
|
+
function emit_0(_this__u8e3s4, $this) {
|
|
98
|
+
return $this.d25(_this__u8e3s4.w23_1) + ': ' + $this.n2a(_this__u8e3s4.x23_1);
|
|
99
|
+
}
|
|
100
|
+
function emitAssignSelf(_this__u8e3s4, $this) {
|
|
101
|
+
return $this.d25(_this__u8e3s4.w23_1) + ' = ' + $this.d25(_this__u8e3s4.w23_1);
|
|
102
|
+
}
|
|
103
|
+
function emitAssignSelf_0(_this__u8e3s4, $this, endpoint) {
|
|
104
|
+
var tmp = $this.d25(endpoint.s25_1);
|
|
105
|
+
// Inline function 'kotlin.collections.filter' call
|
|
106
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
107
|
+
var this_0 = $this.l26(_this__u8e3s4, endpoint);
|
|
108
|
+
var destination = ArrayList_init_$Create$();
|
|
109
|
+
var tmp0_iterator = this_0.g();
|
|
110
|
+
while (tmp0_iterator.h()) {
|
|
111
|
+
var element = tmp0_iterator.i();
|
|
112
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
113
|
+
if (element.v23_1.equals(ParamType_PATH_getInstance())) {
|
|
114
|
+
destination.e(element);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var tmp_0 = destination;
|
|
118
|
+
var tmp_1 = joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, PythonEmitter$emitAssignSelf$lambda($this));
|
|
119
|
+
var tmp_2 = $this.d25(endpoint.s25_1);
|
|
120
|
+
// Inline function 'kotlin.collections.filter' call
|
|
121
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
122
|
+
var this_1 = $this.l26(_this__u8e3s4, endpoint);
|
|
123
|
+
var destination_0 = ArrayList_init_$Create$();
|
|
124
|
+
var tmp0_iterator_0 = this_1.g();
|
|
125
|
+
while (tmp0_iterator_0.h()) {
|
|
126
|
+
var element_0 = tmp0_iterator_0.i();
|
|
127
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
128
|
+
if (element_0.v23_1.equals(ParamType_QUERY_getInstance())) {
|
|
129
|
+
destination_0.e(element_0);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var tmp_3 = destination_0;
|
|
133
|
+
var tmp_4 = $this.f26(joinToString(tmp_3, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitAssignSelf$lambda_0($this)), 1);
|
|
134
|
+
var tmp_5 = $this.d25(endpoint.s25_1);
|
|
135
|
+
// Inline function 'kotlin.collections.filter' call
|
|
136
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
137
|
+
var this_2 = $this.l26(_this__u8e3s4, endpoint);
|
|
138
|
+
var destination_1 = ArrayList_init_$Create$();
|
|
139
|
+
var tmp0_iterator_1 = this_2.g();
|
|
140
|
+
while (tmp0_iterator_1.h()) {
|
|
141
|
+
var element_1 = tmp0_iterator_1.i();
|
|
142
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
143
|
+
if (element_1.v23_1.equals(ParamType_HEADER_getInstance())) {
|
|
144
|
+
destination_1.e(element_1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
var tmp_6 = destination_1;
|
|
148
|
+
var tmp_7 = $this.f26(joinToString(tmp_6, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitAssignSelf$lambda_1($this)), 1);
|
|
149
|
+
var tmp_8;
|
|
150
|
+
if (_this__u8e3s4.m26_1 == null) {
|
|
151
|
+
tmp_8 = null;
|
|
152
|
+
} else {
|
|
153
|
+
// Inline function 'kotlin.let' call
|
|
154
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
155
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
156
|
+
tmp_8 = 'body';
|
|
157
|
+
}
|
|
158
|
+
var tmp1_elvis_lhs = tmp_8;
|
|
159
|
+
return trimMargin('\n |self._path = ' + tmp + '.Request.Path(' + tmp_1 + ')\n |self._queries =' + tmp_2 + '.Request.Queries(' + tmp_4 + ')\n |self._headers = ' + tmp_5 + '.Request.Headers(' + tmp_7 + ')\n |self._body = ' + (tmp1_elvis_lhs == null ? 'None' : tmp1_elvis_lhs) + '\n ');
|
|
160
|
+
}
|
|
161
|
+
function emitAssignSelf_1(_this__u8e3s4, $this, endpoint) {
|
|
162
|
+
var tmp = $this.d25(endpoint.s25_1);
|
|
163
|
+
// Inline function 'kotlin.collections.filter' call
|
|
164
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
165
|
+
var this_0 = $this.n26(_this__u8e3s4);
|
|
166
|
+
var destination = ArrayList_init_$Create$();
|
|
167
|
+
var tmp0_iterator = this_0.g();
|
|
168
|
+
while (tmp0_iterator.h()) {
|
|
169
|
+
var element = tmp0_iterator.i();
|
|
170
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
171
|
+
if (element.v23_1.equals(ParamType_HEADER_getInstance())) {
|
|
172
|
+
destination.e(element);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var tmp_0 = destination;
|
|
176
|
+
var tmp_1 = $this.f26(joinToString(tmp_0, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitAssignSelf$lambda_2($this)), 1);
|
|
177
|
+
var tmp_2;
|
|
178
|
+
if (_this__u8e3s4.q26_1 == null) {
|
|
179
|
+
tmp_2 = null;
|
|
180
|
+
} else {
|
|
181
|
+
// Inline function 'kotlin.let' call
|
|
182
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
183
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
184
|
+
tmp_2 = 'body';
|
|
185
|
+
}
|
|
186
|
+
var tmp1_elvis_lhs = tmp_2;
|
|
187
|
+
return trimMargin('\n |self._headers = ' + tmp + '.Response' + _this__u8e3s4.o26_1 + '.Headers(' + tmp_1 + ')\n |self._body = ' + (tmp1_elvis_lhs == null ? 'None' : tmp1_elvis_lhs) + '\n ');
|
|
188
|
+
}
|
|
189
|
+
function emitType(_this__u8e3s4, $this) {
|
|
190
|
+
var tmp;
|
|
191
|
+
if (_this__u8e3s4 instanceof Dict) {
|
|
192
|
+
tmp = 'Dict[str, ' + $this.n2a(_this__u8e3s4.b24_1) + ']';
|
|
193
|
+
} else {
|
|
194
|
+
if (_this__u8e3s4 instanceof Iterable) {
|
|
195
|
+
tmp = 'List[' + $this.n2a(_this__u8e3s4.y23_1) + ']';
|
|
196
|
+
} else {
|
|
197
|
+
if (_this__u8e3s4 instanceof Unit) {
|
|
198
|
+
tmp = 'None';
|
|
199
|
+
} else {
|
|
200
|
+
if (_this__u8e3s4 instanceof Any) {
|
|
201
|
+
tmp = 'Any';
|
|
202
|
+
} else {
|
|
203
|
+
if (_this__u8e3s4 instanceof Custom) {
|
|
204
|
+
tmp = _this__u8e3s4.x28_1;
|
|
205
|
+
} else {
|
|
206
|
+
if (_this__u8e3s4 instanceof Primitive) {
|
|
207
|
+
tmp = $this.c2c(_this__u8e3s4.b29_1);
|
|
208
|
+
} else {
|
|
209
|
+
noWhenBranchMatchedException();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return tmp;
|
|
217
|
+
}
|
|
218
|
+
function emitResponseUnion(_this__u8e3s4, $this) {
|
|
219
|
+
return trimMargin('\n |Response = ' + joinToString(_this__u8e3s4.y25_1, ' | ', VOID, VOID, VOID, VOID, PythonEmitter$emitResponseUnion$lambda) + '\n |\n ');
|
|
220
|
+
}
|
|
221
|
+
function emitHandleClass(_this__u8e3s4, $this) {
|
|
222
|
+
return trimMargin('\n |class Handler(Wirespec.Endpoint.Handler):\n |' + Spacer_instance.toString() + '@abstractmethod\n |' + Spacer_instance.toString() + 'def ' + _this__u8e3s4.s25_1.b1() + "(self, req: '" + $this.d25(_this__u8e3s4.s25_1) + ".Request') -> '" + $this.d25(_this__u8e3s4.s25_1) + ".Response': pass\n |\n ");
|
|
223
|
+
}
|
|
224
|
+
function emitConvertClass(_this__u8e3s4, $this) {
|
|
225
|
+
return trimMargin('\n |class Convert(Wirespec.Endpoint.Convert[Request, Response]):\n |' + $this.f26(emitToRawRequest(first(_this__u8e3s4.x25_1), $this, _this__u8e3s4), 1) + '\n |' + $this.f26(emitFromRawRequest(first(_this__u8e3s4.x25_1), $this, _this__u8e3s4), 1) + '\n |' + $this.f26(emitToRawResponse(_this__u8e3s4, $this), 1) + '\n |' + $this.f26(emitFromRawResponse(_this__u8e3s4, $this), 1) + '\n |\n ');
|
|
226
|
+
}
|
|
227
|
+
function emitToRawRequest(_this__u8e3s4, $this, endpoint) {
|
|
228
|
+
var tmp = $this.d25(endpoint.s25_1);
|
|
229
|
+
var tmp_0 = Spacer_instance.toString();
|
|
230
|
+
var tmp_1 = Spacer_instance.toString();
|
|
231
|
+
var tmp_2 = Spacer_instance.toString();
|
|
232
|
+
var tmp_3 = joinToString(endpoint.u25_1, VOID, VOID, VOID, VOID, VOID, PythonEmitter$emitToRawRequest$lambda($this));
|
|
233
|
+
var tmp_4 = Spacer_instance.toString();
|
|
234
|
+
var tmp_5 = Spacer_instance.toString();
|
|
235
|
+
var tmp_6 = Spacer_instance.toString();
|
|
236
|
+
var tmp_7 = Spacer_instance.toString();
|
|
237
|
+
var tmp_8;
|
|
238
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
239
|
+
if (!endpoint.v25_1.l()) {
|
|
240
|
+
tmp_8 = joinToString(endpoint.v25_1, ',\n', '{', '}', VOID, VOID, PythonEmitter$emitToRawRequest$lambda_0($this));
|
|
241
|
+
} else {
|
|
242
|
+
tmp_8 = '{}';
|
|
243
|
+
}
|
|
244
|
+
var tmp_9 = tmp_8;
|
|
245
|
+
var tmp_10 = Spacer_instance.toString();
|
|
246
|
+
var tmp_11 = Spacer_instance.toString();
|
|
247
|
+
var tmp_12;
|
|
248
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
249
|
+
if (!endpoint.w25_1.l()) {
|
|
250
|
+
tmp_12 = joinToString(endpoint.w25_1, ',\n', '{', '}', VOID, VOID, PythonEmitter$emitToRawRequest$lambda_1($this));
|
|
251
|
+
} else {
|
|
252
|
+
tmp_12 = '{}';
|
|
253
|
+
}
|
|
254
|
+
var tmp_13 = tmp_12;
|
|
255
|
+
var tmp_14 = Spacer_instance.toString();
|
|
256
|
+
var tmp_15 = Spacer_instance.toString();
|
|
257
|
+
var tmp0_safe_receiver = _this__u8e3s4.m26_1;
|
|
258
|
+
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.h24_1;
|
|
259
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : emitType(tmp1_safe_receiver, $this);
|
|
260
|
+
return trimMargin("\n |@staticmethod\n |def to_raw_request(serialization: Wirespec.Serializer, request: '" + tmp + ".Request') -> Wirespec.RawRequest:\n |" + tmp_0 + 'return Wirespec.RawRequest(\n |' + tmp_1 + tmp_2 + 'path = [' + tmp_3 + '],\n |' + tmp_4 + tmp_5 + 'method = request.method.value,\n |' + tmp_6 + tmp_7 + 'queries = ' + tmp_9 + ',\n |' + tmp_10 + tmp_11 + 'headers = ' + tmp_13 + ',\n |' + tmp_14 + tmp_15 + 'body = serialization.serialize(request.body, ' + (tmp2_elvis_lhs == null ? 'type(None)' : tmp2_elvis_lhs) + '),\n |' + Spacer_instance.toString() + ')\n |\n ');
|
|
261
|
+
}
|
|
262
|
+
function emitFromRawRequest(_this__u8e3s4, $this, endpoint) {
|
|
263
|
+
return trimMargin("\n |@staticmethod\n |def from_raw_request(serialization: Wirespec.Deserializer, request: Wirespec.RawRequest) -> '" + $this.d25(endpoint.s25_1) + ".Request':\n |" + Spacer_instance.toString() + 'return ' + $this.d25(endpoint.s25_1) + '.Request' + emitDeserializedParams(_this__u8e3s4, $this, endpoint) + '\n |\n ');
|
|
264
|
+
}
|
|
265
|
+
function emitDeserializedParams(_this__u8e3s4, $this, endpoint) {
|
|
266
|
+
// Inline function 'kotlin.let' call
|
|
267
|
+
var tmp = $this.k26(endpoint);
|
|
268
|
+
var tmp_0 = orNull(joinToString(tmp, VOID, VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda($this)));
|
|
269
|
+
var tmp_1 = orNull(joinToString(endpoint.v25_1, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda_0($this)));
|
|
270
|
+
var tmp_2 = orNull(joinToString(endpoint.w25_1, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda_1($this)));
|
|
271
|
+
var tmp0_safe_receiver = _this__u8e3s4.m26_1;
|
|
272
|
+
var tmp_3;
|
|
273
|
+
if (tmp0_safe_receiver == null) {
|
|
274
|
+
tmp_3 = null;
|
|
275
|
+
} else {
|
|
276
|
+
// Inline function 'kotlin.let' call
|
|
277
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
278
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitDeserializedParams.<anonymous>' call
|
|
279
|
+
tmp_3 = Spacer_instance.p23(3) + 'body = serialization.deserialize(request.body, ' + emitType(tmp0_safe_receiver.h24_1, $this) + '),';
|
|
280
|
+
}
|
|
281
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
282
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitDeserializedParams.<anonymous>' call
|
|
283
|
+
var it = joinToString(listOfNotNull([tmp_0, tmp_1, tmp_2, tmp_3]), ',\n');
|
|
284
|
+
return isBlank(it) ? '()' : '(\n' + it + '\n)';
|
|
285
|
+
}
|
|
286
|
+
function emitDeserialized(_this__u8e3s4, $this) {
|
|
287
|
+
return Spacer_instance.p23(3) + $this.d25(_this__u8e3s4.rd_1.e24_1) + ' = serialization.deserialize(request.path[' + _this__u8e3s4.qd_1 + '], ' + emitType(_this__u8e3s4.rd_1.f24_1, $this) + ')';
|
|
288
|
+
}
|
|
289
|
+
function emitDeserializedParams_0(_this__u8e3s4, $this, type, fields) {
|
|
290
|
+
return $this.d25(_this__u8e3s4.i24_1) + ' = serialization.deserialize_param(' + type + '.' + fields + '.get("' + _this__u8e3s4.i24_1.b1() + '".lower()), ' + emitType(_this__u8e3s4.j24_1, $this) + ')';
|
|
291
|
+
}
|
|
292
|
+
function emitToRawResponse(_this__u8e3s4, $this) {
|
|
293
|
+
var tmp = $this.d25(_this__u8e3s4.s25_1);
|
|
294
|
+
var tmp_0 = Spacer_instance.toString();
|
|
295
|
+
var tmp_1 = $this.s26(_this__u8e3s4.y25_1);
|
|
296
|
+
return trimMargin("\n |@staticmethod\n |def to_raw_response(serialization: Wirespec.Serializer, response: '" + tmp + ".Response') -> Wirespec.RawResponse:\n |" + tmp_0 + 'match response:\n |' + $this.f26(joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emitToRawResponse$lambda($this, _this__u8e3s4)), 2) + '\n |' + Spacer_instance.toString() + Spacer_instance.toString() + 'case _:\n |' + Spacer_instance.toString() + Spacer_instance.toString() + Spacer_instance.toString() + 'raise Exception("Cannot match response with status: " + str(response.status))\n ');
|
|
297
|
+
}
|
|
298
|
+
function emitFromRawResponse(_this__u8e3s4, $this) {
|
|
299
|
+
var tmp = $this.d25(_this__u8e3s4.s25_1);
|
|
300
|
+
var tmp_0 = Spacer_instance.toString();
|
|
301
|
+
// Inline function 'kotlin.collections.filter' call
|
|
302
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
303
|
+
var this_0 = $this.s26(_this__u8e3s4.y25_1);
|
|
304
|
+
var destination = ArrayList_init_$Create$();
|
|
305
|
+
var tmp0_iterator = this_0.g();
|
|
306
|
+
while (tmp0_iterator.h()) {
|
|
307
|
+
var element = tmp0_iterator.i();
|
|
308
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitFromRawResponse.<anonymous>' call
|
|
309
|
+
if (Companion_instance.p24(element.o26_1)) {
|
|
310
|
+
destination.e(element);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
var tmp_1 = destination;
|
|
314
|
+
return trimMargin("\n |@staticmethod\n |def from_raw_response(serialization: Wirespec.Deserializer, response: Wirespec.RawResponse) -> '" + tmp + ".Response':\n |" + tmp_0 + 'match response.status_code:\n |' + $this.f26(joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emitFromRawResponse$lambda($this, _this__u8e3s4)), 2) + '\n |' + Spacer_instance.p23(2) + 'case _:\n |' + Spacer_instance.p23(3) + 'raise Exception("Cannot match response with status: " + str(response.status_code))\n |\n ');
|
|
315
|
+
}
|
|
316
|
+
function emitDeserialized_0(_this__u8e3s4, $this, endpoint) {
|
|
317
|
+
var tmp = 'case ' + _this__u8e3s4.o26_1 + ':';
|
|
318
|
+
var tmp_0 = Spacer_instance.toString() + 'return ' + $this.d25(endpoint.s25_1) + '.Response' + _this__u8e3s4.o26_1 + '(';
|
|
319
|
+
var tmp_1 = Spacer_instance.p23(2);
|
|
320
|
+
var tmp0_safe_receiver = _this__u8e3s4.q26_1;
|
|
321
|
+
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.h24_1;
|
|
322
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : emitType(tmp1_safe_receiver, $this);
|
|
323
|
+
var tmp_2 = tmp_1 + 'body = serialization.deserialize(response.body, ' + (tmp2_elvis_lhs == null ? 'type(None)' : tmp2_elvis_lhs) + '),';
|
|
324
|
+
var tmp3_safe_receiver = orNull(joinToString(_this__u8e3s4.p26_1, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitDeserialized$lambda($this)));
|
|
325
|
+
return joinToString(listOfNotNull([tmp, tmp_0, tmp_2, tmp3_safe_receiver == null ? null : $this.f26(tmp3_safe_receiver, 2), Spacer_instance.toString() + ')']), '\n');
|
|
326
|
+
}
|
|
327
|
+
function emitSerialized(_this__u8e3s4, $this, endpoint) {
|
|
328
|
+
var tmp = $this.d25(endpoint.s25_1);
|
|
329
|
+
var tmp_0 = Spacer_instance.p23(1);
|
|
330
|
+
var tmp_1 = Spacer_instance.p23(2);
|
|
331
|
+
var tmp_2 = Spacer_instance.p23(2);
|
|
332
|
+
var tmp_3;
|
|
333
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
334
|
+
if (!_this__u8e3s4.p26_1.l()) {
|
|
335
|
+
tmp_3 = joinToString(_this__u8e3s4.p26_1, ', ', '{', '}', VOID, VOID, PythonEmitter$emitSerialized$lambda($this));
|
|
336
|
+
} else {
|
|
337
|
+
tmp_3 = '{}';
|
|
338
|
+
}
|
|
339
|
+
var tmp_4 = tmp_3;
|
|
340
|
+
var tmp_5 = Spacer_instance.p23(2);
|
|
341
|
+
var tmp0_safe_receiver = _this__u8e3s4.q26_1;
|
|
342
|
+
var tmp_6;
|
|
343
|
+
if (tmp0_safe_receiver == null) {
|
|
344
|
+
tmp_6 = null;
|
|
345
|
+
} else {
|
|
346
|
+
// Inline function 'kotlin.let' call
|
|
347
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
348
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitSerialized.<anonymous>' call
|
|
349
|
+
tmp_6 = 'serialization.serialize(response.body, ' + emitType(tmp0_safe_receiver.h24_1, $this) + ')';
|
|
350
|
+
}
|
|
351
|
+
var tmp1_elvis_lhs = tmp_6;
|
|
352
|
+
return trimMargin('\n |case ' + tmp + '.Response' + _this__u8e3s4.o26_1 + '():\n |' + tmp_0 + 'return Wirespec.RawResponse(\n |' + tmp_1 + 'status_code = response.status,\n |' + tmp_2 + 'headers = ' + tmp_4 + ',\n |' + tmp_5 + 'body = ' + (tmp1_elvis_lhs == null ? 'type(None)' : tmp1_elvis_lhs) + ',\n |' + Spacer_instance.p23(1) + ')\n ');
|
|
353
|
+
}
|
|
354
|
+
function emitSerializedParams(_this__u8e3s4, $this, type, fields) {
|
|
355
|
+
return '"' + _this__u8e3s4.i24_1.b1() + '": serialization.serialize_param(' + type + '.' + fields + '.' + $this.d25(_this__u8e3s4.i24_1) + ', ' + emitType(_this__u8e3s4.j24_1, $this) + ')';
|
|
356
|
+
}
|
|
357
|
+
function emitObject(_this__u8e3s4, $this, name, extends_0, spaces, block) {
|
|
358
|
+
var tmp;
|
|
359
|
+
if (_this__u8e3s4.l()) {
|
|
360
|
+
tmp = trimMargin('\n |' + Spacer_instance.p23(spaces) + '@dataclass\n |' + Spacer_instance.p23(spaces) + 'class ' + name + ' (' + extends_0 + '): pass\n ');
|
|
361
|
+
} else {
|
|
362
|
+
var tmp_0 = Spacer_instance.p23(spaces);
|
|
363
|
+
var tmp_1 = Spacer_instance.p23(spaces);
|
|
364
|
+
tmp = trimMargin('\n |' + tmp_0 + '@dataclass\n |' + tmp_1 + 'class ' + name + ' (' + extends_0 + '):\n |' + joinToString(_this__u8e3s4, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emitObject$lambda(spaces, block)) + '\n ');
|
|
365
|
+
}
|
|
366
|
+
return tmp;
|
|
367
|
+
}
|
|
368
|
+
function emitObject$default(_this__u8e3s4, $this, name, extends_0, spaces, block, $super) {
|
|
369
|
+
spaces = spaces === VOID ? 1 : spaces;
|
|
370
|
+
return emitObject(_this__u8e3s4, $this, name, extends_0, spaces, block);
|
|
371
|
+
}
|
|
372
|
+
function emit_1(_this__u8e3s4, $this) {
|
|
373
|
+
var tmp1_safe_receiver = _this__u8e3s4 == null ? null : _this__u8e3s4.h24_1;
|
|
374
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : $this.n2a(tmp1_safe_receiver);
|
|
375
|
+
return tmp2_elvis_lhs == null ? 'None' : tmp2_elvis_lhs;
|
|
376
|
+
}
|
|
377
|
+
function sanitizeSymbol(_this__u8e3s4, $this) {
|
|
378
|
+
// Inline function 'kotlin.let' call
|
|
379
|
+
// Inline function 'kotlin.text.filter' call
|
|
380
|
+
// Inline function 'kotlin.collections.mapIndexed' call
|
|
381
|
+
var this_0 = split(_this__u8e3s4, ['.', ' ']);
|
|
382
|
+
// Inline function 'kotlin.collections.mapIndexedTo' call
|
|
383
|
+
var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
|
|
384
|
+
var index = 0;
|
|
385
|
+
var tmp0_iterator = this_0.g();
|
|
386
|
+
while (tmp0_iterator.h()) {
|
|
387
|
+
var item = tmp0_iterator.i();
|
|
388
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.sanitizeSymbol.<anonymous>' call
|
|
389
|
+
var tmp1 = index;
|
|
390
|
+
index = tmp1 + 1 | 0;
|
|
391
|
+
var tmp$ret$0 = checkIndexOverflow(tmp1) > 0 ? Companion_instance.k24(item) : item;
|
|
392
|
+
destination.e(tmp$ret$0);
|
|
393
|
+
}
|
|
394
|
+
// Inline function 'kotlin.text.filterTo' call
|
|
395
|
+
var this_1 = joinToString(destination, '');
|
|
396
|
+
var destination_0 = StringBuilder_init_$Create$();
|
|
397
|
+
var inductionVariable = 0;
|
|
398
|
+
var last = charSequenceLength(this_1);
|
|
399
|
+
if (inductionVariable < last)
|
|
400
|
+
do {
|
|
401
|
+
var index_0 = inductionVariable;
|
|
402
|
+
inductionVariable = inductionVariable + 1 | 0;
|
|
403
|
+
var element = charSequenceGet(this_1, index_0);
|
|
404
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.sanitizeSymbol.<anonymous>' call
|
|
405
|
+
if (isLetterOrDigit(element) || element === _Char___init__impl__6a9atx(95)) {
|
|
406
|
+
destination_0.z7(element);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
while (inductionVariable < last);
|
|
410
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
411
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.sanitizeSymbol.<anonymous>' call
|
|
412
|
+
var it = destination_0.toString();
|
|
413
|
+
var tmp;
|
|
414
|
+
var tmp0_safe_receiver = firstOrNull(it);
|
|
415
|
+
var tmp_0;
|
|
416
|
+
var tmp_1 = tmp0_safe_receiver;
|
|
417
|
+
if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
|
|
418
|
+
tmp_0 = null;
|
|
419
|
+
} else {
|
|
420
|
+
tmp_0 = isDigit(tmp0_safe_receiver);
|
|
421
|
+
}
|
|
422
|
+
if (tmp_0 === true) {
|
|
423
|
+
tmp = '_' + it;
|
|
424
|
+
} else {
|
|
425
|
+
tmp = it;
|
|
426
|
+
}
|
|
427
|
+
return tmp;
|
|
428
|
+
}
|
|
429
|
+
function Companion() {
|
|
430
|
+
Companion_instance_2 = this;
|
|
431
|
+
this.d2c_1 = setOf(['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']);
|
|
432
|
+
this.e2c_1 = 'type(None)';
|
|
433
|
+
}
|
|
434
|
+
var Companion_instance_2;
|
|
435
|
+
function Companion_getInstance() {
|
|
436
|
+
if (Companion_instance_2 == null)
|
|
437
|
+
new Companion();
|
|
438
|
+
return Companion_instance_2;
|
|
439
|
+
}
|
|
440
|
+
function sam$kotlin_Comparator$0(function_0) {
|
|
441
|
+
this.f2c_1 = function_0;
|
|
442
|
+
}
|
|
443
|
+
protoOf(sam$kotlin_Comparator$0).uc = function (a, b) {
|
|
444
|
+
return this.f2c_1(a, b);
|
|
445
|
+
};
|
|
446
|
+
protoOf(sam$kotlin_Comparator$0).compare = function (a, b) {
|
|
447
|
+
return this.uc(a, b);
|
|
448
|
+
};
|
|
449
|
+
protoOf(sam$kotlin_Comparator$0).p3 = function () {
|
|
450
|
+
return this.f2c_1;
|
|
451
|
+
};
|
|
452
|
+
protoOf(sam$kotlin_Comparator$0).equals = function (other) {
|
|
453
|
+
var tmp;
|
|
454
|
+
if (!(other == null) ? isInterface(other, Comparator) : false) {
|
|
455
|
+
var tmp_0;
|
|
456
|
+
if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
|
|
457
|
+
tmp_0 = equals(this.p3(), other.p3());
|
|
458
|
+
} else {
|
|
459
|
+
tmp_0 = false;
|
|
460
|
+
}
|
|
461
|
+
tmp = tmp_0;
|
|
462
|
+
} else {
|
|
463
|
+
tmp = false;
|
|
464
|
+
}
|
|
465
|
+
return tmp;
|
|
466
|
+
};
|
|
467
|
+
protoOf(sam$kotlin_Comparator$0).hashCode = function () {
|
|
468
|
+
return hashCode(this.p3());
|
|
469
|
+
};
|
|
470
|
+
function emit$_anonymous_$emitInit_7cggmt(this$0, def) {
|
|
471
|
+
return 'from .' + this$0.d25(def.x24()) + ' import ' + this$0.d25(def.x24());
|
|
472
|
+
}
|
|
473
|
+
function PythonEmitter$emit$lambda(this$0) {
|
|
474
|
+
return function (a, b) {
|
|
475
|
+
// Inline function 'kotlin.comparisons.compareValuesBy' call
|
|
476
|
+
var tmp = this$0.g2c(a);
|
|
477
|
+
var tmp$ret$1 = this$0.g2c(b);
|
|
478
|
+
return compareValues(tmp, tmp$ret$1);
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function PythonEmitter$emit$lambda_0(this$0) {
|
|
482
|
+
return function (it) {
|
|
483
|
+
return emitReferenceCustomImports(it, this$0);
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function PythonEmitter$emit$lambda_1(this$0) {
|
|
487
|
+
return function (it) {
|
|
488
|
+
return emitReferenceCustomImports(it, this$0);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function PythonEmitter$emit$lambda_2(this$0) {
|
|
492
|
+
return function (it) {
|
|
493
|
+
return Spacer_instance.toString() + this$0.q2a(it);
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function PythonEmitter$emitAssignSelf$lambda(this$0) {
|
|
497
|
+
return function (it) {
|
|
498
|
+
return emitAssignSelf(it, this$0);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function PythonEmitter$emitAssignSelf$lambda_0(this$0) {
|
|
502
|
+
return function (it) {
|
|
503
|
+
return emitAssignSelf(it, this$0);
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function PythonEmitter$emitAssignSelf$lambda_1(this$0) {
|
|
507
|
+
return function (it) {
|
|
508
|
+
return emitAssignSelf(it, this$0);
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function PythonEmitter$emitAssignSelf$lambda_2(this$0) {
|
|
512
|
+
return function (it) {
|
|
513
|
+
return emitAssignSelf(it, this$0);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function PythonEmitter$emit$lambda_3(this$0) {
|
|
517
|
+
return function (it) {
|
|
518
|
+
return emitReferenceCustomImports(it, this$0);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function PythonEmitter$emit$lambda_4(this$0, $endpoint) {
|
|
522
|
+
return function (it) {
|
|
523
|
+
return this$0.h2c(it, $endpoint);
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
function PythonEmitter$emitResponseUnion$lambda(it) {
|
|
527
|
+
return 'Response' + it.o26_1;
|
|
528
|
+
}
|
|
529
|
+
function PythonEmitter$emit$lambda_5(this$0) {
|
|
530
|
+
return function (it) {
|
|
531
|
+
return emit(it, this$0);
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function PythonEmitter$emit$lambda_6(this$0) {
|
|
535
|
+
return function (it) {
|
|
536
|
+
return this$0.q2a(it);
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function PythonEmitter$emit$lambda_7(this$0) {
|
|
540
|
+
return function (it) {
|
|
541
|
+
return this$0.q2a(it);
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
function PythonEmitter$emit$lambda_8(this$0) {
|
|
545
|
+
return function (it) {
|
|
546
|
+
return emit_0(it, this$0);
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function PythonEmitter$emitToRawRequest$lambda(this$0) {
|
|
550
|
+
return function (it) {
|
|
551
|
+
var tmp;
|
|
552
|
+
if (it instanceof Literal) {
|
|
553
|
+
tmp = '"' + it.i26_1 + '"';
|
|
554
|
+
} else {
|
|
555
|
+
if (it instanceof Param) {
|
|
556
|
+
tmp = 'str(request.path.' + this$0.d25(it.e24_1) + ')';
|
|
557
|
+
} else {
|
|
558
|
+
noWhenBranchMatchedException();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return tmp;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function PythonEmitter$emitToRawRequest$lambda_0(this$0) {
|
|
565
|
+
return function (it) {
|
|
566
|
+
return emitSerializedParams(it, this$0, 'request', 'queries');
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function PythonEmitter$emitToRawRequest$lambda_1(this$0) {
|
|
570
|
+
return function (it) {
|
|
571
|
+
return emitSerializedParams(it, this$0, 'request', 'headers');
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function PythonEmitter$emitDeserializedParams$lambda(this$0) {
|
|
575
|
+
return function (it) {
|
|
576
|
+
return emitDeserialized(it, this$0);
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function PythonEmitter$emitDeserializedParams$lambda_0(this$0) {
|
|
580
|
+
return function (it) {
|
|
581
|
+
return emitDeserializedParams_0(it, this$0, 'request', 'queries');
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function PythonEmitter$emitDeserializedParams$lambda_1(this$0) {
|
|
585
|
+
return function (it) {
|
|
586
|
+
return emitDeserializedParams_0(it, this$0, 'request', 'headers');
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function PythonEmitter$emit$lambda_9(this$0) {
|
|
590
|
+
return function (it) {
|
|
591
|
+
return this$0.q2a(it);
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function PythonEmitter$emit$lambda_10(this$0) {
|
|
595
|
+
return function (it) {
|
|
596
|
+
return emit_0(it, this$0);
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function PythonEmitter$emitToRawResponse$lambda(this$0, $this_emitToRawResponse) {
|
|
600
|
+
return function (it) {
|
|
601
|
+
return emitSerialized(it, this$0, $this_emitToRawResponse);
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function PythonEmitter$emitFromRawResponse$lambda(this$0, $this_emitFromRawResponse) {
|
|
605
|
+
return function (it) {
|
|
606
|
+
return emitDeserialized_0(it, this$0, $this_emitFromRawResponse);
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function PythonEmitter$emitDeserialized$lambda(this$0) {
|
|
610
|
+
return function (it) {
|
|
611
|
+
return emitDeserializedParams_0(it, this$0, 'response', 'headers');
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function PythonEmitter$emitSerialized$lambda(this$0) {
|
|
615
|
+
return function (it) {
|
|
616
|
+
return emitSerializedParams(it, this$0, 'response', 'headers');
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function PythonEmitter$emitObject$lambda($spaces, $block) {
|
|
620
|
+
return function (it) {
|
|
621
|
+
return Spacer_instance.p23($spaces + 2 | 0) + $block(it);
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function PythonEmitter$emit$lambda_11(this$0) {
|
|
625
|
+
return function (it) {
|
|
626
|
+
return Spacer_instance.toString() + this$0.s2a(this$0.r2a(it)) + ' = "' + it + '"';
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function PythonEmitter(packageName, emitShared) {
|
|
630
|
+
Companion_getInstance();
|
|
631
|
+
packageName = packageName === VOID ? Companion_instance_0.y26('community.flock.wirespec.generated') : packageName;
|
|
632
|
+
emitShared = emitShared === VOID ? Companion_instance_1.r23() : emitShared;
|
|
633
|
+
Emitter.call(this);
|
|
634
|
+
this.w2b_1 = packageName;
|
|
635
|
+
this.x2b_1 = emitShared;
|
|
636
|
+
this.y2b_1 = 'import re\n\nfrom abc import abstractmethod\nfrom dataclasses import dataclass\nfrom typing import List, Optional\nfrom enum import Enum\n\nfrom ..wirespec import T, Wirespec\n';
|
|
637
|
+
this.z2b_1 = FileExtension_Python_getInstance();
|
|
638
|
+
this.a2c_1 = PythonShared_instance;
|
|
639
|
+
this.b2c_1 = '#';
|
|
640
|
+
}
|
|
641
|
+
protoOf(PythonEmitter).q24 = function () {
|
|
642
|
+
return this.z2b_1;
|
|
643
|
+
};
|
|
644
|
+
protoOf(PythonEmitter).u2a = function () {
|
|
645
|
+
return this.a2c_1;
|
|
646
|
+
};
|
|
647
|
+
protoOf(PythonEmitter).w26 = function () {
|
|
648
|
+
return this.b2c_1;
|
|
649
|
+
};
|
|
650
|
+
protoOf(PythonEmitter).g2c = function (definition) {
|
|
651
|
+
var tmp;
|
|
652
|
+
if (definition instanceof Enum) {
|
|
653
|
+
tmp = 1;
|
|
654
|
+
} else {
|
|
655
|
+
if (definition instanceof Refined) {
|
|
656
|
+
tmp = 2;
|
|
657
|
+
} else {
|
|
658
|
+
if (definition instanceof Type) {
|
|
659
|
+
tmp = 3;
|
|
660
|
+
} else {
|
|
661
|
+
if (definition instanceof Union) {
|
|
662
|
+
tmp = 4;
|
|
663
|
+
} else {
|
|
664
|
+
if (definition instanceof Endpoint) {
|
|
665
|
+
tmp = 5;
|
|
666
|
+
} else {
|
|
667
|
+
if (definition instanceof Channel) {
|
|
668
|
+
tmp = 6;
|
|
669
|
+
} else {
|
|
670
|
+
noWhenBranchMatchedException();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return tmp;
|
|
678
|
+
};
|
|
679
|
+
protoOf(PythonEmitter).s24 = function (module_0, logger) {
|
|
680
|
+
// Inline function 'kotlin.collections.sortedBy' call
|
|
681
|
+
var this_0 = module_0.o24_1;
|
|
682
|
+
// Inline function 'kotlin.comparisons.compareBy' call
|
|
683
|
+
var tmp = PythonEmitter$emit$lambda(this);
|
|
684
|
+
var tmp$ret$0 = new sam$kotlin_Comparator$0(tmp);
|
|
685
|
+
var tmp$ret$1 = sortedWith(this_0, tmp$ret$0);
|
|
686
|
+
var statements = ensureNotNull(toNonEmptyListOrNull(tmp$ret$1));
|
|
687
|
+
// Inline function 'kotlin.let' call
|
|
688
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
689
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>' call
|
|
690
|
+
var it = protoOf(Emitter).s24.call(this, module_0.x27(VOID, statements), logger);
|
|
691
|
+
var init = new Emitted(this.w2b_1.b27() + '__init__', 'from . import model\nfrom . import endpoint\nfrom . import wirespec\n');
|
|
692
|
+
var tmp_0 = this.w2b_1.b27() + 'endpoint/' + '__init__';
|
|
693
|
+
// Inline function 'kotlin.collections.map' call
|
|
694
|
+
// Inline function 'kotlin.collections.filter' call
|
|
695
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
696
|
+
var this_1 = module_0.o24_1;
|
|
697
|
+
var destination = ArrayList_init_$Create$();
|
|
698
|
+
var tmp0_iterator = this_1.g();
|
|
699
|
+
while (tmp0_iterator.h()) {
|
|
700
|
+
var element = tmp0_iterator.i();
|
|
701
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>.<anonymous>' call
|
|
702
|
+
if (element instanceof Endpoint) {
|
|
703
|
+
destination.e(element);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// Inline function 'kotlin.collections.mapTo' call
|
|
707
|
+
var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10));
|
|
708
|
+
var tmp0_iterator_0 = destination.g();
|
|
709
|
+
while (tmp0_iterator_0.h()) {
|
|
710
|
+
var item = tmp0_iterator_0.i();
|
|
711
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>.<anonymous>' call
|
|
712
|
+
var tmp$ret$5 = emit$_anonymous_$emitInit_7cggmt(this, item);
|
|
713
|
+
destination_0.e(tmp$ret$5);
|
|
714
|
+
}
|
|
715
|
+
var initEndpoint = new Emitted(tmp_0, joinToString(destination_0, '\n'));
|
|
716
|
+
var tmp_1 = this.w2b_1.b27() + 'model/' + '__init__';
|
|
717
|
+
// Inline function 'kotlin.collections.map' call
|
|
718
|
+
// Inline function 'kotlin.collections.filter' call
|
|
719
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
720
|
+
var this_2 = module_0.o24_1;
|
|
721
|
+
var destination_1 = ArrayList_init_$Create$();
|
|
722
|
+
var tmp0_iterator_1 = this_2.g();
|
|
723
|
+
while (tmp0_iterator_1.h()) {
|
|
724
|
+
var element_0 = tmp0_iterator_1.i();
|
|
725
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>.<anonymous>' call
|
|
726
|
+
if (isInterface(element_0, Model)) {
|
|
727
|
+
destination_1.e(element_0);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
// Inline function 'kotlin.collections.mapTo' call
|
|
731
|
+
var destination_2 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination_1, 10));
|
|
732
|
+
var tmp0_iterator_2 = destination_1.g();
|
|
733
|
+
while (tmp0_iterator_2.h()) {
|
|
734
|
+
var item_0 = tmp0_iterator_2.i();
|
|
735
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>.<anonymous>' call
|
|
736
|
+
var tmp$ret$11 = emit$_anonymous_$emitInit_7cggmt(this, item_0);
|
|
737
|
+
destination_2.e(tmp$ret$11);
|
|
738
|
+
}
|
|
739
|
+
var initModel = new Emitted(tmp_1, joinToString(destination_2, '\n'));
|
|
740
|
+
var shared = new Emitted(this.w2b_1.b27() + 'wirespec', this.u2a().j2c_1);
|
|
741
|
+
return this.x2b_1.s23_1 ? it.pk(init).pk(initEndpoint).pk(initModel).pk(shared) : it.pk(init);
|
|
742
|
+
};
|
|
743
|
+
protoOf(PythonEmitter).w24 = function (definition, module_0, logger) {
|
|
744
|
+
var subPackageName = plus(this.w2b_1, definition);
|
|
745
|
+
// Inline function 'kotlin.let' call
|
|
746
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
747
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>' call
|
|
748
|
+
var it = protoOf(Emitter).w24.call(this, definition, module_0, logger);
|
|
749
|
+
var tmp = subPackageName.b27() + sanitizeSymbol(it.t23_1, this);
|
|
750
|
+
// Inline function 'kotlin.text.trimStart' call
|
|
751
|
+
var this_0 = trimMargin('\n |' + this.y2b_1 + '\n |' + it.u23_1 + '\n ');
|
|
752
|
+
var tmp$ret$0 = toString(trimStart(isCharSequence(this_0) ? this_0 : THROW_CCE()));
|
|
753
|
+
return new Emitted(tmp, tmp$ret$0);
|
|
754
|
+
};
|
|
755
|
+
protoOf(PythonEmitter).e26 = function (type, module_0) {
|
|
756
|
+
var tmp;
|
|
757
|
+
if (type.c26_1.u26_1.l()) {
|
|
758
|
+
var tmp_0 = this.d25(type.b26_1);
|
|
759
|
+
var tmp_1 = Spacer_instance.toString();
|
|
760
|
+
var tmp_2 = this.t26(type);
|
|
761
|
+
tmp = trimMargin('\n |@dataclass\n |class ' + tmp_0 + ':\n |' + tmp_1 + 'pass\n |\n |' + joinToString(tmp_2, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_0(this)) + '\n |\n ');
|
|
762
|
+
} else {
|
|
763
|
+
var tmp_3 = this.d25(type.b26_1);
|
|
764
|
+
var tmp_4 = this.x2a(type.c26_1);
|
|
765
|
+
var tmp_5 = this.t26(type);
|
|
766
|
+
tmp = trimMargin('\n |@dataclass\n |class ' + tmp_3 + ':\n |' + tmp_4 + '\n |\n |' + joinToString(tmp_5, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_1(this)) + '\n ');
|
|
767
|
+
}
|
|
768
|
+
return tmp;
|
|
769
|
+
};
|
|
770
|
+
protoOf(PythonEmitter).x2a = function (_this__u8e3s4) {
|
|
771
|
+
return joinToString(_this__u8e3s4.u26_1, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_2(this));
|
|
772
|
+
};
|
|
773
|
+
protoOf(PythonEmitter).q2a = function (_this__u8e3s4) {
|
|
774
|
+
return this.d25(_this__u8e3s4.i24_1) + ": '" + this.n2a(_this__u8e3s4.j24_1) + "'";
|
|
775
|
+
};
|
|
776
|
+
protoOf(PythonEmitter).n2a = function (_this__u8e3s4) {
|
|
777
|
+
// Inline function 'kotlin.let' call
|
|
778
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
779
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>' call
|
|
780
|
+
var it = emitType(_this__u8e3s4, this);
|
|
781
|
+
return _this__u8e3s4.hm() ? 'Optional[' + it + ']' : it;
|
|
782
|
+
};
|
|
783
|
+
protoOf(PythonEmitter).c2c = function (_this__u8e3s4) {
|
|
784
|
+
var tmp;
|
|
785
|
+
if (_this__u8e3s4 instanceof String_0) {
|
|
786
|
+
tmp = 'str';
|
|
787
|
+
} else {
|
|
788
|
+
if (_this__u8e3s4 instanceof Integer) {
|
|
789
|
+
tmp = 'int';
|
|
790
|
+
} else {
|
|
791
|
+
if (_this__u8e3s4 instanceof Number_0) {
|
|
792
|
+
tmp = 'float';
|
|
793
|
+
} else {
|
|
794
|
+
if (_this__u8e3s4 instanceof Boolean_0) {
|
|
795
|
+
tmp = 'bool';
|
|
796
|
+
} else {
|
|
797
|
+
if (_this__u8e3s4 instanceof Bytes) {
|
|
798
|
+
tmp = 'bytes';
|
|
799
|
+
} else {
|
|
800
|
+
noWhenBranchMatchedException();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
return tmp;
|
|
807
|
+
};
|
|
808
|
+
protoOf(PythonEmitter).d25 = function (identifier) {
|
|
809
|
+
var tmp;
|
|
810
|
+
if (identifier instanceof DefinitionIdentifier) {
|
|
811
|
+
tmp = sanitizeSymbol(identifier.b1(), this);
|
|
812
|
+
} else {
|
|
813
|
+
if (identifier instanceof FieldIdentifier) {
|
|
814
|
+
tmp = this.s2a(sanitizeSymbol(identifier.b1(), this));
|
|
815
|
+
} else {
|
|
816
|
+
noWhenBranchMatchedException();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return tmp;
|
|
820
|
+
};
|
|
821
|
+
protoOf(PythonEmitter).m25 = function (refined) {
|
|
822
|
+
return trimMargin('\n |@dataclass\n |class ' + sanitizeSymbol(refined.k25_1.b1(), this) + '(Wirespec.Refined):\n |' + Spacer_instance.toString() + 'value: str\n |\n |' + Spacer_instance.toString() + 'def validate(self) -> bool:\n |' + Spacer_instance.p23(2) + 'return ' + this.y2a(refined) + '\n |\n |' + Spacer_instance.toString() + 'def __str__(self) -> str:\n |' + Spacer_instance.p23(2) + 'return self.value\n ');
|
|
823
|
+
};
|
|
824
|
+
protoOf(PythonEmitter).y2a = function (_this__u8e3s4) {
|
|
825
|
+
var defaultReturn = 'true';
|
|
826
|
+
var type = _this__u8e3s4.l25_1.b29_1;
|
|
827
|
+
var tmp;
|
|
828
|
+
if (type instanceof Integer) {
|
|
829
|
+
var tmp0_safe_receiver = type.h28_1;
|
|
830
|
+
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : this.z2a(tmp0_safe_receiver);
|
|
831
|
+
tmp = tmp1_elvis_lhs == null ? defaultReturn : tmp1_elvis_lhs;
|
|
832
|
+
} else {
|
|
833
|
+
if (type instanceof Number_0) {
|
|
834
|
+
var tmp2_safe_receiver = type.k28_1;
|
|
835
|
+
var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : this.z2a(tmp2_safe_receiver);
|
|
836
|
+
tmp = tmp3_elvis_lhs == null ? defaultReturn : tmp3_elvis_lhs;
|
|
837
|
+
} else {
|
|
838
|
+
if (type instanceof String_0) {
|
|
839
|
+
var tmp4_safe_receiver = type.e28_1;
|
|
840
|
+
var tmp_0;
|
|
841
|
+
var tmp_1 = tmp4_safe_receiver;
|
|
842
|
+
if ((tmp_1 == null ? null : new RegExp_0(tmp_1)) == null) {
|
|
843
|
+
tmp_0 = null;
|
|
844
|
+
} else {
|
|
845
|
+
tmp_0 = this.z2a(new RegExp_0(tmp4_safe_receiver));
|
|
846
|
+
}
|
|
847
|
+
var tmp5_elvis_lhs = tmp_0;
|
|
848
|
+
tmp = tmp5_elvis_lhs == null ? defaultReturn : tmp5_elvis_lhs;
|
|
849
|
+
} else {
|
|
850
|
+
if (equals(type, Boolean_instance)) {
|
|
851
|
+
tmp = defaultReturn;
|
|
852
|
+
} else {
|
|
853
|
+
if (equals(type, Bytes_instance)) {
|
|
854
|
+
tmp = defaultReturn;
|
|
855
|
+
} else {
|
|
856
|
+
noWhenBranchMatchedException();
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return tmp;
|
|
863
|
+
};
|
|
864
|
+
protoOf(PythonEmitter).z2a = function (_this__u8e3s4) {
|
|
865
|
+
var tmp;
|
|
866
|
+
if (_this__u8e3s4 instanceof RegExp_0) {
|
|
867
|
+
tmp = Spacer_instance.toString() + 'bool(re.match(r"' + _RegExp___get_value__impl__7o7618(_this__u8e3s4.b28_1) + '", self.value))';
|
|
868
|
+
} else {
|
|
869
|
+
if (_this__u8e3s4 instanceof Bound) {
|
|
870
|
+
tmp = Spacer_instance.toString() + _this__u8e3s4.c28_1 + ' < record.value < ' + _this__u8e3s4.d28_1 + ';';
|
|
871
|
+
} else {
|
|
872
|
+
noWhenBranchMatchedException();
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return tmp;
|
|
876
|
+
};
|
|
877
|
+
protoOf(PythonEmitter).z25 = function (endpoint) {
|
|
878
|
+
var tmp = this.t26(endpoint);
|
|
879
|
+
var tmp_0 = joinToString(tmp, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_3(this));
|
|
880
|
+
var tmp_1 = this.d25(endpoint.s25_1);
|
|
881
|
+
var tmp_2 = this.f26(this.a2b(first(endpoint.x25_1), endpoint), 1);
|
|
882
|
+
var tmp_3 = this.s26(endpoint.y25_1);
|
|
883
|
+
return trimMargin('\n |' + tmp_0 + '\n |\n |class ' + tmp_1 + ' (Wirespec.Endpoint):\n |' + tmp_2 + '\n |' + this.f26(joinToString(tmp_3, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_4(this, endpoint)), 1) + '\n |' + this.f26(emitResponseUnion(endpoint, this), 1) + '\n |' + this.f26(emitHandleClass(endpoint, this), 1) + '\n |' + this.f26(emitConvertClass(endpoint, this), 1) + '\n |\n ');
|
|
884
|
+
};
|
|
885
|
+
protoOf(PythonEmitter).a2b = function (_this__u8e3s4, endpoint) {
|
|
886
|
+
var tmp = emit_1(_this__u8e3s4.m26_1, this);
|
|
887
|
+
var tmp_0 = this.j26(endpoint);
|
|
888
|
+
var tmp_1 = emitObject$default(tmp_0, this, 'Path', 'Wirespec.Request.Path', VOID, PythonEmitter$emit$lambda_5(this));
|
|
889
|
+
var tmp_2 = emitObject$default(endpoint.v25_1, this, 'Queries', 'Wirespec.Request.Queries', VOID, PythonEmitter$emit$lambda_6(this));
|
|
890
|
+
var tmp_3 = emitObject$default(endpoint.w25_1, this, 'Headers', 'Wirespec.Request.Headers', VOID, PythonEmitter$emit$lambda_7(this));
|
|
891
|
+
var tmp_4 = Spacer_instance.toString();
|
|
892
|
+
var tmp_5 = Spacer_instance.toString();
|
|
893
|
+
var tmp_6 = emit_1(_this__u8e3s4.m26_1, this);
|
|
894
|
+
var tmp_7 = Spacer_instance.toString();
|
|
895
|
+
var tmp_8 = Spacer_instance.toString();
|
|
896
|
+
var tmp_9 = Spacer_instance.toString();
|
|
897
|
+
var tmp_10 = Spacer_instance.toString();
|
|
898
|
+
var tmp_11 = Spacer_instance.toString();
|
|
899
|
+
var tmp_12 = Spacer_instance.toString();
|
|
900
|
+
var tmp_13 = Spacer_instance.toString();
|
|
901
|
+
var tmp_14 = Spacer_instance.toString();
|
|
902
|
+
var tmp_15 = Spacer_instance.toString();
|
|
903
|
+
var tmp_16 = Spacer_instance.toString();
|
|
904
|
+
var tmp_17 = Spacer_instance.toString();
|
|
905
|
+
var tmp_18 = Spacer_instance.toString();
|
|
906
|
+
var tmp_19 = Spacer_instance.toString();
|
|
907
|
+
var tmp_20 = Spacer_instance.toString();
|
|
908
|
+
var tmp_21 = Spacer_instance.toString();
|
|
909
|
+
var tmp_22 = emit_1(_this__u8e3s4.m26_1, this);
|
|
910
|
+
var tmp_23 = Spacer_instance.toString();
|
|
911
|
+
var tmp_24 = Spacer_instance.toString();
|
|
912
|
+
var tmp_25 = Spacer_instance.toString();
|
|
913
|
+
var tmp_26 = Spacer_instance.toString();
|
|
914
|
+
var tmp_27 = Spacer_instance.toString();
|
|
915
|
+
var tmp_28 = this.l26(_this__u8e3s4, endpoint);
|
|
916
|
+
return trimMargin('\n |@dataclass\n |class Request(Wirespec.Request[' + tmp + ']):\n |' + tmp_1 + '\n |' + tmp_2 + '\n |' + tmp_3 + '\n |\n |' + tmp_4 + '@property\n |' + tmp_5 + 'def body(self) -> ' + tmp_6 + ':\n |' + tmp_7 + tmp_8 + 'return self._body\n |\n |' + tmp_9 + '@property\n |' + tmp_10 + 'def path(self) -> Path:\n |' + tmp_11 + tmp_12 + 'return self._path\n |\n |' + tmp_13 + '@property\n |' + tmp_14 + 'def queries(self) -> Queries:\n |' + tmp_15 + tmp_16 + 'return self._queries\n |\n |' + tmp_17 + '@property\n |' + tmp_18 + 'def headers(self) -> Headers:\n |' + tmp_19 + tmp_20 + 'return self._headers\n |\n |' + tmp_21 + '_body: ' + tmp_22 + '\n |' + tmp_23 + '_headers: Headers\n |' + tmp_24 + '_queries: Queries\n |' + tmp_25 + '_path: Path\n |' + tmp_26 + 'method: Wirespec.Method = Wirespec.Method.' + endpoint.t25_1.q2_1 + '\n |\n |' + tmp_27 + 'def __init__(self, ' + joinToString(tmp_28, ', ', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_8(this)) + '):\n |' + this.f26(emitAssignSelf_0(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
917
|
+
};
|
|
918
|
+
protoOf(PythonEmitter).h2c = function (_this__u8e3s4, endpoint) {
|
|
919
|
+
var tmp = emit_1(_this__u8e3s4.q26_1, this);
|
|
920
|
+
var tmp_0 = emitObject$default(_this__u8e3s4.p26_1, this, 'Headers', 'Wirespec.Response.Headers', VOID, PythonEmitter$emit$lambda_9(this));
|
|
921
|
+
var tmp_1 = Spacer_instance.toString();
|
|
922
|
+
var tmp_2 = Spacer_instance.toString();
|
|
923
|
+
var tmp_3 = Spacer_instance.toString();
|
|
924
|
+
var tmp_4 = Spacer_instance.toString();
|
|
925
|
+
var tmp_5 = Spacer_instance.toString();
|
|
926
|
+
var tmp_6 = Spacer_instance.toString();
|
|
927
|
+
var tmp_7 = emit_1(_this__u8e3s4.q26_1, this);
|
|
928
|
+
var tmp_8 = Spacer_instance.toString();
|
|
929
|
+
var tmp_9 = Spacer_instance.toString();
|
|
930
|
+
var tmp_10 = Spacer_instance.toString();
|
|
931
|
+
var tmp_11 = emit_1(_this__u8e3s4.q26_1, this);
|
|
932
|
+
var tmp_12 = Spacer_instance.toString();
|
|
933
|
+
var tmp_13 = Spacer_instance.toString();
|
|
934
|
+
var tmp_14 = Spacer_instance.toString();
|
|
935
|
+
var tmp_15 = this.n26(_this__u8e3s4);
|
|
936
|
+
return trimMargin('\n |@dataclass\n |class Response' + _this__u8e3s4.o26_1 + '(Wirespec.Response[' + tmp + ']):\n |' + tmp_0 + '\n |\n |' + tmp_1 + '@property\n |' + tmp_2 + 'def headers(self) -> Headers:\n |' + tmp_3 + tmp_4 + 'return self._headers\n |\n |' + tmp_5 + '@property\n |' + tmp_6 + 'def body(self) -> ' + tmp_7 + ':\n |' + tmp_8 + tmp_9 + 'return self._body\n |\n |' + tmp_10 + '_body: ' + tmp_11 + '\n |' + tmp_12 + '_headers: Headers\n |' + tmp_13 + 'status: int = ' + _this__u8e3s4.o26_1 + '\n |\n |' + tmp_14 + 'def __init__(self, ' + joinToString(tmp_15, ', ', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_10(this)) + '):\n |' + this.f26(emitAssignSelf_1(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
937
|
+
};
|
|
938
|
+
protoOf(PythonEmitter).e25 = function (channel) {
|
|
939
|
+
return '';
|
|
940
|
+
};
|
|
941
|
+
protoOf(PythonEmitter).q25 = function (enum_0, module_0) {
|
|
942
|
+
var tmp = sanitizeSymbol(enum_0.o25_1.b1(), this);
|
|
943
|
+
return trimMargin('\n |class ' + tmp + '(str, Enum):\n |' + joinToString(enum_0.p25_1, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_11(this)) + '\n |\n |' + Spacer_instance.toString() + '@property\n |' + Spacer_instance.toString() + 'def label(self) -> str:\n |' + Spacer_instance.p23(2) + 'return self.value\n |\n |' + Spacer_instance.toString() + 'def __str__(self) -> str:\n |' + Spacer_instance.p23(2) + 'return self.value\n ');
|
|
944
|
+
};
|
|
945
|
+
protoOf(PythonEmitter).i25 = function (union) {
|
|
946
|
+
return trimMargin('\n |class ' + this.d25(union.g25_1) + '(ABC):\n |' + Spacer_instance.toString() + 'pass\n ');
|
|
947
|
+
};
|
|
948
|
+
protoOf(PythonEmitter).r2a = function (_this__u8e3s4) {
|
|
949
|
+
// Inline function 'kotlin.let' call
|
|
950
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
951
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.sanitizeEnum.<anonymous>' call
|
|
952
|
+
var it = joinToString(split(_this__u8e3s4, ['-', ', ', '.', ' ', '//']), '_');
|
|
953
|
+
var tmp;
|
|
954
|
+
var tmp0_safe_receiver = firstOrNull(it);
|
|
955
|
+
var tmp_0;
|
|
956
|
+
var tmp_1 = tmp0_safe_receiver;
|
|
957
|
+
if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
|
|
958
|
+
tmp_0 = null;
|
|
959
|
+
} else {
|
|
960
|
+
tmp_0 = isDigit(tmp0_safe_receiver);
|
|
961
|
+
}
|
|
962
|
+
if (tmp_0 === true) {
|
|
963
|
+
tmp = '_' + it;
|
|
964
|
+
} else {
|
|
965
|
+
tmp = it;
|
|
966
|
+
}
|
|
967
|
+
return tmp;
|
|
968
|
+
};
|
|
969
|
+
protoOf(PythonEmitter).s2a = function (_this__u8e3s4) {
|
|
970
|
+
return Companion_getInstance().d2c_1.o1(_this__u8e3s4) ? '_' + _this__u8e3s4 : _this__u8e3s4;
|
|
971
|
+
};
|
|
972
|
+
function PythonShared() {
|
|
973
|
+
this.i2c_1 = 'shared';
|
|
974
|
+
this.j2c_1 = "from abc import ABC, abstractmethod\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import Generic, List, Dict, Optional, TypeVar\n\nT = TypeVar('T')\nREQ = TypeVar('REQ')\nRES = TypeVar('RES')\n\nclass Wirespec:\n\n class Refined(ABC):\n @property\n @abstractmethod\n def value(self) -> str: pass\n\n class Endpoint(ABC):\n\n class Handler(ABC):\n pass\n\n class Convert(ABC, Generic[REQ, RES]):\n @staticmethod\n @abstractmethod\n def to_raw_request(serializer: 'Wirespec.Serializer', req: REQ) -> 'Wirespec.RawRequest': pass\n\n @staticmethod\n @abstractmethod\n def from_raw_response(serializer: 'Wirespec.Deserializer', res: 'Wirespec.RawResponse') -> RES: pass\n\n @staticmethod\n @abstractmethod\n def to_raw_response(serializer: 'Wirespec.Serializer', res: RES) -> 'Wirespec.RawResponse': pass\n\n @staticmethod\n @abstractmethod\n def from_raw_request(serializer: 'Wirespec.Deserializer[T]', req: 'Wirespec.RawRequest') -> REQ: pass\n\n class Method(Enum):\n GET = \"GET\"\n PUT = \"PUT\"\n POST = \"POST\"\n DELETE = \"DELETE\"\n OPTIONS = \"OPTIONS\"\n HEAD = \"HEAD\"\n PATCH = \"PATCH\"\n TRACE = \"TRACE\"\n\n class Request(Generic[T], ABC):\n\n class Path(ABC): pass\n\n class Queries(ABC): pass\n\n class Headers(ABC): pass\n\n @property\n @abstractmethod\n def path(self) -> Path: pass\n\n @property\n @abstractmethod\n def method(self) -> 'Wirespec.Method': pass\n\n @property\n @abstractmethod\n def queries(self) -> Queries: pass\n\n @property\n @abstractmethod\n def headers(self) -> Headers: pass\n\n @property\n @abstractmethod\n def body(self) -> T: pass\n\n class Response(Generic[T], ABC):\n\n class Headers(ABC): pass\n\n @property\n @abstractmethod\n def status(self) -> int: pass\n\n @property\n @abstractmethod\n def headers(self) -> Headers: pass\n\n @property\n @abstractmethod\n def body(self) -> T: pass\n\n class Serializer(Generic[T], ABC):\n @abstractmethod\n def serialize(self, value: T, t: type[T]) -> str: pass\n @abstractmethod\n def serialize_param(self, value: T, t: type[T]) -> List[str]: pass\n\n class Deserializer(Generic[T], ABC):\n @abstractmethod\n def deserialize(self, value: str | None, t: type[T]) -> T: pass\n @abstractmethod\n def deserialize_param(self, value: List[str] | None, t: type[T]) -> T: pass\n\n class Serialization(Serializer, Deserializer):\n @abstractmethod\n def serialize(self, value: T, t: type[T]) -> str: pass\n @abstractmethod\n def serialize_param(self, value: T, t: type[T]) -> List[str]: pass\n @abstractmethod\n def deserialize(self, value: str | None, t: type[T]) -> T: pass\n @abstractmethod\n def deserialize_param(self, value: List[str] | None, t: type[T]) -> T: pass\n\n @dataclass\n class RawRequest:\n method: str\n path: List[str]\n queries: Dict[str, List[str]]\n headers: Dict[str, List[str]]\n body: Optional[str]\n\n\n @dataclass\n class RawResponse:\n status_code: int\n headers: Dict[str, List[str]]\n body: Optional[str]\n";
|
|
975
|
+
}
|
|
976
|
+
protoOf(PythonShared).toString = function () {
|
|
977
|
+
return 'PythonShared';
|
|
978
|
+
};
|
|
979
|
+
protoOf(PythonShared).hashCode = function () {
|
|
980
|
+
return 988605686;
|
|
981
|
+
};
|
|
982
|
+
protoOf(PythonShared).equals = function (other) {
|
|
983
|
+
if (this === other)
|
|
984
|
+
return true;
|
|
985
|
+
if (!(other instanceof PythonShared))
|
|
986
|
+
return false;
|
|
987
|
+
other instanceof PythonShared || THROW_CCE();
|
|
988
|
+
return true;
|
|
989
|
+
};
|
|
990
|
+
var PythonShared_instance;
|
|
991
|
+
function PythonShared_getInstance() {
|
|
992
|
+
return PythonShared_instance;
|
|
993
|
+
}
|
|
994
|
+
//region block: init
|
|
995
|
+
PythonShared_instance = new PythonShared();
|
|
996
|
+
//endregion
|
|
997
|
+
//region block: exports
|
|
998
|
+
export {
|
|
999
|
+
PythonEmitter as PythonEmitter2pjclp0u1gkmn,
|
|
1000
|
+
PythonShared_instance as PythonShared_instance2e1tc3jds5wkh,
|
|
1001
|
+
};
|
|
1002
|
+
//endregion
|
|
1003
|
+
|
|
1004
|
+
//# sourceMappingURL=wirespec-src-compiler-emitters-python.mjs.map
|