@outfoxx/sunday 1.1.0-alpha.13 → 1.1.0-alpha.16
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/dist/fetch-event-source.d.ts +4 -0
- package/dist/fetch-event-source.js.map +1 -1
- package/dist/fetch.js +6 -1
- package/dist/fetch.js.map +1 -1
- package/dist/media-type-codecs/media-type-decoders.js.map +1 -1
- package/dist/media-type.d.ts +1 -1
- package/dist/media-type.js +10 -4
- package/dist/media-type.js.map +1 -1
- package/package.json +1 -1
- package/src/class-type.ts +2 -2
- package/src/event-parser.ts +4 -4
- package/src/fetch-event-source.ts +22 -7
- package/src/fetch-request-factory.ts +23 -23
- package/src/fetch.ts +8 -4
- package/src/header-parameters.ts +2 -2
- package/src/media-type-codecs/binary-decoder.ts +1 -1
- package/src/media-type-codecs/binary-encoder.ts +1 -1
- package/src/media-type-codecs/cbor-decoder.ts +16 -16
- package/src/media-type-codecs/cbor-encoder.ts +14 -14
- package/src/media-type-codecs/json-decoder.ts +15 -15
- package/src/media-type-codecs/json-encoder.ts +7 -7
- package/src/media-type-codecs/media-type-decoder.ts +1 -1
- package/src/media-type-codecs/media-type-decoders.ts +4 -5
- package/src/media-type-codecs/media-type-encoder.ts +3 -3
- package/src/media-type-codecs/media-type-encoders.ts +4 -4
- package/src/media-type-codecs/www-form-url-encoder.ts +15 -15
- package/src/media-type.ts +17 -10
- package/src/problem.ts +1 -1
- package/src/request-factory.ts +7 -7
- package/src/sunday-error.ts +4 -4
- package/src/url-template.ts +1 -1
- package/src/util/base64.ts +1 -1
- package/src/util/rxjs.ts +3 -3
- package/src/util/stream-rxjs.ts +1 -1
|
@@ -39,7 +39,7 @@ import { MediaTypeDecoder } from './media-type-decoder';
|
|
|
39
39
|
export class CBORDecoder implements MediaTypeDecoder {
|
|
40
40
|
static get default(): CBORDecoder {
|
|
41
41
|
return new CBORDecoder(
|
|
42
|
-
CBORDecoder.NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH
|
|
42
|
+
CBORDecoder.NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH,
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -170,7 +170,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
170
170
|
|
|
171
171
|
private zonedDateTimeDeserializer: Deserializer = (
|
|
172
172
|
key: string,
|
|
173
|
-
value: unknown
|
|
173
|
+
value: unknown,
|
|
174
174
|
) => {
|
|
175
175
|
if (value == null) {
|
|
176
176
|
return value;
|
|
@@ -199,7 +199,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
199
199
|
const duration = Duration.parse(`PT${value}S`);
|
|
200
200
|
const instant = Instant.ofEpochSecond(
|
|
201
201
|
duration.seconds(),
|
|
202
|
-
duration.nano()
|
|
202
|
+
duration.nano(),
|
|
203
203
|
);
|
|
204
204
|
return ZonedDateTime.ofInstant(instant, ZoneId.UTC);
|
|
205
205
|
} else {
|
|
@@ -208,7 +208,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
208
208
|
}
|
|
209
209
|
if (typeof value === 'string') {
|
|
210
210
|
return ZonedDateTime.from(
|
|
211
|
-
DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(value)
|
|
211
|
+
DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(value),
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -216,7 +216,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
216
216
|
|
|
217
217
|
private offsetDateTimeDeserializer: Deserializer = (
|
|
218
218
|
key: string,
|
|
219
|
-
value: unknown
|
|
219
|
+
value: unknown,
|
|
220
220
|
) => {
|
|
221
221
|
if (value == null) {
|
|
222
222
|
return value;
|
|
@@ -248,7 +248,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
248
248
|
const duration = Duration.parse(`PT${value}S`);
|
|
249
249
|
const instant = Instant.ofEpochSecond(
|
|
250
250
|
duration.seconds(),
|
|
251
|
-
duration.nano()
|
|
251
|
+
duration.nano(),
|
|
252
252
|
);
|
|
253
253
|
return OffsetDateTime.ofInstant(instant, ZoneId.UTC);
|
|
254
254
|
} else {
|
|
@@ -257,7 +257,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
257
257
|
}
|
|
258
258
|
if (typeof value === 'string') {
|
|
259
259
|
return OffsetDateTime.from(
|
|
260
|
-
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value)
|
|
260
|
+
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value),
|
|
261
261
|
);
|
|
262
262
|
}
|
|
263
263
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -271,7 +271,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
271
271
|
|
|
272
272
|
private offsetTimeDeserializer: Deserializer = (
|
|
273
273
|
key: string,
|
|
274
|
-
value: unknown
|
|
274
|
+
value: unknown,
|
|
275
275
|
) => {
|
|
276
276
|
if (value == null) {
|
|
277
277
|
return value;
|
|
@@ -304,7 +304,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
304
304
|
minute,
|
|
305
305
|
second,
|
|
306
306
|
nanoOfSecond,
|
|
307
|
-
ZoneOffset.of(offset)
|
|
307
|
+
ZoneOffset.of(offset),
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
310
|
if (typeof value === 'string') {
|
|
@@ -315,7 +315,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
315
315
|
|
|
316
316
|
private localDateTimeDeserializer: Deserializer = (
|
|
317
317
|
key: string,
|
|
318
|
-
value: unknown
|
|
318
|
+
value: unknown,
|
|
319
319
|
) => {
|
|
320
320
|
if (value == null) {
|
|
321
321
|
return value;
|
|
@@ -356,12 +356,12 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
356
356
|
hour,
|
|
357
357
|
minute,
|
|
358
358
|
second,
|
|
359
|
-
nanoOfSecond
|
|
359
|
+
nanoOfSecond,
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
if (typeof value === 'string') {
|
|
363
363
|
return LocalDateTime.from(
|
|
364
|
-
DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(value)
|
|
364
|
+
DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(value),
|
|
365
365
|
);
|
|
366
366
|
}
|
|
367
367
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -369,7 +369,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
369
369
|
|
|
370
370
|
private localDateDeserializer: Deserializer = (
|
|
371
371
|
key: string,
|
|
372
|
-
value: unknown
|
|
372
|
+
value: unknown,
|
|
373
373
|
) => {
|
|
374
374
|
if (value == null) {
|
|
375
375
|
return value;
|
|
@@ -398,7 +398,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
398
398
|
|
|
399
399
|
private localTimeDeserializer: Deserializer = (
|
|
400
400
|
key: string,
|
|
401
|
-
value: unknown
|
|
401
|
+
value: unknown,
|
|
402
402
|
) => {
|
|
403
403
|
if (value == null) {
|
|
404
404
|
return value;
|
|
@@ -489,7 +489,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
489
489
|
|
|
490
490
|
private arrayBufferDeserializer: Deserializer = (
|
|
491
491
|
key: string,
|
|
492
|
-
value: unknown
|
|
492
|
+
value: unknown,
|
|
493
493
|
) => {
|
|
494
494
|
if (value == null) {
|
|
495
495
|
return value;
|
|
@@ -500,7 +500,7 @@ export class CBORDecoder implements MediaTypeDecoder {
|
|
|
500
500
|
if (ArrayBuffer.isView(value)) {
|
|
501
501
|
return value.buffer.slice(
|
|
502
502
|
value.byteOffset,
|
|
503
|
-
value.byteOffset + value.byteLength
|
|
503
|
+
value.byteOffset + value.byteLength,
|
|
504
504
|
);
|
|
505
505
|
}
|
|
506
506
|
if (typeof value === 'string') {
|
|
@@ -38,7 +38,7 @@ import { MediaTypeEncoder } from './media-type-encoder';
|
|
|
38
38
|
export class CBOREncoder implements MediaTypeEncoder {
|
|
39
39
|
static get default(): CBOREncoder {
|
|
40
40
|
return new CBOREncoder(
|
|
41
|
-
CBOREncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH
|
|
41
|
+
CBOREncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH,
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -96,7 +96,7 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
96
96
|
Reflect.hasMetadata(
|
|
97
97
|
'jackson:defaultContextGroup:JsonSubTypes',
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
(value as any).constructor ?? {}
|
|
99
|
+
(value as any).constructor ?? {},
|
|
100
100
|
)
|
|
101
101
|
) {
|
|
102
102
|
type = [Object];
|
|
@@ -117,16 +117,16 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
117
117
|
case CBOREncoder.DateEncoding.ISO8601:
|
|
118
118
|
return new TaggedValue(
|
|
119
119
|
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
|
|
120
|
-
value.atZone(ZoneId.UTC)
|
|
120
|
+
value.atZone(ZoneId.UTC),
|
|
121
121
|
),
|
|
122
|
-
isoDateTimeTag
|
|
122
|
+
isoDateTimeTag,
|
|
123
123
|
);
|
|
124
124
|
case CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH:
|
|
125
125
|
return new TaggedValue(value.toEpochMilli(), epochDateTimeTag);
|
|
126
126
|
case CBOREncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH:
|
|
127
127
|
return new TaggedValue(
|
|
128
128
|
secondsToNumber(value.epochSecond(), value.nano()),
|
|
129
|
-
epochDateTimeTag
|
|
129
|
+
epochDateTimeTag,
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
};
|
|
@@ -140,18 +140,18 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
140
140
|
case CBOREncoder.DateEncoding.ISO8601:
|
|
141
141
|
return new TaggedValue(
|
|
142
142
|
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value),
|
|
143
|
-
isoDateTimeTag
|
|
143
|
+
isoDateTimeTag,
|
|
144
144
|
);
|
|
145
145
|
case CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH:
|
|
146
146
|
return new TaggedValue(
|
|
147
147
|
value.toInstant().toEpochMilli(),
|
|
148
|
-
epochDateTimeTag
|
|
148
|
+
epochDateTimeTag,
|
|
149
149
|
);
|
|
150
150
|
case CBOREncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH:
|
|
151
151
|
const instant = value.toInstant();
|
|
152
152
|
return new TaggedValue(
|
|
153
153
|
secondsToNumber(instant.epochSecond(), instant.nano()),
|
|
154
|
-
epochDateTimeTag
|
|
154
|
+
epochDateTimeTag,
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
};
|
|
@@ -165,18 +165,18 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
165
165
|
case CBOREncoder.DateEncoding.ISO8601:
|
|
166
166
|
return new TaggedValue(
|
|
167
167
|
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value),
|
|
168
|
-
isoDateTimeTag
|
|
168
|
+
isoDateTimeTag,
|
|
169
169
|
);
|
|
170
170
|
case CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH:
|
|
171
171
|
return new TaggedValue(
|
|
172
172
|
value.toInstant().toEpochMilli(),
|
|
173
|
-
epochDateTimeTag
|
|
173
|
+
epochDateTimeTag,
|
|
174
174
|
);
|
|
175
175
|
case CBOREncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH:
|
|
176
176
|
const instant = value.toInstant();
|
|
177
177
|
return new TaggedValue(
|
|
178
178
|
secondsToNumber(instant.epochSecond(), instant.nano()),
|
|
179
|
-
epochDateTimeTag
|
|
179
|
+
epochDateTimeTag,
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
};
|
|
@@ -203,7 +203,7 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
203
203
|
this.dateEncoding ==
|
|
204
204
|
CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
205
205
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
206
|
-
: value.nano()
|
|
206
|
+
: value.nano(),
|
|
207
207
|
),
|
|
208
208
|
value.offset().toString(),
|
|
209
209
|
];
|
|
@@ -230,7 +230,7 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
230
230
|
this.dateEncoding ==
|
|
231
231
|
CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
232
232
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
233
|
-
: value.nano()
|
|
233
|
+
: value.nano(),
|
|
234
234
|
),
|
|
235
235
|
];
|
|
236
236
|
}
|
|
@@ -266,7 +266,7 @@ export class CBOREncoder implements MediaTypeEncoder {
|
|
|
266
266
|
this.dateEncoding ==
|
|
267
267
|
CBOREncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
268
268
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
269
|
-
: value.nano()
|
|
269
|
+
: value.nano(),
|
|
270
270
|
),
|
|
271
271
|
];
|
|
272
272
|
}
|
|
@@ -42,7 +42,7 @@ export class JSONDecoder
|
|
|
42
42
|
{
|
|
43
43
|
static get default(): JSONDecoder {
|
|
44
44
|
return new JSONDecoder(
|
|
45
|
-
JSONDecoder.NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH
|
|
45
|
+
JSONDecoder.NumericDateDecoding.DECIMAL_SECONDS_SINCE_EPOCH,
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -146,7 +146,7 @@ export class JSONDecoder
|
|
|
146
146
|
|
|
147
147
|
private zonedDateTimeDeserializer: Deserializer = (
|
|
148
148
|
key: string,
|
|
149
|
-
value: unknown
|
|
149
|
+
value: unknown,
|
|
150
150
|
) => {
|
|
151
151
|
if (value == null) {
|
|
152
152
|
return value;
|
|
@@ -172,7 +172,7 @@ export class JSONDecoder
|
|
|
172
172
|
const duration = Duration.parse(`PT${value}S`);
|
|
173
173
|
const instant = Instant.ofEpochSecond(
|
|
174
174
|
duration.seconds(),
|
|
175
|
-
duration.nano()
|
|
175
|
+
duration.nano(),
|
|
176
176
|
);
|
|
177
177
|
return ZonedDateTime.ofInstant(instant, ZoneId.UTC);
|
|
178
178
|
} else {
|
|
@@ -181,7 +181,7 @@ export class JSONDecoder
|
|
|
181
181
|
}
|
|
182
182
|
if (typeof value === 'string') {
|
|
183
183
|
return ZonedDateTime.from(
|
|
184
|
-
DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(value)
|
|
184
|
+
DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(value),
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -189,7 +189,7 @@ export class JSONDecoder
|
|
|
189
189
|
|
|
190
190
|
private offsetDateTimeDeserializer: Deserializer = (
|
|
191
191
|
key: string,
|
|
192
|
-
value: unknown
|
|
192
|
+
value: unknown,
|
|
193
193
|
) => {
|
|
194
194
|
if (value == null) {
|
|
195
195
|
return value;
|
|
@@ -215,7 +215,7 @@ export class JSONDecoder
|
|
|
215
215
|
const duration = Duration.parse(`PT${value}S`);
|
|
216
216
|
const instant = Instant.ofEpochSecond(
|
|
217
217
|
duration.seconds(),
|
|
218
|
-
duration.nano()
|
|
218
|
+
duration.nano(),
|
|
219
219
|
);
|
|
220
220
|
return OffsetDateTime.ofInstant(instant, ZoneId.UTC);
|
|
221
221
|
} else {
|
|
@@ -224,7 +224,7 @@ export class JSONDecoder
|
|
|
224
224
|
}
|
|
225
225
|
if (typeof value === 'string') {
|
|
226
226
|
return OffsetDateTime.from(
|
|
227
|
-
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value)
|
|
227
|
+
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value),
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
230
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -238,7 +238,7 @@ export class JSONDecoder
|
|
|
238
238
|
|
|
239
239
|
private offsetTimeDeserializer: Deserializer = (
|
|
240
240
|
key: string,
|
|
241
|
-
value: unknown
|
|
241
|
+
value: unknown,
|
|
242
242
|
) => {
|
|
243
243
|
if (value == null) {
|
|
244
244
|
return value;
|
|
@@ -271,7 +271,7 @@ export class JSONDecoder
|
|
|
271
271
|
minute,
|
|
272
272
|
second,
|
|
273
273
|
nanoOfSecond,
|
|
274
|
-
ZoneOffset.of(offset)
|
|
274
|
+
ZoneOffset.of(offset),
|
|
275
275
|
);
|
|
276
276
|
}
|
|
277
277
|
if (typeof value === 'string') {
|
|
@@ -282,7 +282,7 @@ export class JSONDecoder
|
|
|
282
282
|
|
|
283
283
|
private localDateTimeDeserializer: Deserializer = (
|
|
284
284
|
key: string,
|
|
285
|
-
value: unknown
|
|
285
|
+
value: unknown,
|
|
286
286
|
) => {
|
|
287
287
|
if (value == null) {
|
|
288
288
|
return value;
|
|
@@ -323,12 +323,12 @@ export class JSONDecoder
|
|
|
323
323
|
hour,
|
|
324
324
|
minute,
|
|
325
325
|
second,
|
|
326
|
-
nanoOfSecond
|
|
326
|
+
nanoOfSecond,
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
329
|
if (typeof value === 'string') {
|
|
330
330
|
return LocalDateTime.from(
|
|
331
|
-
DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(value)
|
|
331
|
+
DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(value),
|
|
332
332
|
);
|
|
333
333
|
}
|
|
334
334
|
throw new Error(`Invalid date value for property ${key}`);
|
|
@@ -336,7 +336,7 @@ export class JSONDecoder
|
|
|
336
336
|
|
|
337
337
|
private localDateDeserializer: Deserializer = (
|
|
338
338
|
key: string,
|
|
339
|
-
value: unknown
|
|
339
|
+
value: unknown,
|
|
340
340
|
) => {
|
|
341
341
|
if (value == null) {
|
|
342
342
|
return value;
|
|
@@ -365,7 +365,7 @@ export class JSONDecoder
|
|
|
365
365
|
|
|
366
366
|
private localTimeDeserializer: Deserializer = (
|
|
367
367
|
key: string,
|
|
368
|
-
value: unknown
|
|
368
|
+
value: unknown,
|
|
369
369
|
) => {
|
|
370
370
|
if (value == null) {
|
|
371
371
|
return value;
|
|
@@ -450,7 +450,7 @@ export class JSONDecoder
|
|
|
450
450
|
|
|
451
451
|
private arrayBufferDeserializer: Deserializer = (
|
|
452
452
|
key: string,
|
|
453
|
-
value: unknown
|
|
453
|
+
value: unknown,
|
|
454
454
|
) => {
|
|
455
455
|
if (value == null) {
|
|
456
456
|
return value;
|
|
@@ -36,7 +36,7 @@ import { StructuredMediaTypeEncoder } from './media-type-encoder';
|
|
|
36
36
|
export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
37
37
|
static get default(): JSONEncoder {
|
|
38
38
|
return new JSONEncoder(
|
|
39
|
-
JSONEncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH
|
|
39
|
+
JSONEncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH,
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -94,7 +94,7 @@ export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
|
94
94
|
Reflect.hasMetadata(
|
|
95
95
|
'jackson:defaultContextGroup:JsonSubTypes',
|
|
96
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
(value as any).constructor ?? {}
|
|
97
|
+
(value as any).constructor ?? {},
|
|
98
98
|
)
|
|
99
99
|
) {
|
|
100
100
|
type = [Object];
|
|
@@ -118,14 +118,14 @@ export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
|
118
118
|
encodeObject<T>(
|
|
119
119
|
value: T,
|
|
120
120
|
type?: AnyType,
|
|
121
|
-
includeNulls = false
|
|
121
|
+
includeNulls = false,
|
|
122
122
|
): Record<string, unknown> {
|
|
123
123
|
// Use natural type when subtypes exist
|
|
124
124
|
if (
|
|
125
125
|
Reflect.hasMetadata(
|
|
126
126
|
'jackson:defaultContextGroup:JsonSubTypes',
|
|
127
127
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
-
(value as any).constructor ?? {}
|
|
128
|
+
(value as any).constructor ?? {},
|
|
129
129
|
)
|
|
130
130
|
) {
|
|
131
131
|
type = [Object];
|
|
@@ -216,7 +216,7 @@ export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
|
216
216
|
this.dateEncoding ==
|
|
217
217
|
JSONEncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
218
218
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
219
|
-
: value.nano()
|
|
219
|
+
: value.nano(),
|
|
220
220
|
),
|
|
221
221
|
value.offset().toString(),
|
|
222
222
|
];
|
|
@@ -243,7 +243,7 @@ export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
|
243
243
|
this.dateEncoding ==
|
|
244
244
|
JSONEncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
245
245
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
246
|
-
: value.nano()
|
|
246
|
+
: value.nano(),
|
|
247
247
|
),
|
|
248
248
|
];
|
|
249
249
|
}
|
|
@@ -279,7 +279,7 @@ export class JSONEncoder implements StructuredMediaTypeEncoder {
|
|
|
279
279
|
this.dateEncoding ==
|
|
280
280
|
JSONEncoder.DateEncoding.MILLISECONDS_SINCE_EPOCH
|
|
281
281
|
? value.get(ChronoField.MILLI_OF_SECOND)
|
|
282
|
-
: value.nano()
|
|
282
|
+
: value.nano(),
|
|
283
283
|
),
|
|
284
284
|
];
|
|
285
285
|
}
|
|
@@ -27,7 +27,7 @@ export interface StructuredMediaTypeDecoder extends MediaTypeDecoder {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export function isStructuredMediaTypeDecoder(
|
|
30
|
-
decoder: MediaTypeDecoder | StructuredMediaTypeDecoder | undefined
|
|
30
|
+
decoder: MediaTypeDecoder | StructuredMediaTypeDecoder | undefined,
|
|
31
31
|
): decoder is StructuredMediaTypeDecoder {
|
|
32
32
|
const rec = decoder as unknown as Record<string, unknown>;
|
|
33
33
|
return !!rec.decodeObject ?? false;
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
import { AnyTextDecoder } from './any-text-decoder';
|
|
16
16
|
import { BinaryDecoder } from './binary-decoder';
|
|
17
|
-
import { BinaryEncoder } from './binary-encoder';
|
|
18
17
|
import { CBORDecoder } from './cbor-decoder';
|
|
19
18
|
import { JSONDecoder } from './json-decoder';
|
|
20
19
|
import { MediaType } from '../media-type';
|
|
@@ -25,7 +24,7 @@ export interface MediaTypeDecodersBuilder {
|
|
|
25
24
|
|
|
26
25
|
add(
|
|
27
26
|
mediaType: MediaType,
|
|
28
|
-
decoder: MediaTypeDecoder
|
|
27
|
+
decoder: MediaTypeDecoder,
|
|
29
28
|
): MediaTypeDecodersBuilder;
|
|
30
29
|
|
|
31
30
|
build(): MediaTypeDecoders;
|
|
@@ -42,7 +41,7 @@ export class MediaTypeDecoders {
|
|
|
42
41
|
|
|
43
42
|
add(
|
|
44
43
|
mediaType: MediaType,
|
|
45
|
-
decoder: MediaTypeDecoder
|
|
44
|
+
decoder: MediaTypeDecoder,
|
|
46
45
|
): MediaTypeDecodersBuilder {
|
|
47
46
|
this.decoders.set(mediaType, decoder);
|
|
48
47
|
return this;
|
|
@@ -71,13 +70,13 @@ export class MediaTypeDecoders {
|
|
|
71
70
|
|
|
72
71
|
supports(mediaType: MediaType): boolean {
|
|
73
72
|
return Array.from(this.decoders.keys()).some((key) =>
|
|
74
|
-
key.compatible(mediaType)
|
|
73
|
+
key.compatible(mediaType),
|
|
75
74
|
);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
find(mediaType: MediaType): MediaTypeDecoder {
|
|
79
78
|
const found = Array.from(this.decoders.entries()).find(([type]) =>
|
|
80
|
-
type.compatible(mediaType)
|
|
79
|
+
type.compatible(mediaType),
|
|
81
80
|
);
|
|
82
81
|
if (!found) {
|
|
83
82
|
throw Error(`Unsupported media type - ${mediaType}`);
|
|
@@ -23,7 +23,7 @@ export interface URLQueryParamsEncoder extends MediaTypeEncoder {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function isURLQueryParamsEncoder(
|
|
26
|
-
encoder: MediaTypeEncoder | URLQueryParamsEncoder | undefined
|
|
26
|
+
encoder: MediaTypeEncoder | URLQueryParamsEncoder | undefined,
|
|
27
27
|
): encoder is URLQueryParamsEncoder {
|
|
28
28
|
const rec = encoder as unknown as Record<string, unknown>;
|
|
29
29
|
return !!rec.encodeQueryString ?? false;
|
|
@@ -33,12 +33,12 @@ export interface StructuredMediaTypeEncoder extends MediaTypeEncoder {
|
|
|
33
33
|
encodeObject<T = unknown>(
|
|
34
34
|
value: T,
|
|
35
35
|
type?: AnyType,
|
|
36
|
-
includeNulls?: boolean
|
|
36
|
+
includeNulls?: boolean,
|
|
37
37
|
): Record<string, unknown>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function isStructuredMediaTypeEncoder(
|
|
41
|
-
encoder: MediaTypeEncoder | StructuredMediaTypeEncoder | undefined
|
|
41
|
+
encoder: MediaTypeEncoder | StructuredMediaTypeEncoder | undefined,
|
|
42
42
|
): encoder is StructuredMediaTypeEncoder {
|
|
43
43
|
const rec = encoder as unknown as Record<string, unknown>;
|
|
44
44
|
return !!rec.encodeObject ?? false;
|
|
@@ -25,7 +25,7 @@ export interface MediaTypeEncodersBuilder {
|
|
|
25
25
|
|
|
26
26
|
add(
|
|
27
27
|
mediaType: MediaType,
|
|
28
|
-
encoder: MediaTypeEncoder
|
|
28
|
+
encoder: MediaTypeEncoder,
|
|
29
29
|
): MediaTypeEncodersBuilder;
|
|
30
30
|
|
|
31
31
|
build(): MediaTypeEncoders;
|
|
@@ -42,7 +42,7 @@ export class MediaTypeEncoders {
|
|
|
42
42
|
|
|
43
43
|
add(
|
|
44
44
|
mediaType: MediaType,
|
|
45
|
-
encoder: MediaTypeEncoder
|
|
45
|
+
encoder: MediaTypeEncoder,
|
|
46
46
|
): MediaTypeEncodersBuilder {
|
|
47
47
|
this.encoders.set(mediaType, encoder);
|
|
48
48
|
return this;
|
|
@@ -71,13 +71,13 @@ export class MediaTypeEncoders {
|
|
|
71
71
|
|
|
72
72
|
supports(mediaType: MediaType): boolean {
|
|
73
73
|
return Array.from(this.encoders.keys()).some((key) =>
|
|
74
|
-
key.compatible(mediaType)
|
|
74
|
+
key.compatible(mediaType),
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
find(mediaType: MediaType): MediaTypeEncoder {
|
|
79
79
|
const found = Array.from(this.encoders.entries()).find(([type]) =>
|
|
80
|
-
type.compatible(mediaType)
|
|
80
|
+
type.compatible(mediaType),
|
|
81
81
|
);
|
|
82
82
|
if (!found) {
|
|
83
83
|
throw Error(`Unsupported media type - ${mediaType}`);
|
|
@@ -31,7 +31,7 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
31
31
|
return new WWWFormUrlEncoder(
|
|
32
32
|
WWWFormUrlEncoder.ArrayEncoding.UNBRACKETED,
|
|
33
33
|
WWWFormUrlEncoder.BoolEncoding.LITERAL,
|
|
34
|
-
WWWFormUrlEncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH
|
|
34
|
+
WWWFormUrlEncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH,
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
40
40
|
private boolEncoding: WWWFormUrlEncoder.BoolEncoding,
|
|
41
41
|
private dateEncoding: WWWFormUrlEncoder.DateEncoding,
|
|
42
42
|
private json = new JsonStringifier(),
|
|
43
|
-
private encoder = new TextEncoder()
|
|
43
|
+
private encoder = new TextEncoder(),
|
|
44
44
|
) {}
|
|
45
45
|
|
|
46
46
|
encode<T = unknown>(value: T): ArrayBuffer | SharedArrayBuffer {
|
|
@@ -74,8 +74,8 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
74
74
|
components.push(
|
|
75
75
|
...this.encodeQueryComponent(
|
|
76
76
|
encodeArrayKey(key, this.arrayEncoding),
|
|
77
|
-
item
|
|
78
|
-
)
|
|
77
|
+
item,
|
|
78
|
+
),
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
} else if (value instanceof Date) {
|
|
@@ -86,23 +86,23 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
86
86
|
encodeURIComponent(
|
|
87
87
|
encodeInstant(
|
|
88
88
|
Instant.ofEpochMilli(value.getTime()),
|
|
89
|
-
this.dateEncoding
|
|
90
|
-
)
|
|
91
|
-
)
|
|
89
|
+
this.dateEncoding,
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
92
|
);
|
|
93
93
|
} else if (value instanceof Temporal) {
|
|
94
94
|
//
|
|
95
95
|
components.push(
|
|
96
96
|
encodeURIComponent(key) +
|
|
97
97
|
'=' +
|
|
98
|
-
encodeURIComponent(encodeTemporal(value, this.dateEncoding))
|
|
98
|
+
encodeURIComponent(encodeTemporal(value, this.dateEncoding)),
|
|
99
99
|
);
|
|
100
100
|
} else if (typeof value === 'boolean') {
|
|
101
101
|
//
|
|
102
102
|
components.push(
|
|
103
103
|
encodeURIComponent(key) +
|
|
104
104
|
'=' +
|
|
105
|
-
encodeURIComponent(encodeBoolean(value, this.boolEncoding))
|
|
105
|
+
encodeURIComponent(encodeBoolean(value, this.boolEncoding)),
|
|
106
106
|
);
|
|
107
107
|
} else if (typeof value === 'object') {
|
|
108
108
|
//
|
|
@@ -110,13 +110,13 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
110
110
|
|
|
111
111
|
for (const nestedKey of Object.keys(rec).sort()) {
|
|
112
112
|
components.push(
|
|
113
|
-
...this.encodeQueryComponent(`${key}[${nestedKey}]`, rec[nestedKey])
|
|
113
|
+
...this.encodeQueryComponent(`${key}[${nestedKey}]`, rec[nestedKey]),
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
} else {
|
|
117
117
|
//
|
|
118
118
|
components.push(
|
|
119
|
-
encodeURIComponent(key) + '=' + encodeURIComponent(`${value}`)
|
|
119
|
+
encodeURIComponent(key) + '=' + encodeURIComponent(`${value}`),
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -126,7 +126,7 @@ export class WWWFormUrlEncoder implements URLQueryParamsEncoder {
|
|
|
126
126
|
|
|
127
127
|
function encodeArrayKey(
|
|
128
128
|
key: string,
|
|
129
|
-
encoding: WWWFormUrlEncoder.ArrayEncoding
|
|
129
|
+
encoding: WWWFormUrlEncoder.ArrayEncoding,
|
|
130
130
|
): string {
|
|
131
131
|
return encoding === WWWFormUrlEncoder.ArrayEncoding.BRACKETED
|
|
132
132
|
? `${key}[]`
|
|
@@ -135,7 +135,7 @@ function encodeArrayKey(
|
|
|
135
135
|
|
|
136
136
|
function encodeBoolean(
|
|
137
137
|
value: boolean,
|
|
138
|
-
encoding: WWWFormUrlEncoder.BoolEncoding
|
|
138
|
+
encoding: WWWFormUrlEncoder.BoolEncoding,
|
|
139
139
|
): string {
|
|
140
140
|
switch (encoding) {
|
|
141
141
|
case WWWFormUrlEncoder.BoolEncoding.NUMERIC:
|
|
@@ -149,7 +149,7 @@ function encodeBoolean(
|
|
|
149
149
|
|
|
150
150
|
function encodeTemporal(
|
|
151
151
|
value: Temporal,
|
|
152
|
-
encoding: WWWFormUrlEncoder.DateEncoding
|
|
152
|
+
encoding: WWWFormUrlEncoder.DateEncoding,
|
|
153
153
|
): string {
|
|
154
154
|
if (value instanceof Instant) {
|
|
155
155
|
return encodeInstant(value, encoding);
|
|
@@ -178,7 +178,7 @@ function encodeTemporal(
|
|
|
178
178
|
|
|
179
179
|
function encodeInstant(
|
|
180
180
|
value: Instant,
|
|
181
|
-
encoding: WWWFormUrlEncoder.DateEncoding
|
|
181
|
+
encoding: WWWFormUrlEncoder.DateEncoding,
|
|
182
182
|
): string {
|
|
183
183
|
switch (encoding) {
|
|
184
184
|
case WWWFormUrlEncoder.DateEncoding.DECIMAL_SECONDS_SINCE_EPOCH:
|