@flock/wirespec 0.18.13 → 0.18.14

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
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@flock/wirespec",
3
- "version": "0.18.13",
3
+ "version": "0.18.14",
4
4
  "main": "wirespec-src-plugin-npm.mjs",
5
5
  "types": "wirespec-src-plugin-npm.d.mts",
6
6
  "devDependencies": {
7
7
  "typescript": "5.9.3"
8
8
  },
9
9
  "dependencies": {},
10
- "peerDependencies": {},
10
+ "peerDependencies": {
11
+ "msw": "^2.0.0"
12
+ },
11
13
  "optionalDependencies": {},
12
14
  "bundledDependencies": [],
13
15
  "bin": {
@@ -27,6 +29,15 @@
27
29
  "./serialization": {
28
30
  "types": "./wirespec-serialization.d.ts",
29
31
  "default": "./wirespec-serialization.mjs"
32
+ },
33
+ "./msw": {
34
+ "types": "./wirespec-msw.d.ts",
35
+ "default": "./wirespec-msw.mjs"
36
+ }
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "msw": {
40
+ "optional": true
30
41
  }
31
42
  },
32
43
  "repository": {
@@ -0,0 +1,53 @@
1
+ import type { RequestHandler } from 'msw'
2
+ import type { Serialization } from './wirespec-serialization'
3
+
4
+ // Mirrors the generated `Wirespec.RawRequest` / `RawResponse` so generated endpoint `api`
5
+ // objects are assignable to WirespecMswEndpoint (the method union must match exactly).
6
+ type Method = 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH' | 'TRACE'
7
+
8
+ type RawRequest = {
9
+ method: Method
10
+ path: string[]
11
+ queries: Record<string, string>
12
+ headers: Record<string, string>
13
+ body?: string
14
+ }
15
+
16
+ type RawResponse = {
17
+ status: number
18
+ headers: Record<string, string>
19
+ body?: string
20
+ }
21
+
22
+ /**
23
+ * Structural mirror of the generated `Wirespec.Api<Req, Res>` type. The shipped module
24
+ * cannot import the consumer's per-project generated `Wirespec` namespace, so the shape
25
+ * is redeclared here; generated endpoint `api` objects are assignable to it.
26
+ */
27
+ export type WirespecMswEndpoint<Req, Res> = {
28
+ method: string
29
+ path: string
30
+ server: (serialization: Serialization) => {
31
+ from: (request: RawRequest) => Req
32
+ to: (response: Res) => RawResponse
33
+ }
34
+ }
35
+
36
+ export type WirespecMswOptions = {
37
+ /** Host or path prefix prepended to the contract path, e.g. "https://api.example.com" or "/api". */
38
+ baseUrl?: string
39
+ /** Override the serialization used to (de)serialize requests/responses. */
40
+ serialization?: Serialization
41
+ }
42
+
43
+ /**
44
+ * Build a typed MSW request handler for a generated Wirespec endpoint.
45
+ *
46
+ * The generics are inferred from `api.server`, constraining `resolver` to the endpoint's
47
+ * own request/response types: returning a response from a different endpoint is a compile error.
48
+ */
49
+ export declare function wirespec<Req, Res>(
50
+ api: WirespecMswEndpoint<Req, Res>,
51
+ resolver: (request: Req) => Res | Promise<Res>,
52
+ options?: WirespecMswOptions,
53
+ ): RequestHandler
@@ -0,0 +1,83 @@
1
+ import { http, HttpResponse } from 'msw'
2
+ import { wirespecSerialization } from './wirespec-serialization.mjs'
3
+
4
+ const METHODS = {
5
+ GET: 'get',
6
+ PUT: 'put',
7
+ POST: 'post',
8
+ DELETE: 'delete',
9
+ PATCH: 'patch',
10
+ HEAD: 'head',
11
+ OPTIONS: 'options',
12
+ }
13
+
14
+ const PARAM = /^:(.+)$/
15
+ const BRACE = /^\{(.+)\}$/
16
+
17
+ const segments = (path) => path.replace(/^\/+/, '').split('/').filter((s) => s.length > 0)
18
+
19
+ // Normalize a Wirespec contract path into an MSW matcher: `{id}` -> `:id`, single leading slash.
20
+ const normalizePath = (path) => {
21
+ const colon = path.replace(/\{([^/}]+)\}/g, ':$1')
22
+ return colon.startsWith('/') ? colon : `/${colon}`
23
+ }
24
+
25
+ // Without a baseUrl, prefix the contract path with `*` so it matches on any origin
26
+ // (a bare relative path is not matched against absolute request URLs in Node). With a
27
+ // baseUrl, pin the origin/prefix instead.
28
+ const matcher = (baseUrl, path) => {
29
+ const normalized = normalizePath(path)
30
+ return baseUrl ? `${baseUrl.replace(/\/+$/, '')}${normalized}` : `*${normalized}`
31
+ }
32
+
33
+ // Rebuild the positional RawRequest.path from the contract template, substituting MSW's
34
+ // matched params for `:name`/`{name}` segments. Using the template (not the raw URL) keeps
35
+ // path-param indices aligned with the contract even when a baseUrl prefix is present.
36
+ const buildPath = (templatePath, params) =>
37
+ segments(templatePath).map((segment) => {
38
+ const match = segment.match(PARAM) ?? segment.match(BRACE)
39
+ if (!match) return segment
40
+ const value = params[match[1]]
41
+ return Array.isArray(value) ? value[0] : value
42
+ })
43
+
44
+ const readBody = async (request) => {
45
+ if (request.method === 'GET' || request.method === 'HEAD') return undefined
46
+ const text = await request.text()
47
+ return text.length > 0 ? text : undefined
48
+ }
49
+
50
+ /**
51
+ * Build an MSW request handler for a generated Wirespec endpoint `api`.
52
+ *
53
+ * The resolver receives the deserialized, typed Wirespec request and must return one of
54
+ * that endpoint's responses; a response from a different endpoint is a compile error.
55
+ *
56
+ * Options:
57
+ * - baseUrl: host or path prefix to prepend to the contract path (e.g. "https://api.example.com").
58
+ * - serialization: override the (de)serializer (defaults to wirespecSerialization).
59
+ */
60
+ export function wirespec(api, resolver, options = {}) {
61
+ const serialization = options.serialization ?? wirespecSerialization
62
+ const pattern = matcher(options.baseUrl, api.path)
63
+ const method = METHODS[String(api.method).toUpperCase()] ?? 'all'
64
+ const endpoint = api.server(serialization)
65
+
66
+ return http[method](pattern, async ({ request, params }) => {
67
+ const url = new URL(request.url)
68
+ const rawRequest = {
69
+ method: request.method,
70
+ path: buildPath(api.path, params),
71
+ queries: Object.fromEntries(url.searchParams),
72
+ headers: Object.fromEntries(request.headers),
73
+ body: await readBody(request),
74
+ }
75
+ const typedRequest = endpoint.from(rawRequest)
76
+ const response = await resolver(typedRequest)
77
+ const rawResponse = endpoint.to(response)
78
+ return new HttpResponse(rawResponse.body ?? null, {
79
+ status: rawResponse.status,
80
+ headers: rawResponse.headers,
81
+ })
82
+ })
83
+ }
@@ -183,7 +183,7 @@ initMetadataForClass(ParamType, 'ParamType', VOID, Enum);
183
183
  initMetadataForClass(Param, 'Param');
184
184
  initMetadataForClass(FileExtension, 'FileExtension', VOID, Enum);
185
185
  initMetadataForCompanion(Companion_0);
186
- initMetadataForClass(LanguageEmitter, 'LanguageEmitter', VOID, VOID, [TypeDefinitionEmitter, NotYetImplemented]);
186
+ initMetadataForClass(LanguageEmitter, 'LanguageEmitter', VOID, VOID, [NotYetImplemented, TypeDefinitionEmitter]);
187
187
  initMetadataForCompanion(Companion_1);
188
188
  initMetadataForClass(PackageName, 'PackageName');
189
189
  initMetadataForObject(Spacer, 'Spacer');
@@ -275,7 +275,107 @@ function emit_8(channel) {
275
275
  return trimMargin('\n |' + emitImports(this, channel) + '\n |\n |@FunctionalInterface\n |public interface ' + this.br(channel.qo_1) + ' {\n | void invoke(' + emitFullyQualified(this, channel, channel.ro_1) + this.j1v(channel.ro_1) + ' message);\n |}\n |\n ');
276
276
  }
277
277
  initMetadataForInterface(JavaChannelDefinitionEmitter, 'JavaChannelDefinitionEmitter', VOID, VOID, [JavaTypeDefinitionEmitter]);
278
- function emit_9(endpoint) {
278
+ function emit_9(refined) {
279
+ return trimMargin('\n |public record ' + this.br(refined.gr_1) + ' (' + this.bq(refined.hr_1) + ' value) implements Wirespec.Refined<' + this.bq(refined.hr_1) + '> {\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String toString() { return value.toString(); }\n |' + Spacer_instance.toString() + 'public boolean validate() {\n |' + Spacer_instance.toString() + Spacer_instance.toString() + this.pr(refined) + '\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public ' + this.bq(refined.hr_1) + ' value() { return value; }\n |}\n |\n ');
280
+ }
281
+ function emitValidator(_this__u8e3s4) {
282
+ var defaultReturn = 'return true;';
283
+ var type = _this__u8e3s4.hr_1.tu_1;
284
+ var tmp;
285
+ if (type instanceof Integer) {
286
+ var tmp0_safe_receiver = type.yt_1;
287
+ var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : this.cq(tmp0_safe_receiver);
288
+ tmp = tmp1_elvis_lhs == null ? defaultReturn : tmp1_elvis_lhs;
289
+ } else {
290
+ if (type instanceof Number_0) {
291
+ var tmp2_safe_receiver = type.bu_1;
292
+ var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : this.cq(tmp2_safe_receiver);
293
+ tmp = tmp3_elvis_lhs == null ? defaultReturn : tmp3_elvis_lhs;
294
+ } else {
295
+ if (type instanceof String_0) {
296
+ var tmp4_safe_receiver = type.vt_1;
297
+ var tmp_0;
298
+ var tmp_1 = tmp4_safe_receiver;
299
+ if ((tmp_1 == null ? null : new RegExp_0(tmp_1)) == null) {
300
+ tmp_0 = null;
301
+ } else {
302
+ tmp_0 = this.cq(new RegExp_0(tmp4_safe_receiver));
303
+ }
304
+ var tmp5_elvis_lhs = tmp_0;
305
+ tmp = tmp5_elvis_lhs == null ? defaultReturn : tmp5_elvis_lhs;
306
+ } else {
307
+ if (equals(type, Boolean_instance)) {
308
+ tmp = defaultReturn;
309
+ } else {
310
+ if (equals(type, Bytes_instance)) {
311
+ tmp = defaultReturn;
312
+ } else {
313
+ noWhenBranchMatchedException();
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ return tmp;
320
+ }
321
+ initMetadataForInterface(JavaRefinedTypeDefinitionEmitter, 'JavaRefinedTypeDefinitionEmitter', VOID, VOID, [JavaTypeDefinitionEmitter]);
322
+ function emit_10(identifier) {
323
+ var tmp;
324
+ if (identifier instanceof DefinitionIdentifier) {
325
+ tmp = this.u1v(identifier.l1());
326
+ } else {
327
+ if (identifier instanceof FieldIdentifier) {
328
+ tmp = this.y1v(this.u1v(identifier.l1()));
329
+ } else {
330
+ noWhenBranchMatchedException();
331
+ }
332
+ }
333
+ return tmp;
334
+ }
335
+ function sanitizeSymbol(_this__u8e3s4) {
336
+ // Inline function 'kotlin.collections.mapIndexed' call
337
+ var this_0 = split(_this__u8e3s4, ['.', ' ', '-']);
338
+ // Inline function 'kotlin.collections.mapIndexedTo' call
339
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
340
+ var index = 0;
341
+ var _iterator__ex2g4s = this_0.t();
342
+ while (_iterator__ex2g4s.u()) {
343
+ var item = _iterator__ex2g4s.v();
344
+ var _unary__edvuaz = index;
345
+ index = _unary__edvuaz + 1 | 0;
346
+ var tmp$ret$0 = checkIndexOverflow(_unary__edvuaz) > 0 ? Companion_instance_1.sq(item) : item;
347
+ destination.x(tmp$ret$0);
348
+ }
349
+ var tmp = asSequence(joinToString(destination, ''));
350
+ return this.x1v(joinToString_0(filter(tmp, JavaIdentifierEmitter$sanitizeSymbol$lambda), ''));
351
+ }
352
+ function sanitizeFirstIsDigit(_this__u8e3s4) {
353
+ var tmp;
354
+ var tmp0_safe_receiver = firstOrNull(_this__u8e3s4);
355
+ var tmp_0;
356
+ var tmp_1 = tmp0_safe_receiver;
357
+ if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
358
+ tmp_0 = null;
359
+ } else {
360
+ tmp_0 = isDigit(tmp0_safe_receiver);
361
+ }
362
+ if (tmp_0 === true) {
363
+ tmp = '_' + _this__u8e3s4;
364
+ } else {
365
+ tmp = _this__u8e3s4;
366
+ }
367
+ return tmp;
368
+ }
369
+ function sanitizeKeywords(_this__u8e3s4) {
370
+ return Companion_getInstance_0().a1w_1.u1(_this__u8e3s4) ? '_' + _this__u8e3s4 : _this__u8e3s4;
371
+ }
372
+ initMetadataForInterface(JavaIdentifierEmitter, 'JavaIdentifierEmitter');
373
+ function emit_11(enum_0, module_0) {
374
+ var tmp = this.br(enum_0.lr_1);
375
+ return trimMargin('\n |public enum ' + tmp + ' implements Wirespec.Enum {\n |' + spacer(joinToString(enum_0.mr_1, ',\n', VOID, VOID, VOID, VOID, JavaEnumDefinitionEmitter$emit$lambda(this))) + ';\n |' + Spacer_instance.toString() + 'public final String label;\n |' + Spacer_instance.toString() + this.br(enum_0.lr_1) + '(String label) {\n |' + Spacer_instance.vr(2) + 'this.label = label;\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String toString() {\n |' + Spacer_instance.vr(2) + 'return label;\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String label() {\n |' + Spacer_instance.vr(2) + 'return label;\n |' + Spacer_instance.toString() + '}\n |}\n |\n ');
376
+ }
377
+ initMetadataForInterface(JavaEnumDefinitionEmitter, 'JavaEnumDefinitionEmitter', VOID, VOID, [JavaIdentifierEmitter]);
378
+ function emit_12(endpoint) {
279
379
  var tmp = emitImports_0(this, endpoint);
280
380
  var tmp_0 = this.br(endpoint.ip_1);
281
381
  var tmp_1 = get_pathParams(endpoint);
@@ -307,10 +407,10 @@ function emit_9(endpoint) {
307
407
  function emitHandleFunction(endpoint) {
308
408
  return 'java.util.concurrent.CompletableFuture<Response<?>> ' + Companion_instance_1.tq(this.br(endpoint.ip_1)) + '(Request request);';
309
409
  }
310
- function emit_10(_this__u8e3s4, endpoint) {
410
+ function emit_13(_this__u8e3s4, endpoint) {
311
411
  return trimMargin('\n |' + Spacer_instance.toString() + 'record Request (\n |' + Spacer_instance.vr(2) + 'Path path,\n |' + Spacer_instance.vr(2) + 'Wirespec.Method method,\n |' + Spacer_instance.vr(2) + 'Queries queries,\n |' + Spacer_instance.vr(2) + 'RequestHeaders headers,\n |' + Spacer_instance.vr(2) + emit_16(this, _this__u8e3s4.rp_1) + ' body\n |' + Spacer_instance.toString() + ') implements Wirespec.Request<' + emit_16(this, _this__u8e3s4.rp_1) + '> {\n |' + Spacer_instance.vr(2) + emitConstructor(this, _this__u8e3s4, endpoint) + '\n |' + Spacer_instance.toString() + '}\n ');
312
412
  }
313
- function emit_11(_this__u8e3s4) {
413
+ function emit_14(_this__u8e3s4) {
314
414
  var tmp = Spacer_instance.toString();
315
415
  var tmp_0 = Companion_instance_1.sq(_this__u8e3s4.up_1);
316
416
  var tmp_1 = Spacer_instance.vr(2);
@@ -343,112 +443,12 @@ function emit_11(_this__u8e3s4) {
343
443
  return trimMargin('\n |' + tmp + 'record Response' + tmp_0 + '(\n |' + tmp_1 + 'Integer status,\n |' + tmp_2 + 'Headers headers,\n |' + tmp_3 + tmp_4 + ' body\n |' + tmp_5 + ') implements Response' + tmp_6 + 'XX<' + tmp_7 + '>, Response' + tmp_8 + ' {\n |' + tmp_9 + 'public Response' + tmp_10 + '(' + tmp_13 + ') {\n |' + tmp_14 + 'this(' + tmp_15 + ', ' + tmp_16 + ', ' + tmp_17 + ');\n |' + tmp_18 + '}\n |' + tmp_19 + emitObject(this, _this__u8e3s4.vp_1, 'Headers', 'Wirespec.Response.Headers', JavaEndpointDefinitionEmitter$emit$lambda_7(this)) + '\n |' + Spacer_instance.toString() + '}\n ');
344
444
  }
345
445
  initMetadataForInterface(JavaEndpointDefinitionEmitter, 'JavaEndpointDefinitionEmitter', VOID, VOID, [JavaTypeDefinitionEmitter]);
346
- function emit_12(identifier) {
347
- var tmp;
348
- if (identifier instanceof DefinitionIdentifier) {
349
- tmp = this.u1v(identifier.l1());
350
- } else {
351
- if (identifier instanceof FieldIdentifier) {
352
- tmp = this.y1v(this.u1v(identifier.l1()));
353
- } else {
354
- noWhenBranchMatchedException();
355
- }
356
- }
357
- return tmp;
358
- }
359
- function sanitizeSymbol(_this__u8e3s4) {
360
- // Inline function 'kotlin.collections.mapIndexed' call
361
- var this_0 = split(_this__u8e3s4, ['.', ' ', '-']);
362
- // Inline function 'kotlin.collections.mapIndexedTo' call
363
- var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
364
- var index = 0;
365
- var _iterator__ex2g4s = this_0.t();
366
- while (_iterator__ex2g4s.u()) {
367
- var item = _iterator__ex2g4s.v();
368
- var _unary__edvuaz = index;
369
- index = _unary__edvuaz + 1 | 0;
370
- var tmp$ret$0 = checkIndexOverflow(_unary__edvuaz) > 0 ? Companion_instance_1.sq(item) : item;
371
- destination.x(tmp$ret$0);
372
- }
373
- var tmp = asSequence(joinToString(destination, ''));
374
- return this.x1v(joinToString_0(filter(tmp, JavaIdentifierEmitter$sanitizeSymbol$lambda), ''));
375
- }
376
- function sanitizeFirstIsDigit(_this__u8e3s4) {
377
- var tmp;
378
- var tmp0_safe_receiver = firstOrNull(_this__u8e3s4);
379
- var tmp_0;
380
- var tmp_1 = tmp0_safe_receiver;
381
- if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
382
- tmp_0 = null;
383
- } else {
384
- tmp_0 = isDigit(tmp0_safe_receiver);
385
- }
386
- if (tmp_0 === true) {
387
- tmp = '_' + _this__u8e3s4;
388
- } else {
389
- tmp = _this__u8e3s4;
390
- }
391
- return tmp;
392
- }
393
- function sanitizeKeywords(_this__u8e3s4) {
394
- return Companion_getInstance_0().a1w_1.u1(_this__u8e3s4) ? '_' + _this__u8e3s4 : _this__u8e3s4;
395
- }
396
- initMetadataForInterface(JavaIdentifierEmitter, 'JavaIdentifierEmitter');
397
- function emit_13(enum_0, module_0) {
398
- var tmp = this.br(enum_0.lr_1);
399
- return trimMargin('\n |public enum ' + tmp + ' implements Wirespec.Enum {\n |' + spacer(joinToString(enum_0.mr_1, ',\n', VOID, VOID, VOID, VOID, JavaEnumDefinitionEmitter$emit$lambda(this))) + ';\n |' + Spacer_instance.toString() + 'public final String label;\n |' + Spacer_instance.toString() + this.br(enum_0.lr_1) + '(String label) {\n |' + Spacer_instance.vr(2) + 'this.label = label;\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String toString() {\n |' + Spacer_instance.vr(2) + 'return label;\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String label() {\n |' + Spacer_instance.vr(2) + 'return label;\n |' + Spacer_instance.toString() + '}\n |}\n |\n ');
400
- }
401
- initMetadataForInterface(JavaEnumDefinitionEmitter, 'JavaEnumDefinitionEmitter', VOID, VOID, [JavaIdentifierEmitter]);
402
- function emit_14(refined) {
403
- return trimMargin('\n |public record ' + this.br(refined.gr_1) + ' (' + this.bq(refined.hr_1) + ' value) implements Wirespec.Refined<' + this.bq(refined.hr_1) + '> {\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public String toString() { return value.toString(); }\n |' + Spacer_instance.toString() + 'public boolean validate() {\n |' + Spacer_instance.toString() + Spacer_instance.toString() + this.pr(refined) + '\n |' + Spacer_instance.toString() + '}\n |' + Spacer_instance.toString() + '@Override\n |' + Spacer_instance.toString() + 'public ' + this.bq(refined.hr_1) + ' value() { return value; }\n |}\n |\n ');
404
- }
405
- function emitValidator(_this__u8e3s4) {
406
- var defaultReturn = 'return true;';
407
- var type = _this__u8e3s4.hr_1.tu_1;
408
- var tmp;
409
- if (type instanceof Integer) {
410
- var tmp0_safe_receiver = type.yt_1;
411
- var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : this.cq(tmp0_safe_receiver);
412
- tmp = tmp1_elvis_lhs == null ? defaultReturn : tmp1_elvis_lhs;
413
- } else {
414
- if (type instanceof Number_0) {
415
- var tmp2_safe_receiver = type.bu_1;
416
- var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : this.cq(tmp2_safe_receiver);
417
- tmp = tmp3_elvis_lhs == null ? defaultReturn : tmp3_elvis_lhs;
418
- } else {
419
- if (type instanceof String_0) {
420
- var tmp4_safe_receiver = type.vt_1;
421
- var tmp_0;
422
- var tmp_1 = tmp4_safe_receiver;
423
- if ((tmp_1 == null ? null : new RegExp_0(tmp_1)) == null) {
424
- tmp_0 = null;
425
- } else {
426
- tmp_0 = this.cq(new RegExp_0(tmp4_safe_receiver));
427
- }
428
- var tmp5_elvis_lhs = tmp_0;
429
- tmp = tmp5_elvis_lhs == null ? defaultReturn : tmp5_elvis_lhs;
430
- } else {
431
- if (equals(type, Boolean_instance)) {
432
- tmp = defaultReturn;
433
- } else {
434
- if (equals(type, Bytes_instance)) {
435
- tmp = defaultReturn;
436
- } else {
437
- noWhenBranchMatchedException();
438
- }
439
- }
440
- }
441
- }
442
- }
443
- return tmp;
444
- }
445
- initMetadataForInterface(JavaRefinedTypeDefinitionEmitter, 'JavaRefinedTypeDefinitionEmitter', VOID, VOID, [JavaTypeDefinitionEmitter]);
446
446
  function emit_15(union) {
447
447
  var tmp = this.br(union.uo_1);
448
448
  return trimMargin('\n |public sealed interface ' + tmp + ' permits ' + joinToString(union.vo_1, VOID, VOID, VOID, VOID, VOID, JavaUnionDefinitionEmitter$emit$lambda) + ' {}\n |\n ');
449
449
  }
450
450
  initMetadataForInterface(JavaUnionDefinitionEmitter, 'JavaUnionDefinitionEmitter', VOID, VOID, [JavaIdentifierEmitter]);
451
- initMetadataForClass(JavaEmitter, 'JavaEmitter', JavaEmitter, LanguageEmitter, [JavaEndpointDefinitionEmitter, JavaEnumDefinitionEmitter, JavaRefinedTypeDefinitionEmitter, JavaUnionDefinitionEmitter, JavaTypeDefinitionEmitter, JavaIdentifierEmitter, JavaChannelDefinitionEmitter, LanguageEmitter]);
451
+ initMetadataForClass(JavaEmitter, 'JavaEmitter', JavaEmitter, LanguageEmitter, [JavaChannelDefinitionEmitter, JavaRefinedTypeDefinitionEmitter, JavaEnumDefinitionEmitter, JavaEndpointDefinitionEmitter, JavaTypeDefinitionEmitter, JavaIdentifierEmitter, JavaUnionDefinitionEmitter, LanguageEmitter]);
452
452
  initMetadataForCompanion(Companion);
453
453
  initMetadataForCompanion(Companion_0);
454
454
  initMetadataForClass(JavaIrEmitter, 'JavaIrEmitter', JavaIrEmitter, VOID, [IrEmitter]);
@@ -1975,19 +1975,19 @@ function JavaUnionDefinitionEmitter$emit$lambda(it) {
1975
1975
  function JavaUnionDefinitionEmitter() {
1976
1976
  }
1977
1977
  //region block: post-declaration
1978
- protoOf(JavaEmitter).br = emit_12;
1978
+ protoOf(JavaEmitter).br = emit_10;
1979
1979
  protoOf(JavaEmitter).yp = emit_3;
1980
1980
  protoOf(JavaEmitter).zp = emit_4;
1981
1981
  protoOf(JavaEmitter).aq = emit_5;
1982
1982
  protoOf(JavaEmitter).bq = emit_6;
1983
1983
  protoOf(JavaEmitter).cq = emit_7;
1984
- protoOf(JavaEmitter).or = emit_9;
1985
- protoOf(JavaEmitter).v1v = emit_10;
1986
- protoOf(JavaEmitter).w1v = emit_11;
1984
+ protoOf(JavaEmitter).or = emit_12;
1985
+ protoOf(JavaEmitter).v1v = emit_13;
1986
+ protoOf(JavaEmitter).w1v = emit_14;
1987
1987
  protoOf(JavaEmitter).cr = emit_8;
1988
- protoOf(JavaEmitter).nr = emit_13;
1988
+ protoOf(JavaEmitter).nr = emit_11;
1989
1989
  protoOf(JavaEmitter).dr = emit_15;
1990
- protoOf(JavaEmitter).ir = emit_14;
1990
+ protoOf(JavaEmitter).ir = emit_9;
1991
1991
  protoOf(JavaEmitter).u1v = sanitizeSymbol;
1992
1992
  protoOf(JavaEmitter).x1v = sanitizeFirstIsDigit;
1993
1993
  protoOf(JavaEmitter).y1v = sanitizeKeywords;