@flock/wirespec 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1374,16 +1374,20 @@
|
|
|
1374
1374
|
var tmp = distinct(destination);
|
|
1375
1375
|
return joinToString(tmp, '\n', VOID, VOID, VOID, VOID, KotlinEmitter$emitResponseInterfaces$lambda);
|
|
1376
1376
|
}
|
|
1377
|
-
function emitObject_0(_this__u8e3s4, $this, name, extends_0, block) {
|
|
1377
|
+
function emitObject_0(_this__u8e3s4, $this, name, extends_0, spaces, block) {
|
|
1378
1378
|
var tmp;
|
|
1379
1379
|
if (_this__u8e3s4.l()) {
|
|
1380
|
-
tmp = Spacer_instance.
|
|
1380
|
+
tmp = Spacer_instance.d24(spaces) + 'data object ' + name + ' : ' + extends_0;
|
|
1381
1381
|
} else {
|
|
1382
|
-
var tmp_0 = Spacer_instance.
|
|
1383
|
-
tmp = trimMargin('\n |' + tmp_0 + 'data class ' + name + '(\n |' + joinToString(_this__u8e3s4, ',\n', VOID, VOID, VOID, VOID, KotlinEmitter$emitObject$lambda(block)) + ',\n |' + Spacer_instance.
|
|
1382
|
+
var tmp_0 = Spacer_instance.d24(spaces);
|
|
1383
|
+
tmp = trimMargin('\n |' + tmp_0 + 'data class ' + name + '(\n |' + joinToString(_this__u8e3s4, ',\n', VOID, VOID, VOID, VOID, KotlinEmitter$emitObject$lambda(spaces, block)) + ',\n |' + Spacer_instance.d24(spaces) + ') : ' + extends_0 + '\n ');
|
|
1384
1384
|
}
|
|
1385
1385
|
return tmp;
|
|
1386
1386
|
}
|
|
1387
|
+
function emitObject$default(_this__u8e3s4, $this, name, extends_0, spaces, block, $super) {
|
|
1388
|
+
spaces = spaces === VOID ? 1 : spaces;
|
|
1389
|
+
return emitObject_0(_this__u8e3s4, $this, name, extends_0, spaces, block);
|
|
1390
|
+
}
|
|
1387
1391
|
function emitConstructor_0(_this__u8e3s4, $this, endpoint) {
|
|
1388
1392
|
// Inline function 'kotlin.let' call
|
|
1389
1393
|
var tmp = $this.j24(endpoint);
|
|
@@ -1427,19 +1431,35 @@
|
|
|
1427
1431
|
return isBlank(it) ? '' : '(\n' + it + '\n' + Spacer_instance.d24(2) + ')';
|
|
1428
1432
|
}
|
|
1429
1433
|
function emitSerialized_0(_this__u8e3s4, $this) {
|
|
1430
|
-
|
|
1434
|
+
var tmp = Spacer_instance.d24(3);
|
|
1435
|
+
var tmp_0 = Spacer_instance.d24(4);
|
|
1436
|
+
var tmp_1 = Spacer_instance.d24(4);
|
|
1437
|
+
var tmp_2;
|
|
1438
|
+
// Inline function 'kotlin.collections.isNotEmpty' call
|
|
1439
|
+
if (!_this__u8e3s4.a24_1.l()) {
|
|
1440
|
+
tmp_2 = joinToString(_this__u8e3s4.a24_1, ' + ', VOID, VOID, VOID, VOID, KotlinEmitter$emitSerialized$lambda($this));
|
|
1441
|
+
} else {
|
|
1442
|
+
tmp_2 = 'emptyMap()';
|
|
1443
|
+
}
|
|
1444
|
+
return trimMargin('\n |' + tmp + 'is Response' + _this__u8e3s4.z23_1 + ' -> Wirespec.RawResponse(\n |' + tmp_0 + 'statusCode = response.status,\n |' + tmp_1 + 'headers = ' + tmp_2 + ',\n |' + Spacer_instance.d24(4) + 'body = ' + (!(_this__u8e3s4.b24_1 == null) ? 'serialization.serialize(response.body, typeOf<' + emit_3(_this__u8e3s4.b24_1, $this) + '>())' : 'null') + ',\n |' + Spacer_instance.d24(3) + ')\n ');
|
|
1431
1445
|
}
|
|
1432
1446
|
function emitDeserialized_1(_this__u8e3s4, $this) {
|
|
1433
|
-
|
|
1447
|
+
var tmp = Spacer_instance.d24(3) + _this__u8e3s4.z23_1 + ' -> Response' + _this__u8e3s4.z23_1 + '(';
|
|
1448
|
+
var tmp_0 = Spacer_instance.d24(4) + 'body = serialization.deserialize(requireNotNull(response.body) { "body is null" }, typeOf<' + emit_3(_this__u8e3s4.b24_1, $this) + '>()),';
|
|
1449
|
+
return joinToString(listOfNotNull([tmp, tmp_0, orNull(joinToString(_this__u8e3s4.a24_1, ',\n', VOID, VOID, VOID, VOID, KotlinEmitter$emitDeserialized$lambda($this))), Spacer_instance.d24(3) + ')']), '\n');
|
|
1434
1450
|
}
|
|
1435
|
-
function emitSerializedParams_0(_this__u8e3s4, $this, fields) {
|
|
1436
|
-
return 'mapOf("' + $this.r24(_this__u8e3s4.n24_1) + '" to (
|
|
1451
|
+
function emitSerializedParams_0(_this__u8e3s4, $this, type, fields) {
|
|
1452
|
+
return 'mapOf("' + $this.r24(_this__u8e3s4.n24_1) + '" to (' + type + '.' + fields + '.' + $this.r24(_this__u8e3s4.n24_1) + '?.let{ serialization.serializeParam(it, typeOf<' + $this.v24(_this__u8e3s4.o24_1) + '>()) } ?: emptyList()))';
|
|
1437
1453
|
}
|
|
1438
1454
|
function emitDeserialized_2(_this__u8e3s4, $this) {
|
|
1439
1455
|
return Spacer_instance.d24(3) + $this.r24(_this__u8e3s4.pd_1.t24_1) + ' = serialization.deserialize(request.path[' + _this__u8e3s4.od_1 + '], typeOf<' + $this.v24(_this__u8e3s4.pd_1.u24_1) + '>())';
|
|
1440
1456
|
}
|
|
1441
|
-
function emitDeserializedParams_3(_this__u8e3s4, $this, fields) {
|
|
1442
|
-
return _this__u8e3s4.p24_1 ? Spacer_instance.d24(
|
|
1457
|
+
function emitDeserializedParams_3(_this__u8e3s4, $this, type, fields, spaces) {
|
|
1458
|
+
return _this__u8e3s4.p24_1 ? Spacer_instance.d24(spaces) + $this.r24(_this__u8e3s4.n24_1) + ' = ' + type + '.' + fields + '["' + _this__u8e3s4.n24_1.b1() + '"]?.let{ serialization.deserializeParam(it, typeOf<' + $this.v24(_this__u8e3s4.o24_1) + '>()) }' : Spacer_instance.d24(spaces) + $this.r24(_this__u8e3s4.n24_1) + ' = serialization.deserializeParam(requireNotNull(' + type + '.' + fields + '["' + _this__u8e3s4.n24_1.b1() + '"]) { "' + $this.r24(_this__u8e3s4.n24_1) + ' is null" }, typeOf<' + $this.v24(_this__u8e3s4.o24_1) + '>())';
|
|
1459
|
+
}
|
|
1460
|
+
function emitDeserializedParams$default(_this__u8e3s4, $this, type, fields, spaces, $super) {
|
|
1461
|
+
spaces = spaces === VOID ? 3 : spaces;
|
|
1462
|
+
return emitDeserializedParams_3(_this__u8e3s4, $this, type, fields, spaces);
|
|
1443
1463
|
}
|
|
1444
1464
|
function emitIdentifier_0(_this__u8e3s4, $this) {
|
|
1445
1465
|
return 'request.path.' + $this.r24(_this__u8e3s4.t24_1) + '.let{serialization.serialize(it, typeOf<' + $this.v24(_this__u8e3s4.u24_1) + '>())}';
|
|
@@ -1584,9 +1604,9 @@
|
|
|
1584
1604
|
function KotlinEmitter$emitResponseInterfaces$lambda(it) {
|
|
1585
1605
|
return Spacer_instance.toString() + 'sealed interface Response' + concatGenerics(it) + ' : Response<' + it + '>';
|
|
1586
1606
|
}
|
|
1587
|
-
function KotlinEmitter$emitObject$lambda($block) {
|
|
1607
|
+
function KotlinEmitter$emitObject$lambda($spaces, $block) {
|
|
1588
1608
|
return function (it) {
|
|
1589
|
-
return Spacer_instance.d24(
|
|
1609
|
+
return Spacer_instance.d24($spaces + 1 | 0) + 'val ' + $block(it);
|
|
1590
1610
|
};
|
|
1591
1611
|
}
|
|
1592
1612
|
function KotlinEmitter$emit$lambda_9(this$0) {
|
|
@@ -1621,12 +1641,27 @@
|
|
|
1621
1641
|
}
|
|
1622
1642
|
function KotlinEmitter$emit$lambda_13(this$0) {
|
|
1623
1643
|
return function (it) {
|
|
1624
|
-
return '(' + emitSerializedParams_0(it, this$0, 'queries') + ')';
|
|
1644
|
+
return '(' + emitSerializedParams_0(it, this$0, 'request', 'queries') + ')';
|
|
1625
1645
|
};
|
|
1626
1646
|
}
|
|
1627
1647
|
function KotlinEmitter$emit$lambda_14(this$0) {
|
|
1628
1648
|
return function (it) {
|
|
1629
|
-
return '(' + emitSerializedParams_0(it, this$0, 'headers') + ')';
|
|
1649
|
+
return '(' + emitSerializedParams_0(it, this$0, 'request', 'headers') + ')';
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
function KotlinEmitter$emit$lambda_15(this$0) {
|
|
1653
|
+
return function (it) {
|
|
1654
|
+
return 'val ' + this$0.r24(it.n24_1) + ': ' + this$0.f26(it);
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
function KotlinEmitter$emit$lambda_16(this$0) {
|
|
1658
|
+
return function (it) {
|
|
1659
|
+
return this$0.r24(it.n24_1);
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
function KotlinEmitter$emit$lambda_17(this$0) {
|
|
1663
|
+
return function (it) {
|
|
1664
|
+
return this$0.z24(it);
|
|
1630
1665
|
};
|
|
1631
1666
|
}
|
|
1632
1667
|
function KotlinEmitter$emitConstructor$lambda(this$0) {
|
|
@@ -1651,12 +1686,22 @@
|
|
|
1651
1686
|
}
|
|
1652
1687
|
function KotlinEmitter$emitDeserializedParams$lambda_0(this$0) {
|
|
1653
1688
|
return function (it) {
|
|
1654
|
-
return
|
|
1689
|
+
return emitDeserializedParams$default(it, this$0, 'request', 'queries');
|
|
1655
1690
|
};
|
|
1656
1691
|
}
|
|
1657
1692
|
function KotlinEmitter$emitDeserializedParams$lambda_1(this$0) {
|
|
1658
1693
|
return function (it) {
|
|
1659
|
-
return
|
|
1694
|
+
return emitDeserializedParams$default(it, this$0, 'request', 'headers');
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function KotlinEmitter$emitSerialized$lambda(this$0) {
|
|
1698
|
+
return function (it) {
|
|
1699
|
+
return '(' + emitSerializedParams_0(it, this$0, 'response', 'headers') + ')';
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
function KotlinEmitter$emitDeserialized$lambda(this$0) {
|
|
1703
|
+
return function (it) {
|
|
1704
|
+
return emitDeserializedParams_3(it, this$0, 'response', 'headers', 4);
|
|
1660
1705
|
};
|
|
1661
1706
|
}
|
|
1662
1707
|
function KotlinEmitter$sanitizeSymbol$lambda(it) {
|
|
@@ -1864,9 +1909,9 @@
|
|
|
1864
1909
|
protoOf(KotlinEmitter).o26 = function (endpoint) {
|
|
1865
1910
|
var tmp = this.r24(endpoint.r23_1);
|
|
1866
1911
|
var tmp_0 = this.j24(endpoint);
|
|
1867
|
-
var tmp_1 =
|
|
1868
|
-
var tmp_2 =
|
|
1869
|
-
var tmp_3 =
|
|
1912
|
+
var tmp_1 = emitObject$default(tmp_0, this, 'Path', 'Wirespec.Path', VOID, KotlinEmitter$emit$lambda_2(this));
|
|
1913
|
+
var tmp_2 = emitObject$default(endpoint.u23_1, this, 'Queries', 'Wirespec.Queries', VOID, KotlinEmitter$emit$lambda_3(this));
|
|
1914
|
+
var tmp_3 = emitObject$default(endpoint.v23_1, this, 'Headers', 'Wirespec.Request.Headers', VOID, KotlinEmitter$emit$lambda_4(this));
|
|
1870
1915
|
var tmp_4 = this.p26(first_0(endpoint.x23_1), endpoint);
|
|
1871
1916
|
var tmp_5 = Spacer_instance.toString();
|
|
1872
1917
|
var tmp_6 = emitStatusInterfaces_0(endpoint, this);
|
|
@@ -1982,7 +2027,21 @@
|
|
|
1982
2027
|
return trimMargin('\n |' + tmp + tmp_0 + '\n |' + tmp_1 + 'override val path = Path' + tmp_3 + '\n |' + tmp_4 + 'override val method = Wirespec.Method.' + endpoint.s23_1.p2_1 + '\n |' + tmp_5 + 'override val queries = Queries' + tmp_6 + '\n |' + tmp_7 + 'override val headers = Headers' + tmp_8 + tmp_9 + '\n |' + tmp_10 + '}\n |\n |' + tmp_11 + 'fun toRequest(serialization: Wirespec.Serializer<String>, request: Request): Wirespec.RawRequest =\n |' + tmp_12 + 'Wirespec.RawRequest(\n |' + tmp_13 + 'path = listOf(' + tmp_14 + '),\n |' + tmp_15 + 'method = request.method.name,\n |' + tmp_16 + 'queries = ' + tmp_18 + ',\n |' + tmp_19 + 'headers = ' + tmp_20 + ',\n |' + Spacer_instance.d24(3) + 'body = serialization.serialize(request.body, typeOf<' + emit_3(_this__u8e3s4.e24_1, this) + '>()),\n |' + Spacer_instance.d24(2) + ')\n |\n |' + Spacer_instance.toString() + 'fun fromRequest(serialization: Wirespec.Deserializer<String>, request: Wirespec.RawRequest): Request =\n |' + Spacer_instance.d24(2) + 'Request' + emitDeserializedParams_2(_this__u8e3s4, this, endpoint) + '\n ');
|
|
1983
2028
|
};
|
|
1984
2029
|
protoOf(KotlinEmitter).c25 = function (_this__u8e3s4) {
|
|
1985
|
-
|
|
2030
|
+
var tmp = Spacer_instance.toString();
|
|
2031
|
+
var tmp_0 = emit_3(_this__u8e3s4.b24_1, this);
|
|
2032
|
+
// Inline function 'kotlin.let' call
|
|
2033
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
2034
|
+
// Inline function 'community.flock.wirespec.compiler.core.emit.KotlinEmitter.emit.<anonymous>' call
|
|
2035
|
+
var it = joinToString(_this__u8e3s4.a24_1, ', ', VOID, VOID, VOID, VOID, KotlinEmitter$emit$lambda_15(this));
|
|
2036
|
+
var tmp_1 = isBlank(it) ? '' : ', ' + it;
|
|
2037
|
+
var tmp_2 = toString_0(charSequenceGet(_this__u8e3s4.z23_1, 0));
|
|
2038
|
+
var tmp_3 = emit_3(_this__u8e3s4.b24_1, this);
|
|
2039
|
+
var tmp_4 = concatGenerics(emit_3(_this__u8e3s4.b24_1, this));
|
|
2040
|
+
var tmp_5 = Spacer_instance.d24(2);
|
|
2041
|
+
var tmp_6 = fixStatus_0(_this__u8e3s4.z23_1, this);
|
|
2042
|
+
var tmp_7 = Spacer_instance.d24(2);
|
|
2043
|
+
var tmp_8 = brace(joinToString(_this__u8e3s4.a24_1, VOID, VOID, VOID, VOID, VOID, KotlinEmitter$emit$lambda_16(this)), this);
|
|
2044
|
+
return trimMargin('\n |' + tmp + 'data class Response' + _this__u8e3s4.z23_1 + '(override val body: ' + tmp_0 + tmp_1 + ') : Response' + tmp_2 + 'XX<' + tmp_3 + '>, Response' + tmp_4 + ' {\n |' + tmp_5 + 'override val status = ' + tmp_6 + '\n |' + tmp_7 + 'override val headers = ResponseHeaders' + tmp_8 + '\n |' + emitObject_0(_this__u8e3s4.a24_1, this, 'ResponseHeaders', 'Wirespec.Response.Headers', 2, KotlinEmitter$emit$lambda_17(this)) + '\n |' + Spacer_instance.toString() + '}\n ');
|
|
1986
2045
|
};
|
|
1987
2046
|
protoOf(KotlinEmitter).a25 = function (_this__u8e3s4) {
|
|
1988
2047
|
return sanitizeFirstIsDigit_0(joinToString(split(_this__u8e3s4, ['-', ', ', '.', ' ', '//']), '_'), this);
|
|
@@ -2293,7 +2352,7 @@
|
|
|
2293
2352
|
var tmp_4 = Companion_getInstance_3().l24(_this__u8e3s4.z23_1);
|
|
2294
2353
|
var tmp_5 = Spacer_instance.d24(2);
|
|
2295
2354
|
var tmp_6 = Spacer_instance.d24(2);
|
|
2296
|
-
var tmp_7 = joinToObject(
|
|
2355
|
+
var tmp_7 = joinToObject(_this__u8e3s4.a24_1, $this, TypeScriptEmitter$emitFunction$lambda_4($this));
|
|
2297
2356
|
var tmp_8 = Spacer_instance.d24(2);
|
|
2298
2357
|
var tmp_9;
|
|
2299
2358
|
if (_this__u8e3s4.b24_1 == null) {
|
|
@@ -2327,7 +2386,7 @@
|
|
|
2327
2386
|
var tmp_0 = emitName(_this__u8e3s4, $this);
|
|
2328
2387
|
var tmp_1 = Spacer_instance.d24(2);
|
|
2329
2388
|
var tmp_2 = Spacer_instance.d24(2);
|
|
2330
|
-
return trimIndent('\n |' + tmp + 'export type ' + tmp_0 + ' = {
|
|
2389
|
+
return trimIndent('\n |' + tmp + 'export type ' + tmp_0 + ' = {\n |' + tmp_1 + 'status: ' + _this__u8e3s4.z23_1 + '\n |' + tmp_2 + 'headers: {' + joinToString(_this__u8e3s4.a24_1, VOID, VOID, VOID, VOID, VOID, TypeScriptEmitter$emitType$lambda_0($this)) + '}\n |' + Spacer_instance.d24(2) + 'body: ' + emitReference_0(_this__u8e3s4, $this) + '\n |' + Spacer_instance.toString() + '}\n ');
|
|
2331
2390
|
}
|
|
2332
2391
|
function sanitizeSymbol_1(_this__u8e3s4, $this) {
|
|
2333
2392
|
return sanitizeSymbol_2(_this__u8e3s4.b1(), $this);
|
|
@@ -2352,14 +2411,17 @@
|
|
|
2352
2411
|
var tmp_3 = Spacer_instance.d24(1);
|
|
2353
2412
|
var tmp_4 = joinToString(_this__u8e3s4.u23_1, VOID, VOID, VOID, VOID, VOID, TypeScriptEmitter$emitClientTo$lambda($this));
|
|
2354
2413
|
var tmp_5 = Spacer_instance.d24(1);
|
|
2355
|
-
return trimMargin('\n |to: (
|
|
2414
|
+
return trimMargin('\n |to: (it) => ({\n |' + tmp + 'method: "' + tmp_0 + '",\n |' + tmp_1 + 'path: ' + tmp_2 + ',\n |' + tmp_3 + 'queries: {' + tmp_4 + '},\n |' + tmp_5 + 'headers: {' + joinToString(_this__u8e3s4.v23_1, VOID, VOID, VOID, VOID, VOID, TypeScriptEmitter$emitClientTo$lambda_0($this)) + '},\n |' + Spacer_instance.d24(1) + 'body: serialization.serialize(it.body)\n |})\n ');
|
|
2356
2415
|
}
|
|
2357
2416
|
function emitClientFrom(_this__u8e3s4, $this) {
|
|
2358
2417
|
var tmp = Spacer_instance.d24(1);
|
|
2359
|
-
return trimMargin('\n |from: (
|
|
2418
|
+
return trimMargin('\n |from: (it) => {\n |' + tmp + 'switch (it.status) {\n |' + prependIndent(joinToString(_this__u8e3s4.y23_1, '\n', VOID, VOID, VOID, VOID, TypeScriptEmitter$emitClientFrom$lambda($this)), Spacer_instance.d24(2)) + '\n |' + Spacer_instance.d24(2) + 'default:\n |' + Spacer_instance.d24(3) + 'throw new Error(`Cannot internalize response with status: ${it.status}`);\n |' + Spacer_instance.d24(1) + '}\n |}\n ');
|
|
2360
2419
|
}
|
|
2361
2420
|
function emitClientFromResponse(_this__u8e3s4, $this) {
|
|
2362
|
-
|
|
2421
|
+
var tmp = Spacer_instance.d24(1);
|
|
2422
|
+
var tmp_0 = Spacer_instance.d24(2);
|
|
2423
|
+
var tmp_1 = Spacer_instance.d24(2);
|
|
2424
|
+
return trimMargin('\n |case ' + _this__u8e3s4.z23_1 + ':\n |' + tmp + 'return {\n |' + tmp_0 + 'status: ' + _this__u8e3s4.z23_1 + ',\n |' + tmp_1 + 'headers: {' + joinToString(_this__u8e3s4.a24_1, VOID, VOID, VOID, VOID, VOID, TypeScriptEmitter$emitClientFromResponse$lambda($this)) + '},\n |' + Spacer_instance.d24(2) + 'body: serialization.deserialize<' + emitReference_0(_this__u8e3s4, $this) + '>(it.body)\n |' + Spacer_instance.d24(1) + '};\n ');
|
|
2363
2425
|
}
|
|
2364
2426
|
function emitServer(_this__u8e3s4, $this) {
|
|
2365
2427
|
return trimMargin('\n |export const server:Wirespec.Server<Request, Response> = (serialization: Wirespec.Serialization) => ({\n |' + prependIndent(emitServerFrom(_this__u8e3s4, $this), Spacer_instance.d24(1)) + ',\n |' + prependIndent(emitServerTo($this), Spacer_instance.d24(1)) + '\n |})\n ');
|
|
@@ -2378,19 +2440,19 @@
|
|
|
2378
2440
|
var tmp_7 = joinToString(_this__u8e3s4.u23_1, ',', VOID, VOID, VOID, VOID, TypeScriptEmitter$emitServerFrom$lambda_0($this));
|
|
2379
2441
|
var tmp_8 = Spacer_instance.d24(2);
|
|
2380
2442
|
var tmp_9 = Spacer_instance.d24(2);
|
|
2381
|
-
return trimMargin('\n |from: (
|
|
2443
|
+
return trimMargin('\n |from: (it) => {\n |' + tmp + 'return {\n |' + tmp_0 + 'method: "' + tmp_1 + '",\n |' + tmp_2 + 'path: { \n |' + tmp_4 + '\n |' + tmp_5 + '},\n |' + tmp_6 + 'queries: {\n |' + tmp_7 + '\n |' + tmp_8 + '},\n |' + tmp_9 + 'headers: {\n |' + joinToString(_this__u8e3s4.v23_1, ',', VOID, VOID, VOID, VOID, TypeScriptEmitter$emitServerFrom$lambda_1($this)) + '\n |' + Spacer_instance.d24(2) + '},\n |' + Spacer_instance.d24(2) + 'body: serialization.deserialize(it.body)\n |' + Spacer_instance.d24(1) + '}\n |}\n ');
|
|
2382
2444
|
}
|
|
2383
2445
|
function emitServerTo($this) {
|
|
2384
|
-
return trimMargin('\n |to: (
|
|
2446
|
+
return trimMargin('\n |to: (it) => ({\n |' + Spacer_instance.d24(1) + 'status: it.status,\n |' + Spacer_instance.d24(1) + 'headers: {},\n |' + Spacer_instance.d24(1) + 'body: serialization.serialize(it.body),\n |})\n ');
|
|
2385
2447
|
}
|
|
2386
2448
|
function emitDeserialize(_this__u8e3s4, $this) {
|
|
2387
|
-
return $this.r24(_this__u8e3s4.pd_1.t24_1) + ': serialization.deserialize(
|
|
2449
|
+
return $this.r24(_this__u8e3s4.pd_1.t24_1) + ': serialization.deserialize(it.path[' + _this__u8e3s4.od_1 + '])';
|
|
2388
2450
|
}
|
|
2389
2451
|
function emitDeserialize_0(_this__u8e3s4, $this, fields) {
|
|
2390
|
-
return $this.r24(_this__u8e3s4.n24_1) + ': serialization.deserialize(
|
|
2452
|
+
return $this.r24(_this__u8e3s4.n24_1) + ': serialization.deserialize(it.' + fields + '.' + $this.r24(_this__u8e3s4.n24_1) + ')';
|
|
2391
2453
|
}
|
|
2392
2454
|
function emitSerialize(_this__u8e3s4, $this, fields) {
|
|
2393
|
-
return $this.r24(_this__u8e3s4.n24_1) + ': serialization.serialize(
|
|
2455
|
+
return $this.r24(_this__u8e3s4.n24_1) + ': serialization.serialize(it.' + fields + '.' + $this.r24(_this__u8e3s4.n24_1) + ')';
|
|
2394
2456
|
}
|
|
2395
2457
|
function TypeScriptEmitter$emit$lambda(it) {
|
|
2396
2458
|
return '"' + it + '"';
|
|
@@ -2477,7 +2539,7 @@
|
|
|
2477
2539
|
}
|
|
2478
2540
|
function TypeScriptEmitter$emitType$lambda_0(this$0) {
|
|
2479
2541
|
return function (it) {
|
|
2480
|
-
return this$0.
|
|
2542
|
+
return '"' + this$0.r24(it.n24_1) + '"' + (it.p24_1 ? '?' : '') + ': ' + this$0.v24(it.o24_1);
|
|
2481
2543
|
};
|
|
2482
2544
|
}
|
|
2483
2545
|
function TypeScriptEmitter$sanitizeSymbol$lambda(it) {
|
|
@@ -2490,7 +2552,7 @@
|
|
|
2490
2552
|
tmp = '"' + it.e25_1 + '"';
|
|
2491
2553
|
} else {
|
|
2492
2554
|
if (it instanceof Param_0) {
|
|
2493
|
-
tmp = 'serialization.serialize(
|
|
2555
|
+
tmp = 'serialization.serialize(it.path.' + this$0.r24(it.t24_1) + ')';
|
|
2494
2556
|
} else {
|
|
2495
2557
|
noWhenBranchMatchedException();
|
|
2496
2558
|
}
|
|
@@ -2513,6 +2575,11 @@
|
|
|
2513
2575
|
return emitClientFromResponse(it, this$0);
|
|
2514
2576
|
};
|
|
2515
2577
|
}
|
|
2578
|
+
function TypeScriptEmitter$emitClientFromResponse$lambda(this$0) {
|
|
2579
|
+
return function (it) {
|
|
2580
|
+
return emitDeserialize_0(it, this$0, 'headers');
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2516
2583
|
function TypeScriptEmitter$emitServerFrom$lambda(this$0) {
|
|
2517
2584
|
return function (it) {
|
|
2518
2585
|
return emitDeserialize(it, this$0);
|
|
@@ -3486,7 +3553,7 @@
|
|
|
3486
3553
|
function TypeScriptShared() {
|
|
3487
3554
|
TypeScriptShared_instance = this;
|
|
3488
3555
|
this.r27_1 = 'community.flock.wirespec';
|
|
3489
|
-
this.s27_1 = trimMargin('\n |export namespace Wirespec {\n |' + Spacer_instance.toString() + 'export type Method = "GET" | "PUT" | "POST" | "DELETE" | "OPTIONS" | "HEAD" | "PATCH" | "TRACE"\n |' + Spacer_instance.toString() + 'export type RawRequest = { method: Method, path: string[], queries: Record<string, string>, headers: Record<string, string>, body?: string }\n |' + Spacer_instance.toString() + 'export type RawResponse = { status: number, headers: Record<string, string>, body?: string }\n |' + Spacer_instance.toString() + 'export type Content<T> = { type:string, body:T }\n |' + Spacer_instance.toString() + 'export type Request<T> = { path: Record<string, unknown>, method: Method, query?: Record<string, unknown>, headers?: Record<string, unknown>, content?:Content<T> }\n |' + Spacer_instance.toString() + 'export type Response<T> = { status:number, headers?: Record<string, unknown
|
|
3556
|
+
this.s27_1 = trimMargin('\n |export namespace Wirespec {\n |' + Spacer_instance.toString() + 'export type Method = "GET" | "PUT" | "POST" | "DELETE" | "OPTIONS" | "HEAD" | "PATCH" | "TRACE"\n |' + Spacer_instance.toString() + 'export type RawRequest = { method: Method, path: string[], queries: Record<string, string>, headers: Record<string, string>, body?: string }\n |' + Spacer_instance.toString() + 'export type RawResponse = { status: number, headers: Record<string, string>, body?: string }\n |' + Spacer_instance.toString() + 'export type Content<T> = { type:string, body:T }\n |' + Spacer_instance.toString() + 'export type Request<T> = { path: Record<string, unknown>, method: Method, query?: Record<string, unknown>, headers?: Record<string, unknown>, content?:Content<T> }\n |' + Spacer_instance.toString() + 'export type Response<T> = { status:number, headers?: Record<string, unknown>, content?:Content<T> }\n |' + Spacer_instance.toString() + 'export type Serialization = { serialize: <T>(type: T) => string; deserialize: <T>(raw: string | undefined) => T }\n |' + Spacer_instance.toString() + 'export type Client<REQ extends Request<unknown>, RES extends Response<unknown>> = (serialization: Serialization) => { to: (request: REQ) => RawRequest; from: (response: RawResponse) => RES }\n |' + Spacer_instance.toString() + 'export type Server<REQ extends Request<unknown>, RES extends Response<unknown>> = (serialization: Serialization) => { from: (request: RawRequest) => REQ; to: (response: RES) => RawResponse }\n |' + Spacer_instance.toString() + 'export type Api<REQ extends Request<unknown>, RES extends Response<unknown>> = { name: string; method: Method, path: string, client: Client<REQ, RES>; server: Server<REQ, RES> }\n |}\n ');
|
|
3490
3557
|
}
|
|
3491
3558
|
protoOf(TypeScriptShared).toString = function () {
|
|
3492
3559
|
return 'TypeScriptShared';
|
|
@@ -3844,41 +3911,21 @@
|
|
|
3844
3911
|
tmp_10 = emptyList();
|
|
3845
3912
|
}
|
|
3846
3913
|
var queryParams = tmp_10;
|
|
3847
|
-
var
|
|
3848
|
-
if (_this__u8e3s4.h28_1.a28_1 instanceof Hash) {
|
|
3849
|
-
raise.qk(_this__u8e3s4.l28());
|
|
3850
|
-
var tmp_13;
|
|
3851
|
-
if (_this__u8e3s4.h28_1.a28_1 instanceof LeftCurly) {
|
|
3852
|
-
// Inline function 'kotlin.with' call
|
|
3853
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
3854
|
-
// Inline function 'community.flock.wirespec.compiler.core.parse.EndpointParser.parseEndpointDefinition.<anonymous>.<anonymous>' call
|
|
3855
|
-
var $this$with_0 = $this.u28_1;
|
|
3856
|
-
tmp_13 = raise.qk($this$with_0.v28(_this__u8e3s4)).e26_1;
|
|
3857
|
-
} else {
|
|
3858
|
-
// Inline function 'community.flock.wirespec.compiler.core.exceptions.Companion.invoke' call
|
|
3859
|
-
var actual_2 = _this__u8e3s4.h28_1;
|
|
3860
|
-
var tmp$ret$18 = new WrongTokenException(getKClass(LeftCurly), actual_2);
|
|
3861
|
-
raise.pk(tmp$ret$18);
|
|
3862
|
-
}
|
|
3863
|
-
tmp_12 = tmp_13;
|
|
3864
|
-
} else {
|
|
3865
|
-
tmp_12 = emptyList();
|
|
3866
|
-
}
|
|
3867
|
-
var headers = tmp_12;
|
|
3914
|
+
var headers = raise.qk(parseHeaders(_this__u8e3s4, $this));
|
|
3868
3915
|
if (_this__u8e3s4.h28_1.a28_1 instanceof Arrow)
|
|
3869
3916
|
raise.qk(_this__u8e3s4.l28());
|
|
3870
3917
|
else {
|
|
3871
3918
|
// Inline function 'community.flock.wirespec.compiler.core.exceptions.Companion.invoke' call
|
|
3872
|
-
var
|
|
3873
|
-
var tmp$ret$
|
|
3874
|
-
raise.pk(tmp$ret$
|
|
3919
|
+
var actual_2 = _this__u8e3s4.h28_1;
|
|
3920
|
+
var tmp$ret$16 = new WrongTokenException(getKClass(Arrow), actual_2);
|
|
3921
|
+
raise.pk(tmp$ret$16);
|
|
3875
3922
|
}
|
|
3876
3923
|
// Inline function 'kotlin.also' call
|
|
3877
3924
|
if (!(_this__u8e3s4.h28_1.a28_1 instanceof LeftCurly)) {
|
|
3878
3925
|
// Inline function 'community.flock.wirespec.compiler.core.exceptions.Companion.invoke' call
|
|
3879
|
-
var
|
|
3880
|
-
var tmp$ret$
|
|
3881
|
-
raise.pk(tmp$ret$
|
|
3926
|
+
var actual_3 = _this__u8e3s4.h28_1;
|
|
3927
|
+
var tmp$ret$17 = new WrongTokenException(getKClass(LeftCurly), actual_3);
|
|
3928
|
+
raise.pk(tmp$ret$17);
|
|
3882
3929
|
}
|
|
3883
3930
|
// Inline function 'kotlin.contracts.contract' call
|
|
3884
3931
|
// Inline function 'community.flock.wirespec.compiler.core.parse.EndpointParser.parseEndpointDefinition.<anonymous>.<anonymous>' call
|
|
@@ -3889,13 +3936,13 @@
|
|
|
3889
3936
|
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
3890
3937
|
tmp = new Right(res);
|
|
3891
3938
|
} catch ($p) {
|
|
3892
|
-
var
|
|
3939
|
+
var tmp_12;
|
|
3893
3940
|
if ($p instanceof RaiseCancellationException) {
|
|
3894
3941
|
var e = $p;
|
|
3895
3942
|
raise.nk();
|
|
3896
3943
|
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
3897
3944
|
var it = raisedOrRethrow(e, raise);
|
|
3898
|
-
|
|
3945
|
+
tmp_12 = new Left(it);
|
|
3899
3946
|
} else {
|
|
3900
3947
|
if ($p instanceof Error) {
|
|
3901
3948
|
var e_0 = $p;
|
|
@@ -3905,7 +3952,7 @@
|
|
|
3905
3952
|
throw $p;
|
|
3906
3953
|
}
|
|
3907
3954
|
}
|
|
3908
|
-
tmp =
|
|
3955
|
+
tmp = tmp_12;
|
|
3909
3956
|
}
|
|
3910
3957
|
return tmp;
|
|
3911
3958
|
}
|
|
@@ -4208,7 +4255,8 @@
|
|
|
4208
4255
|
}
|
|
4209
4256
|
}
|
|
4210
4257
|
var content = this_0;
|
|
4211
|
-
var
|
|
4258
|
+
var headers = raise.qk(parseHeaders(_this__u8e3s4, $this));
|
|
4259
|
+
var res = new Response(statusCode, headers, content);
|
|
4212
4260
|
raise.nk();
|
|
4213
4261
|
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
4214
4262
|
tmp = new Right(res);
|
|
@@ -4233,6 +4281,63 @@
|
|
|
4233
4281
|
}
|
|
4234
4282
|
return tmp;
|
|
4235
4283
|
}
|
|
4284
|
+
function parseHeaders(_this__u8e3s4, $this) {
|
|
4285
|
+
// Inline function 'arrow.core.raise.either' call
|
|
4286
|
+
// Inline function 'arrow.core.raise.fold' call
|
|
4287
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
4288
|
+
// Inline function 'arrow.core.raise.fold' call
|
|
4289
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
4290
|
+
var raise = new DefaultRaise(false);
|
|
4291
|
+
var tmp;
|
|
4292
|
+
try {
|
|
4293
|
+
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
4294
|
+
// Inline function 'community.flock.wirespec.compiler.core.parse.EndpointParser.parseHeaders.<anonymous>' call
|
|
4295
|
+
$this.s28(_this__u8e3s4.h28_1);
|
|
4296
|
+
var tmp_0;
|
|
4297
|
+
if (_this__u8e3s4.h28_1.a28_1 instanceof Hash) {
|
|
4298
|
+
raise.qk(_this__u8e3s4.l28());
|
|
4299
|
+
var tmp_1;
|
|
4300
|
+
if (_this__u8e3s4.h28_1.a28_1 instanceof LeftCurly) {
|
|
4301
|
+
// Inline function 'kotlin.with' call
|
|
4302
|
+
// Inline function 'kotlin.contracts.contract' call
|
|
4303
|
+
// Inline function 'community.flock.wirespec.compiler.core.parse.EndpointParser.parseHeaders.<anonymous>.<anonymous>' call
|
|
4304
|
+
var $this$with = $this.u28_1;
|
|
4305
|
+
tmp_1 = raise.qk($this$with.v28(_this__u8e3s4)).e26_1;
|
|
4306
|
+
} else {
|
|
4307
|
+
// Inline function 'community.flock.wirespec.compiler.core.exceptions.Companion.invoke' call
|
|
4308
|
+
var actual = _this__u8e3s4.h28_1;
|
|
4309
|
+
var tmp$ret$2 = new WrongTokenException(getKClass(LeftCurly), actual);
|
|
4310
|
+
raise.pk(tmp$ret$2);
|
|
4311
|
+
}
|
|
4312
|
+
tmp_0 = tmp_1;
|
|
4313
|
+
} else {
|
|
4314
|
+
tmp_0 = emptyList();
|
|
4315
|
+
}
|
|
4316
|
+
var res = tmp_0;
|
|
4317
|
+
raise.nk();
|
|
4318
|
+
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
4319
|
+
tmp = new Right(res);
|
|
4320
|
+
} catch ($p) {
|
|
4321
|
+
var tmp_2;
|
|
4322
|
+
if ($p instanceof RaiseCancellationException) {
|
|
4323
|
+
var e = $p;
|
|
4324
|
+
raise.nk();
|
|
4325
|
+
// Inline function 'arrow.core.raise.either.<anonymous>' call
|
|
4326
|
+
var it = raisedOrRethrow(e, raise);
|
|
4327
|
+
tmp_2 = new Left(it);
|
|
4328
|
+
} else {
|
|
4329
|
+
if ($p instanceof Error) {
|
|
4330
|
+
var e_0 = $p;
|
|
4331
|
+
raise.nk();
|
|
4332
|
+
throw nonFatalOrThrow(e_0);
|
|
4333
|
+
} else {
|
|
4334
|
+
throw $p;
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
tmp = tmp_2;
|
|
4338
|
+
}
|
|
4339
|
+
return tmp;
|
|
4340
|
+
}
|
|
4236
4341
|
function parseContent(_this__u8e3s4, $this, wsType, value, isDict) {
|
|
4237
4342
|
// Inline function 'arrow.core.raise.either' call
|
|
4238
4343
|
// Inline function 'arrow.core.raise.fold' call
|