@flock/wirespec 0.16.6 → 0.16.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/clikt-clikt.mjs +1166 -1166
- package/colormath-root-colormath.mjs +425 -425
- package/kotlin-kotlin-stdlib.mjs +37 -37
- package/kotlin-kotlin-stdlib.mjs.map +1 -1
- package/kotlin-rgxgen.mjs +1763 -1763
- package/kotlinx-io-kotlinx-io-core.mjs +380 -380
- package/markdown.mjs +1864 -1864
- package/mordant-mordant.mjs +1638 -1638
- package/package.json +1 -1
- package/wirespec-src-compiler-core.mjs +1908 -1928
- package/wirespec-src-compiler-core.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-java.mjs +689 -687
- package/wirespec-src-compiler-emitters-java.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-kotlin.mjs +627 -577
- package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-python.mjs +789 -739
- package/wirespec-src-compiler-emitters-python.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-typescript.mjs +288 -284
- package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-wirespec.mjs +258 -222
- package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -1
- package/wirespec-src-compiler-lib.mjs +310 -310
- package/wirespec-src-converter-avro.mjs +372 -347
- package/wirespec-src-converter-avro.mjs.map +1 -1
- package/wirespec-src-converter-openapi.mjs +507 -499
- package/wirespec-src-converter-openapi.mjs.map +1 -1
- package/wirespec-src-plugin-arguments.mjs +136 -136
- package/wirespec-src-plugin-cli.mjs +75 -75
- package/wirespec-src-plugin-npm.d.ts +1 -1
- package/wirespec-src-plugin-npm.mjs +17 -16
- package/wirespec-src-plugin-npm.mjs.map +1 -1
- package/wirespec-src-tools-generator.mjs +24 -24
|
@@ -1,61 +1,48 @@
|
|
|
1
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
2
|
protoOf180f3jzyo7rfj as protoOf,
|
|
25
|
-
|
|
3
|
+
initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
|
|
26
4
|
equals2au1ep9vhcato as equals,
|
|
27
5
|
FunctionAdapter3lcrrz3moet5b as FunctionAdapter,
|
|
28
6
|
isInterface3d6p8outrmvmk as isInterface,
|
|
29
7
|
Comparator2b3maoeh98xtg as Comparator,
|
|
30
8
|
hashCodeq5arwsb9dgti as hashCode,
|
|
31
9
|
initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
|
|
10
|
+
VOID7hggqo3abtya as VOID,
|
|
32
11
|
compareValues1n2ayl87ihzfk as compareValues,
|
|
12
|
+
noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
|
|
33
13
|
sortedWith2csnbbb21k0lg as sortedWith,
|
|
34
14
|
ensureNotNull1e947j3ixpazm as ensureNotNull,
|
|
15
|
+
ArrayList_init_$Create$2rimpp4x9tjd3 as ArrayList_init_$Create$,
|
|
16
|
+
Unit_instanceat14thlj150z as Unit_instance,
|
|
17
|
+
collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
|
|
18
|
+
ArrayList_init_$Create$3m1kyiqequwm5 as ArrayList_init_$Create$_0,
|
|
19
|
+
joinToString1cxrrlmo0chqs as joinToString,
|
|
20
|
+
trimMarginhyd3fsmh8iev as trimMargin,
|
|
35
21
|
THROW_CCE2g6jy02ryeudk as THROW_CCE,
|
|
36
22
|
isCharSequence1ju9jr1w86plq as isCharSequence,
|
|
37
23
|
trimStart5ewg8zf6cs5u as trimStart,
|
|
38
24
|
toString1pkumu07cwy4m as toString,
|
|
25
|
+
listOfNotNull2woi2boe01ub4 as listOfNotNull,
|
|
26
|
+
isBlank1dvkhjjvox3p0 as isBlank,
|
|
27
|
+
first58ocm7j58k3q as first,
|
|
28
|
+
split2bvyvnrlcifjv as split,
|
|
29
|
+
firstOrNulltrxqttxfxqju as firstOrNull,
|
|
30
|
+
isDigit3mimrri4wkzop as isDigit,
|
|
31
|
+
Char19o2r8palgjof as Char,
|
|
32
|
+
setOf45ia9pnfhe90 as setOf,
|
|
33
|
+
initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion,
|
|
34
|
+
checkIndexOverflow3frtmheghr0th as checkIndexOverflow,
|
|
35
|
+
StringBuilder_init_$Create$zzhi687lupah as StringBuilder_init_$Create$,
|
|
36
|
+
charSequenceLength3278n89t01tmv as charSequenceLength,
|
|
37
|
+
charSequenceGet1vxk1y5n17t1z as charSequenceGet,
|
|
38
|
+
isLetterOrDigit2kuxd9e198haf as isLetterOrDigit,
|
|
39
|
+
_Char___init__impl__6a9atx367vrx0avsvbg as _Char___init__impl__6a9atx,
|
|
39
40
|
initMetadataForObject1cxne3s9w65el as initMetadataForObject,
|
|
40
41
|
} from './kotlin-kotlin-stdlib.mjs';
|
|
41
42
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
43
|
+
LanguageEmitterxhzgykhux3qm as LanguageEmitter,
|
|
44
|
+
Companion_instance2ag0h5twtdral as Companion_instance,
|
|
45
|
+
Companion_instance26a9xkw31611z as Companion_instance_0,
|
|
59
46
|
FileExtension_Python_getInstancenly5nzbfq5gh as FileExtension_Python_getInstance,
|
|
60
47
|
Channel2rnyzzgwpojjq as Channel,
|
|
61
48
|
Endpoint1dn4dd2eg1gxz as Endpoint,
|
|
@@ -66,133 +53,154 @@ import {
|
|
|
66
53
|
Emitted12h24rpo4uifw as Emitted,
|
|
67
54
|
Model25ic6t0badh93 as Model,
|
|
68
55
|
plus2csvv9vgnno78 as plus,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
Spacer_instancel9yep7i0q3er as Spacer_instance,
|
|
57
|
+
get_indexedPathParams3mii47g6wg9rv as get_indexedPathParams,
|
|
58
|
+
orNull2zq556ke3x99j as orNull,
|
|
59
|
+
spacer28p2fwyb64afn as spacer,
|
|
60
|
+
paramList32w7ar4yzhgjr as paramList,
|
|
61
|
+
ParamType_PATH_getInstancehry2hy8gijqh as ParamType_PATH_getInstance,
|
|
62
|
+
ParamType_QUERY_getInstancemt9ylhb8dip2 as ParamType_QUERY_getInstance,
|
|
63
|
+
ParamType_HEADER_getInstance2opzs1jd0w03k as ParamType_HEADER_getInstance,
|
|
64
|
+
paramListu5lifi5jaaet as paramList_0,
|
|
65
|
+
distinctByStatus27eirf52grddm as distinctByStatus,
|
|
66
|
+
Companion_instance2piryw1e8zn12 as Companion_instance_1,
|
|
67
|
+
Param33sus5zaarsk0 as Param,
|
|
68
|
+
Literal32wmkquj6qapn as Literal,
|
|
69
|
+
importReferences3pz8oxxe2hwhu as importReferences,
|
|
70
|
+
get_pathParams29rrc1msn3eoz as get_pathParams,
|
|
74
71
|
FieldIdentifier2fnn30qixmpf as FieldIdentifier,
|
|
75
72
|
DefinitionIdentifier21mzme854zakh as DefinitionIdentifier,
|
|
76
73
|
Bytes_instance1at7binw0nl40 as Bytes_instance,
|
|
77
74
|
Boolean_instance3qnzv8pgzox40 as Boolean_instance,
|
|
78
75
|
RegExp1kvu7kxwy7td5 as RegExp_0,
|
|
76
|
+
String23kqvhe3sk098 as String_0,
|
|
77
|
+
Number3i05nlui0wcz8 as Number_0,
|
|
78
|
+
Integeryrcje1s9u7kr as Integer,
|
|
79
|
+
Primitivexjb7c0cm123a as Primitive,
|
|
80
|
+
Custom37hvrfgd6b0uj as Custom,
|
|
81
|
+
Any268baxyo9do19 as Any,
|
|
82
|
+
Unit3rie819ih39bz as Unit,
|
|
83
|
+
Iterablerto606wd057m as Iterable,
|
|
84
|
+
Dict3l6tdihpke4rr as Dict,
|
|
85
|
+
Bytes2moci2lqqzua3 as Bytes,
|
|
86
|
+
Boolean1v54w5v4qjba1 as Boolean_0,
|
|
79
87
|
Bound1dotva4vah4jp as Bound,
|
|
80
88
|
_RegExp___get_value__impl__7o761828ey0cgsx2afa as _RegExp___get_value__impl__7o7618,
|
|
89
|
+
TypeDefinitionEmitter18est4d94fpw8 as TypeDefinitionEmitter,
|
|
81
90
|
} from './wirespec-src-compiler-core.mjs';
|
|
82
91
|
import { toNonEmptyListOrNull2ovnnazjb3msz as toNonEmptyListOrNull } from './arrow-arrow-core.mjs';
|
|
83
92
|
//region block: imports
|
|
84
93
|
//endregion
|
|
85
94
|
//region block: pre-declaration
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
initMetadataForClass(PythonEmitter, 'PythonEmitter', PythonEmitter, Emitter);
|
|
89
|
-
initMetadataForObject(PythonShared, 'PythonShared');
|
|
90
|
-
//endregion
|
|
91
|
-
function emitReferenceCustomImports(_this__u8e3s4, $this) {
|
|
92
|
-
return 'from ..model.' + _this__u8e3s4.h29_1 + ' import ' + _this__u8e3s4.h29_1;
|
|
93
|
-
}
|
|
94
|
-
function emit(_this__u8e3s4, $this) {
|
|
95
|
-
return $this.s24(_this__u8e3s4.o26_1) + ': ' + $this.w25(_this__u8e3s4.p26_1);
|
|
96
|
-
}
|
|
97
|
-
function emit_0(_this__u8e3s4, $this) {
|
|
98
|
-
return $this.s24(_this__u8e3s4.f27_1) + ': ' + $this.w25(_this__u8e3s4.g27_1);
|
|
95
|
+
function emit(channel) {
|
|
96
|
+
return '';
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
initMetadataForInterface(PythonChannelDefinitionEmitter, 'PythonChannelDefinitionEmitter');
|
|
99
|
+
initMetadataForClass(sam$kotlin_Comparator$0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
|
|
100
|
+
function emit_0(identifier) {
|
|
101
|
+
var tmp;
|
|
102
|
+
if (identifier instanceof DefinitionIdentifier) {
|
|
103
|
+
tmp = this.c2a(identifier);
|
|
104
|
+
} else {
|
|
105
|
+
if (identifier instanceof FieldIdentifier) {
|
|
106
|
+
tmp = this.e2a(this.c2a(identifier));
|
|
107
|
+
} else {
|
|
108
|
+
noWhenBranchMatchedException();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return tmp;
|
|
102
112
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
// Inline function 'kotlin.
|
|
106
|
-
// Inline function 'kotlin.collections.
|
|
107
|
-
var this_0 =
|
|
108
|
-
|
|
113
|
+
function sanitize(_this__u8e3s4) {
|
|
114
|
+
// Inline function 'kotlin.let' call
|
|
115
|
+
// Inline function 'kotlin.text.filter' call
|
|
116
|
+
// Inline function 'kotlin.collections.mapIndexed' call
|
|
117
|
+
var this_0 = split(_this__u8e3s4.b1(), ['.', ' ']);
|
|
118
|
+
// Inline function 'kotlin.collections.mapIndexedTo' call
|
|
119
|
+
var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
|
|
120
|
+
var index = 0;
|
|
109
121
|
var tmp0_iterator = this_0.g();
|
|
110
122
|
while (tmp0_iterator.h()) {
|
|
111
|
-
var
|
|
112
|
-
// Inline function 'community.flock.wirespec.emitters.python.
|
|
113
|
-
|
|
114
|
-
|
|
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.s24(endpoint.h25_1);
|
|
120
|
-
// Inline function 'kotlin.collections.filter' call
|
|
121
|
-
// Inline function 'kotlin.collections.filterTo' call
|
|
122
|
-
var this_1 = $this.e26(_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.e27_1.equals(ParamType_QUERY_getInstance())) {
|
|
129
|
-
destination_0.e(element_0);
|
|
130
|
-
}
|
|
123
|
+
var item = tmp0_iterator.i();
|
|
124
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonIdentifierEmitter.sanitize.<anonymous>' call
|
|
125
|
+
var tmp1 = index;
|
|
126
|
+
index = tmp1 + 1 | 0;
|
|
127
|
+
var tmp$ret$0 = checkIndexOverflow(tmp1) > 0 ? Companion_instance_1.x25(item) : item;
|
|
128
|
+
destination.e(tmp$ret$0);
|
|
131
129
|
}
|
|
132
|
-
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
// Inline function 'kotlin.text.filterTo' call
|
|
131
|
+
var this_1 = joinToString(destination, '');
|
|
132
|
+
var destination_0 = StringBuilder_init_$Create$();
|
|
133
|
+
var inductionVariable = 0;
|
|
134
|
+
var last = charSequenceLength(this_1);
|
|
135
|
+
if (inductionVariable < last)
|
|
136
|
+
do {
|
|
137
|
+
var index_0 = inductionVariable;
|
|
138
|
+
inductionVariable = inductionVariable + 1 | 0;
|
|
139
|
+
var element = charSequenceGet(this_1, index_0);
|
|
140
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonIdentifierEmitter.sanitize.<anonymous>' call
|
|
141
|
+
if (isLetterOrDigit(element) || element === _Char___init__impl__6a9atx(95)) {
|
|
142
|
+
destination_0.z7(element);
|
|
143
|
+
}
|
|
145
144
|
}
|
|
145
|
+
while (inductionVariable < last);
|
|
146
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
147
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonIdentifierEmitter.sanitize.<anonymous>' call
|
|
148
|
+
var it = destination_0.toString();
|
|
149
|
+
var tmp;
|
|
150
|
+
var tmp0_safe_receiver = firstOrNull(it);
|
|
151
|
+
var tmp_0;
|
|
152
|
+
var tmp_1 = tmp0_safe_receiver;
|
|
153
|
+
if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
|
|
154
|
+
tmp_0 = null;
|
|
155
|
+
} else {
|
|
156
|
+
tmp_0 = isDigit(tmp0_safe_receiver);
|
|
146
157
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var tmp_8;
|
|
150
|
-
if (_this__u8e3s4.x26_1 == null) {
|
|
151
|
-
tmp_8 = null;
|
|
158
|
+
if (tmp_0 === true) {
|
|
159
|
+
tmp = '_' + it;
|
|
152
160
|
} else {
|
|
153
|
-
|
|
154
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
155
|
-
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emitAssignSelf.<anonymous>' call
|
|
156
|
-
tmp_8 = 'body';
|
|
161
|
+
tmp = it;
|
|
157
162
|
}
|
|
158
|
-
|
|
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 ');
|
|
163
|
+
return tmp;
|
|
160
164
|
}
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
destination.e(element);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
var tmp_0 = destination;
|
|
176
|
-
var tmp_1 = $this.g26(joinToString(tmp_0, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitAssignSelf$lambda_2($this)), 1);
|
|
177
|
-
var tmp_2;
|
|
178
|
-
if (_this__u8e3s4.t26_1 == null) {
|
|
179
|
-
tmp_2 = null;
|
|
165
|
+
function sanitizeKeywords(_this__u8e3s4) {
|
|
166
|
+
return Companion_getInstance().a2c_1.o1(_this__u8e3s4) ? '_' + _this__u8e3s4 : _this__u8e3s4;
|
|
167
|
+
}
|
|
168
|
+
initMetadataForInterface(PythonIdentifierEmitter, 'PythonIdentifierEmitter');
|
|
169
|
+
function emit_1(type, module_0) {
|
|
170
|
+
var tmp;
|
|
171
|
+
if (type.i24_1.f24_1.l()) {
|
|
172
|
+
var tmp_0 = this.f26(type.h24_1);
|
|
173
|
+
var tmp_1 = Spacer_instance.toString();
|
|
174
|
+
var tmp_2 = importReferences(type);
|
|
175
|
+
tmp = trimMargin('\n |@dataclass\n |class ' + tmp_0 + ':\n |' + tmp_1 + 'pass\n |\n |' + joinToString(tmp_2, '\n', VOID, VOID, VOID, VOID, PythonTypeDefinitionEmitter$emit$lambda(this)) + '\n |\n ');
|
|
180
176
|
} else {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
177
|
+
var tmp_3 = this.f26(type.h24_1);
|
|
178
|
+
var tmp_4 = this.e25(type.i24_1);
|
|
179
|
+
var tmp_5 = importReferences(type);
|
|
180
|
+
tmp = trimMargin('\n |@dataclass\n |class ' + tmp_3 + ':\n |' + tmp_4 + '\n |\n |' + joinToString(tmp_5, '\n', VOID, VOID, VOID, VOID, PythonTypeDefinitionEmitter$emit$lambda_0(this)) + '\n ');
|
|
185
181
|
}
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
return tmp;
|
|
183
|
+
}
|
|
184
|
+
function emit_2(_this__u8e3s4) {
|
|
185
|
+
return joinToString(_this__u8e3s4.f24_1, '\n', VOID, VOID, VOID, VOID, PythonTypeDefinitionEmitter$emit$lambda_1(this));
|
|
186
|
+
}
|
|
187
|
+
function emit_3(_this__u8e3s4) {
|
|
188
|
+
return this.f26(_this__u8e3s4.l24_1) + ": '" + this.g25(_this__u8e3s4.m24_1) + "'";
|
|
189
|
+
}
|
|
190
|
+
function emit_4(_this__u8e3s4) {
|
|
191
|
+
// Inline function 'kotlin.let' call
|
|
192
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
193
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonTypeDefinitionEmitter.emit.<anonymous>' call
|
|
194
|
+
var it = this.y2b(_this__u8e3s4);
|
|
195
|
+
return _this__u8e3s4.hm() ? 'Optional[' + it + ']' : it;
|
|
188
196
|
}
|
|
189
|
-
function emitType(_this__u8e3s4
|
|
197
|
+
function emitType(_this__u8e3s4) {
|
|
190
198
|
var tmp;
|
|
191
199
|
if (_this__u8e3s4 instanceof Dict) {
|
|
192
|
-
tmp = 'Dict[str, ' +
|
|
200
|
+
tmp = 'Dict[str, ' + this.g25(_this__u8e3s4.r23_1) + ']';
|
|
193
201
|
} else {
|
|
194
202
|
if (_this__u8e3s4 instanceof Iterable) {
|
|
195
|
-
tmp = 'List[' +
|
|
203
|
+
tmp = 'List[' + this.g25(_this__u8e3s4.o23_1) + ']';
|
|
196
204
|
} else {
|
|
197
205
|
if (_this__u8e3s4 instanceof Unit) {
|
|
198
206
|
tmp = 'None';
|
|
@@ -201,10 +209,10 @@ function emitType(_this__u8e3s4, $this) {
|
|
|
201
209
|
tmp = 'Any';
|
|
202
210
|
} else {
|
|
203
211
|
if (_this__u8e3s4 instanceof Custom) {
|
|
204
|
-
tmp = _this__u8e3s4.
|
|
212
|
+
tmp = _this__u8e3s4.w28_1;
|
|
205
213
|
} else {
|
|
206
214
|
if (_this__u8e3s4 instanceof Primitive) {
|
|
207
|
-
tmp =
|
|
215
|
+
tmp = this.w2b(_this__u8e3s4.a29_1);
|
|
208
216
|
} else {
|
|
209
217
|
noWhenBranchMatchedException();
|
|
210
218
|
}
|
|
@@ -215,201 +223,105 @@ function emitType(_this__u8e3s4, $this) {
|
|
|
215
223
|
}
|
|
216
224
|
return tmp;
|
|
217
225
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return trimMargin('\n |class Handler(Wirespec.Endpoint.Handler):\n |' + Spacer_instance.toString() + '@abstractmethod\n |' + Spacer_instance.toString() + 'def ' + _this__u8e3s4.h25_1.b1() + "(self, req: '" + $this.s24(_this__u8e3s4.h25_1) + ".Request') -> '" + $this.s24(_this__u8e3s4.h25_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.g26(emitToRawRequest(first(_this__u8e3s4.m25_1), $this, _this__u8e3s4), 1) + '\n |' + $this.g26(emitFromRawRequest(first(_this__u8e3s4.m25_1), $this, _this__u8e3s4), 1) + '\n |' + $this.g26(emitToRawResponse(_this__u8e3s4, $this), 1) + '\n |' + $this.g26(emitFromRawResponse(_this__u8e3s4, $this), 1) + '\n |\n ');
|
|
226
|
-
}
|
|
227
|
-
function emitToRawRequest(_this__u8e3s4, $this, endpoint) {
|
|
228
|
-
var tmp = $this.s24(endpoint.h25_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.j25_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.k25_1.l()) {
|
|
240
|
-
tmp_8 = joinToString(endpoint.k25_1, ',\n', '{', '}', VOID, VOID, PythonEmitter$emitToRawRequest$lambda_0($this));
|
|
226
|
+
function emit_5(_this__u8e3s4) {
|
|
227
|
+
var tmp;
|
|
228
|
+
if (_this__u8e3s4 instanceof String_0) {
|
|
229
|
+
tmp = 'str';
|
|
241
230
|
} else {
|
|
242
|
-
|
|
231
|
+
if (_this__u8e3s4 instanceof Integer) {
|
|
232
|
+
tmp = 'int';
|
|
233
|
+
} else {
|
|
234
|
+
if (_this__u8e3s4 instanceof Number_0) {
|
|
235
|
+
tmp = 'float';
|
|
236
|
+
} else {
|
|
237
|
+
if (_this__u8e3s4 instanceof Boolean_0) {
|
|
238
|
+
tmp = 'bool';
|
|
239
|
+
} else {
|
|
240
|
+
if (_this__u8e3s4 instanceof Bytes) {
|
|
241
|
+
tmp = 'bytes';
|
|
242
|
+
} else {
|
|
243
|
+
noWhenBranchMatchedException();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
243
248
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
tmp_12 = joinToString(endpoint.l25_1, ',\n', '{', '}', VOID, VOID, PythonEmitter$emitToRawRequest$lambda_1($this));
|
|
249
|
+
return tmp;
|
|
250
|
+
}
|
|
251
|
+
function emit_6(_this__u8e3s4) {
|
|
252
|
+
var tmp;
|
|
253
|
+
if (_this__u8e3s4 instanceof RegExp_0) {
|
|
254
|
+
tmp = Spacer_instance.toString() + 'bool(re.match(r"' + _RegExp___get_value__impl__7o7618(_this__u8e3s4.a28_1) + '", self.value))';
|
|
251
255
|
} else {
|
|
252
|
-
|
|
256
|
+
if (_this__u8e3s4 instanceof Bound) {
|
|
257
|
+
tmp = Spacer_instance.toString() + _this__u8e3s4.b28_1 + ' < record.value < ' + _this__u8e3s4.c28_1 + ';';
|
|
258
|
+
} else {
|
|
259
|
+
noWhenBranchMatchedException();
|
|
260
|
+
}
|
|
253
261
|
}
|
|
254
|
-
|
|
255
|
-
var tmp_14 = Spacer_instance.toString();
|
|
256
|
-
var tmp_15 = Spacer_instance.toString();
|
|
257
|
-
var tmp0_safe_receiver = _this__u8e3s4.x26_1;
|
|
258
|
-
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.z26_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 ');
|
|
262
|
+
return tmp;
|
|
261
263
|
}
|
|
262
|
-
function
|
|
263
|
-
return
|
|
264
|
+
function emitReferenceCustomImports(_this__u8e3s4) {
|
|
265
|
+
return 'from ..model.' + _this__u8e3s4.w28_1 + ' import ' + _this__u8e3s4.w28_1;
|
|
264
266
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var tmp_0 = orNull(joinToString(tmp, VOID, VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda($this)));
|
|
269
|
-
var tmp_1 = orNull(joinToString(endpoint.k25_1, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda_0($this)));
|
|
270
|
-
var tmp_2 = orNull(joinToString(endpoint.l25_1, ',\n', VOID, VOID, VOID, VOID, PythonEmitter$emitDeserializedParams$lambda_1($this)));
|
|
271
|
-
var tmp0_safe_receiver = _this__u8e3s4.x26_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.i27(3) + 'body = serialization.deserialize(request.body, ' + emitType(tmp0_safe_receiver.z26_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.i27(3) + $this.s24(_this__u8e3s4.rd_1.o26_1) + ' = serialization.deserialize(request.path[' + _this__u8e3s4.qd_1 + '], ' + emitType(_this__u8e3s4.rd_1.p26_1, $this) + ')';
|
|
288
|
-
}
|
|
289
|
-
function emitDeserializedParams_0(_this__u8e3s4, $this, type, fields) {
|
|
290
|
-
return $this.s24(_this__u8e3s4.v26_1) + ' = serialization.deserialize_param(' + type + '.' + fields + '.get("' + _this__u8e3s4.v26_1.b1() + '".lower()), ' + emitType(_this__u8e3s4.w26_1, $this) + ')';
|
|
291
|
-
}
|
|
292
|
-
function emitToRawResponse(_this__u8e3s4, $this) {
|
|
293
|
-
var tmp = $this.s24(_this__u8e3s4.h25_1);
|
|
294
|
-
var tmp_0 = Spacer_instance.toString();
|
|
295
|
-
var tmp_1 = $this.l26(_this__u8e3s4.n25_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.g26(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.s24(_this__u8e3s4.h25_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.l26(_this__u8e3s4.n25_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.e24(element.r26_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.g26(joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, PythonEmitter$emitFromRawResponse$lambda($this, _this__u8e3s4)), 2) + '\n |' + Spacer_instance.i27(2) + 'case _:\n |' + Spacer_instance.i27(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.r26_1 + ':';
|
|
318
|
-
var tmp_0 = Spacer_instance.toString() + 'return ' + $this.s24(endpoint.h25_1) + '.Response' + _this__u8e3s4.r26_1 + '(';
|
|
319
|
-
var tmp_1 = Spacer_instance.i27(2);
|
|
320
|
-
var tmp0_safe_receiver = _this__u8e3s4.t26_1;
|
|
321
|
-
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.z26_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.s26_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.g26(tmp3_safe_receiver, 2), Spacer_instance.toString() + ')']), '\n');
|
|
326
|
-
}
|
|
327
|
-
function emitSerialized(_this__u8e3s4, $this, endpoint) {
|
|
328
|
-
var tmp = $this.s24(endpoint.h25_1);
|
|
329
|
-
var tmp_0 = Spacer_instance.i27(1);
|
|
330
|
-
var tmp_1 = Spacer_instance.i27(2);
|
|
331
|
-
var tmp_2 = Spacer_instance.i27(2);
|
|
332
|
-
var tmp_3;
|
|
333
|
-
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
334
|
-
if (!_this__u8e3s4.s26_1.l()) {
|
|
335
|
-
tmp_3 = joinToString(_this__u8e3s4.s26_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.i27(2);
|
|
341
|
-
var tmp0_safe_receiver = _this__u8e3s4.t26_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.z26_1, $this) + ')';
|
|
350
|
-
}
|
|
351
|
-
var tmp1_elvis_lhs = tmp_6;
|
|
352
|
-
return trimMargin('\n |case ' + tmp + '.Response' + _this__u8e3s4.r26_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.i27(1) + ')\n ');
|
|
267
|
+
initMetadataForInterface(PythonTypeDefinitionEmitter, 'PythonTypeDefinitionEmitter', VOID, VOID, [TypeDefinitionEmitter, PythonIdentifierEmitter]);
|
|
268
|
+
function emit_7(refined) {
|
|
269
|
+
return trimMargin('\n |@dataclass\n |class ' + this.c2a(refined.j26_1) + '(Wirespec.Refined):\n |' + Spacer_instance.toString() + 'value: str\n |\n |' + Spacer_instance.toString() + 'def validate(self) -> bool:\n |' + Spacer_instance.x26(2) + 'return ' + this.r26(refined) + '\n |\n |' + Spacer_instance.toString() + 'def __str__(self) -> str:\n |' + Spacer_instance.x26(2) + 'return self.value\n ');
|
|
353
270
|
}
|
|
354
|
-
function
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
function emitObject(_this__u8e3s4, $this, name, extends_0, spaces, block) {
|
|
271
|
+
function emitValidator(_this__u8e3s4) {
|
|
272
|
+
var defaultReturn = 'true';
|
|
273
|
+
var type = _this__u8e3s4.k26_1.a29_1;
|
|
358
274
|
var tmp;
|
|
359
|
-
if (
|
|
360
|
-
|
|
275
|
+
if (type instanceof Integer) {
|
|
276
|
+
var tmp0_safe_receiver = type.g28_1;
|
|
277
|
+
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : this.h25(tmp0_safe_receiver);
|
|
278
|
+
tmp = tmp1_elvis_lhs == null ? defaultReturn : tmp1_elvis_lhs;
|
|
361
279
|
} else {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
280
|
+
if (type instanceof Number_0) {
|
|
281
|
+
var tmp2_safe_receiver = type.j28_1;
|
|
282
|
+
var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : this.h25(tmp2_safe_receiver);
|
|
283
|
+
tmp = tmp3_elvis_lhs == null ? defaultReturn : tmp3_elvis_lhs;
|
|
284
|
+
} else {
|
|
285
|
+
if (type instanceof String_0) {
|
|
286
|
+
var tmp4_safe_receiver = type.d28_1;
|
|
287
|
+
var tmp_0;
|
|
288
|
+
var tmp_1 = tmp4_safe_receiver;
|
|
289
|
+
if ((tmp_1 == null ? null : new RegExp_0(tmp_1)) == null) {
|
|
290
|
+
tmp_0 = null;
|
|
291
|
+
} else {
|
|
292
|
+
tmp_0 = this.h25(new RegExp_0(tmp4_safe_receiver));
|
|
293
|
+
}
|
|
294
|
+
var tmp5_elvis_lhs = tmp_0;
|
|
295
|
+
tmp = tmp5_elvis_lhs == null ? defaultReturn : tmp5_elvis_lhs;
|
|
296
|
+
} else {
|
|
297
|
+
if (equals(type, Boolean_instance)) {
|
|
298
|
+
tmp = defaultReturn;
|
|
299
|
+
} else {
|
|
300
|
+
if (equals(type, Bytes_instance)) {
|
|
301
|
+
tmp = defaultReturn;
|
|
302
|
+
} else {
|
|
303
|
+
noWhenBranchMatchedException();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
365
308
|
}
|
|
366
309
|
return tmp;
|
|
367
310
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return
|
|
311
|
+
initMetadataForInterface(PythonRefinedTypeDefinitionEmitter, 'PythonRefinedTypeDefinitionEmitter', VOID, VOID, [PythonTypeDefinitionEmitter, PythonIdentifierEmitter]);
|
|
312
|
+
function emit_8(union) {
|
|
313
|
+
return trimMargin('\n |class ' + this.f26(union.d24_1) + '(ABC):\n |' + Spacer_instance.toString() + 'pass\n ');
|
|
371
314
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
var
|
|
375
|
-
return
|
|
315
|
+
initMetadataForInterface(PythonUnionDefinitionEmitter, 'PythonUnionDefinitionEmitter', VOID, VOID, [PythonIdentifierEmitter]);
|
|
316
|
+
function emit_9(enum_0, module_0) {
|
|
317
|
+
var tmp = this.c2a(enum_0.n26_1);
|
|
318
|
+
return trimMargin('\n |class ' + tmp + '(str, Enum):\n |' + joinToString(enum_0.o26_1, '\n', VOID, VOID, VOID, VOID, PythonEnumDefinitionEmitter$emit$lambda(this)) + '\n |\n |' + Spacer_instance.toString() + '@property\n |' + Spacer_instance.toString() + 'def label(self) -> str:\n |' + Spacer_instance.x26(2) + 'return self.value\n |\n |' + Spacer_instance.toString() + 'def __str__(self) -> str:\n |' + Spacer_instance.x26(2) + 'return self.value\n ');
|
|
376
319
|
}
|
|
377
|
-
function
|
|
320
|
+
function sanitizeEnum(_this__u8e3s4) {
|
|
378
321
|
// 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.z23(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
322
|
// Inline function 'kotlin.contracts.contract' call
|
|
411
|
-
// Inline function 'community.flock.wirespec.emitters.python.
|
|
412
|
-
var it =
|
|
323
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEnumDefinitionEmitter.sanitizeEnum.<anonymous>' call
|
|
324
|
+
var it = joinToString(split(_this__u8e3s4, ['-', ', ', '.', ' ', '//']), '_');
|
|
413
325
|
var tmp;
|
|
414
326
|
var tmp0_safe_receiver = firstOrNull(it);
|
|
415
327
|
var tmp_0;
|
|
@@ -426,28 +338,86 @@ function sanitizeSymbol(_this__u8e3s4, $this) {
|
|
|
426
338
|
}
|
|
427
339
|
return tmp;
|
|
428
340
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
341
|
+
initMetadataForInterface(PythonEnumDefinitionEmitter, 'PythonEnumDefinitionEmitter', VOID, VOID, [PythonIdentifierEmitter]);
|
|
342
|
+
function emit_10(endpoint) {
|
|
343
|
+
var tmp = importReferences(endpoint);
|
|
344
|
+
var tmp_0 = joinToString(tmp, '\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emit$lambda(this));
|
|
345
|
+
var tmp_1 = this.f26(endpoint.o24_1);
|
|
346
|
+
var tmp_2 = spacer(this.o2a(first(endpoint.t24_1), endpoint), 1);
|
|
347
|
+
var tmp_3 = distinctByStatus(endpoint.u24_1);
|
|
348
|
+
return trimMargin('\n |' + tmp_0 + '\n |\n |class ' + tmp_1 + ' (Wirespec.Endpoint):\n |' + tmp_2 + '\n |' + spacer(joinToString(tmp_3, '\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emit$lambda_0(this, endpoint)), 1) + '\n |' + spacer(emitResponseUnion(endpoint, this), 1) + '\n |' + spacer(emitHandleClass(endpoint, this), 1) + '\n |' + spacer(emitConvertClass(endpoint, this), 1) + '\n |\n ');
|
|
433
349
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
350
|
+
function emit_11(_this__u8e3s4, endpoint) {
|
|
351
|
+
var tmp = emit_15(_this__u8e3s4.x24_1, this);
|
|
352
|
+
var tmp_0 = get_pathParams(endpoint);
|
|
353
|
+
var tmp_1 = emitObject$default(tmp_0, this, 'Path', 'Wirespec.Request.Path', VOID, PythonEndpointDefinitionEmitter$emit$lambda_1(this));
|
|
354
|
+
var tmp_2 = emitObject$default(endpoint.r24_1, this, 'Queries', 'Wirespec.Request.Queries', VOID, PythonEndpointDefinitionEmitter$emit$lambda_2(this));
|
|
355
|
+
var tmp_3 = emitObject$default(endpoint.s24_1, this, 'Headers', 'Wirespec.Request.Headers', VOID, PythonEndpointDefinitionEmitter$emit$lambda_3(this));
|
|
356
|
+
var tmp_4 = Spacer_instance.toString();
|
|
357
|
+
var tmp_5 = Spacer_instance.toString();
|
|
358
|
+
var tmp_6 = emit_15(_this__u8e3s4.x24_1, this);
|
|
359
|
+
var tmp_7 = Spacer_instance.toString();
|
|
360
|
+
var tmp_8 = Spacer_instance.toString();
|
|
361
|
+
var tmp_9 = Spacer_instance.toString();
|
|
362
|
+
var tmp_10 = Spacer_instance.toString();
|
|
363
|
+
var tmp_11 = Spacer_instance.toString();
|
|
364
|
+
var tmp_12 = Spacer_instance.toString();
|
|
365
|
+
var tmp_13 = Spacer_instance.toString();
|
|
366
|
+
var tmp_14 = Spacer_instance.toString();
|
|
367
|
+
var tmp_15 = Spacer_instance.toString();
|
|
368
|
+
var tmp_16 = Spacer_instance.toString();
|
|
369
|
+
var tmp_17 = Spacer_instance.toString();
|
|
370
|
+
var tmp_18 = Spacer_instance.toString();
|
|
371
|
+
var tmp_19 = Spacer_instance.toString();
|
|
372
|
+
var tmp_20 = Spacer_instance.toString();
|
|
373
|
+
var tmp_21 = Spacer_instance.toString();
|
|
374
|
+
var tmp_22 = emit_15(_this__u8e3s4.x24_1, this);
|
|
375
|
+
var tmp_23 = Spacer_instance.toString();
|
|
376
|
+
var tmp_24 = Spacer_instance.toString();
|
|
377
|
+
var tmp_25 = Spacer_instance.toString();
|
|
378
|
+
var tmp_26 = Spacer_instance.toString();
|
|
379
|
+
var tmp_27 = Spacer_instance.toString();
|
|
380
|
+
var tmp_28 = paramList(_this__u8e3s4, endpoint);
|
|
381
|
+
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.p24_1.q2_1 + '\n |\n |' + tmp_27 + 'def __init__(self, ' + joinToString(tmp_28, ', ', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emit$lambda_4(this)) + '):\n |' + spacer(emitAssignSelf_0(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
382
|
+
}
|
|
383
|
+
function emit_12(_this__u8e3s4, endpoint) {
|
|
384
|
+
var tmp = emit_15(_this__u8e3s4.c25_1, this);
|
|
385
|
+
var tmp_0 = emitObject$default(_this__u8e3s4.b25_1, this, 'Headers', 'Wirespec.Response.Headers', VOID, PythonEndpointDefinitionEmitter$emit$lambda_5(this));
|
|
386
|
+
var tmp_1 = Spacer_instance.toString();
|
|
387
|
+
var tmp_2 = Spacer_instance.toString();
|
|
388
|
+
var tmp_3 = Spacer_instance.toString();
|
|
389
|
+
var tmp_4 = Spacer_instance.toString();
|
|
390
|
+
var tmp_5 = Spacer_instance.toString();
|
|
391
|
+
var tmp_6 = Spacer_instance.toString();
|
|
392
|
+
var tmp_7 = emit_15(_this__u8e3s4.c25_1, this);
|
|
393
|
+
var tmp_8 = Spacer_instance.toString();
|
|
394
|
+
var tmp_9 = Spacer_instance.toString();
|
|
395
|
+
var tmp_10 = Spacer_instance.toString();
|
|
396
|
+
var tmp_11 = emit_15(_this__u8e3s4.c25_1, this);
|
|
397
|
+
var tmp_12 = Spacer_instance.toString();
|
|
398
|
+
var tmp_13 = Spacer_instance.toString();
|
|
399
|
+
var tmp_14 = Spacer_instance.toString();
|
|
400
|
+
var tmp_15 = paramList_0(_this__u8e3s4);
|
|
401
|
+
return trimMargin('\n |@dataclass\n |class Response' + _this__u8e3s4.a25_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.a25_1 + '\n |\n |' + tmp_14 + 'def __init__(self, ' + joinToString(tmp_15, ', ', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emit$lambda_6(this)) + '):\n |' + spacer(emitAssignSelf_1(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
402
|
+
}
|
|
403
|
+
initMetadataForInterface(PythonEndpointDefinitionEmitter, 'PythonEndpointDefinitionEmitter', VOID, VOID, [PythonTypeDefinitionEmitter]);
|
|
404
|
+
initMetadataForClass(PythonEmitter, 'PythonEmitter', PythonEmitter, LanguageEmitter, [LanguageEmitter, PythonRefinedTypeDefinitionEmitter, PythonUnionDefinitionEmitter, PythonTypeDefinitionEmitter, PythonIdentifierEmitter, PythonChannelDefinitionEmitter, PythonEnumDefinitionEmitter, PythonEndpointDefinitionEmitter]);
|
|
405
|
+
initMetadataForCompanion(Companion);
|
|
406
|
+
initMetadataForObject(PythonShared, 'PythonShared');
|
|
407
|
+
//endregion
|
|
408
|
+
function PythonChannelDefinitionEmitter() {
|
|
439
409
|
}
|
|
440
410
|
function sam$kotlin_Comparator$0(function_0) {
|
|
441
|
-
this.
|
|
411
|
+
this.m2b_1 = function_0;
|
|
442
412
|
}
|
|
443
413
|
protoOf(sam$kotlin_Comparator$0).uc = function (a, b) {
|
|
444
|
-
return this.
|
|
414
|
+
return this.m2b_1(a, b);
|
|
445
415
|
};
|
|
446
416
|
protoOf(sam$kotlin_Comparator$0).compare = function (a, b) {
|
|
447
417
|
return this.uc(a, b);
|
|
448
418
|
};
|
|
449
419
|
protoOf(sam$kotlin_Comparator$0).p3 = function () {
|
|
450
|
-
return this.
|
|
420
|
+
return this.m2b_1;
|
|
451
421
|
};
|
|
452
422
|
protoOf(sam$kotlin_Comparator$0).equals = function (other) {
|
|
453
423
|
var tmp;
|
|
@@ -468,217 +438,68 @@ protoOf(sam$kotlin_Comparator$0).hashCode = function () {
|
|
|
468
438
|
return hashCode(this.p3());
|
|
469
439
|
};
|
|
470
440
|
function emit$_anonymous_$emitInit_7cggmt(this$0, def) {
|
|
471
|
-
return 'from .' + this$0.
|
|
441
|
+
return 'from .' + this$0.f26(def.d26()) + ' import ' + this$0.f26(def.d26());
|
|
472
442
|
}
|
|
473
443
|
function PythonEmitter$emit$lambda(this$0) {
|
|
474
444
|
return function (a, b) {
|
|
475
445
|
// Inline function 'kotlin.comparisons.compareValuesBy' call
|
|
476
|
-
var tmp = this$0.
|
|
477
|
-
var tmp$ret$1 = this$0.
|
|
446
|
+
var tmp = this$0.t2b(a);
|
|
447
|
+
var tmp$ret$1 = this$0.t2b(b);
|
|
478
448
|
return compareValues(tmp, tmp$ret$1);
|
|
479
449
|
};
|
|
480
450
|
}
|
|
481
|
-
function PythonEmitter
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
function PythonEmitter$emit$lambda_2(this$0) {
|
|
492
|
-
return function (it) {
|
|
493
|
-
return Spacer_instance.toString() + this$0.v25(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.i2c(it, $endpoint);
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
function PythonEmitter$emitResponseUnion$lambda(it) {
|
|
527
|
-
return 'Response' + it.r26_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.v25(it);
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
function PythonEmitter$emit$lambda_7(this$0) {
|
|
540
|
-
return function (it) {
|
|
541
|
-
return this$0.v25(it);
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
function PythonEmitter$emit$lambda_8(this$0) {
|
|
545
|
-
return function (it) {
|
|
546
|
-
return emit_0(it, this$0);
|
|
547
|
-
};
|
|
451
|
+
function PythonEmitter(packageName, emitShared) {
|
|
452
|
+
packageName = packageName === VOID ? Companion_instance.s26('community.flock.wirespec.generated') : packageName;
|
|
453
|
+
emitShared = emitShared === VOID ? Companion_instance_0.v23() : emitShared;
|
|
454
|
+
LanguageEmitter.call(this);
|
|
455
|
+
this.n2b_1 = packageName;
|
|
456
|
+
this.o2b_1 = emitShared;
|
|
457
|
+
this.p2b_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';
|
|
458
|
+
this.q2b_1 = FileExtension_Python_getInstance();
|
|
459
|
+
this.r2b_1 = PythonShared_instance;
|
|
460
|
+
this.s2b_1 = '#';
|
|
548
461
|
}
|
|
549
|
-
function
|
|
550
|
-
return
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
462
|
+
protoOf(PythonEmitter).n25 = function () {
|
|
463
|
+
return this.q2b_1;
|
|
464
|
+
};
|
|
465
|
+
protoOf(PythonEmitter).l2a = function () {
|
|
466
|
+
return this.r2b_1;
|
|
467
|
+
};
|
|
468
|
+
protoOf(PythonEmitter).o25 = function () {
|
|
469
|
+
return this.s2b_1;
|
|
470
|
+
};
|
|
471
|
+
protoOf(PythonEmitter).t2b = function (definition) {
|
|
472
|
+
var tmp;
|
|
473
|
+
if (definition instanceof Enum) {
|
|
474
|
+
tmp = 1;
|
|
475
|
+
} else {
|
|
476
|
+
if (definition instanceof Refined) {
|
|
477
|
+
tmp = 2;
|
|
554
478
|
} else {
|
|
555
|
-
if (
|
|
556
|
-
tmp =
|
|
479
|
+
if (definition instanceof Type) {
|
|
480
|
+
tmp = 3;
|
|
557
481
|
} else {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
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.v25(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.i27($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.v2a(this$0.u2a(it)) + ' = "' + it + '"';
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
function PythonEmitter(packageName, emitShared) {
|
|
630
|
-
Companion_getInstance();
|
|
631
|
-
packageName = packageName === VOID ? Companion_instance_0.a27('community.flock.wirespec.generated') : packageName;
|
|
632
|
-
emitShared = emitShared === VOID ? Companion_instance_1.v23() : emitShared;
|
|
633
|
-
Emitter.call(this);
|
|
634
|
-
this.x2b_1 = packageName;
|
|
635
|
-
this.y2b_1 = emitShared;
|
|
636
|
-
this.z2b_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.a2c_1 = FileExtension_Python_getInstance();
|
|
638
|
-
this.b2c_1 = PythonShared_instance;
|
|
639
|
-
this.c2c_1 = '#';
|
|
640
|
-
}
|
|
641
|
-
protoOf(PythonEmitter).k24 = function () {
|
|
642
|
-
return this.a2c_1;
|
|
643
|
-
};
|
|
644
|
-
protoOf(PythonEmitter).x2a = function () {
|
|
645
|
-
return this.b2c_1;
|
|
646
|
-
};
|
|
647
|
-
protoOf(PythonEmitter).b26 = function () {
|
|
648
|
-
return this.c2c_1;
|
|
649
|
-
};
|
|
650
|
-
protoOf(PythonEmitter).h2c = 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
|
-
}
|
|
482
|
+
if (definition instanceof Union) {
|
|
483
|
+
tmp = 4;
|
|
484
|
+
} else {
|
|
485
|
+
if (definition instanceof Endpoint) {
|
|
486
|
+
tmp = 5;
|
|
487
|
+
} else {
|
|
488
|
+
if (definition instanceof Channel) {
|
|
489
|
+
tmp = 6;
|
|
490
|
+
} else {
|
|
491
|
+
noWhenBranchMatchedException();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
674
495
|
}
|
|
675
496
|
}
|
|
676
497
|
}
|
|
677
498
|
return tmp;
|
|
678
499
|
};
|
|
679
|
-
protoOf(PythonEmitter).
|
|
500
|
+
protoOf(PythonEmitter).b26 = function (module_0, logger) {
|
|
680
501
|
// Inline function 'kotlin.collections.sortedBy' call
|
|
681
|
-
var this_0 = module_0.
|
|
502
|
+
var this_0 = module_0.m25_1;
|
|
682
503
|
// Inline function 'kotlin.comparisons.compareBy' call
|
|
683
504
|
var tmp = PythonEmitter$emit$lambda(this);
|
|
684
505
|
var tmp$ret$0 = new sam$kotlin_Comparator$0(tmp);
|
|
@@ -687,13 +508,13 @@ protoOf(PythonEmitter).g24 = function (module_0, logger) {
|
|
|
687
508
|
// Inline function 'kotlin.let' call
|
|
688
509
|
// Inline function 'kotlin.contracts.contract' call
|
|
689
510
|
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>' call
|
|
690
|
-
var it = protoOf(
|
|
691
|
-
var init = new Emitted(this.
|
|
692
|
-
var tmp_0 = this.
|
|
511
|
+
var it = protoOf(LanguageEmitter).b26.call(this, module_0.t27(VOID, statements), logger);
|
|
512
|
+
var init = new Emitted(this.n2b_1.v26() + '__init__', 'from . import model\nfrom . import endpoint\nfrom . import wirespec\n');
|
|
513
|
+
var tmp_0 = this.n2b_1.v26() + 'endpoint/' + '__init__';
|
|
693
514
|
// Inline function 'kotlin.collections.map' call
|
|
694
515
|
// Inline function 'kotlin.collections.filter' call
|
|
695
516
|
// Inline function 'kotlin.collections.filterTo' call
|
|
696
|
-
var this_1 = module_0.
|
|
517
|
+
var this_1 = module_0.m25_1;
|
|
697
518
|
var destination = ArrayList_init_$Create$();
|
|
698
519
|
var tmp0_iterator = this_1.g();
|
|
699
520
|
while (tmp0_iterator.h()) {
|
|
@@ -713,11 +534,11 @@ protoOf(PythonEmitter).g24 = function (module_0, logger) {
|
|
|
713
534
|
destination_0.e(tmp$ret$5);
|
|
714
535
|
}
|
|
715
536
|
var initEndpoint = new Emitted(tmp_0, joinToString(destination_0, '\n'));
|
|
716
|
-
var tmp_1 = this.
|
|
537
|
+
var tmp_1 = this.n2b_1.v26() + 'model/' + '__init__';
|
|
717
538
|
// Inline function 'kotlin.collections.map' call
|
|
718
539
|
// Inline function 'kotlin.collections.filter' call
|
|
719
540
|
// Inline function 'kotlin.collections.filterTo' call
|
|
720
|
-
var this_2 = module_0.
|
|
541
|
+
var this_2 = module_0.m25_1;
|
|
721
542
|
var destination_1 = ArrayList_init_$Create$();
|
|
722
543
|
var tmp0_iterator_1 = this_2.g();
|
|
723
544
|
while (tmp0_iterator_1.h()) {
|
|
@@ -737,241 +558,429 @@ protoOf(PythonEmitter).g24 = function (module_0, logger) {
|
|
|
737
558
|
destination_2.e(tmp$ret$11);
|
|
738
559
|
}
|
|
739
560
|
var initModel = new Emitted(tmp_1, joinToString(destination_2, '\n'));
|
|
740
|
-
var shared = new Emitted(this.
|
|
741
|
-
return this.
|
|
561
|
+
var shared = new Emitted(this.n2b_1.v26() + 'wirespec', this.l2a().v2b_1);
|
|
562
|
+
return this.o2b_1.w23_1 ? it.pk(init).pk(initEndpoint).pk(initModel).pk(shared) : it.pk(init);
|
|
742
563
|
};
|
|
743
|
-
protoOf(PythonEmitter).
|
|
744
|
-
var subPackageName = plus(this.
|
|
564
|
+
protoOf(PythonEmitter).c26 = function (definition, module_0, logger) {
|
|
565
|
+
var subPackageName = plus(this.n2b_1, definition);
|
|
745
566
|
// Inline function 'kotlin.let' call
|
|
746
567
|
// Inline function 'kotlin.contracts.contract' call
|
|
747
568
|
// Inline function 'community.flock.wirespec.emitters.python.PythonEmitter.emit.<anonymous>' call
|
|
748
|
-
var it = protoOf(
|
|
749
|
-
var tmp = subPackageName.
|
|
569
|
+
var it = protoOf(LanguageEmitter).c26.call(this, definition, module_0, logger);
|
|
570
|
+
var tmp = subPackageName.v26() + it.x23_1;
|
|
750
571
|
// Inline function 'kotlin.text.trimStart' call
|
|
751
|
-
var this_0 = trimMargin('\n |' + this.
|
|
572
|
+
var this_0 = trimMargin('\n |' + this.p2b_1 + '\n |' + it.y23_1 + '\n ');
|
|
752
573
|
var tmp$ret$0 = toString(trimStart(isCharSequence(this_0) ? this_0 : THROW_CCE()));
|
|
753
574
|
return new Emitted(tmp, tmp$ret$0);
|
|
754
575
|
};
|
|
755
|
-
|
|
756
|
-
var tmp;
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
576
|
+
function emitToRawRequest(_this__u8e3s4, $this, endpoint) {
|
|
577
|
+
var tmp = $this.f26(endpoint.o24_1);
|
|
578
|
+
var tmp_0 = Spacer_instance.toString();
|
|
579
|
+
var tmp_1 = Spacer_instance.toString();
|
|
580
|
+
var tmp_2 = Spacer_instance.toString();
|
|
581
|
+
var tmp_3 = joinToString(endpoint.q24_1, VOID, VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitToRawRequest$lambda($this));
|
|
582
|
+
var tmp_4 = Spacer_instance.toString();
|
|
583
|
+
var tmp_5 = Spacer_instance.toString();
|
|
584
|
+
var tmp_6 = Spacer_instance.toString();
|
|
585
|
+
var tmp_7 = Spacer_instance.toString();
|
|
586
|
+
var tmp_8;
|
|
587
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
588
|
+
if (!endpoint.r24_1.l()) {
|
|
589
|
+
tmp_8 = joinToString(endpoint.r24_1, ',\n', '{', '}', VOID, VOID, PythonEndpointDefinitionEmitter$emitToRawRequest$lambda_0($this));
|
|
762
590
|
} else {
|
|
763
|
-
|
|
764
|
-
var tmp_4 = this.u25(type.r25_1);
|
|
765
|
-
var tmp_5 = this.i26(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 ');
|
|
591
|
+
tmp_8 = '{}';
|
|
767
592
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
|
|
593
|
+
var tmp_9 = tmp_8;
|
|
594
|
+
var tmp_10 = Spacer_instance.toString();
|
|
595
|
+
var tmp_11 = Spacer_instance.toString();
|
|
596
|
+
var tmp_12;
|
|
597
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
598
|
+
if (!endpoint.s24_1.l()) {
|
|
599
|
+
tmp_12 = joinToString(endpoint.s24_1, ',\n', '{', '}', VOID, VOID, PythonEndpointDefinitionEmitter$emitToRawRequest$lambda_1($this));
|
|
600
|
+
} else {
|
|
601
|
+
tmp_12 = '{}';
|
|
602
|
+
}
|
|
603
|
+
var tmp_13 = tmp_12;
|
|
604
|
+
var tmp_14 = Spacer_instance.toString();
|
|
605
|
+
var tmp_15 = Spacer_instance.toString();
|
|
606
|
+
var tmp0_safe_receiver = _this__u8e3s4.x24_1;
|
|
607
|
+
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.z24_1;
|
|
608
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : $this.y2b(tmp1_safe_receiver);
|
|
609
|
+
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 ');
|
|
610
|
+
}
|
|
611
|
+
function emitFromRawRequest(_this__u8e3s4, $this, endpoint) {
|
|
612
|
+
return trimMargin("\n |@staticmethod\n |def from_raw_request(serialization: Wirespec.Deserializer, request: Wirespec.RawRequest) -> '" + $this.f26(endpoint.o24_1) + ".Request':\n |" + Spacer_instance.toString() + 'return ' + $this.f26(endpoint.o24_1) + '.Request' + emitDeserializedParams(_this__u8e3s4, $this, endpoint) + '\n |\n ');
|
|
613
|
+
}
|
|
614
|
+
function emitDeserializedParams(_this__u8e3s4, $this, endpoint) {
|
|
777
615
|
// Inline function 'kotlin.let' call
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
var
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
tmp = 'str';
|
|
616
|
+
var tmp = get_indexedPathParams(endpoint);
|
|
617
|
+
var tmp_0 = orNull(joinToString(tmp, VOID, VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda($this)));
|
|
618
|
+
var tmp_1 = orNull(joinToString(endpoint.r24_1, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda_0($this)));
|
|
619
|
+
var tmp_2 = orNull(joinToString(endpoint.s24_1, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda_1($this)));
|
|
620
|
+
var tmp0_safe_receiver = _this__u8e3s4.x24_1;
|
|
621
|
+
var tmp_3;
|
|
622
|
+
if (tmp0_safe_receiver == null) {
|
|
623
|
+
tmp_3 = null;
|
|
787
624
|
} else {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
625
|
+
// Inline function 'kotlin.let' call
|
|
626
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
627
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitDeserializedParams.<anonymous>' call
|
|
628
|
+
tmp_3 = Spacer_instance.x26(3) + 'body = serialization.deserialize(request.body, ' + $this.y2b(tmp0_safe_receiver.z24_1) + '),';
|
|
629
|
+
}
|
|
630
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
631
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitDeserializedParams.<anonymous>' call
|
|
632
|
+
var it = joinToString(listOfNotNull([tmp_0, tmp_1, tmp_2, tmp_3]), ',\n');
|
|
633
|
+
return isBlank(it) ? '()' : '(\n' + it + '\n)';
|
|
634
|
+
}
|
|
635
|
+
function emitResponseUnion(_this__u8e3s4, $this) {
|
|
636
|
+
return trimMargin('\n |Response = ' + joinToString(_this__u8e3s4.u24_1, ' | ', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitResponseUnion$lambda) + '\n |\n ');
|
|
637
|
+
}
|
|
638
|
+
function emitHandleClass(_this__u8e3s4, $this) {
|
|
639
|
+
return trimMargin('\n |class Handler(Wirespec.Endpoint.Handler):\n |' + Spacer_instance.toString() + '@abstractmethod\n |' + Spacer_instance.toString() + 'def ' + _this__u8e3s4.o24_1.b1() + "(self, req: '" + $this.f26(_this__u8e3s4.o24_1) + ".Request') -> '" + $this.f26(_this__u8e3s4.o24_1) + ".Response': pass\n |\n ");
|
|
640
|
+
}
|
|
641
|
+
function emitConvertClass(_this__u8e3s4, $this) {
|
|
642
|
+
return trimMargin('\n |class Convert(Wirespec.Endpoint.Convert[Request, Response]):\n |' + spacer(emitToRawRequest(first(_this__u8e3s4.t24_1), $this, _this__u8e3s4), 1) + '\n |' + spacer(emitFromRawRequest(first(_this__u8e3s4.t24_1), $this, _this__u8e3s4), 1) + '\n |' + spacer(emitToRawResponse(_this__u8e3s4, $this), 1) + '\n |' + spacer(emitFromRawResponse(_this__u8e3s4, $this), 1) + '\n |\n ');
|
|
643
|
+
}
|
|
644
|
+
function emit_13(_this__u8e3s4, $this) {
|
|
645
|
+
return $this.f26(_this__u8e3s4.s25_1) + ': ' + $this.g25(_this__u8e3s4.t25_1);
|
|
646
|
+
}
|
|
647
|
+
function emitAssignSelf(_this__u8e3s4, $this) {
|
|
648
|
+
return $this.f26(_this__u8e3s4.s25_1) + ' = ' + $this.f26(_this__u8e3s4.s25_1);
|
|
649
|
+
}
|
|
650
|
+
function emitAssignSelf_0(_this__u8e3s4, $this, endpoint) {
|
|
651
|
+
var tmp = $this.f26(endpoint.o24_1);
|
|
652
|
+
// Inline function 'kotlin.collections.filter' call
|
|
653
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
654
|
+
var this_0 = paramList(_this__u8e3s4, endpoint);
|
|
655
|
+
var destination = ArrayList_init_$Create$();
|
|
656
|
+
var tmp0_iterator = this_0.g();
|
|
657
|
+
while (tmp0_iterator.h()) {
|
|
658
|
+
var element = tmp0_iterator.i();
|
|
659
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
660
|
+
if (element.r25_1.equals(ParamType_PATH_getInstance())) {
|
|
661
|
+
destination.e(element);
|
|
804
662
|
}
|
|
805
663
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
664
|
+
var tmp_0 = destination;
|
|
665
|
+
var tmp_1 = joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitAssignSelf$lambda($this));
|
|
666
|
+
var tmp_2 = $this.f26(endpoint.o24_1);
|
|
667
|
+
// Inline function 'kotlin.collections.filter' call
|
|
668
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
669
|
+
var this_1 = paramList(_this__u8e3s4, endpoint);
|
|
670
|
+
var destination_0 = ArrayList_init_$Create$();
|
|
671
|
+
var tmp0_iterator_0 = this_1.g();
|
|
672
|
+
while (tmp0_iterator_0.h()) {
|
|
673
|
+
var element_0 = tmp0_iterator_0.i();
|
|
674
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
675
|
+
if (element_0.r25_1.equals(ParamType_QUERY_getInstance())) {
|
|
676
|
+
destination_0.e(element_0);
|
|
817
677
|
}
|
|
818
678
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
var
|
|
826
|
-
var
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
679
|
+
var tmp_3 = destination_0;
|
|
680
|
+
var tmp_4 = spacer(joinToString(tmp_3, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_0($this)), 1);
|
|
681
|
+
var tmp_5 = $this.f26(endpoint.o24_1);
|
|
682
|
+
// Inline function 'kotlin.collections.filter' call
|
|
683
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
684
|
+
var this_2 = paramList(_this__u8e3s4, endpoint);
|
|
685
|
+
var destination_1 = ArrayList_init_$Create$();
|
|
686
|
+
var tmp0_iterator_1 = this_2.g();
|
|
687
|
+
while (tmp0_iterator_1.h()) {
|
|
688
|
+
var element_1 = tmp0_iterator_1.i();
|
|
689
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
690
|
+
if (element_1.r25_1.equals(ParamType_HEADER_getInstance())) {
|
|
691
|
+
destination_1.e(element_1);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
var tmp_6 = destination_1;
|
|
695
|
+
var tmp_7 = spacer(joinToString(tmp_6, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_1($this)), 1);
|
|
696
|
+
var tmp_8;
|
|
697
|
+
if (_this__u8e3s4.x24_1 == null) {
|
|
698
|
+
tmp_8 = null;
|
|
832
699
|
} else {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if (equals(type, Bytes_instance)) {
|
|
854
|
-
tmp = defaultReturn;
|
|
855
|
-
} else {
|
|
856
|
-
noWhenBranchMatchedException();
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
}
|
|
700
|
+
// Inline function 'kotlin.let' call
|
|
701
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
702
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
703
|
+
tmp_8 = 'body';
|
|
704
|
+
}
|
|
705
|
+
var tmp1_elvis_lhs = tmp_8;
|
|
706
|
+
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 ');
|
|
707
|
+
}
|
|
708
|
+
function emitAssignSelf_1(_this__u8e3s4, $this, endpoint) {
|
|
709
|
+
var tmp = $this.f26(endpoint.o24_1);
|
|
710
|
+
// Inline function 'kotlin.collections.filter' call
|
|
711
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
712
|
+
var this_0 = paramList_0(_this__u8e3s4);
|
|
713
|
+
var destination = ArrayList_init_$Create$();
|
|
714
|
+
var tmp0_iterator = this_0.g();
|
|
715
|
+
while (tmp0_iterator.h()) {
|
|
716
|
+
var element = tmp0_iterator.i();
|
|
717
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
718
|
+
if (element.r25_1.equals(ParamType_HEADER_getInstance())) {
|
|
719
|
+
destination.e(element);
|
|
860
720
|
}
|
|
861
721
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
tmp = Spacer_instance.toString() + 'bool(re.match(r"' + _RegExp___get_value__impl__7o7618(_this__u8e3s4.l28_1) + '", self.value))';
|
|
722
|
+
var tmp_0 = destination;
|
|
723
|
+
var tmp_1 = spacer(joinToString(tmp_0, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_2($this)), 1);
|
|
724
|
+
var tmp_2;
|
|
725
|
+
if (_this__u8e3s4.c25_1 == null) {
|
|
726
|
+
tmp_2 = null;
|
|
868
727
|
} else {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
728
|
+
// Inline function 'kotlin.let' call
|
|
729
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
730
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitAssignSelf.<anonymous>' call
|
|
731
|
+
tmp_2 = 'body';
|
|
732
|
+
}
|
|
733
|
+
var tmp1_elvis_lhs = tmp_2;
|
|
734
|
+
return trimMargin('\n |self._headers = ' + tmp + '.Response' + _this__u8e3s4.a25_1 + '.Headers(' + tmp_1 + ')\n |self._body = ' + (tmp1_elvis_lhs == null ? 'None' : tmp1_elvis_lhs) + '\n ');
|
|
735
|
+
}
|
|
736
|
+
function emitDeserialized(_this__u8e3s4, $this) {
|
|
737
|
+
return Spacer_instance.x26(3) + $this.f26(_this__u8e3s4.rd_1.v24_1) + ' = serialization.deserialize(request.path[' + _this__u8e3s4.qd_1 + '], ' + $this.y2b(_this__u8e3s4.rd_1.w24_1) + ')';
|
|
738
|
+
}
|
|
739
|
+
function emitDeserializedParams_0(_this__u8e3s4, $this, type, fields) {
|
|
740
|
+
return $this.f26(_this__u8e3s4.l24_1) + ' = serialization.deserialize_param(' + type + '.' + fields + '.get("' + _this__u8e3s4.l24_1.b1() + '".lower()), ' + $this.y2b(_this__u8e3s4.m24_1) + ')';
|
|
741
|
+
}
|
|
742
|
+
function emitToRawResponse(_this__u8e3s4, $this) {
|
|
743
|
+
var tmp = $this.f26(_this__u8e3s4.o24_1);
|
|
744
|
+
var tmp_0 = Spacer_instance.toString();
|
|
745
|
+
var tmp_1 = distinctByStatus(_this__u8e3s4.u24_1);
|
|
746
|
+
return trimMargin("\n |@staticmethod\n |def to_raw_response(serialization: Wirespec.Serializer, response: '" + tmp + ".Response') -> Wirespec.RawResponse:\n |" + tmp_0 + 'match response:\n |' + spacer(joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$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 ');
|
|
747
|
+
}
|
|
748
|
+
function emitFromRawResponse(_this__u8e3s4, $this) {
|
|
749
|
+
var tmp = $this.f26(_this__u8e3s4.o24_1);
|
|
750
|
+
var tmp_0 = Spacer_instance.toString();
|
|
751
|
+
// Inline function 'kotlin.collections.filter' call
|
|
752
|
+
// Inline function 'kotlin.collections.filterTo' call
|
|
753
|
+
var this_0 = distinctByStatus(_this__u8e3s4.u24_1);
|
|
754
|
+
var destination = ArrayList_init_$Create$();
|
|
755
|
+
var tmp0_iterator = this_0.g();
|
|
756
|
+
while (tmp0_iterator.h()) {
|
|
757
|
+
var element = tmp0_iterator.i();
|
|
758
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitFromRawResponse.<anonymous>' call
|
|
759
|
+
if (Companion_instance_1.a26(element.a25_1)) {
|
|
760
|
+
destination.e(element);
|
|
873
761
|
}
|
|
874
762
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
var
|
|
880
|
-
var
|
|
881
|
-
var
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
var
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
var
|
|
891
|
-
var
|
|
892
|
-
var
|
|
893
|
-
var
|
|
894
|
-
var
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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.x26_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.e26(_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.i25_1.q2_1 + '\n |\n |' + tmp_27 + 'def __init__(self, ' + joinToString(tmp_28, ', ', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_8(this)) + '):\n |' + this.g26(emitAssignSelf_0(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
917
|
-
};
|
|
918
|
-
protoOf(PythonEmitter).i2c = function (_this__u8e3s4, endpoint) {
|
|
919
|
-
var tmp = emit_1(_this__u8e3s4.t26_1, this);
|
|
920
|
-
var tmp_0 = emitObject$default(_this__u8e3s4.s26_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.t26_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.t26_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.f26(_this__u8e3s4);
|
|
936
|
-
return trimMargin('\n |@dataclass\n |class Response' + _this__u8e3s4.r26_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.r26_1 + '\n |\n |' + tmp_14 + 'def __init__(self, ' + joinToString(tmp_15, ', ', VOID, VOID, VOID, VOID, PythonEmitter$emit$lambda_10(this)) + '):\n |' + this.g26(emitAssignSelf_1(_this__u8e3s4, this, endpoint), 2) + '\n |\n ');
|
|
937
|
-
};
|
|
938
|
-
protoOf(PythonEmitter).t24 = function (channel) {
|
|
939
|
-
return '';
|
|
940
|
-
};
|
|
941
|
-
protoOf(PythonEmitter).f25 = function (enum_0, module_0) {
|
|
942
|
-
var tmp = sanitizeSymbol(enum_0.d25_1.b1(), this);
|
|
943
|
-
return trimMargin('\n |class ' + tmp + '(str, Enum):\n |' + joinToString(enum_0.e25_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.i27(2) + 'return self.value\n |\n |' + Spacer_instance.toString() + 'def __str__(self) -> str:\n |' + Spacer_instance.i27(2) + 'return self.value\n ');
|
|
944
|
-
};
|
|
945
|
-
protoOf(PythonEmitter).x24 = function (union) {
|
|
946
|
-
return trimMargin('\n |class ' + this.s24(union.v24_1) + '(ABC):\n |' + Spacer_instance.toString() + 'pass\n ');
|
|
947
|
-
};
|
|
948
|
-
protoOf(PythonEmitter).u2a = 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;
|
|
763
|
+
var tmp_1 = destination;
|
|
764
|
+
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 |' + spacer(joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitFromRawResponse$lambda($this, _this__u8e3s4)), 2) + '\n |' + Spacer_instance.x26(2) + 'case _:\n |' + Spacer_instance.x26(3) + 'raise Exception("Cannot match response with status: " + str(response.status_code))\n |\n ');
|
|
765
|
+
}
|
|
766
|
+
function emitDeserialized_0(_this__u8e3s4, $this, endpoint) {
|
|
767
|
+
var tmp = 'case ' + _this__u8e3s4.a25_1 + ':';
|
|
768
|
+
var tmp_0 = Spacer_instance.toString() + 'return ' + $this.f26(endpoint.o24_1) + '.Response' + _this__u8e3s4.a25_1 + '(';
|
|
769
|
+
var tmp_1 = Spacer_instance.x26(2);
|
|
770
|
+
var tmp0_safe_receiver = _this__u8e3s4.c25_1;
|
|
771
|
+
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.z24_1;
|
|
772
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : $this.y2b(tmp1_safe_receiver);
|
|
773
|
+
var tmp_2 = tmp_1 + 'body = serialization.deserialize(response.body, ' + (tmp2_elvis_lhs == null ? 'type(None)' : tmp2_elvis_lhs) + '),';
|
|
774
|
+
var tmp3_safe_receiver = orNull(joinToString(_this__u8e3s4.b25_1, ',\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitDeserialized$lambda($this)));
|
|
775
|
+
return joinToString(listOfNotNull([tmp, tmp_0, tmp_2, tmp3_safe_receiver == null ? null : spacer(tmp3_safe_receiver, 2), Spacer_instance.toString() + ')']), '\n');
|
|
776
|
+
}
|
|
777
|
+
function emitSerialized(_this__u8e3s4, $this, endpoint) {
|
|
778
|
+
var tmp = $this.f26(endpoint.o24_1);
|
|
779
|
+
var tmp_0 = Spacer_instance.x26(1);
|
|
780
|
+
var tmp_1 = Spacer_instance.x26(2);
|
|
781
|
+
var tmp_2 = Spacer_instance.x26(2);
|
|
782
|
+
var tmp_3;
|
|
783
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
784
|
+
if (!_this__u8e3s4.b25_1.l()) {
|
|
785
|
+
tmp_3 = joinToString(_this__u8e3s4.b25_1, ', ', '{', '}', VOID, VOID, PythonEndpointDefinitionEmitter$emitSerialized$lambda($this));
|
|
959
786
|
} else {
|
|
960
|
-
|
|
787
|
+
tmp_3 = '{}';
|
|
961
788
|
}
|
|
962
|
-
|
|
963
|
-
|
|
789
|
+
var tmp_4 = tmp_3;
|
|
790
|
+
var tmp_5 = Spacer_instance.x26(2);
|
|
791
|
+
var tmp0_safe_receiver = _this__u8e3s4.c25_1;
|
|
792
|
+
var tmp_6;
|
|
793
|
+
if (tmp0_safe_receiver == null) {
|
|
794
|
+
tmp_6 = null;
|
|
964
795
|
} else {
|
|
965
|
-
|
|
796
|
+
// Inline function 'kotlin.let' call
|
|
797
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
798
|
+
// Inline function 'community.flock.wirespec.emitters.python.PythonEndpointDefinitionEmitter.emitSerialized.<anonymous>' call
|
|
799
|
+
tmp_6 = 'serialization.serialize(response.body, ' + $this.y2b(tmp0_safe_receiver.z24_1) + ')';
|
|
800
|
+
}
|
|
801
|
+
var tmp1_elvis_lhs = tmp_6;
|
|
802
|
+
return trimMargin('\n |case ' + tmp + '.Response' + _this__u8e3s4.a25_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.x26(1) + ')\n ');
|
|
803
|
+
}
|
|
804
|
+
function emitSerializedParams(_this__u8e3s4, $this, type, fields) {
|
|
805
|
+
return '"' + _this__u8e3s4.l24_1.b1() + '": serialization.serialize_param(' + type + '.' + fields + '.' + $this.f26(_this__u8e3s4.l24_1) + ', ' + $this.y2b(_this__u8e3s4.m24_1) + ')';
|
|
806
|
+
}
|
|
807
|
+
function emitObject(_this__u8e3s4, $this, name, extends_0, spaces, block) {
|
|
808
|
+
var tmp;
|
|
809
|
+
if (_this__u8e3s4.l()) {
|
|
810
|
+
tmp = trimMargin('\n |' + Spacer_instance.x26(spaces) + '@dataclass\n |' + Spacer_instance.x26(spaces) + 'class ' + name + ' (' + extends_0 + '): pass\n ');
|
|
811
|
+
} else {
|
|
812
|
+
var tmp_0 = Spacer_instance.x26(spaces);
|
|
813
|
+
var tmp_1 = Spacer_instance.x26(spaces);
|
|
814
|
+
tmp = trimMargin('\n |' + tmp_0 + '@dataclass\n |' + tmp_1 + 'class ' + name + ' (' + extends_0 + '):\n |' + joinToString(_this__u8e3s4, '\n', VOID, VOID, VOID, VOID, PythonEndpointDefinitionEmitter$emitObject$lambda(spaces, block)) + '\n ');
|
|
966
815
|
}
|
|
967
816
|
return tmp;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
817
|
+
}
|
|
818
|
+
function emitObject$default(_this__u8e3s4, $this, name, extends_0, spaces, block, $super) {
|
|
819
|
+
spaces = spaces === VOID ? 1 : spaces;
|
|
820
|
+
return emitObject(_this__u8e3s4, $this, name, extends_0, spaces, block);
|
|
821
|
+
}
|
|
822
|
+
function emit_14(_this__u8e3s4, $this) {
|
|
823
|
+
return $this.f26(_this__u8e3s4.v24_1) + ': ' + $this.g25(_this__u8e3s4.w24_1);
|
|
824
|
+
}
|
|
825
|
+
function emit_15(_this__u8e3s4, $this) {
|
|
826
|
+
var tmp1_safe_receiver = _this__u8e3s4 == null ? null : _this__u8e3s4.z24_1;
|
|
827
|
+
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : $this.g25(tmp1_safe_receiver);
|
|
828
|
+
return tmp2_elvis_lhs == null ? 'None' : tmp2_elvis_lhs;
|
|
829
|
+
}
|
|
830
|
+
function PythonEndpointDefinitionEmitter$emit$lambda(this$0) {
|
|
831
|
+
return function (it) {
|
|
832
|
+
return this$0.z2b(it);
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_0(this$0, $endpoint) {
|
|
836
|
+
return function (it) {
|
|
837
|
+
return this$0.x2b(it, $endpoint);
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_1(this$0) {
|
|
841
|
+
return function (it) {
|
|
842
|
+
return emit_14(it, this$0);
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_2(this$0) {
|
|
846
|
+
return function (it) {
|
|
847
|
+
return this$0.f25(it);
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_3(this$0) {
|
|
851
|
+
return function (it) {
|
|
852
|
+
return this$0.f25(it);
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_4(this$0) {
|
|
856
|
+
return function (it) {
|
|
857
|
+
return emit_13(it, this$0);
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
function PythonEndpointDefinitionEmitter$emitToRawRequest$lambda(this$0) {
|
|
861
|
+
return function (it) {
|
|
862
|
+
var tmp;
|
|
863
|
+
if (it instanceof Literal) {
|
|
864
|
+
tmp = '"' + it.q25_1 + '"';
|
|
865
|
+
} else {
|
|
866
|
+
if (it instanceof Param) {
|
|
867
|
+
tmp = 'str(request.path.' + this$0.f26(it.v24_1) + ')';
|
|
868
|
+
} else {
|
|
869
|
+
noWhenBranchMatchedException();
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return tmp;
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
function PythonEndpointDefinitionEmitter$emitToRawRequest$lambda_0(this$0) {
|
|
876
|
+
return function (it) {
|
|
877
|
+
return emitSerializedParams(it, this$0, 'request', 'queries');
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
function PythonEndpointDefinitionEmitter$emitToRawRequest$lambda_1(this$0) {
|
|
881
|
+
return function (it) {
|
|
882
|
+
return emitSerializedParams(it, this$0, 'request', 'headers');
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda(this$0) {
|
|
886
|
+
return function (it) {
|
|
887
|
+
return emitDeserialized(it, this$0);
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
function PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda_0(this$0) {
|
|
891
|
+
return function (it) {
|
|
892
|
+
return emitDeserializedParams_0(it, this$0, 'request', 'queries');
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function PythonEndpointDefinitionEmitter$emitDeserializedParams$lambda_1(this$0) {
|
|
896
|
+
return function (it) {
|
|
897
|
+
return emitDeserializedParams_0(it, this$0, 'request', 'headers');
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
function PythonEndpointDefinitionEmitter$emitResponseUnion$lambda(it) {
|
|
901
|
+
return 'Response' + it.a25_1;
|
|
902
|
+
}
|
|
903
|
+
function PythonEndpointDefinitionEmitter$emitAssignSelf$lambda(this$0) {
|
|
904
|
+
return function (it) {
|
|
905
|
+
return emitAssignSelf(it, this$0);
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
function PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_0(this$0) {
|
|
909
|
+
return function (it) {
|
|
910
|
+
return emitAssignSelf(it, this$0);
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_1(this$0) {
|
|
914
|
+
return function (it) {
|
|
915
|
+
return emitAssignSelf(it, this$0);
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function PythonEndpointDefinitionEmitter$emitAssignSelf$lambda_2(this$0) {
|
|
919
|
+
return function (it) {
|
|
920
|
+
return emitAssignSelf(it, this$0);
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_5(this$0) {
|
|
924
|
+
return function (it) {
|
|
925
|
+
return this$0.f25(it);
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function PythonEndpointDefinitionEmitter$emit$lambda_6(this$0) {
|
|
929
|
+
return function (it) {
|
|
930
|
+
return emit_13(it, this$0);
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
function PythonEndpointDefinitionEmitter$emitToRawResponse$lambda(this$0, $this_emitToRawResponse) {
|
|
934
|
+
return function (it) {
|
|
935
|
+
return emitSerialized(it, this$0, $this_emitToRawResponse);
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function PythonEndpointDefinitionEmitter$emitFromRawResponse$lambda(this$0, $this_emitFromRawResponse) {
|
|
939
|
+
return function (it) {
|
|
940
|
+
return emitDeserialized_0(it, this$0, $this_emitFromRawResponse);
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
function PythonEndpointDefinitionEmitter$emitDeserialized$lambda(this$0) {
|
|
944
|
+
return function (it) {
|
|
945
|
+
return emitDeserializedParams_0(it, this$0, 'response', 'headers');
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
function PythonEndpointDefinitionEmitter$emitSerialized$lambda(this$0) {
|
|
949
|
+
return function (it) {
|
|
950
|
+
return emitSerializedParams(it, this$0, 'response', 'headers');
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function PythonEndpointDefinitionEmitter$emitObject$lambda($spaces, $block) {
|
|
954
|
+
return function (it) {
|
|
955
|
+
return Spacer_instance.x26($spaces + 2 | 0) + $block(it);
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function PythonEndpointDefinitionEmitter() {
|
|
959
|
+
}
|
|
960
|
+
function PythonEnumDefinitionEmitter$emit$lambda(this$0) {
|
|
961
|
+
return function (it) {
|
|
962
|
+
return Spacer_instance.toString() + this$0.e2a(this$0.r2a(it)) + ' = "' + it + '"';
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function PythonEnumDefinitionEmitter() {
|
|
966
|
+
}
|
|
967
|
+
function Companion() {
|
|
968
|
+
Companion_instance_2 = this;
|
|
969
|
+
this.a2c_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']);
|
|
970
|
+
}
|
|
971
|
+
var Companion_instance_2;
|
|
972
|
+
function Companion_getInstance() {
|
|
973
|
+
if (Companion_instance_2 == null)
|
|
974
|
+
new Companion();
|
|
975
|
+
return Companion_instance_2;
|
|
976
|
+
}
|
|
977
|
+
function PythonIdentifierEmitter() {
|
|
978
|
+
}
|
|
979
|
+
function PythonRefinedTypeDefinitionEmitter() {
|
|
980
|
+
}
|
|
972
981
|
function PythonShared() {
|
|
973
|
-
this.
|
|
974
|
-
this.
|
|
982
|
+
this.u2b_1 = 'shared';
|
|
983
|
+
this.v2b_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
984
|
}
|
|
976
985
|
protoOf(PythonShared).toString = function () {
|
|
977
986
|
return 'PythonShared';
|
|
@@ -991,6 +1000,47 @@ var PythonShared_instance;
|
|
|
991
1000
|
function PythonShared_getInstance() {
|
|
992
1001
|
return PythonShared_instance;
|
|
993
1002
|
}
|
|
1003
|
+
function PythonTypeDefinitionEmitter$emit$lambda(this$0) {
|
|
1004
|
+
return function (it) {
|
|
1005
|
+
return this$0.z2b(it);
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
function PythonTypeDefinitionEmitter$emit$lambda_0(this$0) {
|
|
1009
|
+
return function (it) {
|
|
1010
|
+
return this$0.z2b(it);
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
function PythonTypeDefinitionEmitter$emit$lambda_1(this$0) {
|
|
1014
|
+
return function (it) {
|
|
1015
|
+
return Spacer_instance.toString() + this$0.f25(it);
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
function PythonTypeDefinitionEmitter() {
|
|
1019
|
+
}
|
|
1020
|
+
function PythonUnionDefinitionEmitter() {
|
|
1021
|
+
}
|
|
1022
|
+
//region block: post-declaration
|
|
1023
|
+
protoOf(PythonEmitter).f26 = emit_0;
|
|
1024
|
+
protoOf(PythonEmitter).d25 = emit_1;
|
|
1025
|
+
protoOf(PythonEmitter).e25 = emit_2;
|
|
1026
|
+
protoOf(PythonEmitter).f25 = emit_3;
|
|
1027
|
+
protoOf(PythonEmitter).g25 = emit_4;
|
|
1028
|
+
protoOf(PythonEmitter).w2b = emit_5;
|
|
1029
|
+
protoOf(PythonEmitter).h25 = emit_6;
|
|
1030
|
+
protoOf(PythonEmitter).q26 = emit_10;
|
|
1031
|
+
protoOf(PythonEmitter).o2a = emit_11;
|
|
1032
|
+
protoOf(PythonEmitter).x2b = emit_12;
|
|
1033
|
+
protoOf(PythonEmitter).g26 = emit;
|
|
1034
|
+
protoOf(PythonEmitter).p26 = emit_9;
|
|
1035
|
+
protoOf(PythonEmitter).h26 = emit_8;
|
|
1036
|
+
protoOf(PythonEmitter).l26 = emit_7;
|
|
1037
|
+
protoOf(PythonEmitter).r26 = emitValidator;
|
|
1038
|
+
protoOf(PythonEmitter).c2a = sanitize;
|
|
1039
|
+
protoOf(PythonEmitter).e2a = sanitizeKeywords;
|
|
1040
|
+
protoOf(PythonEmitter).y2b = emitType;
|
|
1041
|
+
protoOf(PythonEmitter).z2b = emitReferenceCustomImports;
|
|
1042
|
+
protoOf(PythonEmitter).r2a = sanitizeEnum;
|
|
1043
|
+
//endregion
|
|
994
1044
|
//region block: init
|
|
995
1045
|
PythonShared_instance = new PythonShared();
|
|
996
1046
|
//endregion
|