@exodus/xqa 5.5.0 → 7.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.
@@ -0,0 +1,547 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.cjs.js
28
+ var require_index_cjs = __commonJS({
29
+ "../../node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.cjs.js"(exports) {
30
+ "use strict";
31
+ var defaultErrorConfig = {
32
+ withStackTrace: false
33
+ };
34
+ var createNeverThrowError = (message, result, config = defaultErrorConfig) => {
35
+ const data = result.isOk() ? { type: "Ok", value: result.value } : { type: "Err", value: result.error };
36
+ const maybeStack = config.withStackTrace ? new Error().stack : void 0;
37
+ return {
38
+ data,
39
+ message,
40
+ stack: maybeStack
41
+ };
42
+ };
43
+ function __awaiter(thisArg, _arguments, P, generator) {
44
+ function adopt(value) {
45
+ return value instanceof P ? value : new P(function(resolve) {
46
+ resolve(value);
47
+ });
48
+ }
49
+ return new (P || (P = Promise))(function(resolve, reject) {
50
+ function fulfilled(value) {
51
+ try {
52
+ step(generator.next(value));
53
+ } catch (e) {
54
+ reject(e);
55
+ }
56
+ }
57
+ function rejected(value) {
58
+ try {
59
+ step(generator["throw"](value));
60
+ } catch (e) {
61
+ reject(e);
62
+ }
63
+ }
64
+ function step(result) {
65
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
66
+ }
67
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
68
+ });
69
+ }
70
+ function __values(o) {
71
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
72
+ if (m) return m.call(o);
73
+ if (o && typeof o.length === "number") return {
74
+ next: function() {
75
+ if (o && i >= o.length) o = void 0;
76
+ return { value: o && o[i++], done: !o };
77
+ }
78
+ };
79
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
80
+ }
81
+ function __await(v) {
82
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
83
+ }
84
+ function __asyncGenerator(thisArg, _arguments, generator) {
85
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
86
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
87
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
88
+ return this;
89
+ }, i;
90
+ function awaitReturn(f) {
91
+ return function(v) {
92
+ return Promise.resolve(v).then(f, reject);
93
+ };
94
+ }
95
+ function verb(n, f) {
96
+ if (g[n]) {
97
+ i[n] = function(v) {
98
+ return new Promise(function(a, b) {
99
+ q.push([n, v, a, b]) > 1 || resume(n, v);
100
+ });
101
+ };
102
+ if (f) i[n] = f(i[n]);
103
+ }
104
+ }
105
+ function resume(n, v) {
106
+ try {
107
+ step(g[n](v));
108
+ } catch (e) {
109
+ settle(q[0][3], e);
110
+ }
111
+ }
112
+ function step(r) {
113
+ r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
114
+ }
115
+ function fulfill(value) {
116
+ resume("next", value);
117
+ }
118
+ function reject(value) {
119
+ resume("throw", value);
120
+ }
121
+ function settle(f, v) {
122
+ if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
123
+ }
124
+ }
125
+ function __asyncDelegator(o) {
126
+ var i, p;
127
+ return i = {}, verb("next"), verb("throw", function(e) {
128
+ throw e;
129
+ }), verb("return"), i[Symbol.iterator] = function() {
130
+ return this;
131
+ }, i;
132
+ function verb(n, f) {
133
+ i[n] = o[n] ? function(v) {
134
+ return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v;
135
+ } : f;
136
+ }
137
+ }
138
+ function __asyncValues(o) {
139
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
140
+ var m = o[Symbol.asyncIterator], i;
141
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
142
+ return this;
143
+ }, i);
144
+ function verb(n) {
145
+ i[n] = o[n] && function(v) {
146
+ return new Promise(function(resolve, reject) {
147
+ v = o[n](v), settle(resolve, reject, v.done, v.value);
148
+ });
149
+ };
150
+ }
151
+ function settle(resolve, reject, d, v) {
152
+ Promise.resolve(v).then(function(v2) {
153
+ resolve({ value: v2, done: d });
154
+ }, reject);
155
+ }
156
+ }
157
+ var ResultAsync2 = class _ResultAsync {
158
+ constructor(res) {
159
+ this._promise = res;
160
+ }
161
+ static fromSafePromise(promise) {
162
+ const newPromise = promise.then((value) => new Ok(value));
163
+ return new _ResultAsync(newPromise);
164
+ }
165
+ static fromPromise(promise, errorFn) {
166
+ const newPromise = promise.then((value) => new Ok(value)).catch((e) => new Err(errorFn(e)));
167
+ return new _ResultAsync(newPromise);
168
+ }
169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
170
+ static fromThrowable(fn, errorFn) {
171
+ return (...args) => {
172
+ return new _ResultAsync((() => __awaiter(this, void 0, void 0, function* () {
173
+ try {
174
+ return new Ok(yield fn(...args));
175
+ } catch (error) {
176
+ return new Err(errorFn ? errorFn(error) : error);
177
+ }
178
+ }))());
179
+ };
180
+ }
181
+ static combine(asyncResultList) {
182
+ return combineResultAsyncList(asyncResultList);
183
+ }
184
+ static combineWithAllErrors(asyncResultList) {
185
+ return combineResultAsyncListWithAllErrors(asyncResultList);
186
+ }
187
+ map(f) {
188
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
189
+ if (res.isErr()) {
190
+ return new Err(res.error);
191
+ }
192
+ return new Ok(yield f(res.value));
193
+ })));
194
+ }
195
+ andThrough(f) {
196
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
197
+ if (res.isErr()) {
198
+ return new Err(res.error);
199
+ }
200
+ const newRes = yield f(res.value);
201
+ if (newRes.isErr()) {
202
+ return new Err(newRes.error);
203
+ }
204
+ return new Ok(res.value);
205
+ })));
206
+ }
207
+ andTee(f) {
208
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
209
+ if (res.isErr()) {
210
+ return new Err(res.error);
211
+ }
212
+ try {
213
+ yield f(res.value);
214
+ } catch (e) {
215
+ }
216
+ return new Ok(res.value);
217
+ })));
218
+ }
219
+ orTee(f) {
220
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
221
+ if (res.isOk()) {
222
+ return new Ok(res.value);
223
+ }
224
+ try {
225
+ yield f(res.error);
226
+ } catch (e) {
227
+ }
228
+ return new Err(res.error);
229
+ })));
230
+ }
231
+ mapErr(f) {
232
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
233
+ if (res.isOk()) {
234
+ return new Ok(res.value);
235
+ }
236
+ return new Err(yield f(res.error));
237
+ })));
238
+ }
239
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
240
+ andThen(f) {
241
+ return new _ResultAsync(this._promise.then((res) => {
242
+ if (res.isErr()) {
243
+ return new Err(res.error);
244
+ }
245
+ const newValue = f(res.value);
246
+ return newValue instanceof _ResultAsync ? newValue._promise : newValue;
247
+ }));
248
+ }
249
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
250
+ orElse(f) {
251
+ return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
252
+ if (res.isErr()) {
253
+ return f(res.error);
254
+ }
255
+ return new Ok(res.value);
256
+ })));
257
+ }
258
+ match(ok3, _err) {
259
+ return this._promise.then((res) => res.match(ok3, _err));
260
+ }
261
+ unwrapOr(t) {
262
+ return this._promise.then((res) => res.unwrapOr(t));
263
+ }
264
+ /**
265
+ * @deprecated will be removed in 9.0.0.
266
+ *
267
+ * You can use `safeTry` without this method.
268
+ * @example
269
+ * ```typescript
270
+ * safeTry(async function* () {
271
+ * const okValue = yield* yourResult
272
+ * })
273
+ * ```
274
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
275
+ */
276
+ safeUnwrap() {
277
+ return __asyncGenerator(this, arguments, function* safeUnwrap_1() {
278
+ return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(yield __await(this._promise.then((res) => res.safeUnwrap()))))));
279
+ });
280
+ }
281
+ // Makes ResultAsync implement PromiseLike<Result>
282
+ then(successCallback, failureCallback) {
283
+ return this._promise.then(successCallback, failureCallback);
284
+ }
285
+ [Symbol.asyncIterator]() {
286
+ return __asyncGenerator(this, arguments, function* _a() {
287
+ const result = yield __await(this._promise);
288
+ if (result.isErr()) {
289
+ yield yield __await(errAsync2(result.error));
290
+ }
291
+ return yield __await(result.value);
292
+ });
293
+ }
294
+ };
295
+ function okAsync2(value) {
296
+ return new ResultAsync2(Promise.resolve(new Ok(value)));
297
+ }
298
+ function errAsync2(err3) {
299
+ return new ResultAsync2(Promise.resolve(new Err(err3)));
300
+ }
301
+ var fromPromise = ResultAsync2.fromPromise;
302
+ var fromSafePromise = ResultAsync2.fromSafePromise;
303
+ var fromAsyncThrowable = ResultAsync2.fromThrowable;
304
+ var combineResultList = (resultList) => {
305
+ let acc = ok2([]);
306
+ for (const result of resultList) {
307
+ if (result.isErr()) {
308
+ acc = err2(result.error);
309
+ break;
310
+ } else {
311
+ acc.map((list) => list.push(result.value));
312
+ }
313
+ }
314
+ return acc;
315
+ };
316
+ var combineResultAsyncList = (asyncResultList) => ResultAsync2.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
317
+ var combineResultListWithAllErrors = (resultList) => {
318
+ let acc = ok2([]);
319
+ for (const result of resultList) {
320
+ if (result.isErr() && acc.isErr()) {
321
+ acc.error.push(result.error);
322
+ } else if (result.isErr() && acc.isOk()) {
323
+ acc = err2([result.error]);
324
+ } else if (result.isOk() && acc.isOk()) {
325
+ acc.value.push(result.value);
326
+ }
327
+ }
328
+ return acc;
329
+ };
330
+ var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync2.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
331
+ exports.Result = void 0;
332
+ (function(Result2) {
333
+ function fromThrowable3(fn, errorFn) {
334
+ return (...args) => {
335
+ try {
336
+ const result = fn(...args);
337
+ return ok2(result);
338
+ } catch (e) {
339
+ return err2(errorFn ? errorFn(e) : e);
340
+ }
341
+ };
342
+ }
343
+ Result2.fromThrowable = fromThrowable3;
344
+ function combine(resultList) {
345
+ return combineResultList(resultList);
346
+ }
347
+ Result2.combine = combine;
348
+ function combineWithAllErrors(resultList) {
349
+ return combineResultListWithAllErrors(resultList);
350
+ }
351
+ Result2.combineWithAllErrors = combineWithAllErrors;
352
+ })(exports.Result || (exports.Result = {}));
353
+ function ok2(value) {
354
+ return new Ok(value);
355
+ }
356
+ function err2(err3) {
357
+ return new Err(err3);
358
+ }
359
+ function safeTry(body) {
360
+ const n = body().next();
361
+ if (n instanceof Promise) {
362
+ return new ResultAsync2(n.then((r) => r.value));
363
+ }
364
+ return n.value;
365
+ }
366
+ var Ok = class {
367
+ constructor(value) {
368
+ this.value = value;
369
+ }
370
+ isOk() {
371
+ return true;
372
+ }
373
+ isErr() {
374
+ return !this.isOk();
375
+ }
376
+ map(f) {
377
+ return ok2(f(this.value));
378
+ }
379
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
380
+ mapErr(_f) {
381
+ return ok2(this.value);
382
+ }
383
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
384
+ andThen(f) {
385
+ return f(this.value);
386
+ }
387
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
388
+ andThrough(f) {
389
+ return f(this.value).map((_value) => this.value);
390
+ }
391
+ andTee(f) {
392
+ try {
393
+ f(this.value);
394
+ } catch (e) {
395
+ }
396
+ return ok2(this.value);
397
+ }
398
+ orTee(_f) {
399
+ return ok2(this.value);
400
+ }
401
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
402
+ orElse(_f) {
403
+ return ok2(this.value);
404
+ }
405
+ asyncAndThen(f) {
406
+ return f(this.value);
407
+ }
408
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
409
+ asyncAndThrough(f) {
410
+ return f(this.value).map(() => this.value);
411
+ }
412
+ asyncMap(f) {
413
+ return ResultAsync2.fromSafePromise(f(this.value));
414
+ }
415
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
416
+ unwrapOr(_v) {
417
+ return this.value;
418
+ }
419
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
420
+ match(ok3, _err) {
421
+ return ok3(this.value);
422
+ }
423
+ safeUnwrap() {
424
+ const value = this.value;
425
+ return (function* () {
426
+ return value;
427
+ })();
428
+ }
429
+ _unsafeUnwrap(_) {
430
+ return this.value;
431
+ }
432
+ _unsafeUnwrapErr(config) {
433
+ throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
434
+ }
435
+ // eslint-disable-next-line @typescript-eslint/no-this-alias, require-yield
436
+ *[Symbol.iterator]() {
437
+ return this.value;
438
+ }
439
+ };
440
+ var Err = class {
441
+ constructor(error) {
442
+ this.error = error;
443
+ }
444
+ isOk() {
445
+ return false;
446
+ }
447
+ isErr() {
448
+ return !this.isOk();
449
+ }
450
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
451
+ map(_f) {
452
+ return err2(this.error);
453
+ }
454
+ mapErr(f) {
455
+ return err2(f(this.error));
456
+ }
457
+ andThrough(_f) {
458
+ return err2(this.error);
459
+ }
460
+ andTee(_f) {
461
+ return err2(this.error);
462
+ }
463
+ orTee(f) {
464
+ try {
465
+ f(this.error);
466
+ } catch (e) {
467
+ }
468
+ return err2(this.error);
469
+ }
470
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
471
+ andThen(_f) {
472
+ return err2(this.error);
473
+ }
474
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
475
+ orElse(f) {
476
+ return f(this.error);
477
+ }
478
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
479
+ asyncAndThen(_f) {
480
+ return errAsync2(this.error);
481
+ }
482
+ asyncAndThrough(_f) {
483
+ return errAsync2(this.error);
484
+ }
485
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
486
+ asyncMap(_f) {
487
+ return errAsync2(this.error);
488
+ }
489
+ unwrapOr(v) {
490
+ return v;
491
+ }
492
+ match(_ok, err3) {
493
+ return err3(this.error);
494
+ }
495
+ safeUnwrap() {
496
+ const error = this.error;
497
+ return (function* () {
498
+ yield err2(error);
499
+ throw new Error("Do not use this generator out of `safeTry`");
500
+ })();
501
+ }
502
+ _unsafeUnwrap(config) {
503
+ throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
504
+ }
505
+ _unsafeUnwrapErr(_) {
506
+ return this.error;
507
+ }
508
+ *[Symbol.iterator]() {
509
+ const self = this;
510
+ yield self;
511
+ return self;
512
+ }
513
+ };
514
+ var fromThrowable2 = exports.Result.fromThrowable;
515
+ exports.Err = Err;
516
+ exports.Ok = Ok;
517
+ exports.ResultAsync = ResultAsync2;
518
+ exports.err = err2;
519
+ exports.errAsync = errAsync2;
520
+ exports.fromAsyncThrowable = fromAsyncThrowable;
521
+ exports.fromPromise = fromPromise;
522
+ exports.fromSafePromise = fromSafePromise;
523
+ exports.fromThrowable = fromThrowable2;
524
+ exports.ok = ok2;
525
+ exports.okAsync = okAsync2;
526
+ exports.safeTry = safeTry;
527
+ }
528
+ });
529
+
530
+ // src/consumer-neverthrow.ts
531
+ var import_neverthrow = __toESM(require_index_cjs(), 1);
532
+ var export_Result = import_neverthrow.Result;
533
+ var export_ResultAsync = import_neverthrow.ResultAsync;
534
+ var export_err = import_neverthrow.err;
535
+ var export_errAsync = import_neverthrow.errAsync;
536
+ var export_fromThrowable = import_neverthrow.fromThrowable;
537
+ var export_ok = import_neverthrow.ok;
538
+ var export_okAsync = import_neverthrow.okAsync;
539
+ export {
540
+ export_Result as Result,
541
+ export_ResultAsync as ResultAsync,
542
+ export_err as err,
543
+ export_errAsync as errAsync,
544
+ export_fromThrowable as fromThrowable,
545
+ export_ok as ok,
546
+ export_okAsync as okAsync
547
+ };