@learncard/network-plugin 1.7.11 → 1.8.1

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.
@@ -25,7 +25,7 @@ __export(src_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(src_exports);
27
27
 
28
- // ../../../node_modules/.pnpm/@trpc+server@10.17.0/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
28
+ // ../../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
29
29
  function identity(x) {
30
30
  return x;
31
31
  }
@@ -104,7 +104,7 @@ function observable(subscribe) {
104
104
  }
105
105
  __name(observable, "observable");
106
106
 
107
- // ../../../node_modules/.pnpm/@trpc+server@10.17.0/node_modules/@trpc/server/dist/observable/index.mjs
107
+ // ../../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable/index.mjs
108
108
  function share(_opts) {
109
109
  return (originalObserver) => {
110
110
  let refCount = 0;
@@ -207,85 +207,7 @@ function observableToPromise(observable2) {
207
207
  }
208
208
  __name(observableToPromise, "observableToPromise");
209
209
 
210
- // ../../../node_modules/.pnpm/@trpc+client@10.17.0_@trpc+server@10.17.0/node_modules/@trpc/client/dist/transformResult-6fb67924.mjs
211
- var TRPCClientError = class extends Error {
212
- static from(cause, opts = {}) {
213
- if (!(cause instanceof Error)) {
214
- return new TRPCClientError(cause.error.message ?? "", {
215
- ...opts,
216
- cause: void 0,
217
- result: cause
218
- });
219
- }
220
- if (cause.name === "TRPCClientError") {
221
- return cause;
222
- }
223
- return new TRPCClientError(cause.message, {
224
- ...opts,
225
- cause,
226
- result: null
227
- });
228
- }
229
- constructor(message, opts) {
230
- const cause = opts?.cause;
231
- super(message, {
232
- cause
233
- });
234
- this.meta = opts?.meta;
235
- this.cause = cause;
236
- this.shape = opts?.result?.error;
237
- this.data = opts?.result?.error.data;
238
- this.name = "TRPCClientError";
239
- Object.setPrototypeOf(this, TRPCClientError.prototype);
240
- }
241
- };
242
- __name(TRPCClientError, "TRPCClientError");
243
- function transformResultInner(response, runtime) {
244
- if ("error" in response) {
245
- const error = runtime.transformer.deserialize(response.error);
246
- return {
247
- ok: false,
248
- error: {
249
- ...response,
250
- error
251
- }
252
- };
253
- }
254
- const result = {
255
- ...response.result,
256
- ...(!response.result.type || response.result.type === "data") && {
257
- type: "data",
258
- data: runtime.transformer.deserialize(response.result.data)
259
- }
260
- };
261
- return {
262
- ok: true,
263
- result
264
- };
265
- }
266
- __name(transformResultInner, "transformResultInner");
267
- function isObject(value) {
268
- return !!value && !Array.isArray(value) && typeof value === "object";
269
- }
270
- __name(isObject, "isObject");
271
- function transformResult(response, runtime) {
272
- let result;
273
- try {
274
- result = transformResultInner(response, runtime);
275
- } catch (err) {
276
- throw new TRPCClientError("Unable to transform response from server");
277
- }
278
- if (!result.ok && (!isObject(result.error.error) || typeof result.error.error.code !== "number")) {
279
- throw new TRPCClientError("Badly formatted response from server");
280
- }
281
- if (result.ok && !isObject(result.result)) {
282
- throw new TRPCClientError("Badly formatted response from server");
283
- }
284
- return result;
285
- }
286
- __name(transformResult, "transformResult");
287
-
288
- // ../../../node_modules/.pnpm/@trpc+client@10.17.0_@trpc+server@10.17.0/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
210
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
289
211
  function createChain(opts) {
290
212
  return observable((observer) => {
291
213
  function execute(index = 0, op = opts.op) {
@@ -309,7 +231,37 @@ function createChain(opts) {
309
231
  }
310
232
  __name(createChain, "createChain");
311
233
 
312
- // ../../../node_modules/.pnpm/@trpc+server@10.17.0/node_modules/@trpc/server/dist/index-972002da.mjs
234
+ // ../../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/codes-c924c3db.mjs
235
+ function invert(obj) {
236
+ const newObj = /* @__PURE__ */ Object.create(null);
237
+ for (const key in obj) {
238
+ const v = obj[key];
239
+ newObj[v] = key;
240
+ }
241
+ return newObj;
242
+ }
243
+ __name(invert, "invert");
244
+ var TRPC_ERROR_CODES_BY_KEY = {
245
+ PARSE_ERROR: -32700,
246
+ BAD_REQUEST: -32600,
247
+ INTERNAL_SERVER_ERROR: -32603,
248
+ NOT_IMPLEMENTED: -32603,
249
+ UNAUTHORIZED: -32001,
250
+ FORBIDDEN: -32003,
251
+ NOT_FOUND: -32004,
252
+ METHOD_NOT_SUPPORTED: -32005,
253
+ TIMEOUT: -32008,
254
+ CONFLICT: -32009,
255
+ PRECONDITION_FAILED: -32012,
256
+ PAYLOAD_TOO_LARGE: -32013,
257
+ UNPROCESSABLE_CONTENT: -32022,
258
+ TOO_MANY_REQUESTS: -32029,
259
+ CLIENT_CLOSED_REQUEST: -32099
260
+ };
261
+ var TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
262
+
263
+ // ../../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/index-f91d720c.mjs
264
+ var TRPC_ERROR_CODES_BY_NUMBER2 = invert(TRPC_ERROR_CODES_BY_KEY);
313
265
  var noop = /* @__PURE__ */ __name(() => {
314
266
  }, "noop");
315
267
  function createInnerProxy(callback, path) {
@@ -324,9 +276,10 @@ function createInnerProxy(callback, path) {
324
276
  ]);
325
277
  },
326
278
  apply(_1, _2, args) {
279
+ const isApply = path[path.length - 1] === "apply";
327
280
  return callback({
328
- args,
329
- path
281
+ args: isApply ? args.length >= 2 ? args[1] : [] : args,
282
+ path: isApply ? path.slice(0, -1) : path
330
283
  });
331
284
  }
332
285
  });
@@ -345,21 +298,152 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
345
298
  });
346
299
  }, "createFlatProxy");
347
300
 
348
- // ../../../node_modules/.pnpm/@trpc+client@10.17.0_@trpc+server@10.17.0/node_modules/@trpc/client/dist/httpUtils-9b676ab4.mjs
349
- var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
350
- function _bind(fn, thisArg) {
351
- return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
301
+ // ../../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/getCauseFromUnknown-2d66414a.mjs
302
+ function isObject(value) {
303
+ return !!value && !Array.isArray(value) && typeof value === "object";
352
304
  }
353
- __name(_bind, "_bind");
305
+ __name(isObject, "isObject");
306
+ var UnknownCauseError = class extends Error {
307
+ };
308
+ __name(UnknownCauseError, "UnknownCauseError");
309
+ function getCauseFromUnknown(cause) {
310
+ if (cause instanceof Error) {
311
+ return cause;
312
+ }
313
+ const type = typeof cause;
314
+ if (type === "undefined" || type === "function" || cause === null) {
315
+ return void 0;
316
+ }
317
+ if (type !== "object") {
318
+ return new Error(String(cause));
319
+ }
320
+ if (isObject(cause)) {
321
+ const err = new UnknownCauseError();
322
+ for (const key in cause) {
323
+ err[key] = cause[key];
324
+ }
325
+ return err;
326
+ }
327
+ return void 0;
328
+ }
329
+ __name(getCauseFromUnknown, "getCauseFromUnknown");
330
+
331
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
332
+ function isObject2(value) {
333
+ return !!value && !Array.isArray(value) && typeof value === "object";
334
+ }
335
+ __name(isObject2, "isObject");
336
+ function transformResultInner(response, runtime) {
337
+ if ("error" in response) {
338
+ const error = runtime.transformer.deserialize(response.error);
339
+ return {
340
+ ok: false,
341
+ error: {
342
+ ...response,
343
+ error
344
+ }
345
+ };
346
+ }
347
+ const result = {
348
+ ...response.result,
349
+ ...(!response.result.type || response.result.type === "data") && {
350
+ type: "data",
351
+ data: runtime.transformer.deserialize(response.result.data)
352
+ }
353
+ };
354
+ return {
355
+ ok: true,
356
+ result
357
+ };
358
+ }
359
+ __name(transformResultInner, "transformResultInner");
360
+ var TransformResultError = class extends Error {
361
+ constructor() {
362
+ super("Unable to transform response from server");
363
+ }
364
+ };
365
+ __name(TransformResultError, "TransformResultError");
366
+ function transformResult(response, runtime) {
367
+ let result;
368
+ try {
369
+ result = transformResultInner(response, runtime);
370
+ } catch (err) {
371
+ throw new TransformResultError();
372
+ }
373
+ if (!result.ok && (!isObject2(result.error.error) || typeof result.error.error.code !== "number")) {
374
+ throw new TransformResultError();
375
+ }
376
+ if (result.ok && !isObject2(result.result)) {
377
+ throw new TransformResultError();
378
+ }
379
+ return result;
380
+ }
381
+ __name(transformResult, "transformResult");
382
+
383
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs
384
+ function isTRPCClientError(cause) {
385
+ return cause instanceof TRPCClientError || cause instanceof Error && cause.name === "TRPCClientError";
386
+ }
387
+ __name(isTRPCClientError, "isTRPCClientError");
388
+ function isTRPCErrorResponse(obj) {
389
+ return isObject2(obj) && isObject2(obj.error) && typeof obj.error.code === "number" && typeof obj.error.message === "string";
390
+ }
391
+ __name(isTRPCErrorResponse, "isTRPCErrorResponse");
392
+ var TRPCClientError = class extends Error {
393
+ static from(_cause, opts = {}) {
394
+ const cause = _cause;
395
+ if (isTRPCClientError(cause)) {
396
+ if (opts.meta) {
397
+ cause.meta = {
398
+ ...cause.meta,
399
+ ...opts.meta
400
+ };
401
+ }
402
+ return cause;
403
+ }
404
+ if (isTRPCErrorResponse(cause)) {
405
+ return new TRPCClientError(cause.error.message, {
406
+ ...opts,
407
+ result: cause
408
+ });
409
+ }
410
+ if (!(cause instanceof Error)) {
411
+ return new TRPCClientError("Unknown error", {
412
+ ...opts,
413
+ cause
414
+ });
415
+ }
416
+ return new TRPCClientError(cause.message, {
417
+ ...opts,
418
+ cause: getCauseFromUnknown(cause)
419
+ });
420
+ }
421
+ constructor(message, opts) {
422
+ const cause = opts?.cause;
423
+ super(message, {
424
+ cause
425
+ });
426
+ this.meta = opts?.meta;
427
+ this.cause = cause;
428
+ this.shape = opts?.result?.error;
429
+ this.data = opts?.result?.error.data;
430
+ this.name = "TRPCClientError";
431
+ Object.setPrototypeOf(this, TRPCClientError.prototype);
432
+ }
433
+ };
434
+ __name(TRPCClientError, "TRPCClientError");
435
+
436
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs
437
+ var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
354
438
  function getFetch(customFetchImpl) {
355
439
  if (customFetchImpl) {
356
440
  return customFetchImpl;
357
441
  }
358
442
  if (typeof window !== "undefined" && isFunction(window.fetch)) {
359
- return _bind(window.fetch, window);
443
+ return window.fetch;
360
444
  }
361
445
  if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) {
362
- return _bind(globalThis.fetch, globalThis);
446
+ return globalThis.fetch;
363
447
  }
364
448
  throw new Error("No fetch implementation found");
365
449
  }
@@ -378,12 +462,10 @@ function getAbortController(customAbortControllerImpl) {
378
462
  }
379
463
  __name(getAbortController, "getAbortController");
380
464
  function resolveHTTPLinkOptions(opts) {
381
- const headers = opts.headers || (() => ({}));
382
465
  return {
383
- url: opts.url,
384
- fetch: getFetch(opts.fetch),
385
- AbortController: getAbortController(opts.AbortController),
386
- headers: typeof headers === "function" ? headers : () => headers
466
+ url: opts.url.toString().replace(/\/$/, ""),
467
+ fetch: opts.fetch,
468
+ AbortController: getAbortController(opts.AbortController)
387
469
  };
388
470
  }
389
471
  __name(resolveHTTPLinkOptions, "resolveHTTPLinkOptions");
@@ -404,7 +486,7 @@ function getInput(opts) {
404
486
  return "input" in opts ? opts.runtime.transformer.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.runtime.transformer.serialize(_input)));
405
487
  }
406
488
  __name(getInput, "getInput");
407
- function getUrl(opts) {
489
+ var getUrl = /* @__PURE__ */ __name((opts) => {
408
490
  let url = opts.url + "/" + opts.path;
409
491
  const queryParts = [];
410
492
  if ("inputs" in opts) {
@@ -420,48 +502,73 @@ function getUrl(opts) {
420
502
  url += "?" + queryParts.join("&");
421
503
  }
422
504
  return url;
423
- }
424
- __name(getUrl, "getUrl");
425
- function getBody(opts) {
505
+ }, "getUrl");
506
+ var getBody = /* @__PURE__ */ __name((opts) => {
426
507
  if (opts.type === "query") {
427
508
  return void 0;
428
509
  }
429
510
  const input = getInput(opts);
430
511
  return input !== void 0 ? JSON.stringify(input) : void 0;
512
+ }, "getBody");
513
+ var jsonHttpRequester = /* @__PURE__ */ __name((opts) => {
514
+ return httpRequest({
515
+ ...opts,
516
+ contentTypeHeader: "application/json",
517
+ getUrl,
518
+ getBody
519
+ });
520
+ }, "jsonHttpRequester");
521
+ async function fetchHTTPResponse(opts, ac) {
522
+ const url = opts.getUrl(opts);
523
+ const body = opts.getBody(opts);
524
+ const { type } = opts;
525
+ const resolvedHeaders = await opts.headers();
526
+ if (type === "subscription") {
527
+ throw new Error("Subscriptions should use wsLink");
528
+ }
529
+ const headers = {
530
+ ...opts.contentTypeHeader ? {
531
+ "content-type": opts.contentTypeHeader
532
+ } : {},
533
+ ...opts.batchModeHeader ? {
534
+ "trpc-batch-mode": opts.batchModeHeader
535
+ } : {},
536
+ ...resolvedHeaders
537
+ };
538
+ return getFetch(opts.fetch)(url, {
539
+ method: METHOD[type],
540
+ signal: ac?.signal,
541
+ body,
542
+ headers
543
+ });
431
544
  }
432
- __name(getBody, "getBody");
545
+ __name(fetchHTTPResponse, "fetchHTTPResponse");
433
546
  function httpRequest(opts) {
434
- const { type } = opts;
435
547
  const ac = opts.AbortController ? new opts.AbortController() : null;
548
+ const meta = {};
549
+ let done = false;
436
550
  const promise = new Promise((resolve, reject) => {
437
- const url = getUrl(opts);
438
- const body = getBody(opts);
439
- const meta = {};
440
- Promise.resolve(opts.headers()).then((headers) => {
441
- if (type === "subscription") {
442
- throw new Error("Subscriptions should use wsLink");
443
- }
444
- return opts.fetch(url, {
445
- method: METHOD[type],
446
- signal: ac?.signal,
447
- body,
448
- headers: {
449
- "content-type": "application/json",
450
- ...headers
451
- }
452
- });
453
- }).then((_res) => {
551
+ fetchHTTPResponse(opts, ac).then((_res) => {
454
552
  meta.response = _res;
553
+ done = true;
455
554
  return _res.json();
456
555
  }).then((json) => {
556
+ meta.responseJSON = json;
457
557
  resolve({
458
558
  json,
459
559
  meta
460
560
  });
461
- }).catch(reject);
561
+ }).catch((err) => {
562
+ done = true;
563
+ reject(TRPCClientError.from(err, {
564
+ meta
565
+ }));
566
+ });
462
567
  });
463
568
  const cancel = /* @__PURE__ */ __name(() => {
464
- ac?.abort();
569
+ if (!done) {
570
+ ac?.abort();
571
+ }
465
572
  }, "cancel");
466
573
  return {
467
574
  promise,
@@ -470,7 +577,7 @@ function httpRequest(opts) {
470
577
  }
471
578
  __name(httpRequest, "httpRequest");
472
579
 
473
- // ../../../node_modules/.pnpm/@trpc+client@10.17.0_@trpc+server@10.17.0/node_modules/@trpc/client/dist/links/httpBatchLink.mjs
580
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpBatchLink-d0f9eac9.mjs
474
581
  var throwFatalError = /* @__PURE__ */ __name(() => {
475
582
  throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
476
583
  }, "throwFatalError");
@@ -494,7 +601,7 @@ function dataLoader(batchLoader) {
494
601
  }
495
602
  const lastGroup = groupedItems[groupedItems.length - 1];
496
603
  if (item.aborted) {
497
- item.reject(new Error("Aborted"));
604
+ item.reject?.(new Error("Aborted"));
498
605
  index++;
499
606
  continue;
500
607
  }
@@ -505,7 +612,7 @@ function dataLoader(batchLoader) {
505
612
  continue;
506
613
  }
507
614
  if (lastGroup.length === 0) {
508
- item.reject(new Error("Input is too big for a single dispatch"));
615
+ item.reject?.(new Error("Input is too big for a single dispatch"));
509
616
  index++;
510
617
  continue;
511
618
  }
@@ -528,18 +635,27 @@ function dataLoader(batchLoader) {
528
635
  for (const item of items) {
529
636
  item.batch = batch;
530
637
  }
531
- const { promise, cancel } = batchLoader.fetch(batch.items.map((_item) => _item.key));
638
+ const unitResolver = /* @__PURE__ */ __name((index, value) => {
639
+ const item = batch.items[index];
640
+ item.resolve?.(value);
641
+ item.batch = null;
642
+ item.reject = null;
643
+ item.resolve = null;
644
+ }, "unitResolver");
645
+ const { promise, cancel } = batchLoader.fetch(batch.items.map((_item) => _item.key), unitResolver);
532
646
  batch.cancel = cancel;
533
647
  promise.then((result) => {
534
648
  for (let i = 0; i < result.length; i++) {
535
649
  const value = result[i];
536
- const item = batch.items[i];
537
- item.resolve(value);
650
+ unitResolver(i, value);
651
+ }
652
+ for (const item of batch.items) {
653
+ item.reject?.(new Error("Missing result"));
538
654
  item.batch = null;
539
655
  }
540
656
  }).catch((cause) => {
541
657
  for (const item of batch.items) {
542
- item.reject(cause);
658
+ item.reject?.(cause);
543
659
  item.batch = null;
544
660
  }
545
661
  });
@@ -583,89 +699,170 @@ function dataLoader(batchLoader) {
583
699
  };
584
700
  }
585
701
  __name(dataLoader, "dataLoader");
586
- function httpBatchLink(opts) {
587
- const resolvedOpts = resolveHTTPLinkOptions(opts);
588
- return (runtime) => {
589
- const maxURLLength = opts.maxURLLength || Infinity;
590
- const batchLoader = /* @__PURE__ */ __name((type) => {
591
- const validate = /* @__PURE__ */ __name((batchOps) => {
592
- if (maxURLLength === Infinity) {
593
- return true;
594
- }
595
- const path = batchOps.map((op) => op.path).join(",");
596
- const inputs = batchOps.map((op) => op.input);
597
- const url = getUrl({
598
- ...resolvedOpts,
599
- runtime,
600
- type,
601
- path,
602
- inputs
603
- });
604
- return url.length <= maxURLLength;
605
- }, "validate");
606
- const fetch2 = /* @__PURE__ */ __name((batchOps) => {
607
- const path = batchOps.map((op) => op.path).join(",");
608
- const inputs = batchOps.map((op) => op.input);
609
- const { promise, cancel } = httpRequest({
702
+ function createHTTPBatchLink(requester) {
703
+ return /* @__PURE__ */ __name(function httpBatchLink2(opts) {
704
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
705
+ const maxURLLength = opts.maxURLLength ?? Infinity;
706
+ return (runtime) => {
707
+ const batchLoader = /* @__PURE__ */ __name((type) => {
708
+ const validate = /* @__PURE__ */ __name((batchOps) => {
709
+ if (maxURLLength === Infinity) {
710
+ return true;
711
+ }
712
+ const path = batchOps.map((op) => op.path).join(",");
713
+ const inputs = batchOps.map((op) => op.input);
714
+ const url = getUrl({
715
+ ...resolvedOpts,
716
+ runtime,
717
+ type,
718
+ path,
719
+ inputs
720
+ });
721
+ return url.length <= maxURLLength;
722
+ }, "validate");
723
+ const fetch2 = requester({
610
724
  ...resolvedOpts,
611
725
  runtime,
612
726
  type,
613
- path,
614
- inputs
727
+ opts
615
728
  });
616
729
  return {
617
- promise: promise.then((res) => {
618
- const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json);
619
- const result = resJSON.map((item) => ({
620
- meta: res.meta,
621
- json: item
622
- }));
623
- return result;
624
- }),
625
- cancel
730
+ validate,
731
+ fetch: fetch2
626
732
  };
627
- }, "fetch");
628
- return {
629
- validate,
630
- fetch: fetch2
733
+ }, "batchLoader");
734
+ const query = dataLoader(batchLoader("query"));
735
+ const mutation = dataLoader(batchLoader("mutation"));
736
+ const subscription = dataLoader(batchLoader("subscription"));
737
+ const loaders = {
738
+ query,
739
+ subscription,
740
+ mutation
631
741
  };
632
- }, "batchLoader");
633
- const query = dataLoader(batchLoader("query"));
634
- const mutation = dataLoader(batchLoader("mutation"));
635
- const subscription = dataLoader(batchLoader("subscription"));
636
- const loaders = {
637
- query,
638
- subscription,
639
- mutation
640
- };
641
- return ({ op }) => {
642
- return observable((observer) => {
643
- const loader = loaders[op.type];
644
- const { promise, cancel } = loader.load(op);
645
- promise.then((res) => {
646
- const transformed = transformResult(res.json, runtime);
647
- if (!transformed.ok) {
648
- observer.error(TRPCClientError.from(transformed.error, {
649
- meta: res.meta
742
+ return ({ op }) => {
743
+ return observable((observer) => {
744
+ const loader = loaders[op.type];
745
+ const { promise, cancel } = loader.load(op);
746
+ let _res = void 0;
747
+ promise.then((res) => {
748
+ _res = res;
749
+ const transformed = transformResult(res.json, runtime);
750
+ if (!transformed.ok) {
751
+ observer.error(TRPCClientError.from(transformed.error, {
752
+ meta: res.meta
753
+ }));
754
+ return;
755
+ }
756
+ observer.next({
757
+ context: res.meta,
758
+ result: transformed.result
759
+ });
760
+ observer.complete();
761
+ }).catch((err) => {
762
+ observer.error(TRPCClientError.from(err, {
763
+ meta: _res?.meta
650
764
  }));
651
- return;
652
- }
653
- observer.next({
654
- context: res.meta,
655
- result: transformed.result
656
765
  });
657
- observer.complete();
658
- }).catch((err) => observer.error(TRPCClientError.from(err)));
659
- return () => {
660
- cancel();
661
- };
662
- });
766
+ return () => {
767
+ cancel();
768
+ };
769
+ });
770
+ };
663
771
  };
772
+ }, "httpBatchLink");
773
+ }
774
+ __name(createHTTPBatchLink, "createHTTPBatchLink");
775
+ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
776
+ return (batchOps) => {
777
+ const path = batchOps.map((op) => op.path).join(",");
778
+ const inputs = batchOps.map((op) => op.input);
779
+ const { promise, cancel } = jsonHttpRequester({
780
+ ...requesterOpts,
781
+ path,
782
+ inputs,
783
+ headers() {
784
+ if (!requesterOpts.opts.headers) {
785
+ return {};
786
+ }
787
+ if (typeof requesterOpts.opts.headers === "function") {
788
+ return requesterOpts.opts.headers({
789
+ opList: batchOps
790
+ });
791
+ }
792
+ return requesterOpts.opts.headers;
793
+ }
794
+ });
795
+ return {
796
+ promise: promise.then((res) => {
797
+ const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json);
798
+ const result = resJSON.map((item) => ({
799
+ meta: res.meta,
800
+ json: item
801
+ }));
802
+ return result;
803
+ }),
804
+ cancel
805
+ };
806
+ };
807
+ }, "batchRequester");
808
+ var httpBatchLink = createHTTPBatchLink(batchRequester);
809
+
810
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/links/httpLink.mjs
811
+ function httpLinkFactory(factoryOpts) {
812
+ return (opts) => {
813
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
814
+ return (runtime) => ({ op }) => observable((observer) => {
815
+ const { path, input, type } = op;
816
+ const { promise, cancel } = factoryOpts.requester({
817
+ ...resolvedOpts,
818
+ runtime,
819
+ type,
820
+ path,
821
+ input,
822
+ headers() {
823
+ if (!opts.headers) {
824
+ return {};
825
+ }
826
+ if (typeof opts.headers === "function") {
827
+ return opts.headers({
828
+ op
829
+ });
830
+ }
831
+ return opts.headers;
832
+ }
833
+ });
834
+ let meta = void 0;
835
+ promise.then((res) => {
836
+ meta = res.meta;
837
+ const transformed = transformResult(res.json, runtime);
838
+ if (!transformed.ok) {
839
+ observer.error(TRPCClientError.from(transformed.error, {
840
+ meta
841
+ }));
842
+ return;
843
+ }
844
+ observer.next({
845
+ context: res.meta,
846
+ result: transformed.result
847
+ });
848
+ observer.complete();
849
+ }).catch((cause) => {
850
+ observer.error(TRPCClientError.from(cause, {
851
+ meta
852
+ }));
853
+ });
854
+ return () => {
855
+ cancel();
856
+ };
857
+ });
664
858
  };
665
859
  }
666
- __name(httpBatchLink, "httpBatchLink");
860
+ __name(httpLinkFactory, "httpLinkFactory");
861
+ var httpLink = httpLinkFactory({
862
+ requester: jsonHttpRequester
863
+ });
667
864
 
668
- // ../../../node_modules/.pnpm/@trpc+client@10.17.0_@trpc+server@10.17.0/node_modules/@trpc/client/dist/index.mjs
865
+ // ../../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/index.mjs
669
866
  var TRPCUntypedClient = class {
670
867
  $request({ type, input, path, context = {} }) {
671
868
  const chain$ = createChain({
@@ -738,23 +935,34 @@ var TRPCUntypedClient = class {
738
935
  }
739
936
  constructor(opts) {
740
937
  this.requestId = 0;
741
- function getTransformer() {
938
+ const combinedTransformer = (() => {
742
939
  const transformer = opts.transformer;
743
- if (!transformer)
744
- return {
745
- serialize: (data) => data,
746
- deserialize: (data) => data
747
- };
748
- if ("input" in transformer)
940
+ if (!transformer) {
749
941
  return {
750
- serialize: transformer.input.serialize,
751
- deserialize: transformer.output.deserialize
942
+ input: {
943
+ serialize: (data) => data,
944
+ deserialize: (data) => data
945
+ },
946
+ output: {
947
+ serialize: (data) => data,
948
+ deserialize: (data) => data
949
+ }
752
950
  };
753
- return transformer;
754
- }
755
- __name(getTransformer, "getTransformer");
951
+ }
952
+ if ("input" in transformer) {
953
+ return opts.transformer;
954
+ }
955
+ return {
956
+ input: transformer,
957
+ output: transformer
958
+ };
959
+ })();
756
960
  this.runtime = {
757
- transformer: getTransformer()
961
+ transformer: {
962
+ serialize: (data) => combinedTransformer.input.serialize(data),
963
+ deserialize: (data) => combinedTransformer.output.deserialize(data)
964
+ },
965
+ combinedTransformer
758
966
  };
759
967
  this.links = opts.links.map((link) => link(this.runtime));
760
968
  }
@@ -765,18 +973,23 @@ var clientCallTypeMap = {
765
973
  mutate: "mutation",
766
974
  subscribe: "subscription"
767
975
  };
976
+ var clientCallTypeToProcedureType = /* @__PURE__ */ __name((clientCallType) => {
977
+ return clientCallTypeMap[clientCallType];
978
+ }, "clientCallTypeToProcedureType");
768
979
  function createTRPCClientProxy(client) {
769
980
  return createFlatProxy((key) => {
770
981
  if (client.hasOwnProperty(key)) {
771
982
  return client[key];
772
983
  }
984
+ if (key === "__untypedClient") {
985
+ return client;
986
+ }
773
987
  return createRecursiveProxy(({ path, args }) => {
774
988
  const pathCopy = [
775
989
  key,
776
990
  ...path
777
991
  ];
778
- const clientCallType = pathCopy.pop();
779
- const procedureType = clientCallTypeMap[clientCallType];
992
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
780
993
  const fullPath = pathCopy.join(".");
781
994
  return client[procedureType](fullPath, ...args);
782
995
  });
@@ -789,6 +1002,161 @@ function createTRPCProxyClient(opts) {
789
1002
  return proxy;
790
1003
  }
791
1004
  __name(createTRPCProxyClient, "createTRPCProxyClient");
1005
+ function getTextDecoder(customTextDecoder) {
1006
+ if (customTextDecoder) {
1007
+ return customTextDecoder;
1008
+ }
1009
+ if (typeof window !== "undefined" && window.TextDecoder) {
1010
+ return new window.TextDecoder();
1011
+ }
1012
+ if (typeof globalThis !== "undefined" && globalThis.TextDecoder) {
1013
+ return new globalThis.TextDecoder();
1014
+ }
1015
+ throw new Error("No TextDecoder implementation found");
1016
+ }
1017
+ __name(getTextDecoder, "getTextDecoder");
1018
+ async function parseJSONStream(opts) {
1019
+ const parse = opts.parse ?? JSON.parse;
1020
+ const onLine = /* @__PURE__ */ __name((line) => {
1021
+ if (opts.signal?.aborted)
1022
+ return;
1023
+ if (!line || line === "}") {
1024
+ return;
1025
+ }
1026
+ const indexOfColon = line.indexOf(":");
1027
+ const indexAsStr = line.substring(2, indexOfColon - 1);
1028
+ const text = line.substring(indexOfColon + 1);
1029
+ opts.onSingle(Number(indexAsStr), parse(text));
1030
+ }, "onLine");
1031
+ await readLines(opts.readableStream, onLine, opts.textDecoder);
1032
+ }
1033
+ __name(parseJSONStream, "parseJSONStream");
1034
+ async function readLines(readableStream, onLine, textDecoder) {
1035
+ let partOfLine = "";
1036
+ const onChunk = /* @__PURE__ */ __name((chunk) => {
1037
+ const chunkText = textDecoder.decode(chunk);
1038
+ const chunkLines = chunkText.split("\n");
1039
+ if (chunkLines.length === 1) {
1040
+ partOfLine += chunkLines[0];
1041
+ } else if (chunkLines.length > 1) {
1042
+ onLine(partOfLine + chunkLines[0]);
1043
+ for (let i = 1; i < chunkLines.length - 1; i++) {
1044
+ onLine(chunkLines[i]);
1045
+ }
1046
+ partOfLine = chunkLines[chunkLines.length - 1];
1047
+ }
1048
+ }, "onChunk");
1049
+ if ("getReader" in readableStream) {
1050
+ await readStandardChunks(readableStream, onChunk);
1051
+ } else {
1052
+ await readNodeChunks(readableStream, onChunk);
1053
+ }
1054
+ onLine(partOfLine);
1055
+ }
1056
+ __name(readLines, "readLines");
1057
+ function readNodeChunks(stream, onChunk) {
1058
+ return new Promise((resolve) => {
1059
+ stream.on("data", onChunk);
1060
+ stream.on("end", resolve);
1061
+ });
1062
+ }
1063
+ __name(readNodeChunks, "readNodeChunks");
1064
+ async function readStandardChunks(stream, onChunk) {
1065
+ const reader = stream.getReader();
1066
+ let readResult = await reader.read();
1067
+ while (!readResult.done) {
1068
+ onChunk(readResult.value);
1069
+ readResult = await reader.read();
1070
+ }
1071
+ }
1072
+ __name(readStandardChunks, "readStandardChunks");
1073
+ var streamingJsonHttpRequester = /* @__PURE__ */ __name((opts, onSingle) => {
1074
+ const ac = opts.AbortController ? new opts.AbortController() : null;
1075
+ const responsePromise = fetchHTTPResponse({
1076
+ ...opts,
1077
+ contentTypeHeader: "application/json",
1078
+ batchModeHeader: "stream",
1079
+ getUrl,
1080
+ getBody
1081
+ }, ac);
1082
+ const cancel = /* @__PURE__ */ __name(() => ac?.abort(), "cancel");
1083
+ const promise = responsePromise.then(async (res) => {
1084
+ if (!res.body)
1085
+ throw new Error("Received response without body");
1086
+ const meta = {
1087
+ response: res
1088
+ };
1089
+ return parseJSONStream({
1090
+ readableStream: res.body,
1091
+ onSingle,
1092
+ parse: (string) => ({
1093
+ json: JSON.parse(string),
1094
+ meta
1095
+ }),
1096
+ signal: ac?.signal,
1097
+ textDecoder: opts.textDecoder
1098
+ });
1099
+ });
1100
+ return {
1101
+ cancel,
1102
+ promise
1103
+ };
1104
+ }, "streamingJsonHttpRequester");
1105
+ var streamRequester = /* @__PURE__ */ __name((requesterOpts) => {
1106
+ const textDecoder = getTextDecoder(requesterOpts.opts.textDecoder);
1107
+ return (batchOps, unitResolver) => {
1108
+ const path = batchOps.map((op) => op.path).join(",");
1109
+ const inputs = batchOps.map((op) => op.input);
1110
+ const { cancel, promise } = streamingJsonHttpRequester({
1111
+ ...requesterOpts,
1112
+ textDecoder,
1113
+ path,
1114
+ inputs,
1115
+ headers() {
1116
+ if (!requesterOpts.opts.headers) {
1117
+ return {};
1118
+ }
1119
+ if (typeof requesterOpts.opts.headers === "function") {
1120
+ return requesterOpts.opts.headers({
1121
+ opList: batchOps
1122
+ });
1123
+ }
1124
+ return requesterOpts.opts.headers;
1125
+ }
1126
+ }, (index, res) => {
1127
+ unitResolver(index, res);
1128
+ });
1129
+ return {
1130
+ promise: promise.then(() => []),
1131
+ cancel
1132
+ };
1133
+ };
1134
+ }, "streamRequester");
1135
+ var unstable_httpBatchStreamLink = createHTTPBatchLink(streamRequester);
1136
+ var getBody2 = /* @__PURE__ */ __name((opts) => {
1137
+ if (!("input" in opts)) {
1138
+ return void 0;
1139
+ }
1140
+ if (!(opts.input instanceof FormData)) {
1141
+ throw new Error("Input is not FormData");
1142
+ }
1143
+ return opts.input;
1144
+ }, "getBody");
1145
+ var formDataRequester = /* @__PURE__ */ __name((opts) => {
1146
+ if (opts.type !== "mutation") {
1147
+ throw new Error("We only handle mutations with formdata");
1148
+ }
1149
+ return httpRequest({
1150
+ ...opts,
1151
+ getUrl() {
1152
+ return `${opts.url}/${opts.path}`;
1153
+ },
1154
+ getBody: getBody2
1155
+ });
1156
+ }, "formDataRequester");
1157
+ var experimental_formDataLink = httpLinkFactory({
1158
+ requester: formDataRequester
1159
+ });
792
1160
 
793
1161
  // ../../learn-card-network/brain-client/dist/brain-client.esm.js
794
1162
  var __defProp2 = Object.defineProperty;
@@ -831,7 +1199,11 @@ var getClient = /* @__PURE__ */ __name2(async (url, didAuthFunction) => {
831
1199
  let challenges = [];
832
1200
  const challengeRequester = createTRPCProxyClient({
833
1201
  links: [
834
- httpBatchLink({ url, headers: { Authorization: `Bearer ${await didAuthFunction()}` } })
1202
+ httpBatchLink({
1203
+ url,
1204
+ maxURLLength: 2048,
1205
+ headers: { Authorization: `Bearer ${await didAuthFunction()}` }
1206
+ })
835
1207
  ]
836
1208
  });
837
1209
  const getChallenges = /* @__PURE__ */ __name2(async (amount = 95 + Math.round((Math.random() - 0.5) * 5)) => {
@@ -844,6 +1216,7 @@ var getClient = /* @__PURE__ */ __name2(async (url, didAuthFunction) => {
844
1216
  challenges = await getChallenges();
845
1217
  }),
846
1218
  httpBatchLink({
1219
+ maxURLLength: 2048,
847
1220
  url,
848
1221
  headers: async () => {
849
1222
  if (challenges.length === 0)
@@ -4608,11 +4981,17 @@ var BoostValidator = mod.object({
4608
4981
  status: LCNBoostStatus.optional(),
4609
4982
  autoConnectRecipients: mod.boolean().optional()
4610
4983
  });
4984
+ var PaginatedBoostsValidator = PaginationResponseValidator.extend({
4985
+ records: BoostValidator.array()
4986
+ });
4611
4987
  var BoostRecipientValidator = mod.object({
4612
4988
  to: LCNProfileValidator,
4613
4989
  from: mod.string(),
4614
4990
  received: mod.string().optional()
4615
4991
  });
4992
+ var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
4993
+ records: BoostRecipientValidator.array()
4994
+ });
4616
4995
  var LCNBoostClaimLinkSigningAuthorityValidator = mod.object({
4617
4996
  endpoint: mod.string(),
4618
4997
  name: mod.string(),
@@ -4945,21 +5324,39 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
4945
5324
  throw new Error("Please make an account first!");
4946
5325
  return client.profile.acceptConnectionRequest.mutate({ profileId });
4947
5326
  },
4948
- getConnections: async () => {
5327
+ getConnections: async (_learnCard) => {
5328
+ console.warn("The getConnections method is deprecated! Please use getPaginatedConnections instead!");
4949
5329
  if (!userData)
4950
5330
  throw new Error("Please make an account first!");
4951
5331
  return client.profile.connections.query();
4952
5332
  },
4953
- getPendingConnections: async () => {
5333
+ getPaginatedConnections: async (_learnCard, options) => {
5334
+ if (!userData)
5335
+ throw new Error("Please make an account first!");
5336
+ return client.profile.paginatedConnections.query(options);
5337
+ },
5338
+ getPendingConnections: async (_learnCard) => {
5339
+ console.warn("The getPendingConnections method is deprecated! Please use getPaginatedPendingConnections instead!");
4954
5340
  if (!userData)
4955
5341
  throw new Error("Please make an account first!");
4956
5342
  return client.profile.pendingConnections.query();
4957
5343
  },
4958
- getConnectionRequests: async () => {
5344
+ getPaginatedPendingConnections: async (_learnCard, options) => {
5345
+ if (!userData)
5346
+ throw new Error("Please make an account first!");
5347
+ return client.profile.paginatedPendingConnections.query(options);
5348
+ },
5349
+ getConnectionRequests: async (_learnCard) => {
5350
+ console.warn("The getConnectionRequests method is deprecated! Please use getPaginatedConnectionRequests instead!");
4959
5351
  if (!userData)
4960
5352
  throw new Error("Please make an account first!");
4961
5353
  return client.profile.connectionRequests.query();
4962
5354
  },
5355
+ getPaginatedConnectionRequests: async (_learnCard, options) => {
5356
+ if (!userData)
5357
+ throw new Error("Please make an account first!");
5358
+ return client.profile.paginatedConnectionRequests.query(options);
5359
+ },
4963
5360
  generateInvite: async (_learnCard, challenge, expiration) => {
4964
5361
  if (!userData)
4965
5362
  throw new Error("Please make an account first!");
@@ -5067,12 +5464,19 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
5067
5464
  throw new Error("Please make an account first!");
5068
5465
  return client.boost.getBoost.query({ uri });
5069
5466
  },
5070
- getBoosts: async () => {
5467
+ getBoosts: async (_learnCard) => {
5468
+ console.warn("The getBoosts method is deprecated! Please use getPaginatedBoosts instead!");
5071
5469
  if (!userData)
5072
5470
  throw new Error("Please make an account first!");
5073
5471
  return client.boost.getBoosts.query();
5074
5472
  },
5473
+ getPaginatedBoosts: async (_learnCard, options) => {
5474
+ if (!userData)
5475
+ throw new Error("Please make an account first!");
5476
+ return client.boost.getPaginatedBoosts.query(options);
5477
+ },
5075
5478
  getBoostRecipients: async (_learnCard, uri, limit = 25, skip = void 0, includeUnacceptedBoosts = true) => {
5479
+ console.warn("The getBoostRecipients method is deprecated! Please use getPaginatedBoostRecipients instead!");
5076
5480
  if (!userData)
5077
5481
  throw new Error("Please make an account first!");
5078
5482
  return client.boost.getBoostRecipients.query({
@@ -5082,6 +5486,16 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
5082
5486
  includeUnacceptedBoosts
5083
5487
  });
5084
5488
  },
5489
+ getPaginatedBoostRecipients: async (_learnCard, uri, limit = 25, cursor = void 0, includeUnacceptedBoosts = true) => {
5490
+ if (!userData)
5491
+ throw new Error("Please make an account first!");
5492
+ return client.boost.getPaginatedBoostRecipients.query({
5493
+ uri,
5494
+ limit,
5495
+ cursor,
5496
+ includeUnacceptedBoosts
5497
+ });
5498
+ },
5085
5499
  countBoostRecipients: async (_learnCard, uri, includeUnacceptedBoosts = true) => {
5086
5500
  if (!userData)
5087
5501
  throw new Error("Please make an account first!");