@everyonesoftware/common 5.0.0 → 6.0.0
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/outputs/characterWriteStream-DUlG_bx_.d.cts +795 -0
- package/outputs/characterWriteStream-DUlG_bx_.d.ts +795 -0
- package/outputs/{chunk-AY3YWKOM.js → chunk-5Z677JON.js} +947 -3386
- package/outputs/chunk-5Z677JON.js.map +1 -0
- package/outputs/chunk-6V7JRJ7P.js +2469 -0
- package/outputs/chunk-6V7JRJ7P.js.map +1 -0
- package/outputs/chunk-CHBOMCYM.js +845 -0
- package/outputs/chunk-CHBOMCYM.js.map +1 -0
- package/outputs/{sources.cjs → sourceIndex.cjs} +1 -1
- package/outputs/{sources.d.cts → sourceIndex.d.cts} +351 -1143
- package/outputs/{sources.d.ts → sourceIndex.d.ts} +351 -1143
- package/outputs/{sources.js → sourceIndex.js} +32 -30
- package/outputs/{sources.js.map → sourceIndex.js.map} +1 -1
- package/outputs/testIndex.cjs +5832 -0
- package/outputs/testIndex.cjs.map +1 -0
- package/outputs/testIndex.d.cts +428 -0
- package/outputs/testIndex.d.ts +428 -0
- package/outputs/testIndex.js +26 -0
- package/outputs/testIndex.js.map +1 -0
- package/outputs/tests.js +2171 -2985
- package/outputs/tests.js.map +1 -1
- package/package.json +7 -7
- package/outputs/chunk-AY3YWKOM.js.map +0 -1
- /package/outputs/{sources.cjs.map → sourceIndex.cjs.map} +0 -0
|
@@ -4007,3590 +4007,1183 @@ var Condition = class _Condition {
|
|
|
4007
4007
|
}
|
|
4008
4008
|
};
|
|
4009
4009
|
|
|
4010
|
-
// sources/
|
|
4011
|
-
var
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
constructor(disposedFunction) {
|
|
4015
|
-
PreCondition.assertNotUndefinedAndNotNull(disposedFunction, "disposedFunction");
|
|
4016
|
-
this.disposedFunction = disposedFunction;
|
|
4017
|
-
this.disposed = false;
|
|
4018
|
-
}
|
|
4019
|
-
/**
|
|
4020
|
-
* Create a new {@link Disposable} that will invoke the provided {@link Function} when it is
|
|
4021
|
-
* disposed.
|
|
4022
|
-
* @param disposedFunction The function to invoke when the returned {@link Disposable} is
|
|
4023
|
-
* disposed.
|
|
4024
|
-
*/
|
|
4025
|
-
static create(disposedFunction) {
|
|
4026
|
-
return new _SyncDisposable(disposedFunction);
|
|
4027
|
-
}
|
|
4028
|
-
dispose() {
|
|
4029
|
-
return SyncResult.create(() => {
|
|
4030
|
-
const result = !this.disposed;
|
|
4031
|
-
if (result) {
|
|
4032
|
-
try {
|
|
4033
|
-
this.disposedFunction();
|
|
4034
|
-
} finally {
|
|
4035
|
-
this.disposed = true;
|
|
4036
|
-
}
|
|
4037
|
-
}
|
|
4038
|
-
return result;
|
|
4039
|
-
});
|
|
4040
|
-
}
|
|
4041
|
-
isDisposed() {
|
|
4042
|
-
return this.disposed;
|
|
4043
|
-
}
|
|
4044
|
-
};
|
|
4045
|
-
|
|
4046
|
-
// sources/byteList.ts
|
|
4047
|
-
var ByteList = class _ByteList {
|
|
4048
|
-
bytes;
|
|
4049
|
-
count;
|
|
4050
|
-
constructor() {
|
|
4051
|
-
this.bytes = new Uint8Array(0);
|
|
4052
|
-
this.count = 0;
|
|
4053
|
-
}
|
|
4054
|
-
static create(initialValues) {
|
|
4055
|
-
const result = new _ByteList();
|
|
4056
|
-
if (initialValues) {
|
|
4057
|
-
result.addAll(initialValues);
|
|
4058
|
-
}
|
|
4059
|
-
return result;
|
|
4060
|
-
}
|
|
4061
|
-
add(value) {
|
|
4062
|
-
return List.add(this, value);
|
|
4063
|
-
}
|
|
4064
|
-
addAll(values) {
|
|
4065
|
-
return List.addAll(this, values);
|
|
4066
|
-
}
|
|
4067
|
-
insert(index, value) {
|
|
4068
|
-
PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
|
|
4069
|
-
PreCondition.assertByte(value, "value");
|
|
4070
|
-
if (this.count < this.bytes.length) {
|
|
4071
|
-
if (index < this.count) {
|
|
4072
|
-
this.bytes.copyWithin(index + 1, index, this.count);
|
|
4073
|
-
}
|
|
4074
|
-
this.bytes[index] = value;
|
|
4075
|
-
} else {
|
|
4076
|
-
const newCapacity = this.bytes.length * 2 + 1;
|
|
4077
|
-
const newBytes = new Uint8Array(newCapacity);
|
|
4078
|
-
if (index > 0) {
|
|
4079
|
-
newBytes.set(this.bytes.subarray(0, index));
|
|
4080
|
-
}
|
|
4081
|
-
newBytes[index] = value;
|
|
4082
|
-
if (index < this.count) {
|
|
4083
|
-
newBytes.set(this.bytes.subarray(index), index + 1);
|
|
4084
|
-
}
|
|
4085
|
-
this.bytes = newBytes;
|
|
4086
|
-
}
|
|
4087
|
-
this.count++;
|
|
4088
|
-
return this;
|
|
4089
|
-
}
|
|
4090
|
-
insertAll(index, values) {
|
|
4091
|
-
return List.insertAll(this, index, values);
|
|
4092
|
-
}
|
|
4093
|
-
remove(value, equalFunctions) {
|
|
4094
|
-
PreCondition.assertByte(value, "value");
|
|
4095
|
-
return List.remove(this, value, equalFunctions);
|
|
4096
|
-
}
|
|
4097
|
-
removeAt(index) {
|
|
4098
|
-
PreCondition.assertAccessIndex(index, this.count, "index");
|
|
4099
|
-
const result = this.bytes[index];
|
|
4100
|
-
this.bytes.copyWithin(index, index + 1, this.count);
|
|
4101
|
-
this.count--;
|
|
4102
|
-
return SyncResult.value(result);
|
|
4103
|
-
}
|
|
4104
|
-
removeFirst() {
|
|
4105
|
-
return List.removeFirst(this);
|
|
4106
|
-
}
|
|
4107
|
-
removeLast() {
|
|
4108
|
-
return List.removeLast(this);
|
|
4109
|
-
}
|
|
4110
|
-
set(index, value) {
|
|
4111
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
4112
|
-
PreCondition.assertByte(value, "value");
|
|
4113
|
-
this.bytes[index] = value;
|
|
4114
|
-
return this;
|
|
4115
|
-
}
|
|
4116
|
-
iterate() {
|
|
4117
|
-
return Iterator.create(this.bytes[Symbol.iterator]().take(this.count));
|
|
4118
|
-
}
|
|
4119
|
-
get(index) {
|
|
4120
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
4121
|
-
return SyncResult.value(this.bytes.at(index));
|
|
4122
|
-
}
|
|
4123
|
-
toArray() {
|
|
4124
|
-
return List.toArray(this);
|
|
4125
|
-
}
|
|
4126
|
-
any() {
|
|
4127
|
-
return this.getCount().then((count) => count > 0);
|
|
4128
|
-
}
|
|
4129
|
-
getCount() {
|
|
4130
|
-
return SyncResult.value(this.count);
|
|
4131
|
-
}
|
|
4132
|
-
equals(right, equalFunctions) {
|
|
4133
|
-
return List.equals(this, right, equalFunctions);
|
|
4134
|
-
}
|
|
4135
|
-
toString(toStringFunctions) {
|
|
4136
|
-
return List.toString(this, toStringFunctions);
|
|
4137
|
-
}
|
|
4138
|
-
concatenate(...toConcatenate) {
|
|
4139
|
-
return List.concatenate(this, ...toConcatenate);
|
|
4140
|
-
}
|
|
4141
|
-
map(mapping) {
|
|
4142
|
-
return List.map(this, mapping);
|
|
4143
|
-
}
|
|
4144
|
-
flatMap(mapping) {
|
|
4145
|
-
return List.flatMap(this, mapping);
|
|
4146
|
-
}
|
|
4147
|
-
where(condition) {
|
|
4148
|
-
return List.where(this, condition);
|
|
4149
|
-
}
|
|
4150
|
-
instanceOf(typeOrTypeCheck) {
|
|
4151
|
-
return List.instanceOf(this, typeOrTypeCheck);
|
|
4152
|
-
}
|
|
4153
|
-
first(condition) {
|
|
4154
|
-
return List.first(this, condition);
|
|
4155
|
-
}
|
|
4156
|
-
last(condition) {
|
|
4157
|
-
return List.last(this, condition);
|
|
4158
|
-
}
|
|
4159
|
-
contains(value, equalFunctions) {
|
|
4160
|
-
return List.contains(this, value, equalFunctions);
|
|
4161
|
-
}
|
|
4162
|
-
[Symbol.iterator]() {
|
|
4163
|
-
return List[Symbol.iterator](this);
|
|
4164
|
-
}
|
|
4165
|
-
};
|
|
4166
|
-
|
|
4167
|
-
// sources/byteListStream.ts
|
|
4168
|
-
var ByteListStream = class _ByteListStream {
|
|
4169
|
-
list;
|
|
4170
|
-
constructor() {
|
|
4171
|
-
this.list = ByteList.create();
|
|
4172
|
-
}
|
|
4173
|
-
static create(initialValues) {
|
|
4174
|
-
const result = new _ByteListStream();
|
|
4175
|
-
if (initialValues) {
|
|
4176
|
-
result.writeBytes(initialValues).await();
|
|
4177
|
-
}
|
|
4178
|
-
return result;
|
|
4179
|
-
}
|
|
4180
|
-
/**
|
|
4181
|
-
* Get the number of bytes that are available to be read.
|
|
4182
|
-
*/
|
|
4183
|
-
getAvailableByteCount() {
|
|
4184
|
-
return this.list.getCount().await();
|
|
4185
|
-
}
|
|
4186
|
-
writeBytes(bytes, startIndex, length) {
|
|
4187
|
-
PreCondition.assertNotUndefinedAndNotNull(bytes, "bytes");
|
|
4188
|
-
if (isArray(bytes)) {
|
|
4189
|
-
bytes = new Uint8Array(bytes);
|
|
4190
|
-
}
|
|
4191
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
4192
|
-
startIndex = 0;
|
|
4193
|
-
}
|
|
4194
|
-
if (isUndefinedOrNull(length)) {
|
|
4195
|
-
length = bytes.length - startIndex;
|
|
4196
|
-
}
|
|
4197
|
-
PreCondition.assertInsertIndex(startIndex, bytes.length, "startIndex");
|
|
4198
|
-
PreCondition.assertBetween(0, length, bytes.length - startIndex, "length");
|
|
4199
|
-
this.list.addAll(bytes.subarray(startIndex, length + startIndex));
|
|
4200
|
-
return SyncResult.value(length);
|
|
4201
|
-
}
|
|
4202
|
-
readBytes(countOrOutput, startIndex, count) {
|
|
4203
|
-
let result;
|
|
4204
|
-
if (isNumber(countOrOutput)) {
|
|
4205
|
-
PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
|
|
4206
|
-
if (!this.list.any().await()) {
|
|
4207
|
-
result = SyncResult.error(new EmptyError());
|
|
4208
|
-
} else {
|
|
4209
|
-
const bytesReadCount = Math.min(countOrOutput, this.list.getCount().await());
|
|
4210
|
-
const output = new Uint8Array(bytesReadCount);
|
|
4211
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
4212
|
-
output[i] = this.list.removeFirst().await();
|
|
4213
|
-
}
|
|
4214
|
-
result = SyncResult.value(output);
|
|
4215
|
-
}
|
|
4216
|
-
} else {
|
|
4217
|
-
PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
|
|
4218
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
4219
|
-
startIndex = 0;
|
|
4220
|
-
}
|
|
4221
|
-
if (isUndefinedOrNull(count)) {
|
|
4222
|
-
count = countOrOutput.length - startIndex;
|
|
4223
|
-
}
|
|
4224
|
-
PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
|
|
4225
|
-
PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
|
|
4226
|
-
if (!this.list.any().await()) {
|
|
4227
|
-
result = SyncResult.error(new EmptyError());
|
|
4228
|
-
} else {
|
|
4229
|
-
const bytesReadCount = Math.min(count, this.list.getCount().await());
|
|
4230
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
4231
|
-
countOrOutput[startIndex + i] = this.list.removeFirst().await();
|
|
4232
|
-
}
|
|
4233
|
-
result = SyncResult.value(bytesReadCount);
|
|
4234
|
-
}
|
|
4235
|
-
}
|
|
4236
|
-
return result;
|
|
4237
|
-
}
|
|
4238
|
-
};
|
|
4239
|
-
|
|
4240
|
-
// sources/stringIterator.ts
|
|
4241
|
-
var StringIterator = class _StringIterator {
|
|
4242
|
-
value;
|
|
4243
|
-
currentIndex;
|
|
4244
|
-
started;
|
|
4245
|
-
constructor(value) {
|
|
4246
|
-
this.value = value;
|
|
4247
|
-
this.currentIndex = 0;
|
|
4248
|
-
this.started = false;
|
|
4249
|
-
}
|
|
4250
|
-
static create(value) {
|
|
4251
|
-
PreCondition.assertNotUndefinedAndNotNull(value, "value");
|
|
4252
|
-
return new _StringIterator(value);
|
|
4253
|
-
}
|
|
4254
|
-
getCurrentIndex() {
|
|
4255
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
4256
|
-
return this.currentIndex;
|
|
4257
|
-
}
|
|
4258
|
-
next() {
|
|
4259
|
-
return SyncResult.create(() => {
|
|
4260
|
-
if (!this.hasStarted()) {
|
|
4261
|
-
this.started = true;
|
|
4262
|
-
} else if (this.hasCurrent()) {
|
|
4263
|
-
this.currentIndex++;
|
|
4264
|
-
}
|
|
4265
|
-
return this.hasCurrent();
|
|
4266
|
-
});
|
|
4267
|
-
}
|
|
4268
|
-
hasStarted() {
|
|
4269
|
-
return this.started;
|
|
4270
|
-
}
|
|
4271
|
-
hasCurrent() {
|
|
4272
|
-
return this.hasStarted() && this.currentIndex < this.value.length;
|
|
4273
|
-
}
|
|
4274
|
-
getCurrent() {
|
|
4275
|
-
PreCondition.assertTrue(this.hasCurrent(), "this.hasCurrent()");
|
|
4276
|
-
return this.value[this.currentIndex];
|
|
4277
|
-
}
|
|
4278
|
-
start() {
|
|
4279
|
-
return Iterator.start(this);
|
|
4280
|
-
}
|
|
4281
|
-
takeCurrent() {
|
|
4282
|
-
return Iterator.takeCurrent(this);
|
|
4283
|
-
}
|
|
4284
|
-
any() {
|
|
4285
|
-
return Iterator.any(this);
|
|
4286
|
-
}
|
|
4287
|
-
getCount() {
|
|
4288
|
-
return Iterator.getCount(this);
|
|
4289
|
-
}
|
|
4290
|
-
toArray() {
|
|
4291
|
-
return Iterator.toArray(this);
|
|
4292
|
-
}
|
|
4293
|
-
concatenate(...toConcatenate) {
|
|
4294
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
4295
|
-
}
|
|
4296
|
-
map(mapping) {
|
|
4297
|
-
return Iterator.map(this, mapping);
|
|
4298
|
-
}
|
|
4299
|
-
flatMap(mapping) {
|
|
4300
|
-
return Iterator.flatMap(this, mapping);
|
|
4301
|
-
}
|
|
4302
|
-
first() {
|
|
4303
|
-
return Iterator.first(this);
|
|
4304
|
-
}
|
|
4305
|
-
last() {
|
|
4306
|
-
return Iterator.last(this);
|
|
4307
|
-
}
|
|
4308
|
-
where(condition) {
|
|
4309
|
-
return Iterator.where(this, condition);
|
|
4310
|
-
}
|
|
4311
|
-
whereInstanceOf(typeCheck) {
|
|
4312
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
4313
|
-
}
|
|
4314
|
-
whereInstanceOfType(type) {
|
|
4315
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
4316
|
-
}
|
|
4317
|
-
take(maximumToTake) {
|
|
4318
|
-
return Iterator.take(this, maximumToTake);
|
|
4319
|
-
}
|
|
4320
|
-
skip(maximumToSkip) {
|
|
4321
|
-
return Iterator.skip(this, maximumToSkip);
|
|
4322
|
-
}
|
|
4323
|
-
[Symbol.iterator]() {
|
|
4324
|
-
return Iterator[Symbol.iterator](this);
|
|
4325
|
-
}
|
|
4326
|
-
};
|
|
4327
|
-
|
|
4328
|
-
// sources/characterList.ts
|
|
4329
|
-
var CharacterList = class _CharacterList {
|
|
4330
|
-
characters;
|
|
4331
|
-
constructor(values) {
|
|
4332
|
-
if (isString(values)) {
|
|
4333
|
-
this.characters = values;
|
|
4334
|
-
} else if (values) {
|
|
4335
|
-
this.characters = join("", values);
|
|
4336
|
-
} else {
|
|
4337
|
-
this.characters = "";
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
|
-
static create(values) {
|
|
4341
|
-
return new _CharacterList(values);
|
|
4342
|
-
}
|
|
4343
|
-
getCount() {
|
|
4344
|
-
return SyncResult.value(this.characters.length);
|
|
4345
|
-
}
|
|
4346
|
-
insert(index, value) {
|
|
4347
|
-
PreCondition.assertInsertIndex(index, this.getCount().await(), "index");
|
|
4348
|
-
PreCondition.assertCharacter(value, "value");
|
|
4349
|
-
if (index === 0) {
|
|
4350
|
-
this.characters = value + this.characters;
|
|
4351
|
-
} else if (index === this.getCount().await()) {
|
|
4352
|
-
this.characters += value;
|
|
4353
|
-
} else {
|
|
4354
|
-
this.characters = this.characters.slice(0, index) + value + this.characters.slice(index);
|
|
4355
|
-
}
|
|
4356
|
-
return this;
|
|
4357
|
-
}
|
|
4358
|
-
removeAt(index) {
|
|
4359
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
4360
|
-
const result = this.get(index).await();
|
|
4361
|
-
this.characters = (index === 0 ? "" : this.characters.slice(0, index)) + (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
|
|
4362
|
-
return SyncResult.value(result);
|
|
4363
|
-
}
|
|
4364
|
-
set(index, value) {
|
|
4365
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
4366
|
-
PreCondition.assertCharacter(value, "value");
|
|
4367
|
-
this.characters = (index === 0 ? "" : this.characters.slice(0, index)) + value + (index === this.getCount().await() - 1 ? "" : this.characters.slice(index + 1));
|
|
4368
|
-
return this;
|
|
4369
|
-
}
|
|
4370
|
-
iterate() {
|
|
4371
|
-
return StringIterator.create(this.characters);
|
|
4372
|
-
}
|
|
4373
|
-
get(index) {
|
|
4374
|
-
PreCondition.assertAccessIndex(index, this.getCount().await(), "index");
|
|
4375
|
-
return SyncResult.value(this.characters.charAt(index));
|
|
4376
|
-
}
|
|
4377
|
-
add(value) {
|
|
4378
|
-
return List.add(this, value);
|
|
4379
|
-
}
|
|
4380
|
-
addAll(values) {
|
|
4381
|
-
return List.addAll(this, values);
|
|
4382
|
-
}
|
|
4383
|
-
insertAll(index, values) {
|
|
4384
|
-
return List.insertAll(this, index, values);
|
|
4385
|
-
}
|
|
4386
|
-
remove(value, equalFunctions) {
|
|
4387
|
-
return List.remove(this, value, equalFunctions);
|
|
4388
|
-
}
|
|
4389
|
-
removeFirst() {
|
|
4390
|
-
return List.removeFirst(this);
|
|
4391
|
-
}
|
|
4392
|
-
removeLast() {
|
|
4393
|
-
return List.removeLast(this);
|
|
4394
|
-
}
|
|
4395
|
-
toArray() {
|
|
4396
|
-
return List.toArray(this);
|
|
4397
|
-
}
|
|
4398
|
-
any() {
|
|
4399
|
-
return List.any(this);
|
|
4400
|
-
}
|
|
4401
|
-
equals(right, equalFunctions) {
|
|
4402
|
-
return List.equals(this, right, equalFunctions);
|
|
4403
|
-
}
|
|
4404
|
-
toString(toStringFunctions) {
|
|
4405
|
-
return List.toString(this, toStringFunctions);
|
|
4406
|
-
}
|
|
4407
|
-
concatenate(...toConcatenate) {
|
|
4408
|
-
return List.concatenate(this, ...toConcatenate);
|
|
4409
|
-
}
|
|
4410
|
-
map(mapping) {
|
|
4411
|
-
return List.map(this, mapping);
|
|
4412
|
-
}
|
|
4413
|
-
flatMap(mapping) {
|
|
4414
|
-
return List.flatMap(this, mapping);
|
|
4415
|
-
}
|
|
4416
|
-
where(condition) {
|
|
4417
|
-
return List.where(this, condition);
|
|
4418
|
-
}
|
|
4419
|
-
instanceOf(typeOrTypeCheck) {
|
|
4420
|
-
return List.instanceOf(this, typeOrTypeCheck);
|
|
4421
|
-
}
|
|
4422
|
-
first(condition) {
|
|
4423
|
-
return List.first(this, condition);
|
|
4424
|
-
}
|
|
4425
|
-
last(condition) {
|
|
4426
|
-
return List.last(this, condition);
|
|
4427
|
-
}
|
|
4428
|
-
contains(value, equalFunctions) {
|
|
4429
|
-
return List.contains(this, value, equalFunctions);
|
|
4430
|
-
}
|
|
4431
|
-
[Symbol.iterator]() {
|
|
4432
|
-
return List[Symbol.iterator](this);
|
|
4433
|
-
}
|
|
4434
|
-
};
|
|
4435
|
-
|
|
4436
|
-
// sources/characterReadStream.ts
|
|
4437
|
-
var CharacterReadStream = class _CharacterReadStream {
|
|
4438
|
-
readCharacters(count) {
|
|
4439
|
-
return _CharacterReadStream.readCharacters(this, count);
|
|
4440
|
-
}
|
|
4441
|
-
static readCharacters(readStream, count) {
|
|
4442
|
-
let characters = "";
|
|
4443
|
-
function readUntilCount(countRemaining) {
|
|
4444
|
-
return readStream.readCharacter().then((character) => {
|
|
4445
|
-
characters += character;
|
|
4446
|
-
return countRemaining === 0 ? SyncResult.value(characters) : readUntilCount(countRemaining - 1);
|
|
4447
|
-
});
|
|
4448
|
-
}
|
|
4449
|
-
return readUntilCount(count);
|
|
4450
|
-
}
|
|
4451
|
-
/**
|
|
4452
|
-
* Read characters from this stream until the provided {@link searchString} is found or the end
|
|
4453
|
-
* of the stream is reached. The {@link searchString} will be included in the returned string if
|
|
4454
|
-
* it is found..
|
|
4455
|
-
* @param searchString The string to search for.
|
|
4456
|
-
*/
|
|
4457
|
-
readUntil(searchString) {
|
|
4458
|
-
return _CharacterReadStream.readUntil(this, searchString);
|
|
4459
|
-
}
|
|
4460
|
-
static readUntil(readStream, searchString) {
|
|
4461
|
-
PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
|
|
4462
|
-
PreCondition.assertNotEmpty(searchString, "searchString");
|
|
4463
|
-
let characters = "";
|
|
4464
|
-
function readUntilSearchString() {
|
|
4465
|
-
return readStream.readCharacter().then((character) => {
|
|
4466
|
-
characters += character;
|
|
4467
|
-
return characters.endsWith(searchString) ? SyncResult.value(characters) : readUntilSearchString();
|
|
4468
|
-
});
|
|
4469
|
-
}
|
|
4470
|
-
return readUntilSearchString();
|
|
4471
|
-
}
|
|
4472
|
-
/**
|
|
4473
|
-
* Read a sequence of characters from this stream until either a newline character ('\\n') or
|
|
4474
|
-
* the end of the stream is reached. Terminating newline characters will be included in the
|
|
4475
|
-
* returned string.
|
|
4476
|
-
*/
|
|
4477
|
-
readLine() {
|
|
4478
|
-
return _CharacterReadStream.readLine(this);
|
|
4479
|
-
}
|
|
4480
|
-
static readLine(readStream) {
|
|
4481
|
-
PreCondition.assertNotUndefinedAndNotNull(readStream, "readStream");
|
|
4482
|
-
return readStream.readUntil("\n");
|
|
4483
|
-
}
|
|
4484
|
-
};
|
|
4485
|
-
|
|
4486
|
-
// sources/postConditionError.ts
|
|
4487
|
-
var PostConditionError = class extends Error {
|
|
4488
|
-
constructor(...message) {
|
|
4489
|
-
super(join("\n", message));
|
|
4490
|
-
}
|
|
4491
|
-
};
|
|
4492
|
-
|
|
4493
|
-
// sources/postCondition.ts
|
|
4494
|
-
var PostCondition = class _PostCondition {
|
|
4495
|
-
static condition;
|
|
4496
|
-
static getCondition() {
|
|
4497
|
-
if (_PostCondition.condition === void 0) {
|
|
4498
|
-
_PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
|
|
4499
|
-
return new PostConditionError(message);
|
|
4500
|
-
});
|
|
4501
|
-
}
|
|
4502
|
-
return _PostCondition.condition;
|
|
4503
|
-
}
|
|
4504
|
-
/**
|
|
4505
|
-
* Assert that the provided value is undefined.
|
|
4506
|
-
* @param value The value to check.
|
|
4507
|
-
* @param expression The name of the expression that produced the value.
|
|
4508
|
-
* @param message An additional message that will be included with the error.
|
|
4509
|
-
*/
|
|
4510
|
-
static assertUndefined(value, expression, message) {
|
|
4511
|
-
return _PostCondition.getCondition().assertUndefined(value, expression, message);
|
|
4512
|
-
}
|
|
4513
|
-
/**
|
|
4514
|
-
* Assert that the provided value is not undefined and not null.
|
|
4515
|
-
* @param value The value to check.
|
|
4516
|
-
* @param expression The name of the expression that produced the value.
|
|
4517
|
-
* @param message An additional message that will be included with the error.
|
|
4518
|
-
*/
|
|
4519
|
-
static assertNotUndefined(value, expression, message) {
|
|
4520
|
-
return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
4521
|
-
}
|
|
4522
|
-
/**
|
|
4523
|
-
* Assert that the provided value is not undefined and not null.
|
|
4524
|
-
* @param value The value to check.
|
|
4525
|
-
* @param expression The name of the expression that produced the value.
|
|
4526
|
-
* @param message An additional message that will be included with the error.
|
|
4527
|
-
*/
|
|
4528
|
-
static assertNotUndefinedAndNotNull(value, expression, message) {
|
|
4529
|
-
return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
4530
|
-
}
|
|
4531
|
-
/**
|
|
4532
|
-
* Assert that the provided value is true.
|
|
4533
|
-
* @param value The value to check.
|
|
4534
|
-
* @param expression The name of the expression that produced the value.
|
|
4535
|
-
* @param message An additional message that will be included with the error.
|
|
4536
|
-
*/
|
|
4537
|
-
static assertTrue(value, expression, message) {
|
|
4538
|
-
return _PostCondition.getCondition().assertTrue(value, expression, message);
|
|
4539
|
-
}
|
|
4540
|
-
/**
|
|
4541
|
-
* Assert that the provided value is false.
|
|
4542
|
-
* @param value The value to check.
|
|
4543
|
-
* @param expression The name of the expression that produced the value.
|
|
4544
|
-
* @param message An additional message that will be included with the error.
|
|
4545
|
-
*/
|
|
4546
|
-
static assertFalse(value, expression, message) {
|
|
4547
|
-
return _PostCondition.getCondition().assertFalse(value, expression, message);
|
|
4548
|
-
}
|
|
4549
|
-
/**
|
|
4550
|
-
* Assert that the provided actual value is the same as the provided expected value.
|
|
4551
|
-
* @param expected The expected value.
|
|
4552
|
-
* @param actual The actual value.
|
|
4553
|
-
* @param expression The expression that produced the actual value.
|
|
4554
|
-
* @param message An optional message that describes the scenario.
|
|
4555
|
-
*/
|
|
4556
|
-
static assertSame(expected, actual, expression, message) {
|
|
4557
|
-
return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
4558
|
-
}
|
|
4559
|
-
/**
|
|
4560
|
-
* Assert that the provided actual value is not the same as the provided expected value.
|
|
4561
|
-
* @param expected The expected value.
|
|
4562
|
-
* @param actual The actual value.
|
|
4563
|
-
* @param expression The expression that produced the actual value.
|
|
4564
|
-
* @param message An optional message that describes the scenario.
|
|
4565
|
-
*/
|
|
4566
|
-
static assertNotSame(expected, actual, expression, message) {
|
|
4567
|
-
return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
4568
|
-
}
|
|
4569
|
-
/**
|
|
4570
|
-
* Assert that the provided actual value is equal to the provided expected value.
|
|
4571
|
-
* @param expected The expected value.
|
|
4572
|
-
* @param actual The actual value.
|
|
4573
|
-
* @param expression The expression that produced the actual value.
|
|
4574
|
-
* @param message An optional message that describes the scenario.
|
|
4575
|
-
*/
|
|
4576
|
-
static assertEqual(expected, actual, expression, message) {
|
|
4577
|
-
return _PostCondition.getCondition().assertEqual(expected, actual, expression, message);
|
|
4578
|
-
}
|
|
4579
|
-
/**
|
|
4580
|
-
* Assert that the provided actual value is not equal to the provided expected value.
|
|
4581
|
-
* @param notExpected The not expected value.
|
|
4582
|
-
* @param actual The actual value.
|
|
4583
|
-
* @param expression The expression that produced the actual value.
|
|
4584
|
-
* @param message An optional message that describes the scenario.
|
|
4585
|
-
*/
|
|
4586
|
-
static assertNotEqual(notExpected, actual, expression, message) {
|
|
4587
|
-
return _PostCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
|
|
4588
|
-
}
|
|
4589
|
-
/**
|
|
4590
|
-
* Assert that the provided value is not empty.
|
|
4591
|
-
* @param value The value to check.
|
|
4592
|
-
* @param expression The expression that produced the actual value.
|
|
4593
|
-
* @param message An optional message that describes the scenario.
|
|
4594
|
-
*/
|
|
4595
|
-
static assertNotEmpty(value, expression, message) {
|
|
4596
|
-
return _PostCondition.getCondition().assertNotEmpty(value, expression, message);
|
|
4597
|
-
}
|
|
4598
|
-
/**
|
|
4599
|
-
* Assert that the provided value is less than the provided upperBound.
|
|
4600
|
-
* @param value The value to check.
|
|
4601
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
4602
|
-
* @param expression The expression that produced the actual value.
|
|
4603
|
-
* @param message An optional message that describes the scenario.
|
|
4604
|
-
*/
|
|
4605
|
-
static assertLessThan(value, upperBound, expression, message) {
|
|
4606
|
-
return _PostCondition.getCondition().assertLessThan(value, upperBound, expression, message);
|
|
4607
|
-
}
|
|
4608
|
-
/**
|
|
4609
|
-
* Assert that the provided value is less than or equal to the provided upperBound.
|
|
4610
|
-
* @param value The value to check.
|
|
4611
|
-
* @param upperBound The upperBound that the value must be less than.
|
|
4612
|
-
* @param expression The expression that produced the actual value.
|
|
4613
|
-
* @param message An optional message that describes the scenario.
|
|
4614
|
-
*/
|
|
4615
|
-
static assertLessThanOrEqualTo(value, upperBound, expression, message) {
|
|
4616
|
-
return _PostCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
|
|
4617
|
-
}
|
|
4618
|
-
/**
|
|
4619
|
-
* Assert that the provided value is greater than or equal to the provided lowerBound.
|
|
4620
|
-
* @param value The value to check.
|
|
4621
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
4622
|
-
* @param expression The expression that produced the actual value.
|
|
4623
|
-
* @param message An optional message that describes the scenario.
|
|
4624
|
-
*/
|
|
4625
|
-
static assertGreaterThanOrEqualTo(value, lowerBound, expression, message) {
|
|
4626
|
-
return _PostCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
|
|
4627
|
-
}
|
|
4628
|
-
/**
|
|
4629
|
-
* Assert that the provided value is greater than the provided lowerBound.
|
|
4630
|
-
* @param value The value to check.
|
|
4631
|
-
* @param lowerBound The lowerBound that the value must be greater than.
|
|
4632
|
-
* @param expression The expression that produced the actual value.
|
|
4633
|
-
* @param message An optional message that describes the scenario.
|
|
4634
|
-
*/
|
|
4635
|
-
static assertGreaterThan(value, lowerBound, expression, message) {
|
|
4636
|
-
return _PostCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
|
|
4637
|
-
}
|
|
4638
|
-
/**
|
|
4639
|
-
* Assert that the value is greater than or equal to the lowerBound and less than or equal to
|
|
4640
|
-
* the upperBound.
|
|
4641
|
-
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
4642
|
-
* @param value The value to check.
|
|
4643
|
-
* @param upperBound The upperBound that the value must be less than or equal to.
|
|
4644
|
-
* @param expression The expression that produced the actual value.
|
|
4645
|
-
* @param message An optional message that describes the scenario.
|
|
4646
|
-
*/
|
|
4647
|
-
static assertBetween(lowerBound, value, upperBound, expression, message) {
|
|
4648
|
-
return _PostCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
|
|
4649
|
-
}
|
|
4650
|
-
/**
|
|
4651
|
-
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
4652
|
-
* @param index The index to check.
|
|
4653
|
-
* @param count The number of elements in the indexable.
|
|
4654
|
-
* @param expression The expression that produced the actual value.
|
|
4655
|
-
* @param message An optional message that describes the scenario.
|
|
4656
|
-
*/
|
|
4657
|
-
static assertAccessIndex(index, count, expression, message) {
|
|
4658
|
-
return _PostCondition.getCondition().assertAccessIndex(index, count, expression, message);
|
|
4659
|
-
}
|
|
4660
|
-
/**
|
|
4661
|
-
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
4662
|
-
* @param index The index to check.
|
|
4663
|
-
* @param count The number of elements in the indexable.
|
|
4664
|
-
* @param expression The expression that produced the actual value.
|
|
4665
|
-
* @param message An optional message that describes the scenario.
|
|
4666
|
-
*/
|
|
4667
|
-
static assertInsertIndex(index, count, expression, message) {
|
|
4668
|
-
return _PostCondition.getCondition().assertInsertIndex(index, count, expression, message);
|
|
4669
|
-
}
|
|
4670
|
-
/**
|
|
4671
|
-
* Assert that the value is one of the possibilities.
|
|
4672
|
-
* @param possibilities The possible values that the value can be.
|
|
4673
|
-
* @param value The value to check.
|
|
4674
|
-
* @param expression The expression that produced the value.
|
|
4675
|
-
* @param message An optional error message.
|
|
4676
|
-
*/
|
|
4677
|
-
static assertOneOf(possibilities, value, expression, message) {
|
|
4678
|
-
return _PostCondition.getCondition().assertOneOf(possibilities, value, expression, message);
|
|
4679
|
-
}
|
|
4680
|
-
/**
|
|
4681
|
-
* Assert that the value is within the bounds of a byte.
|
|
4682
|
-
* @param value The value to check.
|
|
4683
|
-
* @param expression The expression that produced the value.
|
|
4684
|
-
* @param message An optional error message.
|
|
4685
|
-
*/
|
|
4686
|
-
static assertByte(value, expression, message) {
|
|
4687
|
-
return _PostCondition.getCondition().assertByte(value, expression, message);
|
|
4688
|
-
}
|
|
4689
|
-
/**
|
|
4690
|
-
* Assert that the value is an integer.
|
|
4691
|
-
* @param value The value to check.
|
|
4692
|
-
* @param expression The expression that produced the value.
|
|
4693
|
-
* @param message An optional error message.
|
|
4694
|
-
*/
|
|
4695
|
-
static assertInteger(value, expression, message) {
|
|
4696
|
-
return _PostCondition.getCondition().assertInteger(value, expression, message);
|
|
4697
|
-
}
|
|
4698
|
-
/**
|
|
4699
|
-
* Assert that the value is a characer (single character string).
|
|
4700
|
-
* @param value The value to check.
|
|
4701
|
-
* @param expression The expression that produced the value.
|
|
4702
|
-
* @param message An optional error message.
|
|
4703
|
-
*/
|
|
4704
|
-
static assertCharacter(value, expression, message) {
|
|
4705
|
-
return _PostCondition.getCondition().assertCharacter(value, expression, message);
|
|
4706
|
-
}
|
|
4707
|
-
assertInstanceOf(parametersOrValue, type, typeCheck, expression, message) {
|
|
4708
|
-
return _PostCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
|
|
4709
|
-
}
|
|
4710
|
-
};
|
|
4711
|
-
|
|
4712
|
-
// sources/characterWriteStream.ts
|
|
4713
|
-
var CharacterWriteStream = class _CharacterWriteStream {
|
|
4714
|
-
/**
|
|
4715
|
-
* Write the provided text (if provided) and then write a newline character sequence to this
|
|
4716
|
-
* {@link CharacterWriteStream}.
|
|
4717
|
-
* @param text The optional text to write before the newline character sequence.
|
|
4718
|
-
* @returns The number of characters that were written.
|
|
4719
|
-
*/
|
|
4720
|
-
writeLine(text) {
|
|
4721
|
-
return _CharacterWriteStream.writeLine(this, text);
|
|
4722
|
-
}
|
|
4723
|
-
static writeLine(writeStream, text) {
|
|
4724
|
-
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
4725
|
-
return PromiseAsyncResult.create(async () => {
|
|
4726
|
-
let result = 0;
|
|
4727
|
-
if (text) {
|
|
4728
|
-
result += await writeStream.writeString(text);
|
|
4729
|
-
}
|
|
4730
|
-
result += await writeStream.writeString("\n");
|
|
4731
|
-
PostCondition.assertGreaterThan(result, 0, "result");
|
|
4732
|
-
return result;
|
|
4733
|
-
});
|
|
4734
|
-
}
|
|
4735
|
-
};
|
|
4736
|
-
|
|
4737
|
-
// sources/characterListStream.ts
|
|
4738
|
-
var CharacterListStream = class _CharacterListStream {
|
|
4739
|
-
list;
|
|
4740
|
-
constructor() {
|
|
4741
|
-
this.list = CharacterList.create();
|
|
4742
|
-
}
|
|
4743
|
-
static create(initialValues) {
|
|
4744
|
-
const result = new _CharacterListStream();
|
|
4745
|
-
if (initialValues) {
|
|
4746
|
-
result.writeCharacters(initialValues).await();
|
|
4747
|
-
}
|
|
4748
|
-
return result;
|
|
4749
|
-
}
|
|
4750
|
-
writeCharacters(characters, startIndex, length) {
|
|
4751
|
-
PreCondition.assertNotUndefinedAndNotNull(characters, "characters");
|
|
4752
|
-
const characterString = isString(characters) ? characters : join("", characters);
|
|
4753
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
4754
|
-
startIndex = 0;
|
|
4755
|
-
}
|
|
4756
|
-
if (isUndefinedOrNull(length)) {
|
|
4757
|
-
length = characterString.length - startIndex;
|
|
4758
|
-
}
|
|
4759
|
-
PreCondition.assertInsertIndex(startIndex, characterString.length, "startIndex");
|
|
4760
|
-
PreCondition.assertBetween(0, length, characterString.length - startIndex, "length");
|
|
4761
|
-
this.list.addAll(characterString.slice(startIndex, length + startIndex));
|
|
4762
|
-
return SyncResult.value(length);
|
|
4763
|
-
}
|
|
4764
|
-
writeString(text) {
|
|
4765
|
-
this.list.addAll(text);
|
|
4766
|
-
return SyncResult.value(text.length);
|
|
4767
|
-
}
|
|
4768
|
-
writeLine(text) {
|
|
4769
|
-
return CharacterWriteStream.writeLine(this, text);
|
|
4770
|
-
}
|
|
4771
|
-
/**
|
|
4772
|
-
* Get the number of characters that are available to be read.
|
|
4773
|
-
*/
|
|
4774
|
-
getAvailableCharacterCount() {
|
|
4775
|
-
return this.list.getCount().await();
|
|
4776
|
-
}
|
|
4777
|
-
readCharacter() {
|
|
4778
|
-
return !this.list.any().await() ? SyncResult.error(new EmptyError()) : SyncResult.value(this.list.removeFirst().await());
|
|
4779
|
-
}
|
|
4780
|
-
readCharacters(countOrOutput, startIndex, count) {
|
|
4781
|
-
let result;
|
|
4782
|
-
if (isNumber(countOrOutput)) {
|
|
4783
|
-
PreCondition.assertGreaterThanOrEqualTo(countOrOutput, 0, "count");
|
|
4784
|
-
if (!this.list.any().await()) {
|
|
4785
|
-
result = SyncResult.error(new EmptyError());
|
|
4786
|
-
} else {
|
|
4787
|
-
const bytesReadCount = Math.min(countOrOutput, this.list.getCount().await());
|
|
4788
|
-
let output = "";
|
|
4789
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
4790
|
-
output += this.list.removeFirst().await();
|
|
4791
|
-
}
|
|
4792
|
-
result = SyncResult.value(output);
|
|
4793
|
-
}
|
|
4794
|
-
} else {
|
|
4795
|
-
PreCondition.assertNotUndefinedAndNotNull(countOrOutput, "output");
|
|
4796
|
-
if (isUndefinedOrNull(startIndex)) {
|
|
4797
|
-
startIndex = 0;
|
|
4798
|
-
}
|
|
4799
|
-
if (isUndefinedOrNull(count)) {
|
|
4800
|
-
count = countOrOutput.length - startIndex;
|
|
4801
|
-
}
|
|
4802
|
-
PreCondition.assertInsertIndex(startIndex, countOrOutput.length, "startIndex");
|
|
4803
|
-
PreCondition.assertBetween(0, count, countOrOutput.length - startIndex, "count");
|
|
4804
|
-
if (!this.list.any().await()) {
|
|
4805
|
-
result = SyncResult.error(new EmptyError());
|
|
4806
|
-
} else {
|
|
4807
|
-
const bytesReadCount = Math.min(count, this.list.getCount().await());
|
|
4808
|
-
for (let i = 0; i < bytesReadCount; i++) {
|
|
4809
|
-
countOrOutput[startIndex + i] = this.list.removeFirst().await();
|
|
4810
|
-
}
|
|
4811
|
-
result = SyncResult.value(bytesReadCount);
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
return result;
|
|
4815
|
-
}
|
|
4816
|
-
readUntil(searchString) {
|
|
4817
|
-
return CharacterReadStream.readUntil(this, searchString);
|
|
4818
|
-
}
|
|
4819
|
-
readLine() {
|
|
4820
|
-
return CharacterReadStream.readLine(this);
|
|
4821
|
-
}
|
|
4822
|
-
};
|
|
4823
|
-
|
|
4824
|
-
// sources/commandLineParameters.ts
|
|
4825
|
-
var CommandLineParameters = class _CommandLineParameters {
|
|
4826
|
-
args;
|
|
4827
|
-
constructor(argv) {
|
|
4828
|
-
this.args = argv;
|
|
4829
|
-
}
|
|
4830
|
-
static create(args) {
|
|
4831
|
-
return new _CommandLineParameters(args);
|
|
4832
|
-
}
|
|
4833
|
-
};
|
|
4834
|
-
|
|
4835
|
-
// sources/nodeJSCharacterWriteStream.ts
|
|
4836
|
-
var NodeJSCharacterWriteStream = class _NodeJSCharacterWriteStream extends CharacterWriteStream {
|
|
4837
|
-
nodeJSWriteStream;
|
|
4838
|
-
constructor(nodeJSWriteStream) {
|
|
4839
|
-
PreCondition.assertNotUndefinedAndNotNull(nodeJSWriteStream, "nodeJSWriteStream");
|
|
4840
|
-
super();
|
|
4841
|
-
this.nodeJSWriteStream = nodeJSWriteStream;
|
|
4842
|
-
}
|
|
4843
|
-
static create(nodeJSWriteStream) {
|
|
4844
|
-
return new _NodeJSCharacterWriteStream(nodeJSWriteStream);
|
|
4845
|
-
}
|
|
4846
|
-
writeString(text) {
|
|
4847
|
-
PreCondition.assertNotUndefinedAndNotNull(text, "text");
|
|
4848
|
-
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
4849
|
-
this.nodeJSWriteStream.write(text, (error) => {
|
|
4850
|
-
if (error) {
|
|
4851
|
-
reject(error);
|
|
4852
|
-
} else {
|
|
4853
|
-
resolve(text.length);
|
|
4854
|
-
}
|
|
4855
|
-
});
|
|
4856
|
-
}));
|
|
4857
|
-
}
|
|
4858
|
-
};
|
|
4859
|
-
|
|
4860
|
-
// sources/property.ts
|
|
4861
|
-
var Property = class _Property {
|
|
4862
|
-
getter;
|
|
4863
|
-
setter;
|
|
4864
|
-
constructor(getter, setter) {
|
|
4865
|
-
PreCondition.assertNotUndefinedAndNotNull(getter, "getter");
|
|
4866
|
-
PreCondition.assertNotUndefinedAndNotNull(setter, "setter");
|
|
4867
|
-
this.getter = getter;
|
|
4868
|
-
this.setter = setter;
|
|
4869
|
-
}
|
|
4870
|
-
static create(getterOptionsOrInitialValue, setter) {
|
|
4871
|
-
let getter;
|
|
4872
|
-
if (isFunction(getterOptionsOrInitialValue)) {
|
|
4873
|
-
getter = getterOptionsOrInitialValue;
|
|
4874
|
-
} else if (isObject(getterOptionsOrInitialValue) && hasProperty(getterOptionsOrInitialValue, "getter") && hasProperty(getterOptionsOrInitialValue, "setter")) {
|
|
4875
|
-
const options = getterOptionsOrInitialValue;
|
|
4876
|
-
getter = options.getter;
|
|
4877
|
-
setter = options.setter;
|
|
4878
|
-
} else {
|
|
4879
|
-
let initialValue = getterOptionsOrInitialValue;
|
|
4880
|
-
getter = () => {
|
|
4881
|
-
return initialValue;
|
|
4882
|
-
};
|
|
4883
|
-
setter = (value) => {
|
|
4884
|
-
initialValue = value;
|
|
4885
|
-
};
|
|
4886
|
-
}
|
|
4887
|
-
PreCondition.assertNotUndefinedAndNotNull(getter, "getter");
|
|
4888
|
-
PreCondition.assertNotUndefinedAndNotNull(setter, "setter");
|
|
4889
|
-
return new _Property(getter, setter);
|
|
4890
|
-
}
|
|
4891
|
-
getValue() {
|
|
4892
|
-
return this.getter();
|
|
4893
|
-
}
|
|
4894
|
-
setValue(value) {
|
|
4895
|
-
this.setter(value);
|
|
4896
|
-
return this;
|
|
4897
|
-
}
|
|
4898
|
-
toString() {
|
|
4899
|
-
return `${this.getValue()}`;
|
|
4900
|
-
}
|
|
4901
|
-
};
|
|
4902
|
-
|
|
4903
|
-
// sources/httpHeader.ts
|
|
4904
|
-
var HttpHeader = class _HttpHeader {
|
|
4905
|
-
name;
|
|
4906
|
-
value;
|
|
4907
|
-
constructor(name, value) {
|
|
4908
|
-
PreCondition.assertNotEmpty(name, "name");
|
|
4909
|
-
PreCondition.assertNotUndefinedAndNotNull(value, "value");
|
|
4910
|
-
this.name = name;
|
|
4911
|
-
this.value = value;
|
|
4912
|
-
}
|
|
4913
|
-
static create(name, value) {
|
|
4914
|
-
return new _HttpHeader(name, value);
|
|
4915
|
-
}
|
|
4916
|
-
getName() {
|
|
4917
|
-
return this.name;
|
|
4918
|
-
}
|
|
4919
|
-
getValue() {
|
|
4920
|
-
return this.value;
|
|
4921
|
-
}
|
|
4922
|
-
toString() {
|
|
4923
|
-
return `${escapeAndQuote(this.name)}:${escapeAndQuote(this.value)}`;
|
|
4924
|
-
}
|
|
4925
|
-
};
|
|
4926
|
-
|
|
4927
|
-
// sources/httpHeaders.ts
|
|
4928
|
-
var HttpHeaders = class _HttpHeaders {
|
|
4929
|
-
static contentTypeHeaderName = "Content-Type";
|
|
4930
|
-
static create(headers) {
|
|
4931
|
-
return MutableHttpHeaders.create(headers);
|
|
4932
|
-
}
|
|
4933
|
-
getContentType() {
|
|
4934
|
-
return _HttpHeaders.getContentType(this);
|
|
4935
|
-
}
|
|
4936
|
-
static getContentType(headers) {
|
|
4937
|
-
return headers.get(_HttpHeaders.contentTypeHeaderName);
|
|
4938
|
-
}
|
|
4939
|
-
getContentTypeValue() {
|
|
4940
|
-
return _HttpHeaders.getContentTypeValue(this);
|
|
4941
|
-
}
|
|
4942
|
-
static getContentTypeValue(headers) {
|
|
4943
|
-
return headers.getValue(_HttpHeaders.contentTypeHeaderName);
|
|
4944
|
-
}
|
|
4945
|
-
/**
|
|
4946
|
-
* Get the {@link HttpHeader}s in this {@link HttpHeaders} object as an array.
|
|
4947
|
-
*/
|
|
4948
|
-
toArray() {
|
|
4949
|
-
return _HttpHeaders.toArray(this);
|
|
4950
|
-
}
|
|
4951
|
-
static toArray(headers) {
|
|
4952
|
-
return Iterable.toArray(headers);
|
|
4953
|
-
}
|
|
4954
|
-
any() {
|
|
4955
|
-
return _HttpHeaders.any(this);
|
|
4956
|
-
}
|
|
4957
|
-
static any(headers) {
|
|
4958
|
-
return Iterable.any(headers);
|
|
4959
|
-
}
|
|
4960
|
-
getCount() {
|
|
4961
|
-
return _HttpHeaders.getCount(this);
|
|
4962
|
-
}
|
|
4963
|
-
static getCount(headers) {
|
|
4964
|
-
return Iterable.getCount(headers);
|
|
4965
|
-
}
|
|
4966
|
-
equals(right, equalFunctions) {
|
|
4967
|
-
return _HttpHeaders.equals(this, right, equalFunctions);
|
|
4968
|
-
}
|
|
4969
|
-
static equals(headers, right, equalFunctions) {
|
|
4970
|
-
return Iterable.equals(headers, right, equalFunctions);
|
|
4971
|
-
}
|
|
4972
|
-
toString(toStringFunctions) {
|
|
4973
|
-
return _HttpHeaders.toString(this, toStringFunctions);
|
|
4974
|
-
}
|
|
4975
|
-
static toString(headers, toStringFunctions) {
|
|
4976
|
-
return Iterable.toString(headers, toStringFunctions);
|
|
4977
|
-
}
|
|
4978
|
-
concatenate(...toConcatenate) {
|
|
4979
|
-
return _HttpHeaders.concatenate(this, ...toConcatenate);
|
|
4980
|
-
}
|
|
4981
|
-
static concatenate(headers, ...toConcatenate) {
|
|
4982
|
-
return Iterable.concatenate(headers, ...toConcatenate);
|
|
4983
|
-
}
|
|
4984
|
-
map(mapping) {
|
|
4985
|
-
return _HttpHeaders.map(this, mapping);
|
|
4986
|
-
}
|
|
4987
|
-
static map(headers, mapping) {
|
|
4988
|
-
return Iterable.map(headers, mapping);
|
|
4989
|
-
}
|
|
4990
|
-
flatMap(mapping) {
|
|
4991
|
-
return _HttpHeaders.flatMap(this, mapping);
|
|
4992
|
-
}
|
|
4993
|
-
static flatMap(headers, mapping) {
|
|
4994
|
-
return Iterable.flatMap(headers, mapping);
|
|
4995
|
-
}
|
|
4996
|
-
where(condition) {
|
|
4997
|
-
return _HttpHeaders.where(this, condition);
|
|
4998
|
-
}
|
|
4999
|
-
static where(headers, condition) {
|
|
5000
|
-
return Iterable.where(headers, condition);
|
|
5001
|
-
}
|
|
5002
|
-
instanceOf(typeOrTypeCheck) {
|
|
5003
|
-
return _HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
5004
|
-
}
|
|
5005
|
-
static instanceOf(headers, typeOrTypeCheck) {
|
|
5006
|
-
return Iterable.instanceOf(headers, typeOrTypeCheck);
|
|
5007
|
-
}
|
|
5008
|
-
first(condition) {
|
|
5009
|
-
return _HttpHeaders.first(this, condition);
|
|
5010
|
-
}
|
|
5011
|
-
static first(headers, condition) {
|
|
5012
|
-
return Iterable.first(headers, condition);
|
|
5013
|
-
}
|
|
5014
|
-
last(condition) {
|
|
5015
|
-
return _HttpHeaders.last(this, condition);
|
|
5016
|
-
}
|
|
5017
|
-
static last(headers, condition) {
|
|
5018
|
-
return Iterable.last(headers, condition);
|
|
5019
|
-
}
|
|
5020
|
-
[Symbol.iterator]() {
|
|
5021
|
-
return _HttpHeaders[Symbol.iterator](this);
|
|
5022
|
-
}
|
|
5023
|
-
static [Symbol.iterator](headers) {
|
|
5024
|
-
return Iterable[Symbol.iterator](headers);
|
|
5025
|
-
}
|
|
5026
|
-
contains(value, equalFunctions) {
|
|
5027
|
-
return _HttpHeaders.contains(this, value, equalFunctions);
|
|
5028
|
-
}
|
|
5029
|
-
static contains(headers, value, equalFunctions) {
|
|
5030
|
-
return SyncResult.create(() => {
|
|
5031
|
-
if (!equalFunctions) {
|
|
5032
|
-
equalFunctions = EqualFunctions.create();
|
|
5033
|
-
}
|
|
5034
|
-
return headers.getValue(value.getName()).then((headerValue) => equalFunctions.areEqual(headerValue, value.getValue()).await()).catch(NotFoundError, () => false).await();
|
|
5035
|
-
});
|
|
5036
|
-
}
|
|
5037
|
-
};
|
|
5038
|
-
|
|
5039
|
-
// sources/mutableHttpHeaders.ts
|
|
5040
|
-
var MutableHttpHeaders = class _MutableHttpHeaders {
|
|
5041
|
-
headers;
|
|
5042
|
-
constructor(headers) {
|
|
5043
|
-
this.headers = List.create();
|
|
5044
|
-
if (headers) {
|
|
5045
|
-
this.setAll(headers);
|
|
5046
|
-
}
|
|
5047
|
-
}
|
|
5048
|
-
static create(headers) {
|
|
5049
|
-
return new _MutableHttpHeaders(headers);
|
|
5050
|
-
}
|
|
5051
|
-
iterate() {
|
|
5052
|
-
return this.headers.iterate();
|
|
5053
|
-
}
|
|
5054
|
-
get(headerName) {
|
|
5055
|
-
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5056
|
-
return SyncResult.create(() => {
|
|
5057
|
-
let result;
|
|
5058
|
-
const lowerHeaderName = headerName.toLowerCase();
|
|
5059
|
-
for (const header of this.headers) {
|
|
5060
|
-
if (header.getName().toLowerCase() === lowerHeaderName) {
|
|
5061
|
-
result = header;
|
|
5062
|
-
break;
|
|
5063
|
-
}
|
|
5064
|
-
}
|
|
5065
|
-
if (result === void 0) {
|
|
5066
|
-
throw new NotFoundError(`No HttpHeader found with the name ${escapeAndQuote(headerName)}.`);
|
|
5067
|
-
}
|
|
5068
|
-
return result;
|
|
5069
|
-
});
|
|
5070
|
-
}
|
|
5071
|
-
getValue(headerName) {
|
|
5072
|
-
return this.get(headerName).then((header) => header.getValue());
|
|
5073
|
-
}
|
|
5074
|
-
set(headerOrHeaderName, headerValue) {
|
|
5075
|
-
let headerName;
|
|
5076
|
-
if (isString(headerOrHeaderName)) {
|
|
5077
|
-
headerName = headerOrHeaderName;
|
|
5078
|
-
} else {
|
|
5079
|
-
headerName = headerOrHeaderName.getName();
|
|
5080
|
-
headerValue = headerOrHeaderName.getValue();
|
|
5081
|
-
}
|
|
5082
|
-
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5083
|
-
PreCondition.assertNotUndefinedAndNotNull(headerValue, "headerValue");
|
|
5084
|
-
let insertIndex = 0;
|
|
5085
|
-
for (let insertIndex2 = 0; insertIndex2 < this.headers.getCount().await(); insertIndex2++) {
|
|
5086
|
-
const header = this.headers.get(insertIndex2).await();
|
|
5087
|
-
if (header.getName() === headerName) {
|
|
5088
|
-
this.headers.removeAt(insertIndex2);
|
|
5089
|
-
break;
|
|
5090
|
-
}
|
|
5091
|
-
}
|
|
5092
|
-
this.headers.insert(insertIndex, HttpHeader.create(headerName, headerValue));
|
|
5093
|
-
return this;
|
|
5094
|
-
}
|
|
5095
|
-
setAll(headers) {
|
|
5096
|
-
PreCondition.assertNotUndefinedAndNotNull(headers, "headers");
|
|
5097
|
-
for (const header of headers) {
|
|
5098
|
-
this.set(header);
|
|
5099
|
-
}
|
|
5100
|
-
return this;
|
|
5101
|
-
}
|
|
5102
|
-
setContentType(contentType) {
|
|
5103
|
-
return this.set(HttpHeaders.contentTypeHeaderName, contentType);
|
|
5104
|
-
}
|
|
5105
|
-
getContentType() {
|
|
5106
|
-
return this.get(HttpHeaders.contentTypeHeaderName);
|
|
5107
|
-
}
|
|
5108
|
-
getContentTypeValue() {
|
|
5109
|
-
return this.getValue(HttpHeaders.contentTypeHeaderName);
|
|
5110
|
-
}
|
|
5111
|
-
getCount() {
|
|
5112
|
-
return this.headers.getCount();
|
|
5113
|
-
}
|
|
5114
|
-
toArray() {
|
|
5115
|
-
return HttpHeaders.toArray(this);
|
|
5116
|
-
}
|
|
5117
|
-
any() {
|
|
5118
|
-
return HttpHeaders.any(this);
|
|
5119
|
-
}
|
|
5120
|
-
equals(right, equalFunctions) {
|
|
5121
|
-
return HttpHeaders.equals(this, right, equalFunctions);
|
|
5122
|
-
}
|
|
5123
|
-
toString(toStringFunctions) {
|
|
5124
|
-
return HttpHeaders.toString(this, toStringFunctions);
|
|
5125
|
-
}
|
|
5126
|
-
concatenate(...toConcatenate) {
|
|
5127
|
-
return HttpHeaders.concatenate(this, ...toConcatenate);
|
|
5128
|
-
}
|
|
5129
|
-
map(mapping) {
|
|
5130
|
-
return HttpHeaders.map(this, mapping);
|
|
5131
|
-
}
|
|
5132
|
-
flatMap(mapping) {
|
|
5133
|
-
return HttpHeaders.flatMap(this, mapping);
|
|
5134
|
-
}
|
|
5135
|
-
where(condition) {
|
|
5136
|
-
return HttpHeaders.where(this, condition);
|
|
5137
|
-
}
|
|
5138
|
-
instanceOf(typeOrTypeCheck) {
|
|
5139
|
-
return HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
5140
|
-
}
|
|
5141
|
-
first(condition) {
|
|
5142
|
-
return HttpHeaders.first(this, condition);
|
|
5143
|
-
}
|
|
5144
|
-
last(condition) {
|
|
5145
|
-
return HttpHeaders.last(this, condition);
|
|
5146
|
-
}
|
|
5147
|
-
[Symbol.iterator]() {
|
|
5148
|
-
return HttpHeaders[Symbol.iterator](this);
|
|
5149
|
-
}
|
|
5150
|
-
contains(value, equalFunctions) {
|
|
5151
|
-
return HttpHeaders.contains(this, value, equalFunctions);
|
|
5152
|
-
}
|
|
5153
|
-
};
|
|
5154
|
-
|
|
5155
|
-
// sources/httpIncomingResponse.ts
|
|
5156
|
-
var HttpIncomingResponse = class {
|
|
5157
|
-
};
|
|
5158
|
-
|
|
5159
|
-
// sources/fetchHttpResponse.ts
|
|
5160
|
-
var FetchHttpIncomingResponse = class _FetchHttpIncomingResponse extends HttpIncomingResponse {
|
|
5161
|
-
response;
|
|
5162
|
-
constructor(response) {
|
|
5163
|
-
PreCondition.assertNotUndefinedAndNotNull(response, "response");
|
|
5164
|
-
super();
|
|
5165
|
-
this.response = response;
|
|
5166
|
-
}
|
|
5167
|
-
static create(response) {
|
|
5168
|
-
return new _FetchHttpIncomingResponse(response);
|
|
5169
|
-
}
|
|
5170
|
-
getStatusCode() {
|
|
5171
|
-
return this.response.status;
|
|
5172
|
-
}
|
|
5173
|
-
getHeaders() {
|
|
5174
|
-
return SyncResult.create(() => {
|
|
5175
|
-
const result = HttpHeaders.create();
|
|
5176
|
-
for (const header of this.response.headers) {
|
|
5177
|
-
result.set(header[0], header[1]);
|
|
5178
|
-
}
|
|
5179
|
-
return result;
|
|
5180
|
-
});
|
|
5181
|
-
}
|
|
5182
|
-
getHeader(headerName) {
|
|
5183
|
-
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5184
|
-
return SyncResult.create(() => {
|
|
5185
|
-
let result;
|
|
5186
|
-
const lowerHeaderName = headerName.toLowerCase();
|
|
5187
|
-
for (const header of this.response.headers) {
|
|
5188
|
-
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
5189
|
-
result = HttpHeader.create(header[0], header[1]);
|
|
5190
|
-
break;
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
if (result === void 0) {
|
|
5194
|
-
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
5195
|
-
}
|
|
5196
|
-
return result;
|
|
5197
|
-
});
|
|
5198
|
-
}
|
|
5199
|
-
getHeaderValue(headerName) {
|
|
5200
|
-
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5201
|
-
return SyncResult.create(() => {
|
|
5202
|
-
let result;
|
|
5203
|
-
const lowerHeaderName = headerName.toLowerCase();
|
|
5204
|
-
for (const header of this.response.headers) {
|
|
5205
|
-
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
5206
|
-
result = header[1];
|
|
5207
|
-
break;
|
|
5208
|
-
}
|
|
5209
|
-
}
|
|
5210
|
-
if (result === void 0) {
|
|
5211
|
-
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
5212
|
-
}
|
|
5213
|
-
return result;
|
|
5214
|
-
});
|
|
5215
|
-
}
|
|
5216
|
-
getBody() {
|
|
5217
|
-
return PromiseAsyncResult.create(this.response.text());
|
|
5218
|
-
}
|
|
5219
|
-
};
|
|
5220
|
-
|
|
5221
|
-
// sources/httpMethod.ts
|
|
5222
|
-
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
5223
|
-
HttpMethod2[HttpMethod2["GET"] = 0] = "GET";
|
|
5224
|
-
HttpMethod2[HttpMethod2["HEAD"] = 1] = "HEAD";
|
|
5225
|
-
HttpMethod2[HttpMethod2["POST"] = 2] = "POST";
|
|
5226
|
-
HttpMethod2[HttpMethod2["PUT"] = 3] = "PUT";
|
|
5227
|
-
HttpMethod2[HttpMethod2["DELETE"] = 4] = "DELETE";
|
|
5228
|
-
HttpMethod2[HttpMethod2["CONNECT"] = 5] = "CONNECT";
|
|
5229
|
-
HttpMethod2[HttpMethod2["OPTIONS"] = 6] = "OPTIONS";
|
|
5230
|
-
HttpMethod2[HttpMethod2["TRACE"] = 7] = "TRACE";
|
|
5231
|
-
HttpMethod2[HttpMethod2["PATCH"] = 8] = "PATCH";
|
|
5232
|
-
return HttpMethod2;
|
|
5233
|
-
})(HttpMethod || {});
|
|
5234
|
-
function parseHttpMethod(text) {
|
|
5235
|
-
return SyncResult.create(() => {
|
|
5236
|
-
let result;
|
|
5237
|
-
switch (text.toUpperCase()) {
|
|
5238
|
-
case "GET":
|
|
5239
|
-
result = 0 /* GET */;
|
|
5240
|
-
break;
|
|
5241
|
-
case "HEAD":
|
|
5242
|
-
result = 1 /* HEAD */;
|
|
5243
|
-
break;
|
|
5244
|
-
case "POST":
|
|
5245
|
-
result = 2 /* POST */;
|
|
5246
|
-
break;
|
|
5247
|
-
case "PUT":
|
|
5248
|
-
result = 3 /* PUT */;
|
|
5249
|
-
break;
|
|
5250
|
-
case "DELETE":
|
|
5251
|
-
result = 4 /* DELETE */;
|
|
5252
|
-
break;
|
|
5253
|
-
case "CONNECT":
|
|
5254
|
-
result = 5 /* CONNECT */;
|
|
5255
|
-
break;
|
|
5256
|
-
case "OPTIONS":
|
|
5257
|
-
result = 6 /* OPTIONS */;
|
|
5258
|
-
break;
|
|
5259
|
-
case "TRACE":
|
|
5260
|
-
result = 7 /* TRACE */;
|
|
5261
|
-
break;
|
|
5262
|
-
case "PATCH":
|
|
5263
|
-
result = 8 /* PATCH */;
|
|
5264
|
-
break;
|
|
5265
|
-
default:
|
|
5266
|
-
throw new NotFoundError(`No HttpMethod exists for the text "${text}".`);
|
|
5267
|
-
}
|
|
5268
|
-
return result;
|
|
5269
|
-
});
|
|
5270
|
-
}
|
|
5271
|
-
function httpMethodToString(httpMethod) {
|
|
5272
|
-
PreCondition.assertNotUndefinedAndNotNull(httpMethod, "httpMethod");
|
|
5273
|
-
let result;
|
|
5274
|
-
switch (httpMethod) {
|
|
5275
|
-
case 0 /* GET */:
|
|
5276
|
-
result = "GET";
|
|
5277
|
-
break;
|
|
5278
|
-
case 1 /* HEAD */:
|
|
5279
|
-
result = "HEAD";
|
|
5280
|
-
break;
|
|
5281
|
-
case 2 /* POST */:
|
|
5282
|
-
result = "POST";
|
|
5283
|
-
break;
|
|
5284
|
-
case 3 /* PUT */:
|
|
5285
|
-
result = "PUT";
|
|
5286
|
-
break;
|
|
5287
|
-
case 4 /* DELETE */:
|
|
5288
|
-
result = "DELETE";
|
|
5289
|
-
break;
|
|
5290
|
-
case 5 /* CONNECT */:
|
|
5291
|
-
result = "CONNECT";
|
|
5292
|
-
break;
|
|
5293
|
-
case 6 /* OPTIONS */:
|
|
5294
|
-
result = "OPTIONS";
|
|
5295
|
-
break;
|
|
5296
|
-
case 7 /* TRACE */:
|
|
5297
|
-
result = "TRACE";
|
|
5298
|
-
break;
|
|
5299
|
-
case 8 /* PATCH */:
|
|
5300
|
-
result = "PATCH";
|
|
5301
|
-
break;
|
|
5302
|
-
default:
|
|
5303
|
-
throw new NotFoundError(`Unrecognized HttpMethod: ${httpMethod}`);
|
|
5304
|
-
}
|
|
5305
|
-
return result;
|
|
5306
|
-
}
|
|
5307
|
-
|
|
5308
|
-
// sources/httpOutgoingRequest.ts
|
|
5309
|
-
var HttpOutgoingRequest = class _HttpOutgoingRequest {
|
|
5310
|
-
method;
|
|
5311
|
-
url;
|
|
5312
|
-
headers;
|
|
5313
|
-
body;
|
|
5314
|
-
constructor(method, url) {
|
|
5315
|
-
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5316
|
-
PreCondition.assertNotEmpty(url, "url");
|
|
5317
|
-
this.method = method;
|
|
5318
|
-
this.url = url;
|
|
5319
|
-
this.headers = HttpHeaders.create();
|
|
5320
|
-
this.body = "";
|
|
5321
|
-
}
|
|
5322
|
-
static create(method, url) {
|
|
5323
|
-
return new _HttpOutgoingRequest(method, url);
|
|
5324
|
-
}
|
|
5325
|
-
/**
|
|
5326
|
-
* Create a new {@link HttpOutgoingRequest} with a GET {@link HttpMethod}.
|
|
5327
|
-
* @param url The target URL for the {@link HttpOutgoingRequest}.
|
|
5328
|
-
*/
|
|
5329
|
-
static get(url) {
|
|
5330
|
-
return _HttpOutgoingRequest.create(0 /* GET */, url);
|
|
5331
|
-
}
|
|
5332
|
-
/**
|
|
5333
|
-
* Get the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5334
|
-
*/
|
|
5335
|
-
getMethod() {
|
|
5336
|
-
return this.method;
|
|
5337
|
-
}
|
|
5338
|
-
/**
|
|
5339
|
-
* Set the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5340
|
-
* @param method The {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
5341
|
-
*/
|
|
5342
|
-
setMethod(method) {
|
|
5343
|
-
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5344
|
-
this.method = method;
|
|
5345
|
-
return this;
|
|
5346
|
-
}
|
|
5347
|
-
/**
|
|
5348
|
-
* Get this {@link HttpOutgoingRequest}'s target URL.
|
|
5349
|
-
*/
|
|
5350
|
-
getURL() {
|
|
5351
|
-
return this.url;
|
|
5352
|
-
}
|
|
5353
|
-
/**
|
|
5354
|
-
* Set the URL that this request will be sent to.
|
|
5355
|
-
* @param url The URL to send this request to.
|
|
5356
|
-
*/
|
|
5357
|
-
setURL(url) {
|
|
5358
|
-
PreCondition.assertNotEmpty(url, "url");
|
|
5359
|
-
this.url = url;
|
|
5360
|
-
return this;
|
|
5361
|
-
}
|
|
5362
|
-
/**
|
|
5363
|
-
* Get the {@link HttpHeaders} that will be sent.
|
|
5364
|
-
*/
|
|
5365
|
-
getHeaders() {
|
|
5366
|
-
return this.headers;
|
|
5367
|
-
}
|
|
5368
|
-
getHeader(headerName) {
|
|
5369
|
-
return this.headers.get(headerName);
|
|
5370
|
-
}
|
|
5371
|
-
getHeaderValue(headerName) {
|
|
5372
|
-
return this.headers.getValue(headerName);
|
|
5373
|
-
}
|
|
5374
|
-
/**
|
|
5375
|
-
* Get the body that will be sent.
|
|
5376
|
-
*/
|
|
5377
|
-
getBody() {
|
|
5378
|
-
return this.body;
|
|
5379
|
-
}
|
|
5380
|
-
setBody(body) {
|
|
5381
|
-
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
5382
|
-
this.body = body;
|
|
5383
|
-
return this;
|
|
5384
|
-
}
|
|
5385
|
-
};
|
|
5386
|
-
|
|
5387
|
-
// sources/fetchHttpClient.ts
|
|
5388
|
-
var FetchHttpClient = class _FetchHttpClient {
|
|
5389
|
-
constructor() {
|
|
5390
|
-
}
|
|
5391
|
-
static create() {
|
|
5392
|
-
return new _FetchHttpClient();
|
|
5393
|
-
}
|
|
5394
|
-
sendRequest(request) {
|
|
5395
|
-
PreCondition.assertNotUndefinedAndNotNull(request, "request");
|
|
5396
|
-
return PromiseAsyncResult.create(async () => {
|
|
5397
|
-
const requestInit = {
|
|
5398
|
-
method: _FetchHttpClient.convertMethod(request.getMethod()),
|
|
5399
|
-
headers: request.getHeaders().map((header) => [header.getName(), header.getValue()]).toArray().await(),
|
|
5400
|
-
body: request.getBody() || void 0
|
|
5401
|
-
};
|
|
5402
|
-
const fetchResponse = await fetch(request.getURL(), requestInit);
|
|
5403
|
-
return FetchHttpIncomingResponse.create(fetchResponse);
|
|
5404
|
-
});
|
|
5405
|
-
}
|
|
5406
|
-
sendGetRequest(url) {
|
|
5407
|
-
return this.sendRequest(HttpOutgoingRequest.create(0 /* GET */, url));
|
|
5408
|
-
}
|
|
5409
|
-
static convertMethod(method) {
|
|
5410
|
-
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
5411
|
-
let result;
|
|
5412
|
-
switch (method) {
|
|
5413
|
-
case 5 /* CONNECT */:
|
|
5414
|
-
result = "CONNECT";
|
|
5415
|
-
break;
|
|
5416
|
-
case 4 /* DELETE */:
|
|
5417
|
-
result = "DELETE";
|
|
5418
|
-
break;
|
|
5419
|
-
case 0 /* GET */:
|
|
5420
|
-
result = "GET";
|
|
5421
|
-
break;
|
|
5422
|
-
case 1 /* HEAD */:
|
|
5423
|
-
result = "HEAD";
|
|
5424
|
-
break;
|
|
5425
|
-
case 6 /* OPTIONS */:
|
|
5426
|
-
result = "OPTIONS";
|
|
5427
|
-
break;
|
|
5428
|
-
case 8 /* PATCH */:
|
|
5429
|
-
result = "PATCH";
|
|
5430
|
-
break;
|
|
5431
|
-
case 2 /* POST */:
|
|
5432
|
-
result = "POST";
|
|
5433
|
-
break;
|
|
5434
|
-
case 3 /* PUT */:
|
|
5435
|
-
result = "PUT";
|
|
5436
|
-
break;
|
|
5437
|
-
case 7 /* TRACE */:
|
|
5438
|
-
result = "TRACE";
|
|
5439
|
-
break;
|
|
5440
|
-
}
|
|
5441
|
-
PostCondition.assertNotEmpty(result, "result");
|
|
5442
|
-
return result;
|
|
4010
|
+
// sources/postConditionError.ts
|
|
4011
|
+
var PostConditionError = class extends Error {
|
|
4012
|
+
constructor(...message) {
|
|
4013
|
+
super(join("\n", message));
|
|
5443
4014
|
}
|
|
5444
4015
|
};
|
|
5445
4016
|
|
|
5446
|
-
// sources/
|
|
5447
|
-
var
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
statusCode;
|
|
5457
|
-
headers;
|
|
5458
|
-
body;
|
|
5459
|
-
constructor() {
|
|
5460
|
-
this.statusCode = 200;
|
|
5461
|
-
this.headers = MutableHttpHeaders.create();
|
|
5462
|
-
this.body = "";
|
|
5463
|
-
}
|
|
5464
|
-
static create() {
|
|
5465
|
-
return new _HttpOutgoingResponse();
|
|
4017
|
+
// sources/postCondition.ts
|
|
4018
|
+
var PostCondition = class _PostCondition {
|
|
4019
|
+
static condition;
|
|
4020
|
+
static getCondition() {
|
|
4021
|
+
if (_PostCondition.condition === void 0) {
|
|
4022
|
+
_PostCondition.condition = MutableCondition.create().setCreateErrorFunction((message) => {
|
|
4023
|
+
return new PostConditionError(message);
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
return _PostCondition.condition;
|
|
5466
4027
|
}
|
|
5467
4028
|
/**
|
|
5468
|
-
*
|
|
4029
|
+
* Assert that the provided value is undefined.
|
|
4030
|
+
* @param value The value to check.
|
|
4031
|
+
* @param expression The name of the expression that produced the value.
|
|
4032
|
+
* @param message An additional message that will be included with the error.
|
|
5469
4033
|
*/
|
|
5470
|
-
|
|
5471
|
-
return
|
|
4034
|
+
static assertUndefined(value, expression, message) {
|
|
4035
|
+
return _PostCondition.getCondition().assertUndefined(value, expression, message);
|
|
5472
4036
|
}
|
|
5473
4037
|
/**
|
|
5474
|
-
*
|
|
5475
|
-
* @param
|
|
4038
|
+
* Assert that the provided value is not undefined and not null.
|
|
4039
|
+
* @param value The value to check.
|
|
4040
|
+
* @param expression The name of the expression that produced the value.
|
|
4041
|
+
* @param message An additional message that will be included with the error.
|
|
5476
4042
|
*/
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
this.statusCode = statusCode;
|
|
5480
|
-
return this;
|
|
4043
|
+
static assertNotUndefined(value, expression, message) {
|
|
4044
|
+
return _PostCondition.getCondition().assertNotUndefined(value, expression, message);
|
|
5481
4045
|
}
|
|
5482
|
-
|
|
5483
|
-
|
|
4046
|
+
/**
|
|
4047
|
+
* Assert that the provided value is not undefined and not null.
|
|
4048
|
+
* @param value The value to check.
|
|
4049
|
+
* @param expression The name of the expression that produced the value.
|
|
4050
|
+
* @param message An additional message that will be included with the error.
|
|
4051
|
+
*/
|
|
4052
|
+
static assertNotUndefinedAndNotNull(value, expression, message) {
|
|
4053
|
+
return _PostCondition.getCondition().assertNotUndefinedAndNotNull(value, expression, message);
|
|
5484
4054
|
}
|
|
5485
4055
|
/**
|
|
5486
|
-
*
|
|
5487
|
-
*
|
|
5488
|
-
* @param
|
|
4056
|
+
* Assert that the provided value is true.
|
|
4057
|
+
* @param value The value to check.
|
|
4058
|
+
* @param expression The name of the expression that produced the value.
|
|
4059
|
+
* @param message An additional message that will be included with the error.
|
|
5489
4060
|
*/
|
|
5490
|
-
|
|
5491
|
-
return
|
|
4061
|
+
static assertTrue(value, expression, message) {
|
|
4062
|
+
return _PostCondition.getCondition().assertTrue(value, expression, message);
|
|
5492
4063
|
}
|
|
5493
4064
|
/**
|
|
5494
|
-
*
|
|
5495
|
-
*
|
|
5496
|
-
* @param
|
|
4065
|
+
* Assert that the provided value is false.
|
|
4066
|
+
* @param value The value to check.
|
|
4067
|
+
* @param expression The name of the expression that produced the value.
|
|
4068
|
+
* @param message An additional message that will be included with the error.
|
|
5497
4069
|
*/
|
|
5498
|
-
|
|
5499
|
-
return
|
|
4070
|
+
static assertFalse(value, expression, message) {
|
|
4071
|
+
return _PostCondition.getCondition().assertFalse(value, expression, message);
|
|
5500
4072
|
}
|
|
5501
4073
|
/**
|
|
5502
|
-
*
|
|
5503
|
-
* @param
|
|
5504
|
-
* @param
|
|
4074
|
+
* Assert that the provided actual value is the same as the provided expected value.
|
|
4075
|
+
* @param expected The expected value.
|
|
4076
|
+
* @param actual The actual value.
|
|
4077
|
+
* @param expression The expression that produced the actual value.
|
|
4078
|
+
* @param message An optional message that describes the scenario.
|
|
5505
4079
|
*/
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
return this;
|
|
4080
|
+
static assertSame(expected, actual, expression, message) {
|
|
4081
|
+
return _PostCondition.getCondition().assertSame(expected, actual, expression, message);
|
|
5509
4082
|
}
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
4083
|
+
/**
|
|
4084
|
+
* Assert that the provided actual value is not the same as the provided expected value.
|
|
4085
|
+
* @param expected The expected value.
|
|
4086
|
+
* @param actual The actual value.
|
|
4087
|
+
* @param expression The expression that produced the actual value.
|
|
4088
|
+
* @param message An optional message that describes the scenario.
|
|
4089
|
+
*/
|
|
4090
|
+
static assertNotSame(expected, actual, expression, message) {
|
|
4091
|
+
return _PostCondition.getCondition().assertNotSame(expected, actual, expression, message);
|
|
5513
4092
|
}
|
|
5514
4093
|
/**
|
|
5515
|
-
*
|
|
4094
|
+
* Assert that the provided actual value is equal to the provided expected value.
|
|
4095
|
+
* @param expected The expected value.
|
|
4096
|
+
* @param actual The actual value.
|
|
4097
|
+
* @param expression The expression that produced the actual value.
|
|
4098
|
+
* @param message An optional message that describes the scenario.
|
|
5516
4099
|
*/
|
|
5517
|
-
|
|
5518
|
-
return
|
|
4100
|
+
static assertEqual(expected, actual, expression, message) {
|
|
4101
|
+
return _PostCondition.getCondition().assertEqual(expected, actual, expression, message);
|
|
5519
4102
|
}
|
|
5520
4103
|
/**
|
|
5521
|
-
*
|
|
5522
|
-
* @param
|
|
4104
|
+
* Assert that the provided actual value is not equal to the provided expected value.
|
|
4105
|
+
* @param notExpected The not expected value.
|
|
4106
|
+
* @param actual The actual value.
|
|
4107
|
+
* @param expression The expression that produced the actual value.
|
|
4108
|
+
* @param message An optional message that describes the scenario.
|
|
5523
4109
|
*/
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
this.body = body;
|
|
5527
|
-
return this;
|
|
4110
|
+
static assertNotEqual(notExpected, actual, expression, message) {
|
|
4111
|
+
return _PostCondition.getCondition().assertNotEqual(notExpected, actual, expression, message);
|
|
5528
4112
|
}
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
super();
|
|
5538
|
-
this.disposed = false;
|
|
4113
|
+
/**
|
|
4114
|
+
* Assert that the provided value is not empty.
|
|
4115
|
+
* @param value The value to check.
|
|
4116
|
+
* @param expression The expression that produced the actual value.
|
|
4117
|
+
* @param message An optional message that describes the scenario.
|
|
4118
|
+
*/
|
|
4119
|
+
static assertNotEmpty(value, expression, message) {
|
|
4120
|
+
return _PostCondition.getCondition().assertNotEmpty(value, expression, message);
|
|
5539
4121
|
}
|
|
5540
|
-
|
|
5541
|
-
|
|
4122
|
+
/**
|
|
4123
|
+
* Assert that the provided value is less than the provided upperBound.
|
|
4124
|
+
* @param value The value to check.
|
|
4125
|
+
* @param upperBound The upperBound that the value must be less than.
|
|
4126
|
+
* @param expression The expression that produced the actual value.
|
|
4127
|
+
* @param message An optional message that describes the scenario.
|
|
4128
|
+
*/
|
|
4129
|
+
static assertLessThan(value, upperBound, expression, message) {
|
|
4130
|
+
return _PostCondition.getCondition().assertLessThan(value, upperBound, expression, message);
|
|
5542
4131
|
}
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
if (error) {
|
|
5553
|
-
reject(error);
|
|
5554
|
-
} else {
|
|
5555
|
-
this.disposed = true;
|
|
5556
|
-
this.httpServer = void 0;
|
|
5557
|
-
resolve(true);
|
|
5558
|
-
}
|
|
5559
|
-
});
|
|
5560
|
-
}
|
|
5561
|
-
}));
|
|
4132
|
+
/**
|
|
4133
|
+
* Assert that the provided value is less than or equal to the provided upperBound.
|
|
4134
|
+
* @param value The value to check.
|
|
4135
|
+
* @param upperBound The upperBound that the value must be less than.
|
|
4136
|
+
* @param expression The expression that produced the actual value.
|
|
4137
|
+
* @param message An optional message that describes the scenario.
|
|
4138
|
+
*/
|
|
4139
|
+
static assertLessThanOrEqualTo(value, upperBound, expression, message) {
|
|
4140
|
+
return _PostCondition.getCondition().assertLessThanOrEqualTo(value, upperBound, expression, message);
|
|
5562
4141
|
}
|
|
5563
|
-
|
|
5564
|
-
|
|
4142
|
+
/**
|
|
4143
|
+
* Assert that the provided value is greater than or equal to the provided lowerBound.
|
|
4144
|
+
* @param value The value to check.
|
|
4145
|
+
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
4146
|
+
* @param expression The expression that produced the actual value.
|
|
4147
|
+
* @param message An optional message that describes the scenario.
|
|
4148
|
+
*/
|
|
4149
|
+
static assertGreaterThanOrEqualTo(value, lowerBound, expression, message) {
|
|
4150
|
+
return _PostCondition.getCondition().assertGreaterThanOrEqualTo(value, lowerBound, expression, message);
|
|
5565
4151
|
}
|
|
5566
|
-
|
|
5567
|
-
|
|
4152
|
+
/**
|
|
4153
|
+
* Assert that the provided value is greater than the provided lowerBound.
|
|
4154
|
+
* @param value The value to check.
|
|
4155
|
+
* @param lowerBound The lowerBound that the value must be greater than.
|
|
4156
|
+
* @param expression The expression that produced the actual value.
|
|
4157
|
+
* @param message An optional message that describes the scenario.
|
|
4158
|
+
*/
|
|
4159
|
+
static assertGreaterThan(value, lowerBound, expression, message) {
|
|
4160
|
+
return _PostCondition.getCondition().assertGreaterThan(value, lowerBound, expression, message);
|
|
5568
4161
|
}
|
|
5569
|
-
|
|
5570
|
-
|
|
4162
|
+
/**
|
|
4163
|
+
* Assert that the value is greater than or equal to the lowerBound and less than or equal to
|
|
4164
|
+
* the upperBound.
|
|
4165
|
+
* @param lowerBound The lowerBound that the value must be greater than or equal to.
|
|
4166
|
+
* @param value The value to check.
|
|
4167
|
+
* @param upperBound The upperBound that the value must be less than or equal to.
|
|
4168
|
+
* @param expression The expression that produced the actual value.
|
|
4169
|
+
* @param message An optional message that describes the scenario.
|
|
4170
|
+
*/
|
|
4171
|
+
static assertBetween(lowerBound, value, upperBound, expression, message) {
|
|
4172
|
+
return _PostCondition.getCondition().assertBetween(lowerBound, value, upperBound, expression, message);
|
|
5571
4173
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
4174
|
+
/**
|
|
4175
|
+
* Assert that the index is within the access bounds of an indexable with the provided count.
|
|
4176
|
+
* @param index The index to check.
|
|
4177
|
+
* @param count The number of elements in the indexable.
|
|
4178
|
+
* @param expression The expression that produced the actual value.
|
|
4179
|
+
* @param message An optional message that describes the scenario.
|
|
4180
|
+
*/
|
|
4181
|
+
static assertAccessIndex(index, count, expression, message) {
|
|
4182
|
+
return _PostCondition.getCondition().assertAccessIndex(index, count, expression, message);
|
|
5574
4183
|
}
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
this.httpServer.on("request", (request, response) => {
|
|
5585
|
-
const httpResponse = HttpOutgoingResponse.create().setStatusCode(200).setHeader("Content-Type", "text/plain").setBody("Hello world!");
|
|
5586
|
-
const statusCode = httpResponse.getStatusCode();
|
|
5587
|
-
const headers = httpResponse.getHeaders();
|
|
5588
|
-
const responseHeaders = {};
|
|
5589
|
-
for (const header of headers) {
|
|
5590
|
-
responseHeaders[header.getName()] = header.getValue();
|
|
5591
|
-
}
|
|
5592
|
-
response.writeHead(statusCode, responseHeaders);
|
|
5593
|
-
response.end(httpResponse.getBody());
|
|
5594
|
-
});
|
|
5595
|
-
this.httpServer.on("close", () => {
|
|
5596
|
-
resolve();
|
|
5597
|
-
});
|
|
5598
|
-
this.httpServer.on("error", (error) => {
|
|
5599
|
-
reject(error);
|
|
5600
|
-
});
|
|
5601
|
-
this.httpServer.listen(portNumber);
|
|
5602
|
-
}
|
|
5603
|
-
}));
|
|
4184
|
+
/**
|
|
4185
|
+
* Assert that the index is within the insertion bounds of a {@link List} with the provided count.
|
|
4186
|
+
* @param index The index to check.
|
|
4187
|
+
* @param count The number of elements in the indexable.
|
|
4188
|
+
* @param expression The expression that produced the actual value.
|
|
4189
|
+
* @param message An optional message that describes the scenario.
|
|
4190
|
+
*/
|
|
4191
|
+
static assertInsertIndex(index, count, expression, message) {
|
|
4192
|
+
return _PostCondition.getCondition().assertInsertIndex(index, count, expression, message);
|
|
5604
4193
|
}
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
4194
|
+
/**
|
|
4195
|
+
* Assert that the value is one of the possibilities.
|
|
4196
|
+
* @param possibilities The possible values that the value can be.
|
|
4197
|
+
* @param value The value to check.
|
|
4198
|
+
* @param expression The expression that produced the value.
|
|
4199
|
+
* @param message An optional error message.
|
|
4200
|
+
*/
|
|
4201
|
+
static assertOneOf(possibilities, value, expression, message) {
|
|
4202
|
+
return _PostCondition.getCondition().assertOneOf(possibilities, value, expression, message);
|
|
5611
4203
|
}
|
|
5612
|
-
|
|
5613
|
-
|
|
4204
|
+
/**
|
|
4205
|
+
* Assert that the value is within the bounds of a byte.
|
|
4206
|
+
* @param value The value to check.
|
|
4207
|
+
* @param expression The expression that produced the value.
|
|
4208
|
+
* @param message An optional error message.
|
|
4209
|
+
*/
|
|
4210
|
+
static assertByte(value, expression, message) {
|
|
4211
|
+
return _PostCondition.getCondition().assertByte(value, expression, message);
|
|
5614
4212
|
}
|
|
5615
|
-
|
|
5616
|
-
|
|
4213
|
+
/**
|
|
4214
|
+
* Assert that the value is an integer.
|
|
4215
|
+
* @param value The value to check.
|
|
4216
|
+
* @param expression The expression that produced the value.
|
|
4217
|
+
* @param message An optional error message.
|
|
4218
|
+
*/
|
|
4219
|
+
static assertInteger(value, expression, message) {
|
|
4220
|
+
return _PostCondition.getCondition().assertInteger(value, expression, message);
|
|
5617
4221
|
}
|
|
5618
|
-
|
|
5619
|
-
|
|
4222
|
+
/**
|
|
4223
|
+
* Assert that the value is a characer (single character string).
|
|
4224
|
+
* @param value The value to check.
|
|
4225
|
+
* @param expression The expression that produced the value.
|
|
4226
|
+
* @param message An optional error message.
|
|
4227
|
+
*/
|
|
4228
|
+
static assertCharacter(value, expression, message) {
|
|
4229
|
+
return _PostCondition.getCondition().assertCharacter(value, expression, message);
|
|
4230
|
+
}
|
|
4231
|
+
assertInstanceOf(parametersOrValue, type, typeCheck, expression, message) {
|
|
4232
|
+
return _PostCondition.getCondition().assertInstanceOf(parametersOrValue, type, typeCheck, expression, message);
|
|
5620
4233
|
}
|
|
5621
4234
|
};
|
|
5622
4235
|
|
|
5623
|
-
// sources/
|
|
5624
|
-
var
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
return new _CurrentProcess();
|
|
4236
|
+
// sources/characterWriteStream.ts
|
|
4237
|
+
var CharacterWriteStream = class _CharacterWriteStream {
|
|
4238
|
+
/**
|
|
4239
|
+
* Write the provided text (if provided) and then write a newline character sequence to this
|
|
4240
|
+
* {@link CharacterWriteStream}.
|
|
4241
|
+
* @param text The optional text to write before the newline character sequence.
|
|
4242
|
+
* @returns The number of characters that were written.
|
|
4243
|
+
*/
|
|
4244
|
+
writeLine(text) {
|
|
4245
|
+
return _CharacterWriteStream.writeLine(this, text);
|
|
5634
4246
|
}
|
|
5635
|
-
static
|
|
5636
|
-
PreCondition.assertNotUndefinedAndNotNull(
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
currentProcess.setExitCode(result);
|
|
5642
|
-
}
|
|
5643
|
-
} catch (error) {
|
|
5644
|
-
currentProcess.setExitCode(-1);
|
|
5645
|
-
const writeStream = currentProcess.getOutputWriteStream();
|
|
5646
|
-
if (error instanceof Error && error.stack) {
|
|
5647
|
-
writeStream.writeLine(error.stack);
|
|
5648
|
-
} else {
|
|
5649
|
-
writeStream.writeLine(`${error}`);
|
|
4247
|
+
static writeLine(writeStream, text) {
|
|
4248
|
+
PreCondition.assertNotUndefinedAndNotNull(writeStream, "writeStream");
|
|
4249
|
+
return PromiseAsyncResult.create(async () => {
|
|
4250
|
+
let result = 0;
|
|
4251
|
+
if (text) {
|
|
4252
|
+
result += await writeStream.writeString(text);
|
|
5650
4253
|
}
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
this.args = process.argv;
|
|
5656
|
-
}
|
|
5657
|
-
return this.args;
|
|
5658
|
-
}
|
|
5659
|
-
setArguments(args) {
|
|
5660
|
-
PreCondition.assertNotUndefinedAndNotNull(args, "args");
|
|
5661
|
-
PreCondition.assertUndefined(this.parameters, "this.parameters");
|
|
5662
|
-
this.args = args;
|
|
5663
|
-
return this;
|
|
5664
|
-
}
|
|
5665
|
-
getParameters() {
|
|
5666
|
-
if (!this.parameters) {
|
|
5667
|
-
this.parameters = CommandLineParameters.create(this.getArguments());
|
|
5668
|
-
}
|
|
5669
|
-
return this.parameters;
|
|
4254
|
+
result += await writeStream.writeString("\n");
|
|
4255
|
+
PostCondition.assertGreaterThan(result, 0, "result");
|
|
4256
|
+
return result;
|
|
4257
|
+
});
|
|
5670
4258
|
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
4259
|
+
};
|
|
4260
|
+
|
|
4261
|
+
// sources/commandLineParameters.ts
|
|
4262
|
+
var CommandLineParameters = class _CommandLineParameters {
|
|
4263
|
+
args;
|
|
4264
|
+
constructor(argv) {
|
|
4265
|
+
this.args = argv;
|
|
5676
4266
|
}
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
this.outputWriteStream = outputWriteStream;
|
|
5680
|
-
return this;
|
|
4267
|
+
static create(args) {
|
|
4268
|
+
return new _CommandLineParameters(args);
|
|
5681
4269
|
}
|
|
5682
|
-
|
|
5683
|
-
|
|
4270
|
+
};
|
|
4271
|
+
|
|
4272
|
+
// sources/nodeJSCharacterWriteStream.ts
|
|
4273
|
+
var NodeJSCharacterWriteStream = class _NodeJSCharacterWriteStream extends CharacterWriteStream {
|
|
4274
|
+
nodeJSWriteStream;
|
|
4275
|
+
constructor(nodeJSWriteStream) {
|
|
4276
|
+
PreCondition.assertNotUndefinedAndNotNull(nodeJSWriteStream, "nodeJSWriteStream");
|
|
4277
|
+
super();
|
|
4278
|
+
this.nodeJSWriteStream = nodeJSWriteStream;
|
|
5684
4279
|
}
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
this.getExitCodeProperty().setValue(exitCode);
|
|
5688
|
-
return this;
|
|
4280
|
+
static create(nodeJSWriteStream) {
|
|
4281
|
+
return new _NodeJSCharacterWriteStream(nodeJSWriteStream);
|
|
5689
4282
|
}
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
4283
|
+
writeString(text) {
|
|
4284
|
+
PreCondition.assertNotUndefinedAndNotNull(text, "text");
|
|
4285
|
+
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
4286
|
+
this.nodeJSWriteStream.write(text, (error) => {
|
|
4287
|
+
if (error) {
|
|
4288
|
+
reject(error);
|
|
4289
|
+
} else {
|
|
4290
|
+
resolve(text.length);
|
|
5696
4291
|
}
|
|
5697
4292
|
});
|
|
5698
|
-
}
|
|
5699
|
-
return this.exitCodeProperty;
|
|
4293
|
+
}));
|
|
5700
4294
|
}
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
4295
|
+
};
|
|
4296
|
+
|
|
4297
|
+
// sources/property.ts
|
|
4298
|
+
var Property = class _Property {
|
|
4299
|
+
getter;
|
|
4300
|
+
setter;
|
|
4301
|
+
constructor(getter, setter) {
|
|
4302
|
+
PreCondition.assertNotUndefinedAndNotNull(getter, "getter");
|
|
4303
|
+
PreCondition.assertNotUndefinedAndNotNull(setter, "setter");
|
|
4304
|
+
this.getter = getter;
|
|
4305
|
+
this.setter = setter;
|
|
5705
4306
|
}
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
4307
|
+
static create(getterOptionsOrInitialValue, setter) {
|
|
4308
|
+
let getter;
|
|
4309
|
+
if (isFunction(getterOptionsOrInitialValue)) {
|
|
4310
|
+
getter = getterOptionsOrInitialValue;
|
|
4311
|
+
} else if (isObject(getterOptionsOrInitialValue) && hasProperty(getterOptionsOrInitialValue, "getter") && hasProperty(getterOptionsOrInitialValue, "setter")) {
|
|
4312
|
+
const options = getterOptionsOrInitialValue;
|
|
4313
|
+
getter = options.getter;
|
|
4314
|
+
setter = options.setter;
|
|
4315
|
+
} else {
|
|
4316
|
+
let initialValue = getterOptionsOrInitialValue;
|
|
4317
|
+
getter = () => {
|
|
4318
|
+
return initialValue;
|
|
4319
|
+
};
|
|
4320
|
+
setter = (value) => {
|
|
4321
|
+
initialValue = value;
|
|
4322
|
+
};
|
|
5709
4323
|
}
|
|
5710
|
-
|
|
4324
|
+
PreCondition.assertNotUndefinedAndNotNull(getter, "getter");
|
|
4325
|
+
PreCondition.assertNotUndefinedAndNotNull(setter, "setter");
|
|
4326
|
+
return new _Property(getter, setter);
|
|
5711
4327
|
}
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
4328
|
+
getValue() {
|
|
4329
|
+
return this.getter();
|
|
4330
|
+
}
|
|
4331
|
+
setValue(value) {
|
|
4332
|
+
this.setter(value);
|
|
5716
4333
|
return this;
|
|
5717
4334
|
}
|
|
4335
|
+
toString() {
|
|
4336
|
+
return `${this.getValue()}`;
|
|
4337
|
+
}
|
|
5718
4338
|
};
|
|
5719
4339
|
|
|
5720
|
-
// sources/
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
return LuxonDateTime.now();
|
|
5730
|
-
}
|
|
5731
|
-
/**
|
|
5732
|
-
* Compare this {@link DateTime} to the provided {@link DateTime}. If this {@link DateTime} is
|
|
5733
|
-
* less than the provided {@link DateTime}, then a negative number will be returned, 0 if
|
|
5734
|
-
* they're equal, or a positive number if this {@link DateTime} is greater than the provided
|
|
5735
|
-
* {@link DateTime}.
|
|
5736
|
-
* @param dateTime The {@link DateTime} to compare to this {@link DateTime}.
|
|
5737
|
-
*/
|
|
5738
|
-
compareTo(dateTime, compareTimes) {
|
|
5739
|
-
return _DateTime.compareTo(this, dateTime, compareTimes);
|
|
5740
|
-
}
|
|
5741
|
-
static compareTo(left, right, compareTimes) {
|
|
5742
|
-
let result = left.getYear() - right.getYear();
|
|
5743
|
-
if (result === 0) {
|
|
5744
|
-
result = left.getMonth() - right.getMonth();
|
|
5745
|
-
if (result === 0) {
|
|
5746
|
-
result = left.getDay() - right.getDay();
|
|
5747
|
-
if (compareTimes && result === 0) {
|
|
5748
|
-
result = left.getHour() - right.getHour();
|
|
5749
|
-
if (result === 0) {
|
|
5750
|
-
result = left.getMinute() - right.getMinute();
|
|
5751
|
-
if (result === 0) {
|
|
5752
|
-
result = left.getSecond();
|
|
5753
|
-
-right.getSecond();
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
}
|
|
5757
|
-
}
|
|
5758
|
-
}
|
|
5759
|
-
return result;
|
|
5760
|
-
}
|
|
5761
|
-
lessThan(dateTime, compareTimes) {
|
|
5762
|
-
return _DateTime.lessThan(this, dateTime, compareTimes);
|
|
4340
|
+
// sources/httpHeader.ts
|
|
4341
|
+
var HttpHeader = class _HttpHeader {
|
|
4342
|
+
name;
|
|
4343
|
+
value;
|
|
4344
|
+
constructor(name, value) {
|
|
4345
|
+
PreCondition.assertNotEmpty(name, "name");
|
|
4346
|
+
PreCondition.assertNotUndefinedAndNotNull(value, "value");
|
|
4347
|
+
this.name = name;
|
|
4348
|
+
this.value = value;
|
|
5763
4349
|
}
|
|
5764
|
-
static
|
|
5765
|
-
return
|
|
4350
|
+
static create(name, value) {
|
|
4351
|
+
return new _HttpHeader(name, value);
|
|
5766
4352
|
}
|
|
5767
|
-
|
|
5768
|
-
return
|
|
4353
|
+
getName() {
|
|
4354
|
+
return this.name;
|
|
5769
4355
|
}
|
|
5770
|
-
|
|
5771
|
-
return
|
|
4356
|
+
getValue() {
|
|
4357
|
+
return this.value;
|
|
5772
4358
|
}
|
|
5773
|
-
|
|
5774
|
-
return
|
|
4359
|
+
toString() {
|
|
4360
|
+
return `${escapeAndQuote(this.name)}:${escapeAndQuote(this.value)}`;
|
|
5775
4361
|
}
|
|
5776
|
-
|
|
5777
|
-
|
|
4362
|
+
};
|
|
4363
|
+
|
|
4364
|
+
// sources/httpHeaders.ts
|
|
4365
|
+
var HttpHeaders = class _HttpHeaders {
|
|
4366
|
+
static contentTypeHeaderName = "Content-Type";
|
|
4367
|
+
static create(headers) {
|
|
4368
|
+
return MutableHttpHeaders.create(headers);
|
|
5778
4369
|
}
|
|
5779
|
-
|
|
5780
|
-
return
|
|
4370
|
+
getContentType() {
|
|
4371
|
+
return _HttpHeaders.getContentType(this);
|
|
5781
4372
|
}
|
|
5782
|
-
static
|
|
5783
|
-
return
|
|
4373
|
+
static getContentType(headers) {
|
|
4374
|
+
return headers.get(_HttpHeaders.contentTypeHeaderName);
|
|
5784
4375
|
}
|
|
5785
|
-
|
|
5786
|
-
return
|
|
4376
|
+
getContentTypeValue() {
|
|
4377
|
+
return _HttpHeaders.getContentTypeValue(this);
|
|
5787
4378
|
}
|
|
5788
|
-
static
|
|
5789
|
-
return
|
|
4379
|
+
static getContentTypeValue(headers) {
|
|
4380
|
+
return headers.getValue(_HttpHeaders.contentTypeHeaderName);
|
|
5790
4381
|
}
|
|
5791
|
-
|
|
5792
|
-
|
|
4382
|
+
/**
|
|
4383
|
+
* Get the {@link HttpHeader}s in this {@link HttpHeaders} object as an array.
|
|
4384
|
+
*/
|
|
4385
|
+
toArray() {
|
|
4386
|
+
return _HttpHeaders.toArray(this);
|
|
5793
4387
|
}
|
|
5794
|
-
static
|
|
5795
|
-
return
|
|
4388
|
+
static toArray(headers) {
|
|
4389
|
+
return Iterable.toArray(headers);
|
|
5796
4390
|
}
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
// sources/luxonDateTime.ts
|
|
5800
|
-
var pctTimeZone = "America/Los_Angeles";
|
|
5801
|
-
var LuxonDateTime = class _LuxonDateTime {
|
|
5802
|
-
dateTime;
|
|
5803
|
-
constructor(dateTime) {
|
|
5804
|
-
this.dateTime = dateTime;
|
|
4391
|
+
any() {
|
|
4392
|
+
return _HttpHeaders.any(this);
|
|
5805
4393
|
}
|
|
5806
|
-
static
|
|
5807
|
-
return
|
|
4394
|
+
static any(headers) {
|
|
4395
|
+
return Iterable.any(headers);
|
|
5808
4396
|
}
|
|
5809
|
-
|
|
5810
|
-
return
|
|
4397
|
+
getCount() {
|
|
4398
|
+
return _HttpHeaders.getCount(this);
|
|
5811
4399
|
}
|
|
5812
|
-
static
|
|
5813
|
-
return
|
|
4400
|
+
static getCount(headers) {
|
|
4401
|
+
return Iterable.getCount(headers);
|
|
5814
4402
|
}
|
|
5815
|
-
|
|
5816
|
-
return this
|
|
4403
|
+
equals(right, equalFunctions) {
|
|
4404
|
+
return _HttpHeaders.equals(this, right, equalFunctions);
|
|
5817
4405
|
}
|
|
5818
|
-
|
|
5819
|
-
return
|
|
4406
|
+
static equals(headers, right, equalFunctions) {
|
|
4407
|
+
return Iterable.equals(headers, right, equalFunctions);
|
|
5820
4408
|
}
|
|
5821
|
-
|
|
5822
|
-
return this
|
|
4409
|
+
toString(toStringFunctions) {
|
|
4410
|
+
return _HttpHeaders.toString(this, toStringFunctions);
|
|
5823
4411
|
}
|
|
5824
|
-
|
|
5825
|
-
return
|
|
4412
|
+
static toString(headers, toStringFunctions) {
|
|
4413
|
+
return Iterable.toString(headers, toStringFunctions);
|
|
5826
4414
|
}
|
|
5827
|
-
|
|
5828
|
-
return this
|
|
4415
|
+
concatenate(...toConcatenate) {
|
|
4416
|
+
return _HttpHeaders.concatenate(this, ...toConcatenate);
|
|
5829
4417
|
}
|
|
5830
|
-
|
|
5831
|
-
return
|
|
4418
|
+
static concatenate(headers, ...toConcatenate) {
|
|
4419
|
+
return Iterable.concatenate(headers, ...toConcatenate);
|
|
5832
4420
|
}
|
|
5833
|
-
|
|
5834
|
-
return
|
|
4421
|
+
map(mapping) {
|
|
4422
|
+
return _HttpHeaders.map(this, mapping);
|
|
5835
4423
|
}
|
|
5836
|
-
|
|
5837
|
-
return
|
|
4424
|
+
static map(headers, mapping) {
|
|
4425
|
+
return Iterable.map(headers, mapping);
|
|
5838
4426
|
}
|
|
5839
|
-
|
|
5840
|
-
return
|
|
4427
|
+
flatMap(mapping) {
|
|
4428
|
+
return _HttpHeaders.flatMap(this, mapping);
|
|
5841
4429
|
}
|
|
5842
|
-
|
|
5843
|
-
return
|
|
4430
|
+
static flatMap(headers, mapping) {
|
|
4431
|
+
return Iterable.flatMap(headers, mapping);
|
|
5844
4432
|
}
|
|
5845
|
-
|
|
5846
|
-
return
|
|
4433
|
+
where(condition) {
|
|
4434
|
+
return _HttpHeaders.where(this, condition);
|
|
5847
4435
|
}
|
|
5848
|
-
|
|
5849
|
-
return
|
|
4436
|
+
static where(headers, condition) {
|
|
4437
|
+
return Iterable.where(headers, condition);
|
|
5850
4438
|
}
|
|
5851
|
-
|
|
5852
|
-
return
|
|
4439
|
+
instanceOf(typeOrTypeCheck) {
|
|
4440
|
+
return _HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
5853
4441
|
}
|
|
5854
|
-
|
|
5855
|
-
return
|
|
4442
|
+
static instanceOf(headers, typeOrTypeCheck) {
|
|
4443
|
+
return Iterable.instanceOf(headers, typeOrTypeCheck);
|
|
5856
4444
|
}
|
|
5857
|
-
|
|
5858
|
-
return
|
|
4445
|
+
first(condition) {
|
|
4446
|
+
return _HttpHeaders.first(this, condition);
|
|
5859
4447
|
}
|
|
5860
|
-
|
|
5861
|
-
return
|
|
4448
|
+
static first(headers, condition) {
|
|
4449
|
+
return Iterable.first(headers, condition);
|
|
5862
4450
|
}
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
// sources/listStack.ts
|
|
5866
|
-
var ListStack = class _ListStack {
|
|
5867
|
-
list;
|
|
5868
|
-
constructor(list2) {
|
|
5869
|
-
this.list = list2 ?? List.create();
|
|
4451
|
+
last(condition) {
|
|
4452
|
+
return _HttpHeaders.last(this, condition);
|
|
5870
4453
|
}
|
|
5871
|
-
static
|
|
5872
|
-
return
|
|
4454
|
+
static last(headers, condition) {
|
|
4455
|
+
return Iterable.last(headers, condition);
|
|
5873
4456
|
}
|
|
5874
|
-
|
|
5875
|
-
return
|
|
4457
|
+
[Symbol.iterator]() {
|
|
4458
|
+
return _HttpHeaders[Symbol.iterator](this);
|
|
5876
4459
|
}
|
|
5877
|
-
|
|
5878
|
-
return
|
|
5879
|
-
this.list.add(value);
|
|
5880
|
-
});
|
|
4460
|
+
static [Symbol.iterator](headers) {
|
|
4461
|
+
return Iterable[Symbol.iterator](headers);
|
|
5881
4462
|
}
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
return SyncResult.create(() => {
|
|
5885
|
-
this.list.addAll(values);
|
|
5886
|
-
});
|
|
4463
|
+
contains(value, equalFunctions) {
|
|
4464
|
+
return _HttpHeaders.contains(this, value, equalFunctions);
|
|
5887
4465
|
}
|
|
5888
|
-
|
|
4466
|
+
static contains(headers, value, equalFunctions) {
|
|
5889
4467
|
return SyncResult.create(() => {
|
|
5890
|
-
if (!
|
|
5891
|
-
|
|
4468
|
+
if (!equalFunctions) {
|
|
4469
|
+
equalFunctions = EqualFunctions.create();
|
|
5892
4470
|
}
|
|
5893
|
-
return
|
|
4471
|
+
return headers.getValue(value.getName()).then((headerValue) => equalFunctions.areEqual(headerValue, value.getValue()).await()).catch(NotFoundError, () => false).await();
|
|
5894
4472
|
});
|
|
5895
4473
|
}
|
|
5896
|
-
contains(value, equalFunctions) {
|
|
5897
|
-
return this.list.contains(value, equalFunctions);
|
|
5898
|
-
}
|
|
5899
|
-
};
|
|
5900
|
-
|
|
5901
|
-
// sources/stack.ts
|
|
5902
|
-
var Stack = class {
|
|
5903
|
-
/**
|
|
5904
|
-
* Create an instance of the default {@link Stack} implementation.
|
|
5905
|
-
* @returns A new {@link Stack} object.
|
|
5906
|
-
*/
|
|
5907
|
-
static create() {
|
|
5908
|
-
return ListStack.create();
|
|
5909
|
-
}
|
|
5910
4474
|
};
|
|
5911
4475
|
|
|
5912
|
-
// sources/
|
|
5913
|
-
var
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
results;
|
|
5920
|
-
started;
|
|
5921
|
-
done;
|
|
5922
|
-
constructor(initialToVisit, searchAction) {
|
|
5923
|
-
PreCondition.assertNotEmpty(initialToVisit, "initialToVisit");
|
|
5924
|
-
PreCondition.assertNotUndefinedAndNotNull(searchAction, "searchAction");
|
|
5925
|
-
this.searchAction = searchAction;
|
|
5926
|
-
this.toVisit = Stack.create();
|
|
5927
|
-
this.toVisit.addAll(initialToVisit).await();
|
|
5928
|
-
this.visited = Set2.create();
|
|
5929
|
-
this.results = List.create();
|
|
5930
|
-
this.started = false;
|
|
5931
|
-
this.done = false;
|
|
5932
|
-
}
|
|
5933
|
-
static create(initialToVisit, searchAction) {
|
|
5934
|
-
return new _DepthFirstSearch(initialToVisit, searchAction);
|
|
5935
|
-
}
|
|
5936
|
-
addToVisit(toVisit) {
|
|
5937
|
-
if (!this.hasVisited(toVisit)) {
|
|
5938
|
-
this.toVisit.add(toVisit);
|
|
5939
|
-
}
|
|
5940
|
-
}
|
|
5941
|
-
addAllToVisit(values) {
|
|
5942
|
-
for (const value of values) {
|
|
5943
|
-
this.addToVisit(value);
|
|
4476
|
+
// sources/mutableHttpHeaders.ts
|
|
4477
|
+
var MutableHttpHeaders = class _MutableHttpHeaders {
|
|
4478
|
+
headers;
|
|
4479
|
+
constructor(headers) {
|
|
4480
|
+
this.headers = List.create();
|
|
4481
|
+
if (headers) {
|
|
4482
|
+
this.setAll(headers);
|
|
5944
4483
|
}
|
|
5945
4484
|
}
|
|
5946
|
-
|
|
5947
|
-
return
|
|
5948
|
-
}
|
|
5949
|
-
addResult(result) {
|
|
5950
|
-
this.results.add(result);
|
|
5951
|
-
}
|
|
5952
|
-
addResults(results) {
|
|
5953
|
-
this.results.addAll(results);
|
|
4485
|
+
static create(headers) {
|
|
4486
|
+
return new _MutableHttpHeaders(headers);
|
|
5954
4487
|
}
|
|
5955
|
-
|
|
5956
|
-
|
|
4488
|
+
iterate() {
|
|
4489
|
+
return this.headers.iterate();
|
|
5957
4490
|
}
|
|
5958
|
-
|
|
4491
|
+
get(headerName) {
|
|
4492
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
5959
4493
|
return SyncResult.create(() => {
|
|
5960
|
-
let result
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
}
|
|
5967
|
-
while (!this.hasCurrent() && this.toVisit.any().await()) {
|
|
5968
|
-
const current = this.toVisit.remove().await();
|
|
5969
|
-
this.visited.add(current);
|
|
5970
|
-
this.searchAction(this, current);
|
|
4494
|
+
let result;
|
|
4495
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
4496
|
+
for (const header of this.headers) {
|
|
4497
|
+
if (header.getName().toLowerCase() === lowerHeaderName) {
|
|
4498
|
+
result = header;
|
|
4499
|
+
break;
|
|
5971
4500
|
}
|
|
5972
|
-
|
|
5973
|
-
|
|
4501
|
+
}
|
|
4502
|
+
if (result === void 0) {
|
|
4503
|
+
throw new NotFoundError(`No HttpHeader found with the name ${escapeAndQuote(headerName)}.`);
|
|
5974
4504
|
}
|
|
5975
4505
|
return result;
|
|
5976
4506
|
});
|
|
5977
4507
|
}
|
|
5978
|
-
|
|
5979
|
-
return this.
|
|
4508
|
+
getValue(headerName) {
|
|
4509
|
+
return this.get(headerName).then((header) => header.getValue());
|
|
5980
4510
|
}
|
|
5981
|
-
|
|
5982
|
-
|
|
4511
|
+
set(headerOrHeaderName, headerValue) {
|
|
4512
|
+
let headerName;
|
|
4513
|
+
if (isString(headerOrHeaderName)) {
|
|
4514
|
+
headerName = headerOrHeaderName;
|
|
4515
|
+
} else {
|
|
4516
|
+
headerName = headerOrHeaderName.getName();
|
|
4517
|
+
headerValue = headerOrHeaderName.getValue();
|
|
4518
|
+
}
|
|
4519
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4520
|
+
PreCondition.assertNotUndefinedAndNotNull(headerValue, "headerValue");
|
|
4521
|
+
let insertIndex = 0;
|
|
4522
|
+
for (let insertIndex2 = 0; insertIndex2 < this.headers.getCount().await(); insertIndex2++) {
|
|
4523
|
+
const header = this.headers.get(insertIndex2).await();
|
|
4524
|
+
if (header.getName() === headerName) {
|
|
4525
|
+
this.headers.removeAt(insertIndex2);
|
|
4526
|
+
break;
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
this.headers.insert(insertIndex, HttpHeader.create(headerName, headerValue));
|
|
4530
|
+
return this;
|
|
5983
4531
|
}
|
|
5984
|
-
|
|
5985
|
-
PreCondition.
|
|
5986
|
-
|
|
4532
|
+
setAll(headers) {
|
|
4533
|
+
PreCondition.assertNotUndefinedAndNotNull(headers, "headers");
|
|
4534
|
+
for (const header of headers) {
|
|
4535
|
+
this.set(header);
|
|
4536
|
+
}
|
|
4537
|
+
return this;
|
|
5987
4538
|
}
|
|
5988
|
-
|
|
5989
|
-
return
|
|
4539
|
+
setContentType(contentType) {
|
|
4540
|
+
return this.set(HttpHeaders.contentTypeHeaderName, contentType);
|
|
5990
4541
|
}
|
|
5991
|
-
|
|
5992
|
-
return
|
|
4542
|
+
getContentType() {
|
|
4543
|
+
return this.get(HttpHeaders.contentTypeHeaderName);
|
|
5993
4544
|
}
|
|
5994
|
-
|
|
5995
|
-
return
|
|
4545
|
+
getContentTypeValue() {
|
|
4546
|
+
return this.getValue(HttpHeaders.contentTypeHeaderName);
|
|
5996
4547
|
}
|
|
5997
4548
|
getCount() {
|
|
5998
|
-
return
|
|
4549
|
+
return this.headers.getCount();
|
|
5999
4550
|
}
|
|
6000
4551
|
toArray() {
|
|
6001
|
-
return
|
|
6002
|
-
}
|
|
6003
|
-
concatenate(...toConcatenate) {
|
|
6004
|
-
return Iterator.concatenate(this, ...toConcatenate);
|
|
6005
|
-
}
|
|
6006
|
-
where(condition) {
|
|
6007
|
-
return Iterator.where(this, condition);
|
|
6008
|
-
}
|
|
6009
|
-
map(mapping) {
|
|
6010
|
-
return Iterator.map(this, mapping);
|
|
6011
|
-
}
|
|
6012
|
-
flatMap(mapping) {
|
|
6013
|
-
return Iterator.flatMap(this, mapping);
|
|
6014
|
-
}
|
|
6015
|
-
whereInstanceOf(typeCheck) {
|
|
6016
|
-
return Iterator.whereInstanceOf(this, typeCheck);
|
|
6017
|
-
}
|
|
6018
|
-
whereInstanceOfType(type) {
|
|
6019
|
-
return Iterator.whereInstanceOfType(this, type);
|
|
6020
|
-
}
|
|
6021
|
-
first(condition) {
|
|
6022
|
-
return Iterator.first(this, condition);
|
|
6023
|
-
}
|
|
6024
|
-
last(condition) {
|
|
6025
|
-
return Iterator.last(this, condition);
|
|
6026
|
-
}
|
|
6027
|
-
take(maximumToTake) {
|
|
6028
|
-
return Iterator.take(this, maximumToTake);
|
|
6029
|
-
}
|
|
6030
|
-
skip(maximumToSkip) {
|
|
6031
|
-
return Iterator.skip(this, maximumToSkip);
|
|
6032
|
-
}
|
|
6033
|
-
[Symbol.iterator]() {
|
|
6034
|
-
return Iterator[Symbol.iterator](this);
|
|
4552
|
+
return HttpHeaders.toArray(this);
|
|
6035
4553
|
}
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
let initialToVisit;
|
|
6039
|
-
if (isJavascriptIterable(parametersOrInitialToVisit)) {
|
|
6040
|
-
initialToVisit = parametersOrInitialToVisit;
|
|
6041
|
-
searchAction = searchAction;
|
|
6042
|
-
} else {
|
|
6043
|
-
PreCondition.assertNotUndefinedAndNotNull(parametersOrInitialToVisit, "parameters");
|
|
6044
|
-
initialToVisit = parametersOrInitialToVisit.initialToVisit;
|
|
6045
|
-
searchAction = parametersOrInitialToVisit.searchAction;
|
|
4554
|
+
any() {
|
|
4555
|
+
return HttpHeaders.any(this);
|
|
6046
4556
|
}
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
return DepthFirstSearch.create(initialToVisit, searchAction);
|
|
6050
|
-
}
|
|
6051
|
-
|
|
6052
|
-
// sources/disposable.ts
|
|
6053
|
-
var Disposable = class {
|
|
6054
|
-
/**
|
|
6055
|
-
* Create a new {@link Disposable} that will invoke the provided {@link Function} when it is
|
|
6056
|
-
* disposed.
|
|
6057
|
-
* @param disposedFunction The function to invoke when the returned {@link Disposable} is
|
|
6058
|
-
* disposed.
|
|
6059
|
-
*/
|
|
6060
|
-
static create(disposedFunction) {
|
|
6061
|
-
return SyncDisposable.create(disposedFunction);
|
|
4557
|
+
equals(right, equalFunctions) {
|
|
4558
|
+
return HttpHeaders.equals(this, right, equalFunctions);
|
|
6062
4559
|
}
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
// sources/english.ts
|
|
6066
|
-
function andList(values) {
|
|
6067
|
-
return list("and", values);
|
|
6068
|
-
}
|
|
6069
|
-
function orList(values) {
|
|
6070
|
-
return list("or", values);
|
|
6071
|
-
}
|
|
6072
|
-
function list(conjunction, values) {
|
|
6073
|
-
PreCondition.assertNotEmpty(conjunction, "conjunction");
|
|
6074
|
-
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
6075
|
-
let result = "";
|
|
6076
|
-
let index = 0;
|
|
6077
|
-
const iterator = Iterator.create(values).start().await();
|
|
6078
|
-
while (iterator.hasCurrent()) {
|
|
6079
|
-
const currentValue = iterator.takeCurrent().await();
|
|
6080
|
-
if (index >= 1) {
|
|
6081
|
-
if (iterator.hasCurrent()) {
|
|
6082
|
-
result += `, `;
|
|
6083
|
-
} else {
|
|
6084
|
-
if (index >= 2) {
|
|
6085
|
-
result += `,`;
|
|
6086
|
-
}
|
|
6087
|
-
result += ` ${conjunction} `;
|
|
6088
|
-
}
|
|
6089
|
-
}
|
|
6090
|
-
result += currentValue;
|
|
6091
|
-
index++;
|
|
4560
|
+
toString(toStringFunctions) {
|
|
4561
|
+
return HttpHeaders.toString(this, toStringFunctions);
|
|
6092
4562
|
}
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
// sources/generator.ts
|
|
6097
|
-
var InnerGeneratorControl = class _InnerGeneratorControl {
|
|
6098
|
-
returnValues;
|
|
6099
|
-
done;
|
|
6100
|
-
constructor() {
|
|
6101
|
-
this.returnValues = List.create();
|
|
6102
|
-
this.done = false;
|
|
4563
|
+
concatenate(...toConcatenate) {
|
|
4564
|
+
return HttpHeaders.concatenate(this, ...toConcatenate);
|
|
6103
4565
|
}
|
|
6104
|
-
|
|
6105
|
-
return
|
|
4566
|
+
map(mapping) {
|
|
4567
|
+
return HttpHeaders.map(this, mapping);
|
|
6106
4568
|
}
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
this.returnValues.add(returnValue);
|
|
4569
|
+
flatMap(mapping) {
|
|
4570
|
+
return HttpHeaders.flatMap(this, mapping);
|
|
6110
4571
|
}
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
this.returnValues.addAll(returnValues);
|
|
4572
|
+
where(condition) {
|
|
4573
|
+
return HttpHeaders.where(this, condition);
|
|
6114
4574
|
}
|
|
6115
|
-
|
|
6116
|
-
return
|
|
4575
|
+
instanceOf(typeOrTypeCheck) {
|
|
4576
|
+
return HttpHeaders.instanceOf(this, typeOrTypeCheck);
|
|
6117
4577
|
}
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
6121
|
-
return this.returnValues.first().await();
|
|
4578
|
+
first(condition) {
|
|
4579
|
+
return HttpHeaders.first(this, condition);
|
|
6122
4580
|
}
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
6126
|
-
this.returnValues.removeFirst().await();
|
|
4581
|
+
last(condition) {
|
|
4582
|
+
return HttpHeaders.last(this, condition);
|
|
6127
4583
|
}
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
PreCondition.assertFalse(this.isDone(), "this.isDone()");
|
|
6131
|
-
this.done = true;
|
|
4584
|
+
[Symbol.iterator]() {
|
|
4585
|
+
return HttpHeaders[Symbol.iterator](this);
|
|
6132
4586
|
}
|
|
6133
|
-
|
|
6134
|
-
return this
|
|
4587
|
+
contains(value, equalFunctions) {
|
|
4588
|
+
return HttpHeaders.contains(this, value, equalFunctions);
|
|
6135
4589
|
}
|
|
6136
4590
|
};
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
4591
|
+
|
|
4592
|
+
// sources/httpIncomingResponse.ts
|
|
4593
|
+
var HttpIncomingResponse = class {
|
|
4594
|
+
};
|
|
4595
|
+
|
|
4596
|
+
// sources/fetchHttpResponse.ts
|
|
4597
|
+
var FetchHttpIncomingResponse = class _FetchHttpIncomingResponse extends HttpIncomingResponse {
|
|
4598
|
+
response;
|
|
4599
|
+
constructor(response) {
|
|
4600
|
+
PreCondition.assertNotUndefinedAndNotNull(response, "response");
|
|
4601
|
+
super();
|
|
4602
|
+
this.response = response;
|
|
4603
|
+
}
|
|
4604
|
+
static create(response) {
|
|
4605
|
+
return new _FetchHttpIncomingResponse(response);
|
|
6146
4606
|
}
|
|
6147
|
-
|
|
6148
|
-
return
|
|
4607
|
+
getStatusCode() {
|
|
4608
|
+
return this.response.status;
|
|
6149
4609
|
}
|
|
6150
|
-
|
|
4610
|
+
getHeaders() {
|
|
6151
4611
|
return SyncResult.create(() => {
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
} else {
|
|
6156
|
-
this.control.removeCurrent();
|
|
6157
|
-
}
|
|
6158
|
-
if (!this.control.hasCurrent()) {
|
|
6159
|
-
const actionResult = this.generatorAction(this.control);
|
|
6160
|
-
if (actionResult !== void 0) {
|
|
6161
|
-
this.control.addValue(actionResult);
|
|
6162
|
-
}
|
|
6163
|
-
if (!this.control.hasCurrent()) {
|
|
6164
|
-
this.control.setDone();
|
|
6165
|
-
}
|
|
6166
|
-
}
|
|
4612
|
+
const result = HttpHeaders.create();
|
|
4613
|
+
for (const header of this.response.headers) {
|
|
4614
|
+
result.set(header[0], header[1]);
|
|
6167
4615
|
}
|
|
6168
|
-
return
|
|
4616
|
+
return result;
|
|
6169
4617
|
});
|
|
6170
4618
|
}
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
4619
|
+
getHeader(headerName) {
|
|
4620
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4621
|
+
return SyncResult.create(() => {
|
|
4622
|
+
let result;
|
|
4623
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
4624
|
+
for (const header of this.response.headers) {
|
|
4625
|
+
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
4626
|
+
result = HttpHeader.create(header[0], header[1]);
|
|
4627
|
+
break;
|
|
4628
|
+
}
|
|
4629
|
+
}
|
|
4630
|
+
if (result === void 0) {
|
|
4631
|
+
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
4632
|
+
}
|
|
4633
|
+
return result;
|
|
4634
|
+
});
|
|
6183
4635
|
}
|
|
6184
|
-
|
|
6185
|
-
|
|
4636
|
+
getHeaderValue(headerName) {
|
|
4637
|
+
PreCondition.assertNotEmpty(headerName, "headerName");
|
|
4638
|
+
return SyncResult.create(() => {
|
|
4639
|
+
let result;
|
|
4640
|
+
const lowerHeaderName = headerName.toLowerCase();
|
|
4641
|
+
for (const header of this.response.headers) {
|
|
4642
|
+
if (lowerHeaderName === header[0].toLowerCase()) {
|
|
4643
|
+
result = header[1];
|
|
4644
|
+
break;
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
if (result === void 0) {
|
|
4648
|
+
throw new NotFoundError(`Could not find a header with the name ${escapeAndQuote(headerName)}.`);
|
|
4649
|
+
}
|
|
4650
|
+
return result;
|
|
4651
|
+
});
|
|
6186
4652
|
}
|
|
6187
|
-
|
|
6188
|
-
return
|
|
4653
|
+
getBody() {
|
|
4654
|
+
return PromiseAsyncResult.create(this.response.text());
|
|
6189
4655
|
}
|
|
6190
|
-
|
|
6191
|
-
|
|
4656
|
+
};
|
|
4657
|
+
|
|
4658
|
+
// sources/httpMethod.ts
|
|
4659
|
+
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
4660
|
+
HttpMethod2[HttpMethod2["GET"] = 0] = "GET";
|
|
4661
|
+
HttpMethod2[HttpMethod2["HEAD"] = 1] = "HEAD";
|
|
4662
|
+
HttpMethod2[HttpMethod2["POST"] = 2] = "POST";
|
|
4663
|
+
HttpMethod2[HttpMethod2["PUT"] = 3] = "PUT";
|
|
4664
|
+
HttpMethod2[HttpMethod2["DELETE"] = 4] = "DELETE";
|
|
4665
|
+
HttpMethod2[HttpMethod2["CONNECT"] = 5] = "CONNECT";
|
|
4666
|
+
HttpMethod2[HttpMethod2["OPTIONS"] = 6] = "OPTIONS";
|
|
4667
|
+
HttpMethod2[HttpMethod2["TRACE"] = 7] = "TRACE";
|
|
4668
|
+
HttpMethod2[HttpMethod2["PATCH"] = 8] = "PATCH";
|
|
4669
|
+
return HttpMethod2;
|
|
4670
|
+
})(HttpMethod || {});
|
|
4671
|
+
function parseHttpMethod(text) {
|
|
4672
|
+
return SyncResult.create(() => {
|
|
4673
|
+
let result;
|
|
4674
|
+
switch (text.toUpperCase()) {
|
|
4675
|
+
case "GET":
|
|
4676
|
+
result = 0 /* GET */;
|
|
4677
|
+
break;
|
|
4678
|
+
case "HEAD":
|
|
4679
|
+
result = 1 /* HEAD */;
|
|
4680
|
+
break;
|
|
4681
|
+
case "POST":
|
|
4682
|
+
result = 2 /* POST */;
|
|
4683
|
+
break;
|
|
4684
|
+
case "PUT":
|
|
4685
|
+
result = 3 /* PUT */;
|
|
4686
|
+
break;
|
|
4687
|
+
case "DELETE":
|
|
4688
|
+
result = 4 /* DELETE */;
|
|
4689
|
+
break;
|
|
4690
|
+
case "CONNECT":
|
|
4691
|
+
result = 5 /* CONNECT */;
|
|
4692
|
+
break;
|
|
4693
|
+
case "OPTIONS":
|
|
4694
|
+
result = 6 /* OPTIONS */;
|
|
4695
|
+
break;
|
|
4696
|
+
case "TRACE":
|
|
4697
|
+
result = 7 /* TRACE */;
|
|
4698
|
+
break;
|
|
4699
|
+
case "PATCH":
|
|
4700
|
+
result = 8 /* PATCH */;
|
|
4701
|
+
break;
|
|
4702
|
+
default:
|
|
4703
|
+
throw new NotFoundError(`No HttpMethod exists for the text "${text}".`);
|
|
4704
|
+
}
|
|
4705
|
+
return result;
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
function httpMethodToString(httpMethod) {
|
|
4709
|
+
PreCondition.assertNotUndefinedAndNotNull(httpMethod, "httpMethod");
|
|
4710
|
+
let result;
|
|
4711
|
+
switch (httpMethod) {
|
|
4712
|
+
case 0 /* GET */:
|
|
4713
|
+
result = "GET";
|
|
4714
|
+
break;
|
|
4715
|
+
case 1 /* HEAD */:
|
|
4716
|
+
result = "HEAD";
|
|
4717
|
+
break;
|
|
4718
|
+
case 2 /* POST */:
|
|
4719
|
+
result = "POST";
|
|
4720
|
+
break;
|
|
4721
|
+
case 3 /* PUT */:
|
|
4722
|
+
result = "PUT";
|
|
4723
|
+
break;
|
|
4724
|
+
case 4 /* DELETE */:
|
|
4725
|
+
result = "DELETE";
|
|
4726
|
+
break;
|
|
4727
|
+
case 5 /* CONNECT */:
|
|
4728
|
+
result = "CONNECT";
|
|
4729
|
+
break;
|
|
4730
|
+
case 6 /* OPTIONS */:
|
|
4731
|
+
result = "OPTIONS";
|
|
4732
|
+
break;
|
|
4733
|
+
case 7 /* TRACE */:
|
|
4734
|
+
result = "TRACE";
|
|
4735
|
+
break;
|
|
4736
|
+
case 8 /* PATCH */:
|
|
4737
|
+
result = "PATCH";
|
|
4738
|
+
break;
|
|
4739
|
+
default:
|
|
4740
|
+
throw new NotFoundError(`Unrecognized HttpMethod: ${httpMethod}`);
|
|
6192
4741
|
}
|
|
6193
|
-
|
|
6194
|
-
|
|
4742
|
+
return result;
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4745
|
+
// sources/httpOutgoingRequest.ts
|
|
4746
|
+
var HttpOutgoingRequest = class _HttpOutgoingRequest {
|
|
4747
|
+
method;
|
|
4748
|
+
url;
|
|
4749
|
+
headers;
|
|
4750
|
+
body;
|
|
4751
|
+
constructor(method, url) {
|
|
4752
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
4753
|
+
PreCondition.assertNotEmpty(url, "url");
|
|
4754
|
+
this.method = method;
|
|
4755
|
+
this.url = url;
|
|
4756
|
+
this.headers = HttpHeaders.create();
|
|
4757
|
+
this.body = "";
|
|
6195
4758
|
}
|
|
6196
|
-
|
|
6197
|
-
return
|
|
4759
|
+
static create(method, url) {
|
|
4760
|
+
return new _HttpOutgoingRequest(method, url);
|
|
6198
4761
|
}
|
|
6199
|
-
|
|
6200
|
-
|
|
4762
|
+
/**
|
|
4763
|
+
* Create a new {@link HttpOutgoingRequest} with a GET {@link HttpMethod}.
|
|
4764
|
+
* @param url The target URL for the {@link HttpOutgoingRequest}.
|
|
4765
|
+
*/
|
|
4766
|
+
static get(url) {
|
|
4767
|
+
return _HttpOutgoingRequest.create(0 /* GET */, url);
|
|
6201
4768
|
}
|
|
6202
|
-
|
|
6203
|
-
|
|
4769
|
+
/**
|
|
4770
|
+
* Get the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
4771
|
+
*/
|
|
4772
|
+
getMethod() {
|
|
4773
|
+
return this.method;
|
|
6204
4774
|
}
|
|
6205
|
-
|
|
6206
|
-
|
|
4775
|
+
/**
|
|
4776
|
+
* Set the {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
4777
|
+
* @param method The {@link HttpMethod} for this {@link HttpOutgoingRequest}.
|
|
4778
|
+
*/
|
|
4779
|
+
setMethod(method) {
|
|
4780
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
4781
|
+
this.method = method;
|
|
4782
|
+
return this;
|
|
6207
4783
|
}
|
|
6208
|
-
|
|
6209
|
-
|
|
4784
|
+
/**
|
|
4785
|
+
* Get this {@link HttpOutgoingRequest}'s target URL.
|
|
4786
|
+
*/
|
|
4787
|
+
getURL() {
|
|
4788
|
+
return this.url;
|
|
6210
4789
|
}
|
|
6211
|
-
|
|
6212
|
-
|
|
4790
|
+
/**
|
|
4791
|
+
* Set the URL that this request will be sent to.
|
|
4792
|
+
* @param url The URL to send this request to.
|
|
4793
|
+
*/
|
|
4794
|
+
setURL(url) {
|
|
4795
|
+
PreCondition.assertNotEmpty(url, "url");
|
|
4796
|
+
this.url = url;
|
|
4797
|
+
return this;
|
|
6213
4798
|
}
|
|
6214
|
-
|
|
6215
|
-
|
|
4799
|
+
/**
|
|
4800
|
+
* Get the {@link HttpHeaders} that will be sent.
|
|
4801
|
+
*/
|
|
4802
|
+
getHeaders() {
|
|
4803
|
+
return this.headers;
|
|
6216
4804
|
}
|
|
6217
|
-
|
|
6218
|
-
return
|
|
4805
|
+
getHeader(headerName) {
|
|
4806
|
+
return this.headers.get(headerName);
|
|
6219
4807
|
}
|
|
6220
|
-
|
|
6221
|
-
return
|
|
4808
|
+
getHeaderValue(headerName) {
|
|
4809
|
+
return this.headers.getValue(headerName);
|
|
6222
4810
|
}
|
|
6223
|
-
|
|
6224
|
-
|
|
4811
|
+
/**
|
|
4812
|
+
* Get the body that will be sent.
|
|
4813
|
+
*/
|
|
4814
|
+
getBody() {
|
|
4815
|
+
return this.body;
|
|
6225
4816
|
}
|
|
6226
|
-
|
|
6227
|
-
|
|
4817
|
+
setBody(body) {
|
|
4818
|
+
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
4819
|
+
this.body = body;
|
|
4820
|
+
return this;
|
|
6228
4821
|
}
|
|
6229
4822
|
};
|
|
6230
4823
|
|
|
6231
|
-
// sources/
|
|
6232
|
-
var
|
|
4824
|
+
// sources/fetchHttpClient.ts
|
|
4825
|
+
var FetchHttpClient = class _FetchHttpClient {
|
|
4826
|
+
constructor() {
|
|
4827
|
+
}
|
|
6233
4828
|
static create() {
|
|
6234
|
-
return
|
|
4829
|
+
return new _FetchHttpClient();
|
|
4830
|
+
}
|
|
4831
|
+
sendRequest(request) {
|
|
4832
|
+
PreCondition.assertNotUndefinedAndNotNull(request, "request");
|
|
4833
|
+
return PromiseAsyncResult.create(async () => {
|
|
4834
|
+
const requestInit = {
|
|
4835
|
+
method: _FetchHttpClient.convertMethod(request.getMethod()),
|
|
4836
|
+
headers: request.getHeaders().map((header) => [header.getName(), header.getValue()]).toArray().await(),
|
|
4837
|
+
body: request.getBody() || void 0
|
|
4838
|
+
};
|
|
4839
|
+
const fetchResponse = await fetch(request.getURL(), requestInit);
|
|
4840
|
+
return FetchHttpIncomingResponse.create(fetchResponse);
|
|
4841
|
+
});
|
|
6235
4842
|
}
|
|
6236
|
-
/**
|
|
6237
|
-
* Send a GET {@link HttpOutgoingRequest} to the provided URL.
|
|
6238
|
-
* @param url The URL to send the GET {@link HttpOutgoingRequest} to.
|
|
6239
|
-
*/
|
|
6240
4843
|
sendGetRequest(url) {
|
|
6241
|
-
return
|
|
4844
|
+
return this.sendRequest(HttpOutgoingRequest.create(0 /* GET */, url));
|
|
6242
4845
|
}
|
|
6243
|
-
static
|
|
6244
|
-
|
|
4846
|
+
static convertMethod(method) {
|
|
4847
|
+
PreCondition.assertNotUndefinedAndNotNull(method, "method");
|
|
4848
|
+
let result;
|
|
4849
|
+
switch (method) {
|
|
4850
|
+
case 5 /* CONNECT */:
|
|
4851
|
+
result = "CONNECT";
|
|
4852
|
+
break;
|
|
4853
|
+
case 4 /* DELETE */:
|
|
4854
|
+
result = "DELETE";
|
|
4855
|
+
break;
|
|
4856
|
+
case 0 /* GET */:
|
|
4857
|
+
result = "GET";
|
|
4858
|
+
break;
|
|
4859
|
+
case 1 /* HEAD */:
|
|
4860
|
+
result = "HEAD";
|
|
4861
|
+
break;
|
|
4862
|
+
case 6 /* OPTIONS */:
|
|
4863
|
+
result = "OPTIONS";
|
|
4864
|
+
break;
|
|
4865
|
+
case 8 /* PATCH */:
|
|
4866
|
+
result = "PATCH";
|
|
4867
|
+
break;
|
|
4868
|
+
case 2 /* POST */:
|
|
4869
|
+
result = "POST";
|
|
4870
|
+
break;
|
|
4871
|
+
case 3 /* PUT */:
|
|
4872
|
+
result = "PUT";
|
|
4873
|
+
break;
|
|
4874
|
+
case 7 /* TRACE */:
|
|
4875
|
+
result = "TRACE";
|
|
4876
|
+
break;
|
|
4877
|
+
}
|
|
4878
|
+
PostCondition.assertNotEmpty(result, "result");
|
|
4879
|
+
return result;
|
|
6245
4880
|
}
|
|
6246
4881
|
};
|
|
6247
4882
|
|
|
6248
|
-
// sources/
|
|
6249
|
-
var
|
|
6250
|
-
|
|
6251
|
-
|
|
4883
|
+
// sources/network.ts
|
|
4884
|
+
var Network = class {
|
|
4885
|
+
};
|
|
4886
|
+
|
|
4887
|
+
// sources/httpServer.ts
|
|
4888
|
+
var HttpServer = class {
|
|
4889
|
+
};
|
|
4890
|
+
|
|
4891
|
+
// sources/httpOutgoingResponse.ts
|
|
4892
|
+
var HttpOutgoingResponse = class _HttpOutgoingResponse {
|
|
4893
|
+
statusCode;
|
|
4894
|
+
headers;
|
|
4895
|
+
body;
|
|
6252
4896
|
constructor() {
|
|
6253
|
-
|
|
6254
|
-
this.
|
|
6255
|
-
this.
|
|
4897
|
+
this.statusCode = 200;
|
|
4898
|
+
this.headers = MutableHttpHeaders.create();
|
|
4899
|
+
this.body = "";
|
|
6256
4900
|
}
|
|
6257
4901
|
static create() {
|
|
6258
|
-
return new
|
|
6259
|
-
}
|
|
6260
|
-
getNewlineSequence() {
|
|
6261
|
-
return this.newlineSequence;
|
|
6262
|
-
}
|
|
6263
|
-
setNewlineSequence(newlineSequence) {
|
|
6264
|
-
PreCondition.assertNotUndefinedAndNotNull(newlineSequence, "newlineSequence");
|
|
6265
|
-
this.newlineSequence = newlineSequence;
|
|
6266
|
-
return this;
|
|
4902
|
+
return new _HttpOutgoingResponse();
|
|
6267
4903
|
}
|
|
6268
|
-
|
|
6269
|
-
|
|
4904
|
+
/**
|
|
4905
|
+
* Get the status code of this {@link HttpOutgoingResponse}.
|
|
4906
|
+
*/
|
|
4907
|
+
getStatusCode() {
|
|
4908
|
+
return this.statusCode;
|
|
6270
4909
|
}
|
|
6271
|
-
|
|
6272
|
-
|
|
4910
|
+
/**
|
|
4911
|
+
* Set the status code of this {@link HttpOutgoingResponse}.
|
|
4912
|
+
* @param statusCode The status code of this {@link HttpOutgoingResponse}.
|
|
4913
|
+
*/
|
|
4914
|
+
setStatusCode(statusCode) {
|
|
4915
|
+
PreCondition.assertBetween(100, statusCode, 599, "statusCode");
|
|
4916
|
+
this.statusCode = statusCode;
|
|
6273
4917
|
return this;
|
|
6274
4918
|
}
|
|
6275
|
-
|
|
6276
|
-
return
|
|
6277
|
-
if (text) {
|
|
6278
|
-
this.writtenText += text;
|
|
6279
|
-
}
|
|
6280
|
-
return getLength(text);
|
|
6281
|
-
});
|
|
6282
|
-
}
|
|
6283
|
-
writeLine(text) {
|
|
6284
|
-
return SyncResult.create(() => {
|
|
6285
|
-
let result = 0;
|
|
6286
|
-
if (text) {
|
|
6287
|
-
result += this.writeString(text).await();
|
|
6288
|
-
}
|
|
6289
|
-
if (this.newlineSequence) {
|
|
6290
|
-
result += this.writeString(this.newlineSequence).await();
|
|
6291
|
-
}
|
|
6292
|
-
return result;
|
|
6293
|
-
});
|
|
6294
|
-
}
|
|
6295
|
-
};
|
|
6296
|
-
|
|
6297
|
-
// sources/listQueue.ts
|
|
6298
|
-
var ListQueue = class _ListQueue {
|
|
6299
|
-
list;
|
|
6300
|
-
constructor(list2) {
|
|
6301
|
-
this.list = list2 ?? List.create();
|
|
4919
|
+
getHeaders() {
|
|
4920
|
+
return this.headers;
|
|
6302
4921
|
}
|
|
6303
|
-
|
|
6304
|
-
|
|
4922
|
+
/**
|
|
4923
|
+
* Get the HTTP header with the provided name or return a {@link NotFoundError} if the header
|
|
4924
|
+
* doesn't exist.
|
|
4925
|
+
* @param headerName The name of the header to get.
|
|
4926
|
+
*/
|
|
4927
|
+
getHeader(headerName) {
|
|
4928
|
+
return this.headers.get(headerName);
|
|
6305
4929
|
}
|
|
6306
|
-
|
|
6307
|
-
|
|
4930
|
+
/**
|
|
4931
|
+
* Get the value of the header with the provided name or return a {@link NotFoundError} if the
|
|
4932
|
+
* header doesn't exist.
|
|
4933
|
+
* @param headerName The name of the header value to get.
|
|
4934
|
+
*/
|
|
4935
|
+
getHeaderValue(headerName) {
|
|
4936
|
+
return this.headers.getValue(headerName);
|
|
6308
4937
|
}
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
4938
|
+
/**
|
|
4939
|
+
* Set the HTTP header in this {@link HttpOutgoingResponse}.
|
|
4940
|
+
* @param headerName The name of the HTTP header.
|
|
4941
|
+
* @param headerValue The value of the HTTP header.
|
|
4942
|
+
*/
|
|
4943
|
+
setHeader(headerName, headerValue) {
|
|
4944
|
+
this.headers.set(headerName, headerValue);
|
|
4945
|
+
return this;
|
|
6313
4946
|
}
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
return
|
|
6317
|
-
this.list.addAll(values);
|
|
6318
|
-
});
|
|
4947
|
+
setContentTypeHeader(contentType) {
|
|
4948
|
+
this.headers.setContentType(contentType);
|
|
4949
|
+
return this;
|
|
6319
4950
|
}
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
return this.list.removeLast().await();
|
|
6326
|
-
});
|
|
4951
|
+
/**
|
|
4952
|
+
* Get the body of this {@link HttpOutgoingResponse}.
|
|
4953
|
+
*/
|
|
4954
|
+
getBody() {
|
|
4955
|
+
return this.body;
|
|
6327
4956
|
}
|
|
6328
|
-
|
|
6329
|
-
|
|
4957
|
+
/**
|
|
4958
|
+
* Set the body of this {@link HttpOutgoingResponse}.
|
|
4959
|
+
* @param body The body for this {@link HttpOutgoingResponse}.
|
|
4960
|
+
*/
|
|
4961
|
+
setBody(body) {
|
|
4962
|
+
PreCondition.assertNotUndefinedAndNotNull(body, "body");
|
|
4963
|
+
this.body = body;
|
|
4964
|
+
return this;
|
|
6330
4965
|
}
|
|
6331
4966
|
};
|
|
6332
4967
|
|
|
6333
|
-
// sources/
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
4968
|
+
// sources/nodeJSHttpServer.ts
|
|
4969
|
+
import * as http from "http";
|
|
4970
|
+
var NodeJSHttpServer = class _NodeJSHttpServer extends HttpServer {
|
|
4971
|
+
httpServer;
|
|
4972
|
+
disposed;
|
|
4973
|
+
constructor() {
|
|
4974
|
+
super();
|
|
4975
|
+
this.disposed = false;
|
|
4976
|
+
}
|
|
4977
|
+
static create() {
|
|
4978
|
+
return new _NodeJSHttpServer();
|
|
6340
4979
|
}
|
|
6341
|
-
|
|
6342
|
-
return new
|
|
4980
|
+
dispose() {
|
|
4981
|
+
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
4982
|
+
if (this.disposed) {
|
|
4983
|
+
resolve(false);
|
|
4984
|
+
} else if (!this.httpServer) {
|
|
4985
|
+
this.disposed = true;
|
|
4986
|
+
resolve(true);
|
|
4987
|
+
} else {
|
|
4988
|
+
this.httpServer.close((error) => {
|
|
4989
|
+
if (error) {
|
|
4990
|
+
reject(error);
|
|
4991
|
+
} else {
|
|
4992
|
+
this.disposed = true;
|
|
4993
|
+
this.httpServer = void 0;
|
|
4994
|
+
resolve(true);
|
|
4995
|
+
}
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
}));
|
|
6343
4999
|
}
|
|
6344
|
-
|
|
6345
|
-
return this.
|
|
5000
|
+
isDisposed() {
|
|
5001
|
+
return this.disposed;
|
|
6346
5002
|
}
|
|
6347
|
-
|
|
6348
|
-
return this.
|
|
5003
|
+
isStarted() {
|
|
5004
|
+
return !!this.httpServer;
|
|
6349
5005
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
this.connectedNodes.add(node);
|
|
5006
|
+
addRequestHandler(requestPath, handler) {
|
|
5007
|
+
throw new Error("Method not implemented.");
|
|
6353
5008
|
}
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
// sources/queue.ts
|
|
6357
|
-
var Queue = class {
|
|
6358
|
-
/**
|
|
6359
|
-
* Create an instance of the default {@link Queue} implementation.
|
|
6360
|
-
* @returns A new {@link Queue} object.
|
|
6361
|
-
*/
|
|
6362
|
-
static create() {
|
|
6363
|
-
return ListQueue.create();
|
|
5009
|
+
setDefaultRequestHandler(handler) {
|
|
5010
|
+
throw new Error("Method not implemented.");
|
|
6364
5011
|
}
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
}
|
|
6388
|
-
const dayAvailabilities = List.create();
|
|
6389
|
-
const quotaUsageByMemberDaily = json.quota_type_maps?.QuotaUsageByMemberDaily;
|
|
6390
|
-
if (quotaUsageByMemberDaily) {
|
|
6391
|
-
for (const quotaUsage of Object.entries(quotaUsageByMemberDaily)) {
|
|
6392
|
-
const dateString = quotaUsage[0];
|
|
6393
|
-
const usageData = quotaUsage[1];
|
|
6394
|
-
let walkup = false;
|
|
6395
|
-
let reservationsRemaining = 0;
|
|
6396
|
-
const boolsEntry = json.bools[dateString];
|
|
6397
|
-
if (boolsEntry) {
|
|
6398
|
-
walkup = usageData.show_walkup;
|
|
6399
|
-
reservationsRemaining = usageData.remaining;
|
|
6400
|
-
}
|
|
6401
|
-
dayAvailabilities.add({
|
|
6402
|
-
date: DateTime.parse(dateString),
|
|
6403
|
-
totalSpots: usageData.total,
|
|
6404
|
-
walkup,
|
|
6405
|
-
reservationsRemaining
|
|
5012
|
+
start(portNumber) {
|
|
5013
|
+
PreCondition.assertGreaterThanOrEqualTo(portNumber, 1, "portNumber");
|
|
5014
|
+
PreCondition.assertFalse(this.isDisposed(), "this.isDisposed()");
|
|
5015
|
+
PreCondition.assertUndefined(this.httpServer, "this.httpServer");
|
|
5016
|
+
return PromiseAsyncResult.create(new Promise((resolve, reject) => {
|
|
5017
|
+
if (this.httpServer) {
|
|
5018
|
+
reject(new Error("Can't run a HttpServer multiple times."));
|
|
5019
|
+
} else {
|
|
5020
|
+
this.httpServer = http.createServer();
|
|
5021
|
+
this.httpServer.on("request", (request, response) => {
|
|
5022
|
+
const httpResponse = HttpOutgoingResponse.create().setStatusCode(200).setHeader("Content-Type", "text/plain").setBody("Hello world!");
|
|
5023
|
+
const statusCode = httpResponse.getStatusCode();
|
|
5024
|
+
const headers = httpResponse.getHeaders();
|
|
5025
|
+
const responseHeaders = {};
|
|
5026
|
+
for (const header of headers) {
|
|
5027
|
+
responseHeaders[header.getName()] = header.getValue();
|
|
5028
|
+
}
|
|
5029
|
+
response.writeHead(statusCode, responseHeaders);
|
|
5030
|
+
response.end(httpResponse.getBody());
|
|
5031
|
+
});
|
|
5032
|
+
this.httpServer.on("close", () => {
|
|
5033
|
+
resolve();
|
|
6406
5034
|
});
|
|
5035
|
+
this.httpServer.on("error", (error) => {
|
|
5036
|
+
reject(error);
|
|
5037
|
+
});
|
|
5038
|
+
this.httpServer.listen(portNumber);
|
|
6407
5039
|
}
|
|
6408
|
-
}
|
|
6409
|
-
this.dayAvailabilities = dayAvailabilities;
|
|
6410
|
-
}
|
|
6411
|
-
static create(json) {
|
|
6412
|
-
return new _RecreationDotGovDivisionAvailability(json);
|
|
6413
|
-
}
|
|
6414
|
-
};
|
|
6415
|
-
var RecreationDotGovError = class extends Error {
|
|
6416
|
-
constructor(message) {
|
|
6417
|
-
super(message);
|
|
6418
|
-
}
|
|
6419
|
-
};
|
|
6420
|
-
var RecreationDotGovClient = class _RecreationDotGovClient {
|
|
6421
|
-
httpClient;
|
|
6422
|
-
constructor(httpClient) {
|
|
6423
|
-
PreCondition.assertNotUndefinedAndNotNull(httpClient, "httpClient");
|
|
6424
|
-
this.httpClient = httpClient;
|
|
6425
|
-
}
|
|
6426
|
-
static create(httpClient) {
|
|
6427
|
-
return new _RecreationDotGovClient(httpClient);
|
|
6428
|
-
}
|
|
6429
|
-
sendRequest(request) {
|
|
6430
|
-
return this.httpClient.sendRequest(request);
|
|
6431
|
-
}
|
|
6432
|
-
sendGetRequest(url) {
|
|
6433
|
-
return HttpClient.sendGetRequest(this, url);
|
|
6434
|
-
}
|
|
6435
|
-
getPermitItinerary(permitItineraryId) {
|
|
6436
|
-
PreCondition.assertNotEmpty(permitItineraryId, "permitItineraryId");
|
|
6437
|
-
return PromiseAsyncResult.create(async () => {
|
|
6438
|
-
const response = await this.sendGetRequest(`https://www.recreation.gov/api/permitcontent/${permitItineraryId}`);
|
|
6439
|
-
const responseBody = await response.getBody();
|
|
6440
|
-
const statusCode = response.getStatusCode();
|
|
6441
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
6442
|
-
const responseBodyJson2 = JSON.parse(responseBody);
|
|
6443
|
-
const errorMessage = responseBodyJson2.error;
|
|
6444
|
-
switch (errorMessage.toLowerCase()) {
|
|
6445
|
-
case "permit not found":
|
|
6446
|
-
throw new RecreationDotGovError(`No permit itinerary found for id: ${JSON.stringify(permitItineraryId)}`);
|
|
6447
|
-
default:
|
|
6448
|
-
throw new RecreationDotGovError(`Unrecognized error: ${JSON.stringify(errorMessage)}`);
|
|
6449
|
-
}
|
|
6450
|
-
}
|
|
6451
|
-
const responseBodyJson = JSON.parse(responseBody);
|
|
6452
|
-
return responseBodyJson.payload;
|
|
6453
|
-
});
|
|
6454
|
-
}
|
|
6455
|
-
getDivisionAvailability(permitItineraryId, divisionId, month, year, earlyAccessPermitLotteryId) {
|
|
6456
|
-
PreCondition.assertNotEmpty(permitItineraryId, "permitItineraryId");
|
|
6457
|
-
PreCondition.assertNotEmpty(divisionId, "divisionId");
|
|
6458
|
-
PreCondition.assertBetween(1, month, 12, "month");
|
|
6459
|
-
return PromiseAsyncResult.create(async () => {
|
|
6460
|
-
const url = earlyAccessPermitLotteryId ? `https://www.recreation.gov/api/permititinerary/${permitItineraryId}/division/${divisionId}/eapavailability/month/${earlyAccessPermitLotteryId}?month=${month}&year=${year}` : `https://www.recreation.gov/api/permititinerary/${permitItineraryId}/division/${divisionId}/availability/month?month=${month}&year=${year}`;
|
|
6461
|
-
const response = await this.sendGetRequest(url);
|
|
6462
|
-
let responseBody = await response.getBody();
|
|
6463
|
-
const statusCode = response.getStatusCode();
|
|
6464
|
-
if (statusCode < 200 || 300 <= statusCode) {
|
|
6465
|
-
const responseBodyJson2 = JSON.parse(responseBody);
|
|
6466
|
-
const errorMessage = responseBodyJson2.error;
|
|
6467
|
-
switch (errorMessage.toLowerCase()) {
|
|
6468
|
-
case "invalid permit id":
|
|
6469
|
-
throw new RecreationDotGovError(`No permit itinerary found for id: ${JSON.stringify(permitItineraryId)}`);
|
|
6470
|
-
case "request year is missing or invalid":
|
|
6471
|
-
const emptyResponseBody = {
|
|
6472
|
-
payload: {
|
|
6473
|
-
bools: {},
|
|
6474
|
-
rules: [],
|
|
6475
|
-
quota_type_maps: {}
|
|
6476
|
-
}
|
|
6477
|
-
};
|
|
6478
|
-
responseBody = JSON.stringify(emptyResponseBody);
|
|
6479
|
-
break;
|
|
6480
|
-
default:
|
|
6481
|
-
throw new RecreationDotGovError(`Unrecognized error: ${JSON.stringify(errorMessage)}`);
|
|
6482
|
-
}
|
|
6483
|
-
}
|
|
6484
|
-
const responseBodyJson = JSON.parse(responseBody);
|
|
6485
|
-
return RecreationDotGovDivisionAvailability.create(responseBodyJson.payload);
|
|
6486
|
-
});
|
|
5040
|
+
}));
|
|
6487
5041
|
}
|
|
6488
5042
|
};
|
|
6489
5043
|
|
|
6490
|
-
// sources/
|
|
6491
|
-
var
|
|
5044
|
+
// sources/realNetwork.ts
|
|
5045
|
+
var RealNetwork = class _RealNetwork extends Network {
|
|
6492
5046
|
constructor() {
|
|
6493
5047
|
super();
|
|
6494
5048
|
}
|
|
6495
5049
|
static create() {
|
|
6496
|
-
return new
|
|
5050
|
+
return new _RealNetwork();
|
|
6497
5051
|
}
|
|
6498
|
-
|
|
6499
|
-
return
|
|
5052
|
+
createHttpServer() {
|
|
5053
|
+
return NodeJSHttpServer.create();
|
|
6500
5054
|
}
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
if (result === void 0) {
|
|
6504
|
-
result = left < right ? 0 /* LessThan */ : 2 /* GreaterThan */;
|
|
6505
|
-
}
|
|
6506
|
-
return result;
|
|
5055
|
+
createHttpClient() {
|
|
5056
|
+
return FetchHttpClient.create();
|
|
6507
5057
|
}
|
|
6508
5058
|
};
|
|
6509
5059
|
|
|
6510
|
-
// sources/
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
trailhead: false,
|
|
6518
|
-
foodCacheStorage: false,
|
|
6519
|
-
divisionId: "46753170009",
|
|
6520
|
-
groupSiteDivisionId: "46753170010",
|
|
6521
|
-
latitude: 46.92058,
|
|
6522
|
-
longitude: -121.708,
|
|
6523
|
-
elevationFeet: 5851
|
|
6524
|
-
};
|
|
6525
|
-
static sunriseCamp = {
|
|
6526
|
-
name: "Sunrise Camp",
|
|
6527
|
-
trailhead: false,
|
|
6528
|
-
foodCacheStorage: false,
|
|
6529
|
-
divisionId: "46753170058",
|
|
6530
|
-
groupSiteDivisionId: "46753170059",
|
|
6531
|
-
latitude: 46.91129,
|
|
6532
|
-
longitude: -121.66002,
|
|
6533
|
-
elevationFeet: 6258
|
|
6534
|
-
};
|
|
6535
|
-
static sunriseVisitorCenter = {
|
|
6536
|
-
name: "Sunrise Visitor Center",
|
|
6537
|
-
trailhead: true,
|
|
6538
|
-
foodCacheStorage: true,
|
|
6539
|
-
divisionId: "",
|
|
6540
|
-
groupSiteDivisionId: "",
|
|
6541
|
-
latitude: 46.91448,
|
|
6542
|
-
longitude: -121.64337,
|
|
6543
|
-
elevationFeet: 6410
|
|
6544
|
-
};
|
|
6545
|
-
static whiteRiver = {
|
|
6546
|
-
name: "White River",
|
|
6547
|
-
trailhead: true,
|
|
6548
|
-
foodCacheStorage: true,
|
|
6549
|
-
divisionId: "46753170066",
|
|
6550
|
-
groupSiteDivisionId: "46753170067",
|
|
6551
|
-
latitude: 46.90255,
|
|
6552
|
-
longitude: -121.63869,
|
|
6553
|
-
elevationFeet: 4229
|
|
6554
|
-
};
|
|
6555
|
-
static fryingPanCreek = {
|
|
6556
|
-
name: "Fryingpan Creek",
|
|
6557
|
-
trailhead: true,
|
|
6558
|
-
foodCacheStorage: false,
|
|
6559
|
-
divisionId: "",
|
|
6560
|
-
groupSiteDivisionId: "",
|
|
6561
|
-
latitude: 46.88809,
|
|
6562
|
-
longitude: -121.61019,
|
|
6563
|
-
elevationFeet: 3835
|
|
6564
|
-
};
|
|
6565
|
-
static summerland = {
|
|
6566
|
-
name: "Summerland",
|
|
6567
|
-
trailhead: false,
|
|
6568
|
-
foodCacheStorage: false,
|
|
6569
|
-
divisionId: "46753170056",
|
|
6570
|
-
groupSiteDivisionId: "46753170057",
|
|
6571
|
-
latitude: 46.86616,
|
|
6572
|
-
longitude: -121.65843,
|
|
6573
|
-
elevationFeet: 5988
|
|
6574
|
-
};
|
|
6575
|
-
static indianBar = {
|
|
6576
|
-
name: "Indian Bar",
|
|
6577
|
-
trailhead: false,
|
|
6578
|
-
foodCacheStorage: false,
|
|
6579
|
-
divisionId: "46753170046",
|
|
6580
|
-
groupSiteDivisionId: "46753170047",
|
|
6581
|
-
latitude: 46.82593,
|
|
6582
|
-
longitude: -121.63942,
|
|
6583
|
-
elevationFeet: 5101
|
|
6584
|
-
};
|
|
6585
|
-
static nickelCreek = {
|
|
6586
|
-
name: "Nickel Creek",
|
|
6587
|
-
trailhead: false,
|
|
6588
|
-
foodCacheStorage: false,
|
|
6589
|
-
divisionId: "46753170051",
|
|
6590
|
-
groupSiteDivisionId: "46753170052",
|
|
6591
|
-
latitude: 46.77204,
|
|
6592
|
-
longitude: -121.62402,
|
|
6593
|
-
elevationFeet: 3383
|
|
6594
|
-
};
|
|
6595
|
-
static boxCanyon = {
|
|
6596
|
-
name: "Box Canyon",
|
|
6597
|
-
trailhead: true,
|
|
6598
|
-
foodCacheStorage: false,
|
|
6599
|
-
divisionId: "",
|
|
6600
|
-
groupSiteDivisionId: "",
|
|
6601
|
-
latitude: 46.7657,
|
|
6602
|
-
longitude: -121.63517,
|
|
6603
|
-
elevationFeet: 3025
|
|
6604
|
-
};
|
|
6605
|
-
static mapleCreek = {
|
|
6606
|
-
name: "Maple Creek",
|
|
6607
|
-
trailhead: false,
|
|
6608
|
-
foodCacheStorage: false,
|
|
6609
|
-
divisionId: "46753170027",
|
|
6610
|
-
groupSiteDivisionId: "46753170028",
|
|
6611
|
-
latitude: 46.75745,
|
|
6612
|
-
longitude: -121.65764,
|
|
6613
|
-
elevationFeet: 2806
|
|
6614
|
-
};
|
|
6615
|
-
static reflectionLakes = {
|
|
6616
|
-
name: "Reflection Lakes",
|
|
6617
|
-
trailhead: true,
|
|
6618
|
-
foodCacheStorage: false,
|
|
6619
|
-
divisionId: "",
|
|
6620
|
-
groupSiteDivisionId: "",
|
|
6621
|
-
latitude: 46.76824,
|
|
6622
|
-
longitude: -121.7289,
|
|
6623
|
-
elevationFeet: 4862
|
|
6624
|
-
};
|
|
6625
|
-
static paradiseRiver = {
|
|
6626
|
-
name: "Paradise River",
|
|
6627
|
-
trailhead: false,
|
|
6628
|
-
foodCacheStorage: false,
|
|
6629
|
-
divisionId: "46753170031",
|
|
6630
|
-
groupSiteDivisionId: "46753170032",
|
|
6631
|
-
latitude: 46.77076,
|
|
6632
|
-
longitude: -121.75909,
|
|
6633
|
-
elevationFeet: 3960
|
|
6634
|
-
};
|
|
6635
|
-
static longmire = {
|
|
6636
|
-
name: "Longmire",
|
|
6637
|
-
trailhead: true,
|
|
6638
|
-
foodCacheStorage: true,
|
|
6639
|
-
divisionId: "",
|
|
6640
|
-
groupSiteDivisionId: "",
|
|
6641
|
-
latitude: 46.75011,
|
|
6642
|
-
longitude: -121.81253,
|
|
6643
|
-
elevationFeet: 2750
|
|
6644
|
-
};
|
|
6645
|
-
static pyramidCreek = {
|
|
6646
|
-
name: "Pyramid Creek",
|
|
6647
|
-
trailhead: false,
|
|
6648
|
-
foodCacheStorage: false,
|
|
6649
|
-
divisionId: "46753170033",
|
|
6650
|
-
groupSiteDivisionId: "",
|
|
6651
|
-
latitude: 46.77832,
|
|
6652
|
-
longitude: -121.80963,
|
|
6653
|
-
elevationFeet: 3721
|
|
6654
|
-
};
|
|
6655
|
-
static devilsDream = {
|
|
6656
|
-
name: "Devil's Dream",
|
|
6657
|
-
trailhead: false,
|
|
6658
|
-
foodCacheStorage: false,
|
|
6659
|
-
divisionId: "46753170040",
|
|
6660
|
-
groupSiteDivisionId: "46753170041",
|
|
6661
|
-
latitude: 46.78196,
|
|
6662
|
-
longitude: -121.83297,
|
|
6663
|
-
elevationFeet: 4929
|
|
6664
|
-
};
|
|
6665
|
-
static southPuyallupRiver = {
|
|
6666
|
-
name: "South Puyallup River",
|
|
6667
|
-
trailhead: false,
|
|
6668
|
-
foodCacheStorage: false,
|
|
6669
|
-
divisionId: "46753170035",
|
|
6670
|
-
groupSiteDivisionId: "46753170036",
|
|
6671
|
-
latitude: 46.81331,
|
|
6672
|
-
longitude: -121.86445,
|
|
6673
|
-
elevationFeet: 4183
|
|
6674
|
-
};
|
|
6675
|
-
static klapatchePark = {
|
|
6676
|
-
name: "Klapatche Park",
|
|
6677
|
-
trailhead: false,
|
|
6678
|
-
foodCacheStorage: false,
|
|
6679
|
-
divisionId: "46753170024",
|
|
6680
|
-
groupSiteDivisionId: "",
|
|
6681
|
-
latitude: 46.83571,
|
|
6682
|
-
longitude: -121.87752,
|
|
6683
|
-
elevationFeet: 5496
|
|
6684
|
-
};
|
|
6685
|
-
static northPuyallupRiver = {
|
|
6686
|
-
name: "North Puyallup River",
|
|
6687
|
-
trailhead: false,
|
|
6688
|
-
foodCacheStorage: false,
|
|
6689
|
-
divisionId: "46753170029",
|
|
6690
|
-
groupSiteDivisionId: "46753170030",
|
|
6691
|
-
latitude: 46.84751,
|
|
6692
|
-
longitude: -121.87005,
|
|
6693
|
-
elevationFeet: 3733
|
|
6694
|
-
};
|
|
6695
|
-
static goldenLakes = {
|
|
6696
|
-
name: "Golden Lakes",
|
|
6697
|
-
trailhead: false,
|
|
6698
|
-
foodCacheStorage: false,
|
|
6699
|
-
divisionId: "46753170022",
|
|
6700
|
-
groupSiteDivisionId: "46753170023",
|
|
6701
|
-
latitude: 46.88327,
|
|
6702
|
-
longitude: -121.89919,
|
|
6703
|
-
elevationFeet: 4927
|
|
6704
|
-
};
|
|
6705
|
-
static southMowichRiver = {
|
|
6706
|
-
name: "South Mowich River",
|
|
6707
|
-
trailhead: false,
|
|
6708
|
-
foodCacheStorage: false,
|
|
6709
|
-
divisionId: "46753170019",
|
|
6710
|
-
groupSiteDivisionId: "46753170020",
|
|
6711
|
-
latitude: 46.91146,
|
|
6712
|
-
longitude: -121.89314,
|
|
6713
|
-
elevationFeet: 2686
|
|
6714
|
-
};
|
|
6715
|
-
static mowichLake = {
|
|
6716
|
-
name: "Mowich Lake",
|
|
6717
|
-
trailhead: false,
|
|
6718
|
-
foodCacheStorage: false,
|
|
6719
|
-
divisionId: "46753170015",
|
|
6720
|
-
groupSiteDivisionId: "46753170016",
|
|
6721
|
-
latitude: 46.93204,
|
|
6722
|
-
longitude: -121.86351,
|
|
6723
|
-
elevationFeet: 4868
|
|
6724
|
-
};
|
|
6725
|
-
static eaglesRoost = {
|
|
6726
|
-
name: "Eagle's Roost",
|
|
6727
|
-
trailhead: false,
|
|
6728
|
-
foodCacheStorage: false,
|
|
6729
|
-
divisionId: "46753170006",
|
|
6730
|
-
groupSiteDivisionId: "",
|
|
6731
|
-
latitude: 46.91529,
|
|
6732
|
-
longitude: -121.84816,
|
|
6733
|
-
elevationFeet: 4834
|
|
6734
|
-
};
|
|
6735
|
-
static cataractValley = {
|
|
6736
|
-
name: "Cataract Valley",
|
|
6737
|
-
trailhead: false,
|
|
6738
|
-
foodCacheStorage: false,
|
|
6739
|
-
divisionId: "46753170003",
|
|
6740
|
-
groupSiteDivisionId: "46753170004",
|
|
6741
|
-
latitude: 46.94049,
|
|
6742
|
-
longitude: -121.80486,
|
|
6743
|
-
elevationFeet: 4488
|
|
6744
|
-
};
|
|
6745
|
-
static ipsutCreek = {
|
|
6746
|
-
name: "Ipsut Creek",
|
|
6747
|
-
trailhead: false,
|
|
6748
|
-
foodCacheStorage: false,
|
|
6749
|
-
divisionId: "46753170011",
|
|
6750
|
-
groupSiteDivisionId: "46753170012",
|
|
6751
|
-
latitude: 46.97615,
|
|
6752
|
-
longitude: -121.83022,
|
|
6753
|
-
elevationFeet: 2359
|
|
6754
|
-
};
|
|
6755
|
-
static carbonRiver = {
|
|
6756
|
-
name: "Carbon River",
|
|
6757
|
-
trailhead: false,
|
|
6758
|
-
foodCacheStorage: false,
|
|
6759
|
-
divisionId: "46753170001",
|
|
6760
|
-
groupSiteDivisionId: "46753170002",
|
|
6761
|
-
latitude: 46.95063,
|
|
6762
|
-
longitude: -121.79991,
|
|
6763
|
-
elevationFeet: 3255
|
|
6764
|
-
};
|
|
6765
|
-
static dickCreek = {
|
|
6766
|
-
name: "Dick Creek",
|
|
6767
|
-
trailhead: false,
|
|
6768
|
-
foodCacheStorage: false,
|
|
6769
|
-
divisionId: "46753170005",
|
|
6770
|
-
groupSiteDivisionId: "",
|
|
6771
|
-
latitude: 46.94071,
|
|
6772
|
-
longitude: -121.78431,
|
|
6773
|
-
elevationFeet: 4114
|
|
6774
|
-
};
|
|
6775
|
-
static mysticLake = {
|
|
6776
|
-
name: "Mystic Lake",
|
|
6777
|
-
trailhead: false,
|
|
6778
|
-
foodCacheStorage: false,
|
|
6779
|
-
divisionId: "46753170017",
|
|
6780
|
-
groupSiteDivisionId: "46753170018",
|
|
6781
|
-
latitude: 46.9157,
|
|
6782
|
-
longitude: -121.75045,
|
|
6783
|
-
elevationFeet: 5538
|
|
6784
|
-
};
|
|
6785
|
-
static getLocations() {
|
|
6786
|
-
return Iterable.create([
|
|
6787
|
-
this.graniteCreek,
|
|
6788
|
-
this.sunriseCamp,
|
|
6789
|
-
this.sunriseVisitorCenter,
|
|
6790
|
-
this.whiteRiver,
|
|
6791
|
-
this.fryingPanCreek,
|
|
6792
|
-
this.summerland,
|
|
6793
|
-
this.indianBar,
|
|
6794
|
-
this.nickelCreek,
|
|
6795
|
-
this.boxCanyon,
|
|
6796
|
-
this.mapleCreek,
|
|
6797
|
-
this.reflectionLakes,
|
|
6798
|
-
this.paradiseRiver,
|
|
6799
|
-
this.longmire,
|
|
6800
|
-
this.pyramidCreek,
|
|
6801
|
-
this.devilsDream,
|
|
6802
|
-
this.southPuyallupRiver,
|
|
6803
|
-
this.klapatchePark,
|
|
6804
|
-
this.northPuyallupRiver,
|
|
6805
|
-
this.goldenLakes,
|
|
6806
|
-
this.southMowichRiver,
|
|
6807
|
-
this.mowichLake,
|
|
6808
|
-
this.eaglesRoost,
|
|
6809
|
-
this.cataractValley,
|
|
6810
|
-
this.ipsutCreek,
|
|
6811
|
-
this.carbonRiver,
|
|
6812
|
-
this.dickCreek,
|
|
6813
|
-
this.mysticLake
|
|
6814
|
-
]);
|
|
6815
|
-
}
|
|
6816
|
-
static getTrailheads() {
|
|
6817
|
-
return this.getLocations().where((location) => location.trailhead);
|
|
6818
|
-
}
|
|
6819
|
-
};
|
|
6820
|
-
var WonderlandTrailReservationType = /* @__PURE__ */ ((WonderlandTrailReservationType2) => {
|
|
6821
|
-
WonderlandTrailReservationType2[WonderlandTrailReservationType2["Reserved"] = 0] = "Reserved";
|
|
6822
|
-
WonderlandTrailReservationType2[WonderlandTrailReservationType2["Walkup"] = 1] = "Walkup";
|
|
6823
|
-
return WonderlandTrailReservationType2;
|
|
6824
|
-
})(WonderlandTrailReservationType || {});
|
|
6825
|
-
var WonderlandTrailAvailability = class _WonderlandTrailAvailability {
|
|
6826
|
-
availabilityMap;
|
|
5060
|
+
// sources/currentProcess.ts
|
|
5061
|
+
var CurrentProcess = class _CurrentProcess {
|
|
5062
|
+
args;
|
|
5063
|
+
parameters;
|
|
5064
|
+
outputWriteStream;
|
|
5065
|
+
exitCodeProperty;
|
|
5066
|
+
network;
|
|
6827
5067
|
constructor() {
|
|
6828
|
-
this.availabilityMap = Map2.create();
|
|
6829
5068
|
}
|
|
6830
5069
|
static create() {
|
|
6831
|
-
return new
|
|
6832
|
-
}
|
|
6833
|
-
any() {
|
|
6834
|
-
return this.availabilityMap.any().await();
|
|
6835
|
-
}
|
|
6836
|
-
addAvailability(location, date, individualSite, groupSite) {
|
|
6837
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
6838
|
-
PreCondition.assertNotUndefinedAndNotNull(date, "date");
|
|
6839
|
-
const locationAvailability = this.getAvailability(location);
|
|
6840
|
-
const dateString = date.toDateString();
|
|
6841
|
-
const locationDayAvailability = locationAvailability.getOrSet(dateString, () => {
|
|
6842
|
-
return {};
|
|
6843
|
-
}).await();
|
|
6844
|
-
locationAvailability.set(dateString, {
|
|
6845
|
-
individualSite: individualSite ?? locationDayAvailability.individualSite,
|
|
6846
|
-
groupSite: groupSite ?? locationDayAvailability.groupSite
|
|
6847
|
-
});
|
|
6848
|
-
}
|
|
6849
|
-
getAvailability(location) {
|
|
6850
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
6851
|
-
return this.availabilityMap.getOrSet(location, () => MutableMap.create()).await();
|
|
6852
|
-
}
|
|
6853
|
-
getDayAvailability(location, date) {
|
|
6854
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
6855
|
-
PreCondition.assertNotUndefinedAndNotNull(date, "date");
|
|
6856
|
-
return this.getAvailability(location).get(date.toDateString()).convertError(NotFoundError, () => new NotFoundError(`No availability was found for ${location.name} on ${date.toDateString()}.`));
|
|
6857
|
-
}
|
|
6858
|
-
};
|
|
6859
|
-
var WonderlandTrailDirection = class _WonderlandTrailDirection {
|
|
6860
|
-
value;
|
|
6861
|
-
constructor(value) {
|
|
6862
|
-
PreCondition.assertNotEmpty(value, "value");
|
|
6863
|
-
this.value = value;
|
|
6864
|
-
}
|
|
6865
|
-
static clockwise = new _WonderlandTrailDirection("Clockwise");
|
|
6866
|
-
static counterClockwise = new _WonderlandTrailDirection("CounterClockwise");
|
|
6867
|
-
toString() {
|
|
6868
|
-
return this.value;
|
|
6869
|
-
}
|
|
6870
|
-
reverse() {
|
|
6871
|
-
return this === _WonderlandTrailDirection.clockwise ? _WonderlandTrailDirection.counterClockwise : _WonderlandTrailDirection.clockwise;
|
|
6872
|
-
}
|
|
6873
|
-
};
|
|
6874
|
-
var WonderlandTrailConnection = class _WonderlandTrailConnection {
|
|
6875
|
-
startLocation;
|
|
6876
|
-
endLocation;
|
|
6877
|
-
distanceMiles;
|
|
6878
|
-
ascentFeet;
|
|
6879
|
-
descentFeet;
|
|
6880
|
-
direction;
|
|
6881
|
-
intermediateLocations;
|
|
6882
|
-
constructor(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations) {
|
|
6883
|
-
PreCondition.assertNotUndefinedAndNotNull(startLocation, "startLocation");
|
|
6884
|
-
PreCondition.assertNotUndefinedAndNotNull(endLocation, "endLocation");
|
|
6885
|
-
PreCondition.assertGreaterThanOrEqualTo(distanceMiles, 0, "distanceMiles");
|
|
6886
|
-
PreCondition.assertGreaterThanOrEqualTo(ascentFeet, 0, "ascentFeet");
|
|
6887
|
-
PreCondition.assertGreaterThanOrEqualTo(descentFeet, 0, "descentFeet");
|
|
6888
|
-
PreCondition.assertNotUndefinedAndNotNull(intermediateLocations, "intermediateLocations");
|
|
6889
|
-
this.startLocation = startLocation;
|
|
6890
|
-
this.endLocation = endLocation;
|
|
6891
|
-
this.distanceMiles = distanceMiles;
|
|
6892
|
-
this.ascentFeet = ascentFeet;
|
|
6893
|
-
this.descentFeet = descentFeet;
|
|
6894
|
-
this.direction = direction;
|
|
6895
|
-
this.intermediateLocations = intermediateLocations;
|
|
6896
|
-
}
|
|
6897
|
-
static create(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations) {
|
|
6898
|
-
return new _WonderlandTrailConnection(startLocation, endLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations);
|
|
6899
|
-
}
|
|
6900
|
-
getLocations() {
|
|
6901
|
-
const result = List.create();
|
|
6902
|
-
_WonderlandTrailConnection.ensureExists(result, this.startLocation);
|
|
6903
|
-
_WonderlandTrailConnection.ensureAllExist(result, this.intermediateLocations);
|
|
6904
|
-
_WonderlandTrailConnection.ensureExists(result, this.endLocation);
|
|
6905
|
-
return result;
|
|
6906
|
-
}
|
|
6907
|
-
static ensureExists(list2, location) {
|
|
6908
|
-
if (!list2.contains(location).await()) {
|
|
6909
|
-
list2.add(location);
|
|
6910
|
-
}
|
|
5070
|
+
return new _CurrentProcess();
|
|
6911
5071
|
}
|
|
6912
|
-
static
|
|
6913
|
-
|
|
6914
|
-
|
|
5072
|
+
static async run(action) {
|
|
5073
|
+
PreCondition.assertNotUndefinedAndNotNull(action, "action");
|
|
5074
|
+
const currentProcess = _CurrentProcess.create();
|
|
5075
|
+
try {
|
|
5076
|
+
const result = await action(currentProcess);
|
|
5077
|
+
if (isNumber(result)) {
|
|
5078
|
+
currentProcess.setExitCode(result);
|
|
5079
|
+
}
|
|
5080
|
+
} catch (error) {
|
|
5081
|
+
currentProcess.setExitCode(-1);
|
|
5082
|
+
const writeStream = currentProcess.getOutputWriteStream();
|
|
5083
|
+
if (error instanceof Error && error.stack) {
|
|
5084
|
+
writeStream.writeLine(error.stack);
|
|
5085
|
+
} else {
|
|
5086
|
+
writeStream.writeLine(`${error}`);
|
|
5087
|
+
}
|
|
6915
5088
|
}
|
|
6916
5089
|
}
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
this.
|
|
6920
|
-
this.startLocation,
|
|
6921
|
-
this.distanceMiles,
|
|
6922
|
-
this.descentFeet,
|
|
6923
|
-
this.ascentFeet,
|
|
6924
|
-
this.direction.reverse(),
|
|
6925
|
-
this.intermediateLocations
|
|
6926
|
-
);
|
|
6927
|
-
}
|
|
6928
|
-
join(connection) {
|
|
6929
|
-
const intermediateLocations = List.create();
|
|
6930
|
-
_WonderlandTrailConnection.ensureAllExist(intermediateLocations, this.intermediateLocations);
|
|
6931
|
-
_WonderlandTrailConnection.ensureExists(intermediateLocations, this.endLocation);
|
|
6932
|
-
_WonderlandTrailConnection.ensureExists(intermediateLocations, connection.startLocation);
|
|
6933
|
-
_WonderlandTrailConnection.ensureAllExist(intermediateLocations, connection.intermediateLocations);
|
|
6934
|
-
return _WonderlandTrailConnection.create(
|
|
6935
|
-
this.startLocation,
|
|
6936
|
-
connection.endLocation,
|
|
6937
|
-
this.distanceMiles + connection.distanceMiles,
|
|
6938
|
-
this.ascentFeet + connection.ascentFeet,
|
|
6939
|
-
this.descentFeet + connection.descentFeet,
|
|
6940
|
-
this.direction,
|
|
6941
|
-
intermediateLocations
|
|
6942
|
-
);
|
|
6943
|
-
}
|
|
6944
|
-
containsLocation(location) {
|
|
6945
|
-
return this.getLocations().contains(location).await();
|
|
6946
|
-
}
|
|
6947
|
-
isLoop() {
|
|
6948
|
-
return this.startLocation === this.endLocation;
|
|
6949
|
-
}
|
|
6950
|
-
};
|
|
6951
|
-
var WonderlandTrailConnections = class _WonderlandTrailConnections {
|
|
6952
|
-
connections;
|
|
6953
|
-
addReverseConnectionDefault;
|
|
6954
|
-
constructor(addReverseConnectionDefault) {
|
|
6955
|
-
this.connections = Map2.create();
|
|
6956
|
-
this.addReverseConnectionDefault = addReverseConnectionDefault;
|
|
6957
|
-
}
|
|
6958
|
-
static create(addReverseConnectionDefault) {
|
|
6959
|
-
return new _WonderlandTrailConnections(!!addReverseConnectionDefault);
|
|
6960
|
-
}
|
|
6961
|
-
static createDefault() {
|
|
6962
|
-
return _WonderlandTrailConnections.create(true).addConnection({
|
|
6963
|
-
startLocation: WonderlandTrailLocations.whiteRiver,
|
|
6964
|
-
endLocation: WonderlandTrailLocations.fryingPanCreek,
|
|
6965
|
-
distanceMiles: 2.7,
|
|
6966
|
-
ascentFeet: 100,
|
|
6967
|
-
descentFeet: 600
|
|
6968
|
-
}).addConnection({
|
|
6969
|
-
startLocation: WonderlandTrailLocations.fryingPanCreek,
|
|
6970
|
-
endLocation: WonderlandTrailLocations.summerland,
|
|
6971
|
-
distanceMiles: 4.3,
|
|
6972
|
-
ascentFeet: 2200,
|
|
6973
|
-
descentFeet: 100
|
|
6974
|
-
}).addConnection({
|
|
6975
|
-
startLocation: WonderlandTrailLocations.summerland,
|
|
6976
|
-
endLocation: WonderlandTrailLocations.indianBar,
|
|
6977
|
-
distanceMiles: 4.7,
|
|
6978
|
-
ascentFeet: 1200,
|
|
6979
|
-
descentFeet: 2100
|
|
6980
|
-
}).addConnection({
|
|
6981
|
-
startLocation: WonderlandTrailLocations.indianBar,
|
|
6982
|
-
endLocation: WonderlandTrailLocations.nickelCreek,
|
|
6983
|
-
distanceMiles: 6.8,
|
|
6984
|
-
ascentFeet: 1400,
|
|
6985
|
-
descentFeet: 3200
|
|
6986
|
-
}).addConnection({
|
|
6987
|
-
startLocation: WonderlandTrailLocations.nickelCreek,
|
|
6988
|
-
endLocation: WonderlandTrailLocations.boxCanyon,
|
|
6989
|
-
distanceMiles: 0.9,
|
|
6990
|
-
ascentFeet: 100,
|
|
6991
|
-
descentFeet: 400
|
|
6992
|
-
}).addConnection({
|
|
6993
|
-
startLocation: WonderlandTrailLocations.boxCanyon,
|
|
6994
|
-
endLocation: WonderlandTrailLocations.mapleCreek,
|
|
6995
|
-
distanceMiles: 2.7,
|
|
6996
|
-
ascentFeet: 500,
|
|
6997
|
-
descentFeet: 700
|
|
6998
|
-
}).addConnection({
|
|
6999
|
-
startLocation: WonderlandTrailLocations.mapleCreek,
|
|
7000
|
-
endLocation: WonderlandTrailLocations.reflectionLakes,
|
|
7001
|
-
distanceMiles: 4.7,
|
|
7002
|
-
ascentFeet: 2300,
|
|
7003
|
-
descentFeet: 200
|
|
7004
|
-
}).addConnection({
|
|
7005
|
-
startLocation: WonderlandTrailLocations.reflectionLakes,
|
|
7006
|
-
endLocation: WonderlandTrailLocations.paradiseRiver,
|
|
7007
|
-
distanceMiles: 2.6,
|
|
7008
|
-
ascentFeet: 200,
|
|
7009
|
-
descentFeet: 1200
|
|
7010
|
-
}).addConnection({
|
|
7011
|
-
startLocation: WonderlandTrailLocations.paradiseRiver,
|
|
7012
|
-
endLocation: WonderlandTrailLocations.longmire,
|
|
7013
|
-
distanceMiles: 3.6,
|
|
7014
|
-
ascentFeet: 100,
|
|
7015
|
-
descentFeet: 1200
|
|
7016
|
-
}).addConnection({
|
|
7017
|
-
startLocation: WonderlandTrailLocations.longmire,
|
|
7018
|
-
endLocation: WonderlandTrailLocations.pyramidCreek,
|
|
7019
|
-
distanceMiles: 3.3,
|
|
7020
|
-
ascentFeet: 1400,
|
|
7021
|
-
descentFeet: 400
|
|
7022
|
-
}).addConnection({
|
|
7023
|
-
startLocation: WonderlandTrailLocations.pyramidCreek,
|
|
7024
|
-
endLocation: WonderlandTrailLocations.devilsDream,
|
|
7025
|
-
distanceMiles: 2.5,
|
|
7026
|
-
ascentFeet: 1400,
|
|
7027
|
-
descentFeet: 100
|
|
7028
|
-
}).addConnection({
|
|
7029
|
-
startLocation: WonderlandTrailLocations.devilsDream,
|
|
7030
|
-
endLocation: WonderlandTrailLocations.southPuyallupRiver,
|
|
7031
|
-
distanceMiles: 6.5,
|
|
7032
|
-
ascentFeet: 1900,
|
|
7033
|
-
descentFeet: 2700
|
|
7034
|
-
}).addConnection({
|
|
7035
|
-
startLocation: WonderlandTrailLocations.southPuyallupRiver,
|
|
7036
|
-
endLocation: WonderlandTrailLocations.klapatchePark,
|
|
7037
|
-
distanceMiles: 4.1,
|
|
7038
|
-
ascentFeet: 2100,
|
|
7039
|
-
descentFeet: 800
|
|
7040
|
-
}).addConnection({
|
|
7041
|
-
startLocation: WonderlandTrailLocations.klapatchePark,
|
|
7042
|
-
endLocation: WonderlandTrailLocations.northPuyallupRiver,
|
|
7043
|
-
distanceMiles: 2.6,
|
|
7044
|
-
ascentFeet: 100,
|
|
7045
|
-
descentFeet: 1900
|
|
7046
|
-
}).addConnection({
|
|
7047
|
-
startLocation: WonderlandTrailLocations.northPuyallupRiver,
|
|
7048
|
-
endLocation: WonderlandTrailLocations.goldenLakes,
|
|
7049
|
-
distanceMiles: 5.1,
|
|
7050
|
-
ascentFeet: 1900,
|
|
7051
|
-
descentFeet: 600
|
|
7052
|
-
}).addConnection({
|
|
7053
|
-
startLocation: WonderlandTrailLocations.goldenLakes,
|
|
7054
|
-
endLocation: WonderlandTrailLocations.southMowichRiver,
|
|
7055
|
-
distanceMiles: 5.8,
|
|
7056
|
-
ascentFeet: 200,
|
|
7057
|
-
descentFeet: 2400
|
|
7058
|
-
}).addConnection({
|
|
7059
|
-
startLocation: WonderlandTrailLocations.southMowichRiver,
|
|
7060
|
-
endLocation: WonderlandTrailLocations.mowichLake,
|
|
7061
|
-
distanceMiles: 4.4,
|
|
7062
|
-
ascentFeet: 2400,
|
|
7063
|
-
descentFeet: 300
|
|
7064
|
-
}).addConnection({
|
|
7065
|
-
startLocation: WonderlandTrailLocations.mowichLake,
|
|
7066
|
-
endLocation: WonderlandTrailLocations.ipsutCreek,
|
|
7067
|
-
distanceMiles: 5.6,
|
|
7068
|
-
ascentFeet: 400,
|
|
7069
|
-
descentFeet: 3e3
|
|
7070
|
-
}).addConnection({
|
|
7071
|
-
startLocation: WonderlandTrailLocations.ipsutCreek,
|
|
7072
|
-
endLocation: WonderlandTrailLocations.carbonRiver,
|
|
7073
|
-
distanceMiles: 4,
|
|
7074
|
-
ascentFeet: 1300,
|
|
7075
|
-
descentFeet: 400
|
|
7076
|
-
}).addConnection({
|
|
7077
|
-
startLocation: WonderlandTrailLocations.mowichLake,
|
|
7078
|
-
endLocation: WonderlandTrailLocations.eaglesRoost,
|
|
7079
|
-
distanceMiles: 2,
|
|
7080
|
-
ascentFeet: 500,
|
|
7081
|
-
descentFeet: 600
|
|
7082
|
-
}).addConnection({
|
|
7083
|
-
startLocation: WonderlandTrailLocations.eaglesRoost,
|
|
7084
|
-
endLocation: WonderlandTrailLocations.cataractValley,
|
|
7085
|
-
distanceMiles: 12.4,
|
|
7086
|
-
ascentFeet: 3300,
|
|
7087
|
-
descentFeet: 3700
|
|
7088
|
-
}).addConnection({
|
|
7089
|
-
startLocation: WonderlandTrailLocations.cataractValley,
|
|
7090
|
-
endLocation: WonderlandTrailLocations.carbonRiver,
|
|
7091
|
-
distanceMiles: 1.6,
|
|
7092
|
-
ascentFeet: 100,
|
|
7093
|
-
descentFeet: 1300
|
|
7094
|
-
}).addConnection({
|
|
7095
|
-
startLocation: WonderlandTrailLocations.carbonRiver,
|
|
7096
|
-
endLocation: WonderlandTrailLocations.dickCreek,
|
|
7097
|
-
distanceMiles: 1.3,
|
|
7098
|
-
ascentFeet: 1e3,
|
|
7099
|
-
descentFeet: 100
|
|
7100
|
-
}).addConnection({
|
|
7101
|
-
startLocation: WonderlandTrailLocations.dickCreek,
|
|
7102
|
-
endLocation: WonderlandTrailLocations.mysticLake,
|
|
7103
|
-
distanceMiles: 3.7,
|
|
7104
|
-
ascentFeet: 2100,
|
|
7105
|
-
descentFeet: 600
|
|
7106
|
-
}).addConnection({
|
|
7107
|
-
startLocation: WonderlandTrailLocations.mysticLake,
|
|
7108
|
-
endLocation: WonderlandTrailLocations.graniteCreek,
|
|
7109
|
-
distanceMiles: 4.1,
|
|
7110
|
-
ascentFeet: 1500,
|
|
7111
|
-
descentFeet: 1200
|
|
7112
|
-
}).addConnection({
|
|
7113
|
-
startLocation: WonderlandTrailLocations.graniteCreek,
|
|
7114
|
-
endLocation: WonderlandTrailLocations.sunriseCamp,
|
|
7115
|
-
distanceMiles: 4.6,
|
|
7116
|
-
ascentFeet: 1400,
|
|
7117
|
-
descentFeet: 1e3
|
|
7118
|
-
}).addConnection({
|
|
7119
|
-
startLocation: WonderlandTrailLocations.sunriseCamp,
|
|
7120
|
-
endLocation: WonderlandTrailLocations.whiteRiver,
|
|
7121
|
-
distanceMiles: 3.5,
|
|
7122
|
-
ascentFeet: 100,
|
|
7123
|
-
descentFeet: 2100
|
|
7124
|
-
}).addConnection({
|
|
7125
|
-
startLocation: WonderlandTrailLocations.sunriseCamp,
|
|
7126
|
-
endLocation: WonderlandTrailLocations.sunriseVisitorCenter,
|
|
7127
|
-
distanceMiles: 1.4,
|
|
7128
|
-
ascentFeet: 400,
|
|
7129
|
-
descentFeet: 200
|
|
7130
|
-
}).addConnection({
|
|
7131
|
-
startLocation: WonderlandTrailLocations.sunriseVisitorCenter,
|
|
7132
|
-
endLocation: WonderlandTrailLocations.whiteRiver,
|
|
7133
|
-
distanceMiles: 3.1,
|
|
7134
|
-
ascentFeet: 0,
|
|
7135
|
-
descentFeet: 2200
|
|
7136
|
-
});
|
|
7137
|
-
}
|
|
7138
|
-
iterateConnections(startLocationOrProperties, endLocation, direction) {
|
|
7139
|
-
let startLocation;
|
|
7140
|
-
if (isWonderlandTrailLocation(startLocationOrProperties)) {
|
|
7141
|
-
startLocation = startLocationOrProperties;
|
|
7142
|
-
} else if (startLocationOrProperties) {
|
|
7143
|
-
startLocation = startLocationOrProperties.startLocation;
|
|
7144
|
-
endLocation = startLocationOrProperties.endLocation;
|
|
7145
|
-
direction = startLocationOrProperties.direction;
|
|
7146
|
-
}
|
|
7147
|
-
let result;
|
|
7148
|
-
if (!startLocation) {
|
|
7149
|
-
result = this.connections.iterateValues().flatMap((x) => x);
|
|
7150
|
-
} else {
|
|
7151
|
-
result = this.connections.get(startLocation).catch(NotFoundError, () => Iterable.create()).await().iterate();
|
|
7152
|
-
}
|
|
7153
|
-
if (endLocation) {
|
|
7154
|
-
result = result.where((connection) => connection.endLocation == endLocation);
|
|
7155
|
-
}
|
|
7156
|
-
if (direction != null) {
|
|
7157
|
-
result = result.where((connection) => connection.direction == direction);
|
|
5090
|
+
getArguments() {
|
|
5091
|
+
if (!this.args) {
|
|
5092
|
+
this.args = process.argv;
|
|
7158
5093
|
}
|
|
7159
|
-
return
|
|
5094
|
+
return this.args;
|
|
7160
5095
|
}
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
addConnection(connectionStartLocationOrProperties, addReverseConnectionOrEndLocation, distanceMiles, ascentFeet, descentFeet, direction, intermediateLocations, addReverseConnection) {
|
|
7166
|
-
let startLocation;
|
|
7167
|
-
let endLocation;
|
|
7168
|
-
if (isWonderlandTrailLocation(connectionStartLocationOrProperties)) {
|
|
7169
|
-
startLocation = connectionStartLocationOrProperties;
|
|
7170
|
-
} else if (connectionStartLocationOrProperties instanceof WonderlandTrailConnection) {
|
|
7171
|
-
startLocation = connectionStartLocationOrProperties.startLocation;
|
|
7172
|
-
endLocation = connectionStartLocationOrProperties.endLocation;
|
|
7173
|
-
distanceMiles = connectionStartLocationOrProperties.distanceMiles;
|
|
7174
|
-
ascentFeet = connectionStartLocationOrProperties.ascentFeet;
|
|
7175
|
-
descentFeet = connectionStartLocationOrProperties.descentFeet;
|
|
7176
|
-
direction = connectionStartLocationOrProperties.direction;
|
|
7177
|
-
intermediateLocations = connectionStartLocationOrProperties.intermediateLocations;
|
|
7178
|
-
addReverseConnection = !!addReverseConnectionOrEndLocation;
|
|
7179
|
-
} else {
|
|
7180
|
-
startLocation = connectionStartLocationOrProperties.startLocation;
|
|
7181
|
-
endLocation = connectionStartLocationOrProperties.endLocation;
|
|
7182
|
-
distanceMiles = connectionStartLocationOrProperties.distanceMiles;
|
|
7183
|
-
ascentFeet = connectionStartLocationOrProperties.ascentFeet;
|
|
7184
|
-
descentFeet = connectionStartLocationOrProperties.descentFeet;
|
|
7185
|
-
direction = connectionStartLocationOrProperties.direction;
|
|
7186
|
-
intermediateLocations = connectionStartLocationOrProperties.intermediateLocations;
|
|
7187
|
-
addReverseConnection = connectionStartLocationOrProperties.addReverseConnection;
|
|
7188
|
-
}
|
|
7189
|
-
const connection = WonderlandTrailConnection.create(
|
|
7190
|
-
startLocation,
|
|
7191
|
-
endLocation,
|
|
7192
|
-
distanceMiles,
|
|
7193
|
-
ascentFeet,
|
|
7194
|
-
descentFeet,
|
|
7195
|
-
direction ?? WonderlandTrailDirection.clockwise,
|
|
7196
|
-
intermediateLocations ?? Iterable.create()
|
|
7197
|
-
);
|
|
7198
|
-
this.addConnectionInner(connection);
|
|
7199
|
-
if (addReverseConnection ?? this.addReverseConnectionDefault) {
|
|
7200
|
-
this.addConnectionInner(connection.reverseDirection());
|
|
7201
|
-
}
|
|
5096
|
+
setArguments(args) {
|
|
5097
|
+
PreCondition.assertNotUndefinedAndNotNull(args, "args");
|
|
5098
|
+
PreCondition.assertUndefined(this.parameters, "this.parameters");
|
|
5099
|
+
this.args = args;
|
|
7202
5100
|
return this;
|
|
7203
5101
|
}
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
return startLocationConnections?.contains(connection)?.await() === true;
|
|
7208
|
-
}
|
|
7209
|
-
reverseDirection() {
|
|
7210
|
-
const result = _WonderlandTrailConnections.create(this.addReverseConnectionDefault);
|
|
7211
|
-
for (const connection of this.iterateConnections()) {
|
|
7212
|
-
result.addConnection(connection.reverseDirection());
|
|
7213
|
-
}
|
|
7214
|
-
return result;
|
|
7215
|
-
}
|
|
7216
|
-
expandConnections(startLocation, endLocation, direction) {
|
|
7217
|
-
if (isUndefinedOrNull(direction)) {
|
|
7218
|
-
direction = WonderlandTrailDirection.clockwise;
|
|
7219
|
-
}
|
|
7220
|
-
const result = _WonderlandTrailConnections.create(this.addReverseConnectionDefault);
|
|
7221
|
-
const toVisit = Stack.create();
|
|
7222
|
-
toVisit.addAll(this.iterateConnections(startLocation, void 0, direction));
|
|
7223
|
-
while (toVisit.any().await()) {
|
|
7224
|
-
const currentConnection = toVisit.remove().await();
|
|
7225
|
-
result.addConnection(currentConnection, false);
|
|
7226
|
-
if (!currentConnection.isLoop() && currentConnection.endLocation !== endLocation) {
|
|
7227
|
-
for (const endLocationConnection of this.iterateConnections(currentConnection.endLocation, void 0, direction)) {
|
|
7228
|
-
if (!result.containsConnection(endLocationConnection) && !toVisit.contains(endLocationConnection)) {
|
|
7229
|
-
toVisit.add(endLocationConnection);
|
|
7230
|
-
}
|
|
7231
|
-
if (!currentConnection.intermediateLocations.contains(endLocationConnection.endLocation)) {
|
|
7232
|
-
toVisit.add(currentConnection.join(endLocationConnection));
|
|
7233
|
-
}
|
|
7234
|
-
}
|
|
7235
|
-
}
|
|
5102
|
+
getParameters() {
|
|
5103
|
+
if (!this.parameters) {
|
|
5104
|
+
this.parameters = CommandLineParameters.create(this.getArguments());
|
|
7236
5105
|
}
|
|
7237
|
-
return
|
|
5106
|
+
return this.parameters;
|
|
7238
5107
|
}
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
connections;
|
|
7243
|
-
availabilityTypes;
|
|
7244
|
-
constructor(startDay) {
|
|
7245
|
-
PreCondition.assertNotUndefinedAndNotNull(startDay, "startDay");
|
|
7246
|
-
this.startDay = startDay;
|
|
7247
|
-
this.connections = List.create();
|
|
7248
|
-
this.availabilityTypes = List.create();
|
|
7249
|
-
}
|
|
7250
|
-
static create(startDay) {
|
|
7251
|
-
return new _WonderlandTrailItinerary(startDay);
|
|
7252
|
-
}
|
|
7253
|
-
clone() {
|
|
7254
|
-
return _WonderlandTrailItinerary.create(this.startDay).addConnections(this.connections).addAvailabilityTypes(this.availabilityTypes);
|
|
7255
|
-
}
|
|
7256
|
-
getConnections() {
|
|
7257
|
-
return this.connections;
|
|
7258
|
-
}
|
|
7259
|
-
getEndDay() {
|
|
7260
|
-
return this.startDay.addDays(this.getDayCount() - 1);
|
|
7261
|
-
}
|
|
7262
|
-
getDayCount() {
|
|
7263
|
-
return this.connections.getCount().await();
|
|
7264
|
-
}
|
|
7265
|
-
getStartLocation() {
|
|
7266
|
-
return this.connections.first().then((firstConnection) => firstConnection.startLocation);
|
|
7267
|
-
}
|
|
7268
|
-
getIntermediateLocations() {
|
|
7269
|
-
const result = List.create();
|
|
7270
|
-
for (const connection of this.connections) {
|
|
7271
|
-
if (result.any().await()) {
|
|
7272
|
-
result.add(connection.startLocation);
|
|
7273
|
-
}
|
|
7274
|
-
result.addAll(connection.intermediateLocations);
|
|
5108
|
+
getOutputWriteStream() {
|
|
5109
|
+
if (!this.outputWriteStream) {
|
|
5110
|
+
this.outputWriteStream = NodeJSCharacterWriteStream.create(process.stdout);
|
|
7275
5111
|
}
|
|
7276
|
-
return
|
|
7277
|
-
}
|
|
7278
|
-
getEndLocation() {
|
|
7279
|
-
return this.connections.last().then((lastConnection) => lastConnection.endLocation);
|
|
5112
|
+
return this.outputWriteStream;
|
|
7280
5113
|
}
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
result.add(connection.startLocation);
|
|
7286
|
-
}
|
|
7287
|
-
result.add(connection.endLocation);
|
|
7288
|
-
}
|
|
7289
|
-
return result;
|
|
5114
|
+
setOutputWriteStream(outputWriteStream) {
|
|
5115
|
+
PreCondition.assertNotUndefinedAndNotNull(outputWriteStream, "outputWriteStream");
|
|
5116
|
+
this.outputWriteStream = outputWriteStream;
|
|
5117
|
+
return this;
|
|
7290
5118
|
}
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
const result = List.create();
|
|
7294
|
-
let availabilityTypeIndex = 0;
|
|
7295
|
-
const availabilityTypeCount = this.availabilityTypes.getCount().await();
|
|
7296
|
-
for (const connection of this.connections) {
|
|
7297
|
-
if (!result.any().await()) {
|
|
7298
|
-
result.add(connection.startLocation.name);
|
|
7299
|
-
}
|
|
7300
|
-
let pathString = connection.endLocation.name;
|
|
7301
|
-
if (includeAvailabilityTypes && availabilityTypeIndex < availabilityTypeCount) {
|
|
7302
|
-
pathString += " ";
|
|
7303
|
-
const availabilityType = this.availabilityTypes.get(availabilityTypeIndex).await();
|
|
7304
|
-
availabilityTypeIndex++;
|
|
7305
|
-
if (availabilityType.individualSite !== void 0) {
|
|
7306
|
-
if (availabilityType.groupSite !== void 0) {
|
|
7307
|
-
pathString += `(Individual ${availabilityType.individualSite}/Group ${availabilityType.groupSite})`;
|
|
7308
|
-
} else {
|
|
7309
|
-
pathString += `(Individual ${availabilityType.individualSite})`;
|
|
7310
|
-
}
|
|
7311
|
-
} else {
|
|
7312
|
-
pathString += `(Group ${availabilityType.groupSite})`;
|
|
7313
|
-
}
|
|
7314
|
-
}
|
|
7315
|
-
result.add(pathString);
|
|
7316
|
-
}
|
|
7317
|
-
return result;
|
|
5119
|
+
getExitCode() {
|
|
5120
|
+
return this.getExitCodeProperty().getValue();
|
|
7318
5121
|
}
|
|
7319
|
-
|
|
7320
|
-
PreCondition.assertNotUndefinedAndNotNull(
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
const checkItineraryIntermediateLocations = parameters.checkItineraryIntermediateLocations ?? true;
|
|
7324
|
-
const checkItineraryEndLocation = parameters.checkItineraryEndLocation ?? true;
|
|
7325
|
-
PreCondition.assertNotUndefinedAndNotNull(location, "location");
|
|
7326
|
-
let result = false;
|
|
7327
|
-
const connectionCount = this.connections.getCount().await();
|
|
7328
|
-
for (let i = 0; i < connectionCount; i++) {
|
|
7329
|
-
if (i !== 0 || checkItineraryStartLocation) {
|
|
7330
|
-
result = this.connections.get(i).await().startLocation === location;
|
|
7331
|
-
if (result) {
|
|
7332
|
-
break;
|
|
7333
|
-
}
|
|
7334
|
-
}
|
|
7335
|
-
if (checkItineraryIntermediateLocations) {
|
|
7336
|
-
result = this.connections.get(i).await().intermediateLocations.contains(location).await();
|
|
7337
|
-
if (result) {
|
|
7338
|
-
break;
|
|
7339
|
-
}
|
|
7340
|
-
}
|
|
7341
|
-
if (i === connectionCount - 1 && checkItineraryEndLocation) {
|
|
7342
|
-
result = this.connections.get(i).await().endLocation === location;
|
|
7343
|
-
if (result) {
|
|
7344
|
-
break;
|
|
7345
|
-
}
|
|
7346
|
-
}
|
|
7347
|
-
}
|
|
7348
|
-
return result;
|
|
5122
|
+
setExitCode(exitCode) {
|
|
5123
|
+
PreCondition.assertNotUndefinedAndNotNull(exitCode, "exitCode");
|
|
5124
|
+
this.getExitCodeProperty().setValue(exitCode);
|
|
5125
|
+
return this;
|
|
7349
5126
|
}
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
const checkItineraryStartLocation = parameters.checkItineraryStartLocation ?? true;
|
|
7357
|
-
const checkItineraryIntermediateLocations = parameters.checkItineraryIntermediateLocations ?? true;
|
|
7358
|
-
const checkItineraryEndLocation = parameters.checkItineraryEndLocation ?? true;
|
|
7359
|
-
PreCondition.assertNotUndefinedAndNotNull(connection, "connection");
|
|
7360
|
-
let result = false;
|
|
7361
|
-
if (!result && checkConnectionStartLocation) {
|
|
7362
|
-
result = this.contains({
|
|
7363
|
-
location: connection.startLocation,
|
|
7364
|
-
checkItineraryStartLocation,
|
|
7365
|
-
checkItineraryIntermediateLocations,
|
|
7366
|
-
checkItineraryEndLocation
|
|
7367
|
-
});
|
|
7368
|
-
}
|
|
7369
|
-
if (!result && checkConnectionIntermediateLocations) {
|
|
7370
|
-
for (const connectionIntermediateLocation of connection.intermediateLocations) {
|
|
7371
|
-
result = this.contains({
|
|
7372
|
-
location: connectionIntermediateLocation,
|
|
7373
|
-
checkItineraryStartLocation,
|
|
7374
|
-
checkItineraryIntermediateLocations,
|
|
7375
|
-
checkItineraryEndLocation
|
|
7376
|
-
});
|
|
7377
|
-
if (result) {
|
|
7378
|
-
break;
|
|
5127
|
+
getExitCodeProperty() {
|
|
5128
|
+
if (!this.exitCodeProperty) {
|
|
5129
|
+
this.exitCodeProperty = Property.create({
|
|
5130
|
+
getter: () => process.exitCode,
|
|
5131
|
+
setter: (value) => {
|
|
5132
|
+
process.exitCode = value;
|
|
7379
5133
|
}
|
|
7380
|
-
}
|
|
7381
|
-
}
|
|
7382
|
-
if (!result && checkConnectionEndLocation) {
|
|
7383
|
-
result = this.contains({
|
|
7384
|
-
location: connection.endLocation,
|
|
7385
|
-
checkItineraryStartLocation,
|
|
7386
|
-
checkItineraryIntermediateLocations,
|
|
7387
|
-
checkItineraryEndLocation
|
|
7388
5134
|
});
|
|
7389
5135
|
}
|
|
7390
|
-
return
|
|
7391
|
-
}
|
|
7392
|
-
addConnection(connection) {
|
|
7393
|
-
PreCondition.assertNotUndefinedAndNotNull(connection, "connection");
|
|
7394
|
-
this.connections.add(connection);
|
|
7395
|
-
return this;
|
|
5136
|
+
return this.exitCodeProperty;
|
|
7396
5137
|
}
|
|
7397
|
-
|
|
7398
|
-
PreCondition.assertNotUndefinedAndNotNull(
|
|
7399
|
-
this.
|
|
5138
|
+
setExitCodeProperty(exitCodeProperty) {
|
|
5139
|
+
PreCondition.assertNotUndefinedAndNotNull(exitCodeProperty, "exitCodeProperty");
|
|
5140
|
+
this.exitCodeProperty = exitCodeProperty;
|
|
7400
5141
|
return this;
|
|
7401
5142
|
}
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
5143
|
+
getNetwork() {
|
|
5144
|
+
if (!this.network) {
|
|
5145
|
+
this.network = RealNetwork.create();
|
|
5146
|
+
}
|
|
5147
|
+
return this.network;
|
|
7406
5148
|
}
|
|
7407
|
-
|
|
7408
|
-
PreCondition.
|
|
7409
|
-
|
|
5149
|
+
setNetwork(network) {
|
|
5150
|
+
PreCondition.assertUndefined(this.network, "this.network");
|
|
5151
|
+
PreCondition.assertNotUndefinedAndNotNull(network, "network");
|
|
5152
|
+
this.network = network;
|
|
7410
5153
|
return this;
|
|
7411
5154
|
}
|
|
7412
|
-
toString(includeAvailabilityTypes) {
|
|
7413
|
-
includeAvailabilityTypes = includeAvailabilityTypes ?? true;
|
|
7414
|
-
return `startDay:${this.startDay.toDateString()},path:${this.getPathStrings(includeAvailabilityTypes)}`;
|
|
7415
|
-
}
|
|
7416
5155
|
};
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
year = year;
|
|
7440
|
-
allowWalkupPermits = allowWalkupPermits;
|
|
7441
|
-
allowIndividualSites = allowIndividualSites;
|
|
7442
|
-
allowGroupSites = allowGroupSites;
|
|
7443
|
-
} else {
|
|
7444
|
-
month = monthOrOptions.month;
|
|
7445
|
-
year = monthOrOptions.year;
|
|
7446
|
-
allowWalkupPermits = monthOrOptions.allowWalkupPermits;
|
|
7447
|
-
allowIndividualSites = monthOrOptions.allowIndividualSites;
|
|
7448
|
-
allowGroupSites = monthOrOptions.allowGroupSites;
|
|
7449
|
-
earlyAccessPermitLotteryId = monthOrOptions.earlyAccessPermitLotteryId;
|
|
7450
|
-
}
|
|
7451
|
-
return PromiseAsyncResult.create(async () => {
|
|
7452
|
-
const result = WonderlandTrailAvailability.create();
|
|
7453
|
-
for (const location of WonderlandTrailLocations.getLocations()) {
|
|
7454
|
-
if (allowIndividualSites && location.divisionId) {
|
|
7455
|
-
const divisionAvailability = await this.recreationDotGovClient.getDivisionAvailability(
|
|
7456
|
-
_WonderlandTrailClient.permitItineraryId,
|
|
7457
|
-
location.divisionId,
|
|
7458
|
-
month,
|
|
7459
|
-
year,
|
|
7460
|
-
earlyAccessPermitLotteryId
|
|
7461
|
-
);
|
|
7462
|
-
const divisionDayAvailabilities = divisionAvailability.dayAvailabilities;
|
|
7463
|
-
if (divisionDayAvailabilities) {
|
|
7464
|
-
for (const divisionDayAvailability of divisionDayAvailabilities) {
|
|
7465
|
-
const hasWalkupPermits = allowWalkupPermits && divisionDayAvailability.walkup;
|
|
7466
|
-
const hasReservationPermits = divisionDayAvailability.reservationsRemaining > 0;
|
|
7467
|
-
if (hasWalkupPermits || hasReservationPermits) {
|
|
7468
|
-
result.addAvailability(
|
|
7469
|
-
location,
|
|
7470
|
-
divisionDayAvailability.date,
|
|
7471
|
-
hasWalkupPermits ? 1 /* Walkup */ : 0 /* Reserved */,
|
|
7472
|
-
void 0
|
|
7473
|
-
);
|
|
7474
|
-
}
|
|
7475
|
-
}
|
|
7476
|
-
}
|
|
7477
|
-
}
|
|
7478
|
-
if (allowGroupSites && location.groupSiteDivisionId) {
|
|
7479
|
-
const groupSiteDivisionAvailability = await this.recreationDotGovClient.getDivisionAvailability(
|
|
7480
|
-
_WonderlandTrailClient.permitItineraryId,
|
|
7481
|
-
location.groupSiteDivisionId,
|
|
7482
|
-
month,
|
|
7483
|
-
year,
|
|
7484
|
-
earlyAccessPermitLotteryId
|
|
7485
|
-
);
|
|
7486
|
-
const groupSiteDivisionDayAvailabilities = groupSiteDivisionAvailability.dayAvailabilities;
|
|
7487
|
-
if (groupSiteDivisionDayAvailabilities) {
|
|
7488
|
-
for (const groupSiteDayAvailability of groupSiteDivisionDayAvailabilities) {
|
|
7489
|
-
const hasWalkupPermits = allowWalkupPermits && groupSiteDayAvailability.walkup;
|
|
7490
|
-
const hasReservationPermits = groupSiteDayAvailability.reservationsRemaining > 0;
|
|
7491
|
-
if (hasWalkupPermits || hasReservationPermits) {
|
|
7492
|
-
result.addAvailability(
|
|
7493
|
-
location,
|
|
7494
|
-
groupSiteDayAvailability.date,
|
|
7495
|
-
void 0,
|
|
7496
|
-
hasWalkupPermits ? 1 /* Walkup */ : 0 /* Reserved */
|
|
7497
|
-
);
|
|
7498
|
-
}
|
|
7499
|
-
}
|
|
7500
|
-
}
|
|
7501
|
-
}
|
|
7502
|
-
}
|
|
7503
|
-
return result;
|
|
7504
|
-
});
|
|
7505
|
-
}
|
|
7506
|
-
findItineraries(parameters) {
|
|
7507
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
7508
|
-
const availability = parameters.availability;
|
|
7509
|
-
const startDate = parameters.startDate;
|
|
7510
|
-
const startLocation = parameters.startLocation;
|
|
7511
|
-
const endLocation = parameters.endLocation;
|
|
7512
|
-
const direction = parameters.direction;
|
|
7513
|
-
const maximumDayDistanceMiles = parameters.maximumDayDistanceMiles;
|
|
7514
|
-
const maximumItineraryDays = parameters.maximumItineraryDays;
|
|
7515
|
-
const campsitesToAvoid = Iterable.create(parameters.campsitesToAvoid ?? []);
|
|
7516
|
-
const result = List.create();
|
|
7517
|
-
const connections = WonderlandTrailConnections.createDefault().expandConnections(startLocation, endLocation, direction);
|
|
7518
|
-
let startLocationConnections = connections.iterateConnections(startLocation, void 0, direction);
|
|
7519
|
-
if (!isUndefinedOrNull(maximumDayDistanceMiles)) {
|
|
7520
|
-
startLocationConnections = startLocationConnections.where((connection) => connection.distanceMiles <= maximumDayDistanceMiles);
|
|
7521
|
-
}
|
|
7522
|
-
const possibleItineraries = Stack.create();
|
|
7523
|
-
possibleItineraries.addAll(startLocationConnections.map((c) => WonderlandTrailItinerary.create(startDate).addConnection(c)));
|
|
7524
|
-
while (possibleItineraries.any().await()) {
|
|
7525
|
-
const currentItinerary = possibleItineraries.remove().await();
|
|
7526
|
-
const currentItineraryEndLocation = currentItinerary.getEndLocation().await();
|
|
7527
|
-
if ((maximumItineraryDays === void 0 || currentItinerary.getDayCount() <= maximumItineraryDays) && (startLocation === currentItineraryEndLocation || endLocation === currentItineraryEndLocation || !campsitesToAvoid.contains(currentItineraryEndLocation).await())) {
|
|
7528
|
-
if (currentItineraryEndLocation === endLocation) {
|
|
7529
|
-
result.add(currentItinerary);
|
|
7530
|
-
} else {
|
|
7531
|
-
const dayAvailability = availability.getDayAvailability(currentItineraryEndLocation, currentItinerary.getEndDay()).catch(() => void 0).await();
|
|
7532
|
-
if (dayAvailability) {
|
|
7533
|
-
currentItinerary.addAvailabilityType(dayAvailability);
|
|
7534
|
-
for (const nextDayConnection of connections.iterateConnections(currentItineraryEndLocation, void 0, direction)) {
|
|
7535
|
-
if (!currentItinerary.containsAny({
|
|
7536
|
-
connection: nextDayConnection,
|
|
7537
|
-
checkConnectionStartLocation: false,
|
|
7538
|
-
checkItineraryStartLocation: false,
|
|
7539
|
-
checkItineraryEndLocation: false
|
|
7540
|
-
})) {
|
|
7541
|
-
if (maximumDayDistanceMiles === void 0 || nextDayConnection.distanceMiles <= maximumDayDistanceMiles) {
|
|
7542
|
-
possibleItineraries.add(currentItinerary.clone().addConnection(nextDayConnection));
|
|
7543
|
-
}
|
|
7544
|
-
}
|
|
7545
|
-
}
|
|
7546
|
-
}
|
|
5156
|
+
|
|
5157
|
+
// sources/english.ts
|
|
5158
|
+
function andList(values) {
|
|
5159
|
+
return list("and", values);
|
|
5160
|
+
}
|
|
5161
|
+
function orList(values) {
|
|
5162
|
+
return list("or", values);
|
|
5163
|
+
}
|
|
5164
|
+
function list(conjunction, values) {
|
|
5165
|
+
PreCondition.assertNotEmpty(conjunction, "conjunction");
|
|
5166
|
+
PreCondition.assertNotUndefinedAndNotNull(values, "values");
|
|
5167
|
+
let result = "";
|
|
5168
|
+
let index = 0;
|
|
5169
|
+
const iterator = Iterator.create(values).start().await();
|
|
5170
|
+
while (iterator.hasCurrent()) {
|
|
5171
|
+
const currentValue = iterator.takeCurrent().await();
|
|
5172
|
+
if (index >= 1) {
|
|
5173
|
+
if (iterator.hasCurrent()) {
|
|
5174
|
+
result += `, `;
|
|
5175
|
+
} else {
|
|
5176
|
+
if (index >= 2) {
|
|
5177
|
+
result += `,`;
|
|
7547
5178
|
}
|
|
5179
|
+
result += ` ${conjunction} `;
|
|
7548
5180
|
}
|
|
7549
5181
|
}
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
findItinerariesAsync(parameters) {
|
|
7553
|
-
PreCondition.assertNotUndefinedAndNotNull(parameters, "parameters");
|
|
7554
|
-
const startDay = parameters.startDay;
|
|
7555
|
-
const startLocation = parameters.startLocation;
|
|
7556
|
-
const endLocation = parameters.endLocation;
|
|
7557
|
-
const direction = parameters.direction;
|
|
7558
|
-
const maximumDayDistanceMiles = parameters.maximumDayDistanceMiles;
|
|
7559
|
-
const maximumItineraryDays = parameters.maximumItineraryDays;
|
|
7560
|
-
const allowWalkupPermits = parameters.allowWalkupPermits ?? true;
|
|
7561
|
-
const allowIndividualSites = parameters.allowIndividualSites ?? true;
|
|
7562
|
-
const allowGroupSites = parameters.allowGroupSites ?? false;
|
|
7563
|
-
const campsitesToAvoid = parameters.campsitesToAvoid ?? [];
|
|
7564
|
-
PreCondition.assertNotUndefinedAndNotNull(startDay, "startDay");
|
|
7565
|
-
return PromiseAsyncResult.create(async () => {
|
|
7566
|
-
const result = List.create();
|
|
7567
|
-
const startLocationsToCheck = !isUndefinedOrNull(startLocation) ? Iterable.create([startLocation]) : WonderlandTrailLocations.getTrailheads();
|
|
7568
|
-
const directionsToCheck = !isUndefinedOrNull(direction) ? Iterable.create([direction]) : Iterable.create([WonderlandTrailDirection.clockwise, WonderlandTrailDirection.counterClockwise]);
|
|
7569
|
-
const availability = await this.getAvailability(
|
|
7570
|
-
startDay.getMonth(),
|
|
7571
|
-
startDay.getYear(),
|
|
7572
|
-
allowWalkupPermits,
|
|
7573
|
-
allowIndividualSites,
|
|
7574
|
-
allowGroupSites
|
|
7575
|
-
);
|
|
7576
|
-
for (const startLocationToCheck of startLocationsToCheck) {
|
|
7577
|
-
for (const directionToCheck of directionsToCheck) {
|
|
7578
|
-
result.addAll(this.findItineraries({
|
|
7579
|
-
availability,
|
|
7580
|
-
startDate: startDay,
|
|
7581
|
-
startLocation: startLocationToCheck,
|
|
7582
|
-
endLocation: endLocation ?? startLocationToCheck,
|
|
7583
|
-
direction: directionToCheck,
|
|
7584
|
-
maximumDayDistanceMiles,
|
|
7585
|
-
maximumItineraryDays,
|
|
7586
|
-
campsitesToAvoid
|
|
7587
|
-
}));
|
|
7588
|
-
}
|
|
7589
|
-
}
|
|
7590
|
-
return result;
|
|
7591
|
-
});
|
|
5182
|
+
result += currentValue;
|
|
5183
|
+
index++;
|
|
7592
5184
|
}
|
|
7593
|
-
|
|
5185
|
+
return result;
|
|
5186
|
+
}
|
|
7594
5187
|
|
|
7595
5188
|
export {
|
|
7596
5189
|
__export,
|
|
@@ -7681,16 +5274,9 @@ export {
|
|
|
7681
5274
|
MutableCondition,
|
|
7682
5275
|
PreConditionError,
|
|
7683
5276
|
PreCondition,
|
|
7684
|
-
SyncDisposable,
|
|
7685
|
-
ByteList,
|
|
7686
|
-
ByteListStream,
|
|
7687
|
-
StringIterator,
|
|
7688
|
-
CharacterList,
|
|
7689
|
-
CharacterReadStream,
|
|
7690
5277
|
PostConditionError,
|
|
7691
5278
|
PostCondition,
|
|
7692
5279
|
CharacterWriteStream,
|
|
7693
|
-
CharacterListStream,
|
|
7694
5280
|
CommandLineParameters,
|
|
7695
5281
|
NodeJSCharacterWriteStream,
|
|
7696
5282
|
Property,
|
|
@@ -7710,32 +5296,7 @@ export {
|
|
|
7710
5296
|
NodeJSHttpServer,
|
|
7711
5297
|
RealNetwork,
|
|
7712
5298
|
CurrentProcess,
|
|
7713
|
-
LuxonDateTime,
|
|
7714
|
-
DateTime,
|
|
7715
|
-
ListStack,
|
|
7716
|
-
Stack,
|
|
7717
|
-
depthFirstSearch,
|
|
7718
|
-
Disposable,
|
|
7719
5299
|
andList,
|
|
7720
|
-
orList
|
|
7721
|
-
Generator,
|
|
7722
|
-
HttpClient,
|
|
7723
|
-
InMemoryCharacterWriteStream,
|
|
7724
|
-
ListQueue,
|
|
7725
|
-
Node,
|
|
7726
|
-
Queue,
|
|
7727
|
-
RecreationDotGovDivisionAvailability,
|
|
7728
|
-
RecreationDotGovError,
|
|
7729
|
-
RecreationDotGovClient,
|
|
7730
|
-
StringComparer,
|
|
7731
|
-
isWonderlandTrailLocation,
|
|
7732
|
-
WonderlandTrailLocations,
|
|
7733
|
-
WonderlandTrailReservationType,
|
|
7734
|
-
WonderlandTrailAvailability,
|
|
7735
|
-
WonderlandTrailDirection,
|
|
7736
|
-
WonderlandTrailConnection,
|
|
7737
|
-
WonderlandTrailConnections,
|
|
7738
|
-
WonderlandTrailItinerary,
|
|
7739
|
-
WonderlandTrailClient
|
|
5300
|
+
orList
|
|
7740
5301
|
};
|
|
7741
|
-
//# sourceMappingURL=chunk-
|
|
5302
|
+
//# sourceMappingURL=chunk-5Z677JON.js.map
|