UEA-Prodem
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Alex Johansson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<p align="center">
|
||||
<a href="https://trpc.io/"><img src="https://assets.trpc.io/icons/svgs/blue-bg-rounded.svg" alt="tRPC" height="75"/></a>
|
||||
</p>
|
||||
|
||||
<h3 align="center">tRPC</h3>
|
||||
|
||||
<p align="center">
|
||||
<strong>End-to-end typesafe APIs made easy</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://assets.trpc.io/www/v10/v10-dark-landscape.gif" alt="Demo" />
|
||||
</p>
|
||||
|
||||
# `@trpc/client`
|
||||
|
||||
> Communicate with a tRPC server on the client side.
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation for `@trpc/client` can be found [here](https://trpc.io/docs/vanilla)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install @trpc/client
|
||||
|
||||
# Yarn
|
||||
yarn add @trpc/client
|
||||
|
||||
# pnpm
|
||||
pnpm add @trpc/client
|
||||
|
||||
# Bun
|
||||
bun add @trpc/client
|
||||
```
|
||||
|
||||
## AI Agents
|
||||
|
||||
If you use an AI coding agent, install tRPC skills for better code generation:
|
||||
|
||||
```bash
|
||||
npx @tanstack/intent@latest install
|
||||
```
|
||||
|
||||
## Basic Example
|
||||
|
||||
```ts
|
||||
import { createTRPCClient, httpBatchLink } from '@trpc/client';
|
||||
// Importing the router type from the server file
|
||||
import type { AppRouter } from './server';
|
||||
|
||||
// Initializing the tRPC client
|
||||
const trpc = createTRPCClient<AppRouter>({
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url: 'http://localhost:3000/trpc',
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
async function main() {
|
||||
// Querying the greeting
|
||||
const helloResponse = await trpc.greeting.query({
|
||||
name: 'world',
|
||||
});
|
||||
|
||||
console.log('helloResponse', helloResponse); // Hello world
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
// Auto-generated by @tanstack/intent setup
|
||||
// Exposes the intent end-user CLI for consumers of this library.
|
||||
// Commit this file, then add to your package.json:
|
||||
// "bin": { "intent": "./bin/intent.js" }
|
||||
try {
|
||||
await import('@tanstack/intent/intent-library');
|
||||
} catch (e) {
|
||||
if (e?.code === 'ERR_MODULE_NOT_FOUND' || e?.code === 'MODULE_NOT_FOUND') {
|
||||
console.error('@tanstack/intent is not installed.');
|
||||
console.error('');
|
||||
console.error('Install it as a dev dependency:');
|
||||
console.error(' npm add -D @tanstack/intent');
|
||||
console.error('');
|
||||
console.error('Or run directly:');
|
||||
console.error(' npx @tanstack/intent@latest list');
|
||||
process.exit(1);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
||||
|
||||
//#region src/TRPCClientError.ts
|
||||
var import_defineProperty = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
function isTRPCClientError(cause) {
|
||||
return cause instanceof TRPCClientError;
|
||||
}
|
||||
function isTRPCErrorResponse(obj) {
|
||||
return (0, __trpc_server_unstable_core_do_not_import.isObject)(obj) && (0, __trpc_server_unstable_core_do_not_import.isObject)(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
|
||||
}
|
||||
function getMessageFromUnknownError(err, fallback) {
|
||||
if (typeof err === "string") return err;
|
||||
if ((0, __trpc_server_unstable_core_do_not_import.isObject)(err) && typeof err["message"] === "string") return err["message"];
|
||||
return fallback;
|
||||
}
|
||||
var TRPCClientError = class TRPCClientError extends Error {
|
||||
constructor(message, opts) {
|
||||
var _opts$result, _opts$result2;
|
||||
const cause = opts === null || opts === void 0 ? void 0 : opts.cause;
|
||||
super(message, { cause });
|
||||
(0, import_defineProperty.default)(this, "cause", void 0);
|
||||
(0, import_defineProperty.default)(this, "shape", void 0);
|
||||
(0, import_defineProperty.default)(this, "data", void 0);
|
||||
(0, import_defineProperty.default)(this, "meta", void 0);
|
||||
this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
||||
this.cause = cause;
|
||||
this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
||||
this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
||||
this.name = "TRPCClientError";
|
||||
Object.setPrototypeOf(this, TRPCClientError.prototype);
|
||||
}
|
||||
static from(_cause, opts = {}) {
|
||||
const cause = _cause;
|
||||
if (isTRPCClientError(cause)) {
|
||||
if (opts.meta) cause.meta = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, cause.meta), opts.meta);
|
||||
return cause;
|
||||
}
|
||||
if (isTRPCErrorResponse(cause)) return new TRPCClientError(cause.error.message, (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
result: cause,
|
||||
cause: opts.cause
|
||||
}));
|
||||
return new TRPCClientError(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, { cause }));
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'TRPCClientError', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return TRPCClientError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isTRPCClientError', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isTRPCClientError;
|
||||
}
|
||||
});
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import { __toESM, require_defineProperty, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { isObject } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/TRPCClientError.ts
|
||||
var import_defineProperty = __toESM(require_defineProperty(), 1);
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
function isTRPCClientError(cause) {
|
||||
return cause instanceof TRPCClientError;
|
||||
}
|
||||
function isTRPCErrorResponse(obj) {
|
||||
return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
|
||||
}
|
||||
function getMessageFromUnknownError(err, fallback) {
|
||||
if (typeof err === "string") return err;
|
||||
if (isObject(err) && typeof err["message"] === "string") return err["message"];
|
||||
return fallback;
|
||||
}
|
||||
var TRPCClientError = class TRPCClientError extends Error {
|
||||
constructor(message, opts) {
|
||||
var _opts$result, _opts$result2;
|
||||
const cause = opts === null || opts === void 0 ? void 0 : opts.cause;
|
||||
super(message, { cause });
|
||||
(0, import_defineProperty.default)(this, "cause", void 0);
|
||||
(0, import_defineProperty.default)(this, "shape", void 0);
|
||||
(0, import_defineProperty.default)(this, "data", void 0);
|
||||
(0, import_defineProperty.default)(this, "meta", void 0);
|
||||
this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
||||
this.cause = cause;
|
||||
this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
||||
this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
||||
this.name = "TRPCClientError";
|
||||
Object.setPrototypeOf(this, TRPCClientError.prototype);
|
||||
}
|
||||
static from(_cause, opts = {}) {
|
||||
const cause = _cause;
|
||||
if (isTRPCClientError(cause)) {
|
||||
if (opts.meta) cause.meta = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, cause.meta), opts.meta);
|
||||
return cause;
|
||||
}
|
||||
if (isTRPCErrorResponse(cause)) return new TRPCClientError(cause.error.message, (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
result: cause,
|
||||
cause: opts.cause
|
||||
}));
|
||||
return new TRPCClientError(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, { cause }));
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
export { TRPCClientError, isTRPCClientError };
|
||||
//# sourceMappingURL=TRPCClientError-apv8gw59.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+39
@@ -0,0 +1,39 @@
|
||||
//#region rolldown:runtime
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
||||
value: mod,
|
||||
enumerable: true
|
||||
}) : target, mod));
|
||||
|
||||
//#endregion
|
||||
|
||||
Object.defineProperty(exports, '__commonJS', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return __commonJS;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, '__toESM', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return __toESM;
|
||||
}
|
||||
});
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_TRPCClientError = require('./TRPCClientError-CQrTQLrk.cjs');
|
||||
const require_httpUtils = require('./httpUtils-wv2o-njD.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
||||
|
||||
//#region src/internals/dataLoader.ts
|
||||
/**
|
||||
* A function that should never be called unless we messed something up.
|
||||
*/
|
||||
const throwFatalError = () => {
|
||||
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
||||
};
|
||||
/**
|
||||
* Dataloader that's very inspired by https://github.com/graphql/dataloader
|
||||
* Less configuration, no caching, and allows you to cancel requests
|
||||
* When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
|
||||
*/
|
||||
function dataLoader(batchLoader) {
|
||||
let pendingItems = null;
|
||||
let dispatchTimer = null;
|
||||
const destroyTimerAndPendingItems = () => {
|
||||
clearTimeout(dispatchTimer);
|
||||
dispatchTimer = null;
|
||||
pendingItems = null;
|
||||
};
|
||||
/**
|
||||
* Iterate through the items and split them into groups based on the `batchLoader`'s validate function
|
||||
*/
|
||||
function groupItems(items) {
|
||||
const groupedItems = [[]];
|
||||
let index = 0;
|
||||
while (true) {
|
||||
const item = items[index];
|
||||
if (!item) break;
|
||||
const lastGroup = groupedItems[groupedItems.length - 1];
|
||||
if (item.aborted) {
|
||||
var _item$reject;
|
||||
(_item$reject = item.reject) === null || _item$reject === void 0 || _item$reject.call(item, new Error("Aborted"));
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
const isValid = batchLoader.validate(lastGroup.concat(item).map((it) => it.key));
|
||||
if (isValid) {
|
||||
lastGroup.push(item);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
if (lastGroup.length === 0) {
|
||||
var _item$reject2;
|
||||
(_item$reject2 = item.reject) === null || _item$reject2 === void 0 || _item$reject2.call(item, new Error("Input is too big for a single dispatch"));
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
groupedItems.push([]);
|
||||
}
|
||||
return groupedItems;
|
||||
}
|
||||
function dispatch() {
|
||||
const groupedItems = groupItems(pendingItems);
|
||||
destroyTimerAndPendingItems();
|
||||
for (const items of groupedItems) {
|
||||
if (!items.length) continue;
|
||||
const batch = { items };
|
||||
for (const item of items) item.batch = batch;
|
||||
const promise = batchLoader.fetch(batch.items.map((_item) => _item.key));
|
||||
promise.then(async (result) => {
|
||||
await Promise.all(result.map(async (valueOrPromise, index) => {
|
||||
const item = batch.items[index];
|
||||
try {
|
||||
var _item$resolve;
|
||||
const value = await Promise.resolve(valueOrPromise);
|
||||
(_item$resolve = item.resolve) === null || _item$resolve === void 0 || _item$resolve.call(item, value);
|
||||
} catch (cause) {
|
||||
var _item$reject3;
|
||||
(_item$reject3 = item.reject) === null || _item$reject3 === void 0 || _item$reject3.call(item, cause);
|
||||
}
|
||||
item.batch = null;
|
||||
item.reject = null;
|
||||
item.resolve = null;
|
||||
}));
|
||||
for (const item of batch.items) {
|
||||
var _item$reject4;
|
||||
(_item$reject4 = item.reject) === null || _item$reject4 === void 0 || _item$reject4.call(item, new Error("Missing result"));
|
||||
item.batch = null;
|
||||
}
|
||||
}).catch((cause) => {
|
||||
for (const item of batch.items) {
|
||||
var _item$reject5;
|
||||
(_item$reject5 = item.reject) === null || _item$reject5 === void 0 || _item$reject5.call(item, cause);
|
||||
item.batch = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function load(key) {
|
||||
var _dispatchTimer;
|
||||
const item = {
|
||||
aborted: false,
|
||||
key,
|
||||
batch: null,
|
||||
resolve: throwFatalError,
|
||||
reject: throwFatalError
|
||||
};
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
var _pendingItems;
|
||||
item.reject = reject;
|
||||
item.resolve = resolve;
|
||||
(_pendingItems = pendingItems) !== null && _pendingItems !== void 0 || (pendingItems = []);
|
||||
pendingItems.push(item);
|
||||
});
|
||||
(_dispatchTimer = dispatchTimer) !== null && _dispatchTimer !== void 0 || (dispatchTimer = setTimeout(dispatch));
|
||||
return promise;
|
||||
}
|
||||
return { load };
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/internals/signals.ts
|
||||
/**
|
||||
* Like `Promise.all()` but for abort signals
|
||||
* - When all signals have been aborted, the merged signal will be aborted
|
||||
* - If one signal is `null`, no signal will be aborted
|
||||
*/
|
||||
function allAbortSignals(...signals) {
|
||||
const ac = new AbortController();
|
||||
const count = signals.length;
|
||||
let abortedCount = 0;
|
||||
const onAbort = () => {
|
||||
if (++abortedCount === count) ac.abort();
|
||||
};
|
||||
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) onAbort();
|
||||
else signal === null || signal === void 0 || signal.addEventListener("abort", onAbort, { once: true });
|
||||
return ac.signal;
|
||||
}
|
||||
/**
|
||||
* Like `Promise.race` but for abort signals
|
||||
*
|
||||
* Basically, a ponyfill for
|
||||
* [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).
|
||||
*/
|
||||
function raceAbortSignals(...signals) {
|
||||
const ac = new AbortController();
|
||||
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) ac.abort();
|
||||
else signal === null || signal === void 0 || signal.addEventListener("abort", () => ac.abort(), { once: true });
|
||||
return ac.signal;
|
||||
}
|
||||
function abortSignalToPromise(signal) {
|
||||
return new Promise((_, reject) => {
|
||||
if (signal.aborted) {
|
||||
reject(signal.reason);
|
||||
return;
|
||||
}
|
||||
signal.addEventListener("abort", () => {
|
||||
reject(signal.reason);
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchLink.ts
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchLink
|
||||
*/
|
||||
function httpBatchLink(opts) {
|
||||
var _opts$maxURLLength, _opts$maxItems;
|
||||
const resolvedOpts = require_httpUtils.resolveHTTPLinkOptions(opts);
|
||||
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
||||
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
||||
return () => {
|
||||
const batchLoader = (type) => {
|
||||
return {
|
||||
validate(batchOps) {
|
||||
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
||||
if (batchOps.length > maxItems) return false;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const url = require_httpUtils.getUrl((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
inputs,
|
||||
signal: null
|
||||
}));
|
||||
return url.length <= maxURLLength;
|
||||
},
|
||||
async fetch(batchOps) {
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const signal = allAbortSignals(...batchOps.map((op) => op.signal));
|
||||
const res = await require_httpUtils.jsonHttpRequester((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
path,
|
||||
inputs,
|
||||
type,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
||||
return opts.headers;
|
||||
},
|
||||
signal
|
||||
}));
|
||||
const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json);
|
||||
const result = resJSON.map((item) => ({
|
||||
meta: res.meta,
|
||||
json: item
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
const query = dataLoader(batchLoader("query"));
|
||||
const mutation = dataLoader(batchLoader("mutation"));
|
||||
const loaders = {
|
||||
query,
|
||||
mutation
|
||||
};
|
||||
return ({ op }) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const loader = loaders[op.type];
|
||||
const promise = loader.load(op);
|
||||
let _res = void 0;
|
||||
promise.then((res) => {
|
||||
_res = res;
|
||||
const transformed = (0, __trpc_server_unstable_core_do_not_import.transformResult)(res.json, resolvedOpts.transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(transformed.error, { meta: res.meta }));
|
||||
return;
|
||||
}
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: transformed.result
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((err) => {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'abortSignalToPromise', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return abortSignalToPromise;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'allAbortSignals', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return allAbortSignals;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'dataLoader', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return dataLoader;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'httpBatchLink', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return httpBatchLink;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'raceAbortSignals', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return raceAbortSignals;
|
||||
}
|
||||
});
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
import { __toESM, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { TRPCClientError } from "./TRPCClientError-apv8gw59.mjs";
|
||||
import { getUrl, jsonHttpRequester, resolveHTTPLinkOptions } from "./httpUtils-pyf5RF99.mjs";
|
||||
import { observable } from "@trpc/server/observable";
|
||||
import { transformResult } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/internals/dataLoader.ts
|
||||
/**
|
||||
* A function that should never be called unless we messed something up.
|
||||
*/
|
||||
const throwFatalError = () => {
|
||||
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
||||
};
|
||||
/**
|
||||
* Dataloader that's very inspired by https://github.com/graphql/dataloader
|
||||
* Less configuration, no caching, and allows you to cancel requests
|
||||
* When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
|
||||
*/
|
||||
function dataLoader(batchLoader) {
|
||||
let pendingItems = null;
|
||||
let dispatchTimer = null;
|
||||
const destroyTimerAndPendingItems = () => {
|
||||
clearTimeout(dispatchTimer);
|
||||
dispatchTimer = null;
|
||||
pendingItems = null;
|
||||
};
|
||||
/**
|
||||
* Iterate through the items and split them into groups based on the `batchLoader`'s validate function
|
||||
*/
|
||||
function groupItems(items) {
|
||||
const groupedItems = [[]];
|
||||
let index = 0;
|
||||
while (true) {
|
||||
const item = items[index];
|
||||
if (!item) break;
|
||||
const lastGroup = groupedItems[groupedItems.length - 1];
|
||||
if (item.aborted) {
|
||||
var _item$reject;
|
||||
(_item$reject = item.reject) === null || _item$reject === void 0 || _item$reject.call(item, new Error("Aborted"));
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
const isValid = batchLoader.validate(lastGroup.concat(item).map((it) => it.key));
|
||||
if (isValid) {
|
||||
lastGroup.push(item);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
if (lastGroup.length === 0) {
|
||||
var _item$reject2;
|
||||
(_item$reject2 = item.reject) === null || _item$reject2 === void 0 || _item$reject2.call(item, new Error("Input is too big for a single dispatch"));
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
groupedItems.push([]);
|
||||
}
|
||||
return groupedItems;
|
||||
}
|
||||
function dispatch() {
|
||||
const groupedItems = groupItems(pendingItems);
|
||||
destroyTimerAndPendingItems();
|
||||
for (const items of groupedItems) {
|
||||
if (!items.length) continue;
|
||||
const batch = { items };
|
||||
for (const item of items) item.batch = batch;
|
||||
const promise = batchLoader.fetch(batch.items.map((_item) => _item.key));
|
||||
promise.then(async (result) => {
|
||||
await Promise.all(result.map(async (valueOrPromise, index) => {
|
||||
const item = batch.items[index];
|
||||
try {
|
||||
var _item$resolve;
|
||||
const value = await Promise.resolve(valueOrPromise);
|
||||
(_item$resolve = item.resolve) === null || _item$resolve === void 0 || _item$resolve.call(item, value);
|
||||
} catch (cause) {
|
||||
var _item$reject3;
|
||||
(_item$reject3 = item.reject) === null || _item$reject3 === void 0 || _item$reject3.call(item, cause);
|
||||
}
|
||||
item.batch = null;
|
||||
item.reject = null;
|
||||
item.resolve = null;
|
||||
}));
|
||||
for (const item of batch.items) {
|
||||
var _item$reject4;
|
||||
(_item$reject4 = item.reject) === null || _item$reject4 === void 0 || _item$reject4.call(item, new Error("Missing result"));
|
||||
item.batch = null;
|
||||
}
|
||||
}).catch((cause) => {
|
||||
for (const item of batch.items) {
|
||||
var _item$reject5;
|
||||
(_item$reject5 = item.reject) === null || _item$reject5 === void 0 || _item$reject5.call(item, cause);
|
||||
item.batch = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function load(key) {
|
||||
var _dispatchTimer;
|
||||
const item = {
|
||||
aborted: false,
|
||||
key,
|
||||
batch: null,
|
||||
resolve: throwFatalError,
|
||||
reject: throwFatalError
|
||||
};
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
var _pendingItems;
|
||||
item.reject = reject;
|
||||
item.resolve = resolve;
|
||||
(_pendingItems = pendingItems) !== null && _pendingItems !== void 0 || (pendingItems = []);
|
||||
pendingItems.push(item);
|
||||
});
|
||||
(_dispatchTimer = dispatchTimer) !== null && _dispatchTimer !== void 0 || (dispatchTimer = setTimeout(dispatch));
|
||||
return promise;
|
||||
}
|
||||
return { load };
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/internals/signals.ts
|
||||
/**
|
||||
* Like `Promise.all()` but for abort signals
|
||||
* - When all signals have been aborted, the merged signal will be aborted
|
||||
* - If one signal is `null`, no signal will be aborted
|
||||
*/
|
||||
function allAbortSignals(...signals) {
|
||||
const ac = new AbortController();
|
||||
const count = signals.length;
|
||||
let abortedCount = 0;
|
||||
const onAbort = () => {
|
||||
if (++abortedCount === count) ac.abort();
|
||||
};
|
||||
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) onAbort();
|
||||
else signal === null || signal === void 0 || signal.addEventListener("abort", onAbort, { once: true });
|
||||
return ac.signal;
|
||||
}
|
||||
/**
|
||||
* Like `Promise.race` but for abort signals
|
||||
*
|
||||
* Basically, a ponyfill for
|
||||
* [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).
|
||||
*/
|
||||
function raceAbortSignals(...signals) {
|
||||
const ac = new AbortController();
|
||||
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) ac.abort();
|
||||
else signal === null || signal === void 0 || signal.addEventListener("abort", () => ac.abort(), { once: true });
|
||||
return ac.signal;
|
||||
}
|
||||
function abortSignalToPromise(signal) {
|
||||
return new Promise((_, reject) => {
|
||||
if (signal.aborted) {
|
||||
reject(signal.reason);
|
||||
return;
|
||||
}
|
||||
signal.addEventListener("abort", () => {
|
||||
reject(signal.reason);
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchLink.ts
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchLink
|
||||
*/
|
||||
function httpBatchLink(opts) {
|
||||
var _opts$maxURLLength, _opts$maxItems;
|
||||
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
||||
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
||||
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
||||
return () => {
|
||||
const batchLoader = (type) => {
|
||||
return {
|
||||
validate(batchOps) {
|
||||
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
||||
if (batchOps.length > maxItems) return false;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const url = getUrl((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
inputs,
|
||||
signal: null
|
||||
}));
|
||||
return url.length <= maxURLLength;
|
||||
},
|
||||
async fetch(batchOps) {
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const signal = allAbortSignals(...batchOps.map((op) => op.signal));
|
||||
const res = await jsonHttpRequester((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
path,
|
||||
inputs,
|
||||
type,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
||||
return opts.headers;
|
||||
},
|
||||
signal
|
||||
}));
|
||||
const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json);
|
||||
const result = resJSON.map((item) => ({
|
||||
meta: res.meta,
|
||||
json: item
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
const query = dataLoader(batchLoader("query"));
|
||||
const mutation = dataLoader(batchLoader("mutation"));
|
||||
const loaders = {
|
||||
query,
|
||||
mutation
|
||||
};
|
||||
return ({ op }) => {
|
||||
return observable((observer) => {
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const loader = loaders[op.type];
|
||||
const promise = loader.load(op);
|
||||
let _res = void 0;
|
||||
promise.then((res) => {
|
||||
_res = res;
|
||||
const transformed = transformResult(res.json, resolvedOpts.transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(TRPCClientError.from(transformed.error, { meta: res.meta }));
|
||||
return;
|
||||
}
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: transformed.result
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((err) => {
|
||||
observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { abortSignalToPromise, allAbortSignals, dataLoader, httpBatchLink, raceAbortSignals };
|
||||
//# sourceMappingURL=httpBatchLink-LhidKAPw.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+33
@@ -0,0 +1,33 @@
|
||||
import { HTTPHeaders, NonEmptyArray, Operation, TRPCLink } from "./types.d-Dmmedc5G.cjs";
|
||||
import { HTTPLinkBaseOptions } from "./httpUtils.d-BqmeKEGo.cjs";
|
||||
import { AnyClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { AnyRouter as AnyRouter$1 } from "@trpc/server";
|
||||
|
||||
//#region src/links/HTTPBatchLinkOptions.d.ts
|
||||
type HTTPBatchLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOptions<TRoot> & {
|
||||
maxURLLength?: number;
|
||||
/**
|
||||
* Headers to be set on outgoing requests or a callback that of said headers
|
||||
* @see http://trpc.io/docs/client/headers
|
||||
*/
|
||||
headers?: HTTPHeaders | ((opts: {
|
||||
opList: NonEmptyArray<Operation>;
|
||||
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
||||
/**
|
||||
* Maximum number of calls in a single batch request
|
||||
* @default Infinity
|
||||
*/
|
||||
maxItems?: number;
|
||||
};
|
||||
//# sourceMappingURL=HTTPBatchLinkOptions.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/httpBatchLink.d.ts
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchLink
|
||||
*/
|
||||
declare function httpBatchLink<TRouter extends AnyRouter$1>(opts: HTTPBatchLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=httpBatchLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { HTTPBatchLinkOptions, httpBatchLink };
|
||||
//# sourceMappingURL=httpBatchLink.d-7jyWtY5H.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpBatchLink.d-7jyWtY5H.d.cts","names":[],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"sourcesContent":[],"mappings":";;;;;;KAKY,mCAAmC,kBAC7C,oBAAoB;;EADV;;;;EACe,OAAzB,CAAA,EAOM,WAPN,GAAA,CAAA,CAAA,IAAA,EAAA;IAOM,MAAA,EAEU,aAFV,CAEwB,SAFxB,CAAA;EAAW,CAAA,EAEa,GAClB,WADkB,GACJ,OADI,CACI,WADJ,CAAA,CAAA;EAAS;;;;EACN,QAAA,CAAA,EAAA,MAAA;;;;;;;;AAXvB,iBCeI,aDfgB,CAAA,gBCec,WDfd,CAAA,CAAA,IAAA,ECgBxB,oBDhBwB,CCgBH,ODhBG,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,ECiB7B,QDjB6B,CCiBpB,ODjBoB,CAAA"}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import { HTTPHeaders, NonEmptyArray, Operation, TRPCLink } from "./types.d-sRNtuQA-.mjs";
|
||||
import { HTTPLinkBaseOptions } from "./httpUtils.d-yYSKGhiS.mjs";
|
||||
import { AnyClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { AnyRouter as AnyRouter$1 } from "@trpc/server";
|
||||
|
||||
//#region src/links/HTTPBatchLinkOptions.d.ts
|
||||
type HTTPBatchLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOptions<TRoot> & {
|
||||
maxURLLength?: number;
|
||||
/**
|
||||
* Headers to be set on outgoing requests or a callback that of said headers
|
||||
* @see http://trpc.io/docs/client/headers
|
||||
*/
|
||||
headers?: HTTPHeaders | ((opts: {
|
||||
opList: NonEmptyArray<Operation>;
|
||||
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
||||
/**
|
||||
* Maximum number of calls in a single batch request
|
||||
* @default Infinity
|
||||
*/
|
||||
maxItems?: number;
|
||||
};
|
||||
//# sourceMappingURL=HTTPBatchLinkOptions.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/httpBatchLink.d.ts
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchLink
|
||||
*/
|
||||
declare function httpBatchLink<TRouter extends AnyRouter$1>(opts: HTTPBatchLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=httpBatchLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { HTTPBatchLinkOptions, httpBatchLink };
|
||||
//# sourceMappingURL=httpBatchLink.d-B6vCg-F-.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpBatchLink.d-B6vCg-F-.d.mts","names":[],"sources":["../src/links/HTTPBatchLinkOptions.ts","../src/links/httpBatchLink.ts"],"sourcesContent":[],"mappings":";;;;;;KAKY,mCAAmC,kBAC7C,oBAAoB;;EADV;;;;EACe,OAAzB,CAAA,EAOM,WAPN,GAAA,CAAA,CAAA,IAAA,EAAA;IAOM,MAAA,EAEU,aAFV,CAEwB,SAFxB,CAAA;EAAW,CAAA,EAEa,GAClB,WADkB,GACJ,OADI,CACI,WADJ,CAAA,CAAA;EAAS;;;;EACN,QAAA,CAAA,EAAA,MAAA;;;;;;;;AAXvB,iBCeI,aDfgB,CAAA,gBCec,WDfd,CAAA,CAAA,IAAA,ECgBxB,oBDhBwB,CCgBH,ODhBG,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,ECiB7B,QDjB6B,CCiBpB,ODjBoB,CAAA"}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_TRPCClientError = require('./TRPCClientError-CQrTQLrk.cjs');
|
||||
const require_httpUtils = require('./httpUtils-wv2o-njD.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
||||
|
||||
//#region src/links/internals/contentTypes.ts
|
||||
function isOctetType(input) {
|
||||
return input instanceof Uint8Array || input instanceof Blob;
|
||||
}
|
||||
function isFormData(input) {
|
||||
return input instanceof FormData;
|
||||
}
|
||||
function isNonJsonSerializable(input) {
|
||||
return isOctetType(input) || isFormData(input);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpLink.ts
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
const universalRequester = (opts) => {
|
||||
if ("input" in opts) {
|
||||
const { input } = opts;
|
||||
if (isFormData(input)) {
|
||||
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
|
||||
return require_httpUtils.httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: void 0,
|
||||
getUrl: require_httpUtils.getUrl,
|
||||
getBody: () => input
|
||||
}));
|
||||
}
|
||||
if (isOctetType(input)) {
|
||||
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
|
||||
return require_httpUtils.httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: "application/octet-stream",
|
||||
getUrl: require_httpUtils.getUrl,
|
||||
getBody: () => input
|
||||
}));
|
||||
}
|
||||
}
|
||||
return require_httpUtils.jsonHttpRequester(opts);
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpLink
|
||||
*/
|
||||
function httpLink(opts) {
|
||||
const resolvedOpts = require_httpUtils.resolveHTTPLinkOptions(opts);
|
||||
return () => {
|
||||
return (operationOpts) => {
|
||||
const { op } = operationOpts;
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
const { path, input, type } = op;
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const request = universalRequester((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
input,
|
||||
signal: op.signal,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ op });
|
||||
return opts.headers;
|
||||
}
|
||||
}));
|
||||
let meta = void 0;
|
||||
request.then((res) => {
|
||||
meta = res.meta;
|
||||
const transformed = (0, __trpc_server_unstable_core_do_not_import.transformResult)(res.json, resolvedOpts.transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(transformed.error, { meta }));
|
||||
return;
|
||||
}
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: transformed.result
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((cause) => {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(cause, { meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'httpLink', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return httpLink;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isFormData', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isFormData;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isNonJsonSerializable', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isNonJsonSerializable;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isOctetType', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isOctetType;
|
||||
}
|
||||
});
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
import { __toESM, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { TRPCClientError } from "./TRPCClientError-apv8gw59.mjs";
|
||||
import { getUrl, httpRequest, jsonHttpRequester, resolveHTTPLinkOptions } from "./httpUtils-pyf5RF99.mjs";
|
||||
import { observable } from "@trpc/server/observable";
|
||||
import { transformResult } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/internals/contentTypes.ts
|
||||
function isOctetType(input) {
|
||||
return input instanceof Uint8Array || input instanceof Blob;
|
||||
}
|
||||
function isFormData(input) {
|
||||
return input instanceof FormData;
|
||||
}
|
||||
function isNonJsonSerializable(input) {
|
||||
return isOctetType(input) || isFormData(input);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpLink.ts
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
const universalRequester = (opts) => {
|
||||
if ("input" in opts) {
|
||||
const { input } = opts;
|
||||
if (isFormData(input)) {
|
||||
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
|
||||
return httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: void 0,
|
||||
getUrl,
|
||||
getBody: () => input
|
||||
}));
|
||||
}
|
||||
if (isOctetType(input)) {
|
||||
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
|
||||
return httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: "application/octet-stream",
|
||||
getUrl,
|
||||
getBody: () => input
|
||||
}));
|
||||
}
|
||||
}
|
||||
return jsonHttpRequester(opts);
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpLink
|
||||
*/
|
||||
function httpLink(opts) {
|
||||
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
||||
return () => {
|
||||
return (operationOpts) => {
|
||||
const { op } = operationOpts;
|
||||
return observable((observer) => {
|
||||
const { path, input, type } = op;
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const request = universalRequester((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
input,
|
||||
signal: op.signal,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ op });
|
||||
return opts.headers;
|
||||
}
|
||||
}));
|
||||
let meta = void 0;
|
||||
request.then((res) => {
|
||||
meta = res.meta;
|
||||
const transformed = transformResult(res.json, resolvedOpts.transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(TRPCClientError.from(transformed.error, { meta }));
|
||||
return;
|
||||
}
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: transformed.result
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((cause) => {
|
||||
observer.error(TRPCClientError.from(cause, { meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { httpLink, isFormData, isNonJsonSerializable, isOctetType };
|
||||
//# sourceMappingURL=httpLink-lG_6juPY.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+23
@@ -0,0 +1,23 @@
|
||||
import { HTTPHeaders, Operation, TRPCLink } from "./types.d-sRNtuQA-.mjs";
|
||||
import { HTTPLinkBaseOptions } from "./httpUtils.d-yYSKGhiS.mjs";
|
||||
import { AnyClientTypes, AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/httpLink.d.ts
|
||||
type HTTPLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOptions<TRoot> & {
|
||||
/**
|
||||
* Headers to be set on outgoing requests or a callback that of said headers
|
||||
* @see http://trpc.io/docs/client/headers
|
||||
*/
|
||||
headers?: HTTPHeaders | ((opts: {
|
||||
op: Operation;
|
||||
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpLink
|
||||
*/
|
||||
declare function httpLink<TRouter extends AnyRouter = AnyRouter>(opts: HTTPLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=httpLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { HTTPLinkOptions, httpLink };
|
||||
//# sourceMappingURL=httpLink.d-CVOTlkUT.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpLink.d-CVOTlkUT.d.mts","names":[],"sources":["../src/links/httpLink.ts"],"sourcesContent":[],"mappings":";;;;;KA0BY,8BAA8B,kBACxC,oBAAoB;;AADtB;;;EAAwD,OAClC,CAAA,EAMd,WANc,GAAA,CAAA,CAAA,IAAA,EAAA;IAApB,EAAA,EAOoB,SAPpB;EAAmB,CAAA,EAMb,GAC8B,WAD9B,GAC4C,OAD5C,CACoD,WADpD,CAAA,CAAA;CAAW;;;;AACwC,iBAwC3C,QAxC2C,CAAA,gBAwClB,SAxCkB,GAwCN,SAxCM,CAAA,CAAA,IAAA,EAyCnD,eAzCmD,CAyCnC,OAzCmC,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,EA0CxD,QA1CwD,CA0C/C,OA1C+C,CAAA;AAwC3D"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { HTTPHeaders, Operation, TRPCLink } from "./types.d-Dmmedc5G.cjs";
|
||||
import { HTTPLinkBaseOptions } from "./httpUtils.d-BqmeKEGo.cjs";
|
||||
import { AnyClientTypes, AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/httpLink.d.ts
|
||||
type HTTPLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOptions<TRoot> & {
|
||||
/**
|
||||
* Headers to be set on outgoing requests or a callback that of said headers
|
||||
* @see http://trpc.io/docs/client/headers
|
||||
*/
|
||||
headers?: HTTPHeaders | ((opts: {
|
||||
op: Operation;
|
||||
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpLink
|
||||
*/
|
||||
declare function httpLink<TRouter extends AnyRouter = AnyRouter>(opts: HTTPLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=httpLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { HTTPLinkOptions, httpLink };
|
||||
//# sourceMappingURL=httpLink.d-D5qR9haY.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpLink.d-D5qR9haY.d.cts","names":[],"sources":["../src/links/httpLink.ts"],"sourcesContent":[],"mappings":";;;;;KA0BY,8BAA8B,kBACxC,oBAAoB;;AADtB;;;EAAwD,OAClC,CAAA,EAMd,WANc,GAAA,CAAA,CAAA,IAAA,EAAA;IAApB,EAAA,EAOoB,SAPpB;EAAmB,CAAA,EAMb,GAC8B,WAD9B,GAC4C,OAD5C,CACoD,WADpD,CAAA,CAAA;CAAW;;;;AACwC,iBAwC3C,QAxC2C,CAAA,gBAwClB,SAxCkB,GAwCN,SAxCM,CAAA,CAAA,IAAA,EAyCnD,eAzCmD,CAyCnC,OAzCmC,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,EA0CxD,QA1CwD,CA0C/C,OA1C+C,CAAA;AAwC3D"}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
import { __toESM, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { getTransformer } from "./unstable-internals-Bg7n9BBj.mjs";
|
||||
|
||||
//#region src/getFetch.ts
|
||||
const isFunction = (fn) => typeof fn === "function";
|
||||
function getFetch(customFetchImpl) {
|
||||
if (customFetchImpl) return customFetchImpl;
|
||||
if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
|
||||
if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
|
||||
throw new Error("No fetch implementation found");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/httpUtils.ts
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
function resolveHTTPLinkOptions(opts) {
|
||||
return {
|
||||
url: opts.url.toString(),
|
||||
fetch: opts.fetch,
|
||||
transformer: getTransformer(opts.transformer),
|
||||
methodOverride: opts.methodOverride
|
||||
};
|
||||
}
|
||||
function arrayToDict(array) {
|
||||
const dict = {};
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
const element = array[index];
|
||||
dict[index] = element;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
const METHOD = {
|
||||
query: "GET",
|
||||
mutation: "POST",
|
||||
subscription: "PATCH"
|
||||
};
|
||||
function getInput(opts) {
|
||||
return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
|
||||
}
|
||||
const getUrl = (opts) => {
|
||||
const parts = opts.url.split("?");
|
||||
const base = parts[0].replace(/\/$/, "");
|
||||
let url = base + "/" + opts.path;
|
||||
const queryParts = [];
|
||||
if (parts[1]) queryParts.push(parts[1]);
|
||||
if ("inputs" in opts) queryParts.push("batch=1");
|
||||
if (opts.type === "query" || opts.type === "subscription") {
|
||||
const input = getInput(opts);
|
||||
if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
||||
}
|
||||
if (queryParts.length) url += "?" + queryParts.join("&");
|
||||
return url;
|
||||
};
|
||||
const getBody = (opts) => {
|
||||
if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
|
||||
const input = getInput(opts);
|
||||
return input !== void 0 ? JSON.stringify(input) : void 0;
|
||||
};
|
||||
const jsonHttpRequester = (opts) => {
|
||||
return httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: "application/json",
|
||||
getUrl,
|
||||
getBody
|
||||
}));
|
||||
};
|
||||
/**
|
||||
* Polyfill for DOMException with AbortError name
|
||||
*/
|
||||
var AbortError = class extends Error {
|
||||
constructor() {
|
||||
const name = "AbortError";
|
||||
super(name);
|
||||
this.name = name;
|
||||
this.message = name;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Polyfill for `signal.throwIfAborted()`
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted
|
||||
*/
|
||||
const throwIfAborted = (signal) => {
|
||||
var _signal$throwIfAborte;
|
||||
if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return;
|
||||
(_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal);
|
||||
if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
|
||||
throw new AbortError();
|
||||
};
|
||||
async function fetchHTTPResponse(opts) {
|
||||
var _opts$methodOverride, _opts$trpcAcceptHeade;
|
||||
throwIfAborted(opts.signal);
|
||||
const url = opts.getUrl(opts);
|
||||
const body = opts.getBody(opts);
|
||||
const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type];
|
||||
const resolvedHeaders = await (async () => {
|
||||
const heads = await opts.headers();
|
||||
if (Symbol.iterator in heads) return Object.fromEntries(heads);
|
||||
return heads;
|
||||
})();
|
||||
const headers = (0, import_objectSpread2.default)((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
|
||||
return getFetch(opts.fetch)(url, {
|
||||
method,
|
||||
signal: opts.signal,
|
||||
body,
|
||||
headers
|
||||
});
|
||||
}
|
||||
async function httpRequest(opts) {
|
||||
const meta = {};
|
||||
const res = await fetchHTTPResponse(opts);
|
||||
meta.response = res;
|
||||
const json = await res.json();
|
||||
meta.responseJSON = json;
|
||||
return {
|
||||
json,
|
||||
meta
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { fetchHTTPResponse, getBody, getFetch, getUrl, httpRequest, jsonHttpRequester, resolveHTTPLinkOptions };
|
||||
//# sourceMappingURL=httpUtils-pyf5RF99.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+163
@@ -0,0 +1,163 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
|
||||
|
||||
//#region src/getFetch.ts
|
||||
const isFunction = (fn) => typeof fn === "function";
|
||||
function getFetch(customFetchImpl) {
|
||||
if (customFetchImpl) return customFetchImpl;
|
||||
if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
|
||||
if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
|
||||
throw new Error("No fetch implementation found");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/httpUtils.ts
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
function resolveHTTPLinkOptions(opts) {
|
||||
return {
|
||||
url: opts.url.toString(),
|
||||
fetch: opts.fetch,
|
||||
transformer: require_unstable_internals.getTransformer(opts.transformer),
|
||||
methodOverride: opts.methodOverride
|
||||
};
|
||||
}
|
||||
function arrayToDict(array) {
|
||||
const dict = {};
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
const element = array[index];
|
||||
dict[index] = element;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
const METHOD = {
|
||||
query: "GET",
|
||||
mutation: "POST",
|
||||
subscription: "PATCH"
|
||||
};
|
||||
function getInput(opts) {
|
||||
return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
|
||||
}
|
||||
const getUrl = (opts) => {
|
||||
const parts = opts.url.split("?");
|
||||
const base = parts[0].replace(/\/$/, "");
|
||||
let url = base + "/" + opts.path;
|
||||
const queryParts = [];
|
||||
if (parts[1]) queryParts.push(parts[1]);
|
||||
if ("inputs" in opts) queryParts.push("batch=1");
|
||||
if (opts.type === "query" || opts.type === "subscription") {
|
||||
const input = getInput(opts);
|
||||
if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
||||
}
|
||||
if (queryParts.length) url += "?" + queryParts.join("&");
|
||||
return url;
|
||||
};
|
||||
const getBody = (opts) => {
|
||||
if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
|
||||
const input = getInput(opts);
|
||||
return input !== void 0 ? JSON.stringify(input) : void 0;
|
||||
};
|
||||
const jsonHttpRequester = (opts) => {
|
||||
return httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
||||
contentTypeHeader: "application/json",
|
||||
getUrl,
|
||||
getBody
|
||||
}));
|
||||
};
|
||||
/**
|
||||
* Polyfill for DOMException with AbortError name
|
||||
*/
|
||||
var AbortError = class extends Error {
|
||||
constructor() {
|
||||
const name = "AbortError";
|
||||
super(name);
|
||||
this.name = name;
|
||||
this.message = name;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Polyfill for `signal.throwIfAborted()`
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted
|
||||
*/
|
||||
const throwIfAborted = (signal) => {
|
||||
var _signal$throwIfAborte;
|
||||
if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return;
|
||||
(_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal);
|
||||
if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
|
||||
throw new AbortError();
|
||||
};
|
||||
async function fetchHTTPResponse(opts) {
|
||||
var _opts$methodOverride, _opts$trpcAcceptHeade;
|
||||
throwIfAborted(opts.signal);
|
||||
const url = opts.getUrl(opts);
|
||||
const body = opts.getBody(opts);
|
||||
const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type];
|
||||
const resolvedHeaders = await (async () => {
|
||||
const heads = await opts.headers();
|
||||
if (Symbol.iterator in heads) return Object.fromEntries(heads);
|
||||
return heads;
|
||||
})();
|
||||
const headers = (0, import_objectSpread2.default)((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
|
||||
return getFetch(opts.fetch)(url, {
|
||||
method,
|
||||
signal: opts.signal,
|
||||
body,
|
||||
headers
|
||||
});
|
||||
}
|
||||
async function httpRequest(opts) {
|
||||
const meta = {};
|
||||
const res = await fetchHTTPResponse(opts);
|
||||
meta.response = res;
|
||||
const json = await res.json();
|
||||
meta.responseJSON = json;
|
||||
return {
|
||||
json,
|
||||
meta
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'fetchHTTPResponse', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return fetchHTTPResponse;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getBody', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return getBody;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getFetch', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return getFetch;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'getUrl', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return getUrl;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'httpRequest', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return httpRequest;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'jsonHttpRequester', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return jsonHttpRequester;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'resolveHTTPLinkOptions', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return resolveHTTPLinkOptions;
|
||||
}
|
||||
});
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { FetchEsque } from "./types.d-Dmmedc5G.cjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-kWsZTlQq.cjs";
|
||||
import { AnyClientTypes, CombinedDataTransformer, Maybe, ProcedureType } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/internals/httpUtils.d.ts
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type HTTPLinkBaseOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = {
|
||||
url: string | URL;
|
||||
/**
|
||||
* Add ponyfill for fetch
|
||||
*/
|
||||
fetch?: FetchEsque;
|
||||
/**
|
||||
* Send all requests `as POST`s requests regardless of the procedure type
|
||||
* The HTTP handler must separately allow overriding the method. See:
|
||||
* @see https://trpc.io/docs/rpc
|
||||
*/
|
||||
methodOverride?: 'POST';
|
||||
} & TransformerOptions<TRoot>;
|
||||
//#endregion
|
||||
export { HTTPLinkBaseOptions };
|
||||
//# sourceMappingURL=httpUtils.d-BqmeKEGo.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpUtils.d-BqmeKEGo.d.cts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqBA;;AACqB,KADT,mBACS,CAAA,cAAL,IAAK,CAAA,cAAA,EAAA,aAAA,CAAA,CAAA,GAAA;EAAc,GAAnB,EAAA,MAAA,GAEA,GAFA;EAAI;;;EAaQ,KAAxB,CAAA,EAPM,UAON;EAAkB;;;;;;IAAlB,mBAAmB"}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { FetchEsque } from "./types.d-sRNtuQA-.mjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-BOmV7EK1.mjs";
|
||||
import { AnyClientTypes, CombinedDataTransformer, Maybe, ProcedureType } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/internals/httpUtils.d.ts
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type HTTPLinkBaseOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = {
|
||||
url: string | URL;
|
||||
/**
|
||||
* Add ponyfill for fetch
|
||||
*/
|
||||
fetch?: FetchEsque;
|
||||
/**
|
||||
* Send all requests `as POST`s requests regardless of the procedure type
|
||||
* The HTTP handler must separately allow overriding the method. See:
|
||||
* @see https://trpc.io/docs/rpc
|
||||
*/
|
||||
methodOverride?: 'POST';
|
||||
} & TransformerOptions<TRoot>;
|
||||
//#endregion
|
||||
export { HTTPLinkBaseOptions };
|
||||
//# sourceMappingURL=httpUtils.d-yYSKGhiS.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"httpUtils.d-yYSKGhiS.d.mts","names":[],"sources":["../src/links/internals/httpUtils.ts"],"sourcesContent":[],"mappings":";;;;;;;AAqBA;;AACqB,KADT,mBACS,CAAA,cAAL,IAAK,CAAA,cAAA,EAAA,aAAA,CAAA,CAAA,GAAA;EAAc,GAAnB,EAAA,MAAA,GAEA,GAFA;EAAI;;;EAaQ,KAAxB,CAAA,EAPM,UAON;EAAkB;;;;;;IAAlB,mBAAmB"}
|
||||
+912
@@ -0,0 +1,912 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_splitLink = require('./splitLink-BMgxggng.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_TRPCClientError = require('./TRPCClientError-CQrTQLrk.cjs');
|
||||
const require_httpUtils = require('./httpUtils-wv2o-njD.cjs');
|
||||
const require_httpLink = require('./httpLink-B8Iv31Ee.cjs');
|
||||
const require_httpBatchLink = require('./httpBatchLink-BGZRsGNf.cjs');
|
||||
const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
|
||||
const require_loggerLink = require('./loggerLink-CuYvRzyH.cjs');
|
||||
const require_wsLink = require('./wsLink-CobRSm6C.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
||||
const __trpc_server = require_chunk.__toESM(require("@trpc/server"));
|
||||
const __trpc_server_rpc = require_chunk.__toESM(require("@trpc/server/rpc"));
|
||||
|
||||
//#region src/internals/TRPCUntypedClient.ts
|
||||
var import_defineProperty = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
var import_objectSpread2$4 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
var TRPCUntypedClient = class {
|
||||
constructor(opts) {
|
||||
(0, import_defineProperty.default)(this, "links", void 0);
|
||||
(0, import_defineProperty.default)(this, "runtime", void 0);
|
||||
(0, import_defineProperty.default)(this, "requestId", void 0);
|
||||
this.requestId = 0;
|
||||
this.runtime = {};
|
||||
this.links = opts.links.map((link) => link(this.runtime));
|
||||
}
|
||||
$request(opts) {
|
||||
var _opts$context;
|
||||
const chain$ = require_splitLink.createChain({
|
||||
links: this.links,
|
||||
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
||||
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
||||
id: ++this.requestId
|
||||
})
|
||||
});
|
||||
return chain$.pipe((0, __trpc_server_observable.share)());
|
||||
}
|
||||
async requestAsPromise(opts) {
|
||||
var _this = this;
|
||||
try {
|
||||
const req$ = _this.$request(opts);
|
||||
const envelope = await (0, __trpc_server_observable.observableToPromise)(req$);
|
||||
const data = envelope.result.data;
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw require_TRPCClientError.TRPCClientError.from(err);
|
||||
}
|
||||
}
|
||||
query(path, input, opts) {
|
||||
return this.requestAsPromise({
|
||||
type: "query",
|
||||
path,
|
||||
input,
|
||||
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
||||
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
||||
});
|
||||
}
|
||||
mutation(path, input, opts) {
|
||||
return this.requestAsPromise({
|
||||
type: "mutation",
|
||||
path,
|
||||
input,
|
||||
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
||||
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
||||
});
|
||||
}
|
||||
subscription(path, input, opts) {
|
||||
const observable$ = this.$request({
|
||||
type: "subscription",
|
||||
path,
|
||||
input,
|
||||
context: opts.context,
|
||||
signal: opts.signal
|
||||
});
|
||||
return observable$.subscribe({
|
||||
next(envelope) {
|
||||
switch (envelope.result.type) {
|
||||
case "state": {
|
||||
var _opts$onConnectionSta;
|
||||
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
||||
break;
|
||||
}
|
||||
case "started": {
|
||||
var _opts$onStarted;
|
||||
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
||||
break;
|
||||
}
|
||||
case "stopped": {
|
||||
var _opts$onStopped;
|
||||
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
||||
break;
|
||||
}
|
||||
case "data":
|
||||
case void 0: {
|
||||
var _opts$onData;
|
||||
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
error(err) {
|
||||
var _opts$onError;
|
||||
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
||||
},
|
||||
complete() {
|
||||
var _opts$onComplete;
|
||||
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/createTRPCUntypedClient.ts
|
||||
function createTRPCUntypedClient(opts) {
|
||||
return new TRPCUntypedClient(opts);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/createTRPCClient.ts
|
||||
const untypedClientSymbol = Symbol.for("trpc_untypedClient");
|
||||
const clientCallTypeMap = {
|
||||
query: "query",
|
||||
mutate: "mutation",
|
||||
subscribe: "subscription"
|
||||
};
|
||||
/** @internal */
|
||||
const clientCallTypeToProcedureType = (clientCallType) => {
|
||||
return clientCallTypeMap[clientCallType];
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function createTRPCClientProxy(client) {
|
||||
const proxy = (0, __trpc_server_unstable_core_do_not_import.createRecursiveProxy)(({ path, args }) => {
|
||||
const pathCopy = [...path];
|
||||
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
||||
const fullPath = pathCopy.join(".");
|
||||
return client[procedureType](fullPath, ...args);
|
||||
});
|
||||
return (0, __trpc_server_unstable_core_do_not_import.createFlatProxy)((key) => {
|
||||
if (key === untypedClientSymbol) return client;
|
||||
return proxy[key];
|
||||
});
|
||||
}
|
||||
function createTRPCClient(opts) {
|
||||
const client = new TRPCUntypedClient(opts);
|
||||
const proxy = createTRPCClientProxy(client);
|
||||
return proxy;
|
||||
}
|
||||
/**
|
||||
* Get an untyped client from a proxy client
|
||||
* @internal
|
||||
*/
|
||||
function getUntypedClient(client) {
|
||||
return client[untypedClientSymbol];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchStreamLink.ts
|
||||
var import_objectSpread2$3 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
||||
*/
|
||||
function httpBatchStreamLink(opts) {
|
||||
var _opts$maxURLLength, _opts$maxItems;
|
||||
const resolvedOpts = require_httpUtils.resolveHTTPLinkOptions(opts);
|
||||
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
||||
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
||||
return () => {
|
||||
const batchLoader = (type) => {
|
||||
return {
|
||||
validate(batchOps) {
|
||||
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
||||
if (batchOps.length > maxItems) return false;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const url = require_httpUtils.getUrl((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
inputs,
|
||||
signal: null
|
||||
}));
|
||||
return url.length <= maxURLLength;
|
||||
},
|
||||
async fetch(batchOps) {
|
||||
var _opts$streamHeader;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const batchSignals = require_httpBatchLink.allAbortSignals(...batchOps.map((op) => op.signal));
|
||||
const abortController = new AbortController();
|
||||
const responsePromise = require_httpUtils.fetchHTTPResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
||||
signal: require_httpBatchLink.raceAbortSignals(batchSignals, abortController.signal),
|
||||
type,
|
||||
contentTypeHeader: "application/json",
|
||||
trpcAcceptHeader: "application/jsonl",
|
||||
trpcAcceptHeaderKey: (_opts$streamHeader = opts.streamHeader) !== null && _opts$streamHeader !== void 0 ? _opts$streamHeader : "trpc-accept",
|
||||
getUrl: require_httpUtils.getUrl,
|
||||
getBody: require_httpUtils.getBody,
|
||||
inputs,
|
||||
path,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
||||
return opts.headers;
|
||||
}
|
||||
}));
|
||||
const res = await responsePromise;
|
||||
if (!res.ok) {
|
||||
const json = await res.json();
|
||||
if ("error" in json) json.error = resolvedOpts.transformer.output.deserialize(json.error);
|
||||
return batchOps.map(() => Promise.resolve({
|
||||
json,
|
||||
meta: { response: res }
|
||||
}));
|
||||
}
|
||||
const [head] = await (0, __trpc_server_unstable_core_do_not_import.jsonlStreamConsumer)({
|
||||
from: res.body,
|
||||
deserialize: (data) => resolvedOpts.transformer.output.deserialize(data),
|
||||
formatError(opts$1) {
|
||||
const error = opts$1.error;
|
||||
return require_TRPCClientError.TRPCClientError.from({ error });
|
||||
},
|
||||
abortController
|
||||
});
|
||||
const promises = Object.keys(batchOps).map(async (key) => {
|
||||
let json = await Promise.resolve(head[key]);
|
||||
if ("result" in json) {
|
||||
/**
|
||||
* Not very pretty, but we need to unwrap nested data as promises
|
||||
* Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
|
||||
*/
|
||||
const result = await Promise.resolve(json.result);
|
||||
json = { result: { data: await Promise.resolve(result.data) } };
|
||||
}
|
||||
return {
|
||||
json,
|
||||
meta: { response: res }
|
||||
};
|
||||
});
|
||||
return promises;
|
||||
}
|
||||
};
|
||||
};
|
||||
const query = require_httpBatchLink.dataLoader(batchLoader("query"));
|
||||
const mutation = require_httpBatchLink.dataLoader(batchLoader("mutation"));
|
||||
const loaders = {
|
||||
query,
|
||||
mutation
|
||||
};
|
||||
return ({ op }) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const loader = loaders[op.type];
|
||||
const promise = loader.load(op);
|
||||
let _res = void 0;
|
||||
promise.then((res) => {
|
||||
_res = res;
|
||||
if ("error" in res.json) {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(res.json, { meta: res.meta }));
|
||||
return;
|
||||
} else if ("result" in res.json) {
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: res.json.result
|
||||
});
|
||||
observer.complete();
|
||||
return;
|
||||
}
|
||||
observer.complete();
|
||||
}).catch((err) => {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link httpBatchStreamLink} instead
|
||||
*/
|
||||
const unstable_httpBatchStreamLink = httpBatchStreamLink;
|
||||
|
||||
//#endregion
|
||||
//#region src/internals/inputWithTrackedEventId.ts
|
||||
var import_objectSpread2$2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
function inputWithTrackedEventId(input, lastEventId) {
|
||||
if (!lastEventId) return input;
|
||||
if (input != null && typeof input !== "object") return input;
|
||||
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId });
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
|
||||
var require_asyncIterator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
|
||||
function _asyncIterator$1(r) {
|
||||
var n, t, o, e = 2;
|
||||
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
||||
if (t && null != (n = r[t])) return n.call(r);
|
||||
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
||||
t = "@@asyncIterator", o = "@@iterator";
|
||||
}
|
||||
throw new TypeError("Object is not async iterable");
|
||||
}
|
||||
function AsyncFromSyncIterator(r) {
|
||||
function AsyncFromSyncIteratorContinuation(r$1) {
|
||||
if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
|
||||
var n = r$1.done;
|
||||
return Promise.resolve(r$1.value).then(function(r$2) {
|
||||
return {
|
||||
value: r$2,
|
||||
done: n
|
||||
};
|
||||
});
|
||||
}
|
||||
return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
|
||||
this.s = r$1, this.n = r$1.next;
|
||||
}, AsyncFromSyncIterator.prototype = {
|
||||
s: null,
|
||||
n: null,
|
||||
next: function next() {
|
||||
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
||||
},
|
||||
"return": function _return(r$1) {
|
||||
var n = this.s["return"];
|
||||
return void 0 === n ? Promise.resolve({
|
||||
value: r$1,
|
||||
done: !0
|
||||
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
||||
},
|
||||
"throw": function _throw(r$1) {
|
||||
var n = this.s["return"];
|
||||
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
||||
}
|
||||
}, new AsyncFromSyncIterator(r);
|
||||
}
|
||||
module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpSubscriptionLink.ts
|
||||
var import_asyncIterator = require_chunk.__toESM(require_asyncIterator(), 1);
|
||||
async function urlWithConnectionParams(opts) {
|
||||
let url = await require_wsLink.resultOf(opts.url);
|
||||
if (opts.connectionParams) {
|
||||
const params = await require_wsLink.resultOf(opts.connectionParams);
|
||||
const prefix = url.includes("?") ? "&" : "?";
|
||||
url += prefix + "connectionParams=" + encodeURIComponent(JSON.stringify(params));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
||||
*/
|
||||
function httpSubscriptionLink(opts) {
|
||||
const transformer = require_unstable_internals.getTransformer(opts.transformer);
|
||||
return () => {
|
||||
return ({ op }) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
var _opts$EventSource;
|
||||
const { type, path, input } = op;
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
|
||||
let lastEventId = void 0;
|
||||
const ac = new AbortController();
|
||||
const signal = require_httpBatchLink.raceAbortSignals(op.signal, ac.signal);
|
||||
const eventSourceStream = (0, __trpc_server_unstable_core_do_not_import.sseStreamConsumer)({
|
||||
url: async () => require_httpUtils.getUrl({
|
||||
transformer,
|
||||
url: await urlWithConnectionParams(opts),
|
||||
input: inputWithTrackedEventId(input, lastEventId),
|
||||
path,
|
||||
type,
|
||||
signal: null
|
||||
}),
|
||||
init: () => require_wsLink.resultOf(opts.eventSourceOptions, { op }),
|
||||
signal,
|
||||
deserialize: (data) => transformer.output.deserialize(data),
|
||||
EventSource: (_opts$EventSource = opts.EventSource) !== null && _opts$EventSource !== void 0 ? _opts$EventSource : globalThis.EventSource
|
||||
});
|
||||
const connectionState = (0, __trpc_server_observable.behaviorSubject)({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
const connectionSub = connectionState.subscribe({ next(state) {
|
||||
observer.next({ result: state });
|
||||
} });
|
||||
(0, __trpc_server_unstable_core_do_not_import.run)(async () => {
|
||||
var _iteratorAbruptCompletion = false;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError;
|
||||
try {
|
||||
for (var _iterator = (0, import_asyncIterator.default)(eventSourceStream), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
||||
const chunk = _step.value;
|
||||
switch (chunk.type) {
|
||||
case "ping": break;
|
||||
case "data":
|
||||
const chunkData = chunk.data;
|
||||
let result;
|
||||
if (chunkData.id) {
|
||||
lastEventId = chunkData.id;
|
||||
result = {
|
||||
id: chunkData.id,
|
||||
data: chunkData
|
||||
};
|
||||
} else result = { data: chunkData.data };
|
||||
observer.next({
|
||||
result,
|
||||
context: { eventSource: chunk.eventSource }
|
||||
});
|
||||
break;
|
||||
case "connected": {
|
||||
observer.next({
|
||||
result: { type: "started" },
|
||||
context: { eventSource: chunk.eventSource }
|
||||
});
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "serialized-error": {
|
||||
const error = require_TRPCClientError.TRPCClientError.from({ error: chunk.error });
|
||||
if (__trpc_server_unstable_core_do_not_import.retryableRpcCodes.includes(chunk.error.code)) {
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error
|
||||
});
|
||||
break;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
case "connecting": {
|
||||
const lastState = connectionState.get();
|
||||
const error = chunk.event && require_TRPCClientError.TRPCClientError.from(chunk.event);
|
||||
if (!error && lastState.state === "connecting") break;
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "timeout": connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: new require_TRPCClientError.TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
|
||||
} finally {
|
||||
if (_didIteratorError) throw _iteratorError;
|
||||
}
|
||||
}
|
||||
observer.next({ result: { type: "stopped" } });
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((error) => {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(error));
|
||||
});
|
||||
return () => {
|
||||
observer.complete();
|
||||
ac.abort();
|
||||
connectionSub.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link httpSubscriptionLink} instead
|
||||
*/
|
||||
const unstable_httpSubscriptionLink = httpSubscriptionLink;
|
||||
|
||||
//#endregion
|
||||
//#region src/links/retryLink.ts
|
||||
var import_objectSpread2$1 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/retryLink
|
||||
*/
|
||||
function retryLink(opts) {
|
||||
return () => {
|
||||
return (callOpts) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
let next$;
|
||||
let callNextTimeout = void 0;
|
||||
let lastEventId = void 0;
|
||||
attempt(1);
|
||||
function opWithLastEventId() {
|
||||
const op = callOpts.op;
|
||||
if (!lastEventId) return op;
|
||||
return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) });
|
||||
}
|
||||
function attempt(attempts) {
|
||||
const op = opWithLastEventId();
|
||||
next$ = callOpts.next(op).subscribe({
|
||||
error(error) {
|
||||
var _opts$retryDelayMs, _opts$retryDelayMs2;
|
||||
const shouldRetry = opts.retry({
|
||||
op,
|
||||
attempts,
|
||||
error
|
||||
});
|
||||
if (!shouldRetry) {
|
||||
observer.error(error);
|
||||
return;
|
||||
}
|
||||
const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0;
|
||||
if (delayMs <= 0) {
|
||||
attempt(attempts + 1);
|
||||
return;
|
||||
}
|
||||
callNextTimeout = setTimeout(() => attempt(attempts + 1), delayMs);
|
||||
},
|
||||
next(envelope) {
|
||||
if ((!envelope.result.type || envelope.result.type === "data") && envelope.result.id) lastEventId = envelope.result.id;
|
||||
observer.next(envelope);
|
||||
},
|
||||
complete() {
|
||||
observer.complete();
|
||||
}
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
next$.unsubscribe();
|
||||
clearTimeout(callNextTimeout);
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
||||
var require_usingCtx = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
||||
function _usingCtx() {
|
||||
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
||||
var n$1 = Error();
|
||||
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
||||
}, e = {}, n = [];
|
||||
function using(r$1, e$1) {
|
||||
if (null != e$1) {
|
||||
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
||||
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
||||
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
||||
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
||||
t && (o = function o$1() {
|
||||
try {
|
||||
t.call(e$1);
|
||||
} catch (r$2) {
|
||||
return Promise.reject(r$2);
|
||||
}
|
||||
}), n.push({
|
||||
v: e$1,
|
||||
d: o,
|
||||
a: r$1
|
||||
});
|
||||
} else r$1 && n.push({
|
||||
d: e$1,
|
||||
a: r$1
|
||||
});
|
||||
return e$1;
|
||||
}
|
||||
return {
|
||||
e,
|
||||
u: using.bind(null, !1),
|
||||
a: using.bind(null, !0),
|
||||
d: function d() {
|
||||
var o, t = this.e, s = 0;
|
||||
function next() {
|
||||
for (; o = n.pop();) try {
|
||||
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
||||
if (o.d) {
|
||||
var r$1 = o.d.call(o.v);
|
||||
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
||||
} else s |= 1;
|
||||
} catch (r$2) {
|
||||
return err(r$2);
|
||||
}
|
||||
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
||||
if (t !== e) throw t;
|
||||
}
|
||||
function err(n$1) {
|
||||
return t = t !== e ? new r(n$1, t) : n$1, next();
|
||||
}
|
||||
return next();
|
||||
}
|
||||
};
|
||||
}
|
||||
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js
|
||||
var require_OverloadYield = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
|
||||
function _OverloadYield(e, d) {
|
||||
this.v = e, this.k = d;
|
||||
}
|
||||
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js
|
||||
var require_awaitAsyncGenerator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
|
||||
var OverloadYield$1 = require_OverloadYield();
|
||||
function _awaitAsyncGenerator$1(e) {
|
||||
return new OverloadYield$1(e, 0);
|
||||
}
|
||||
module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js
|
||||
var require_wrapAsyncGenerator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
|
||||
var OverloadYield = require_OverloadYield();
|
||||
function _wrapAsyncGenerator$1(e) {
|
||||
return function() {
|
||||
return new AsyncGenerator(e.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
function AsyncGenerator(e) {
|
||||
var r, t;
|
||||
function resume(r$1, t$1) {
|
||||
try {
|
||||
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
||||
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
||||
if (u) {
|
||||
var i = "return" === r$1 ? "return" : "next";
|
||||
if (!o.k || t$2.done) return resume(i, t$2);
|
||||
t$2 = e[i](t$2).value;
|
||||
}
|
||||
settle(n.done ? "return" : "normal", t$2);
|
||||
}, function(e$1) {
|
||||
resume("throw", e$1);
|
||||
});
|
||||
} catch (e$1) {
|
||||
settle("throw", e$1);
|
||||
}
|
||||
}
|
||||
function settle(e$1, n) {
|
||||
switch (e$1) {
|
||||
case "return":
|
||||
r.resolve({
|
||||
value: n,
|
||||
done: !0
|
||||
});
|
||||
break;
|
||||
case "throw":
|
||||
r.reject(n);
|
||||
break;
|
||||
default: r.resolve({
|
||||
value: n,
|
||||
done: !1
|
||||
});
|
||||
}
|
||||
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
||||
}
|
||||
this._invoke = function(e$1, n) {
|
||||
return new Promise(function(o, u) {
|
||||
var i = {
|
||||
key: e$1,
|
||||
arg: n,
|
||||
resolve: o,
|
||||
reject: u,
|
||||
next: null
|
||||
};
|
||||
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
||||
});
|
||||
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
||||
}
|
||||
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
||||
return this;
|
||||
}, AsyncGenerator.prototype.next = function(e) {
|
||||
return this._invoke("next", e);
|
||||
}, AsyncGenerator.prototype["throw"] = function(e) {
|
||||
return this._invoke("throw", e);
|
||||
}, AsyncGenerator.prototype["return"] = function(e) {
|
||||
return this._invoke("return", e);
|
||||
};
|
||||
module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region src/links/localLink.ts
|
||||
var import_usingCtx = require_chunk.__toESM(require_usingCtx(), 1);
|
||||
var import_awaitAsyncGenerator = require_chunk.__toESM(require_awaitAsyncGenerator(), 1);
|
||||
var import_wrapAsyncGenerator = require_chunk.__toESM(require_wrapAsyncGenerator(), 1);
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
/**
|
||||
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
||||
*
|
||||
* @see https://trpc.io/docs/links/localLink
|
||||
*/
|
||||
function unstable_localLink(opts) {
|
||||
const transformer = require_unstable_internals.getTransformer(opts.transformer);
|
||||
const transformChunk = (chunk) => {
|
||||
if (opts.transformer) return chunk;
|
||||
if (chunk === void 0) return chunk;
|
||||
const serialized = JSON.stringify(transformer.input.serialize(chunk));
|
||||
const deserialized = JSON.parse(transformer.output.deserialize(serialized));
|
||||
return deserialized;
|
||||
};
|
||||
return () => ({ op }) => (0, __trpc_server_observable.observable)((observer) => {
|
||||
let ctx = void 0;
|
||||
const ac = new AbortController();
|
||||
const signal = require_httpBatchLink.raceAbortSignals(op.signal, ac.signal);
|
||||
const signalPromise = require_httpBatchLink.abortSignalToPromise(signal);
|
||||
signalPromise.catch(() => {});
|
||||
let input = op.input;
|
||||
async function runProcedure(newInput) {
|
||||
input = newInput;
|
||||
ctx = await opts.createContext();
|
||||
return (0, __trpc_server_unstable_core_do_not_import.callProcedure)({
|
||||
router: opts.router,
|
||||
path: op.path,
|
||||
getRawInput: async () => newInput,
|
||||
ctx,
|
||||
type: op.type,
|
||||
signal,
|
||||
batchIndex: 0
|
||||
});
|
||||
}
|
||||
function onErrorCallback(cause) {
|
||||
var _opts$onError;
|
||||
if ((0, __trpc_server_unstable_core_do_not_import.isAbortError)(cause)) return;
|
||||
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
||||
error: (0, __trpc_server.getTRPCErrorFromUnknown)(cause),
|
||||
type: op.type,
|
||||
path: op.path,
|
||||
input,
|
||||
ctx
|
||||
});
|
||||
}
|
||||
function coerceToTRPCClientError(cause) {
|
||||
if (require_TRPCClientError.isTRPCClientError(cause)) return cause;
|
||||
const error = (0, __trpc_server.getTRPCErrorFromUnknown)(cause);
|
||||
const shape = (0, __trpc_server.getTRPCErrorShape)({
|
||||
config: opts.router._def._config,
|
||||
ctx,
|
||||
error,
|
||||
input,
|
||||
path: op.path,
|
||||
type: op.type
|
||||
});
|
||||
return require_TRPCClientError.TRPCClientError.from({ error: transformChunk(shape) }, { cause: cause instanceof Error ? cause : void 0 });
|
||||
}
|
||||
(0, __trpc_server_unstable_core_do_not_import.run)(async () => {
|
||||
switch (op.type) {
|
||||
case "query":
|
||||
case "mutation": {
|
||||
const result = await runProcedure(op.input);
|
||||
if (!(0, __trpc_server_unstable_core_do_not_import.isAsyncIterable)(result)) {
|
||||
observer.next({ result: { data: transformChunk(result) } });
|
||||
observer.complete();
|
||||
break;
|
||||
}
|
||||
observer.next({ result: { data: (0, import_wrapAsyncGenerator.default)(function* () {
|
||||
try {
|
||||
var _usingCtx$1 = (0, import_usingCtx.default)();
|
||||
const iterator = _usingCtx$1.a((0, __trpc_server_unstable_core_do_not_import.iteratorResource)(result));
|
||||
const _finally = _usingCtx$1.u((0, __trpc_server_unstable_core_do_not_import.makeResource)({}, () => {
|
||||
observer.complete();
|
||||
}));
|
||||
try {
|
||||
while (true) {
|
||||
const res = yield (0, import_awaitAsyncGenerator.default)(Promise.race([iterator.next(), signalPromise]));
|
||||
if (res.done) return transformChunk(res.value);
|
||||
yield transformChunk(res.value);
|
||||
}
|
||||
} catch (cause) {
|
||||
onErrorCallback(cause);
|
||||
throw coerceToTRPCClientError(cause);
|
||||
}
|
||||
} catch (_) {
|
||||
_usingCtx$1.e = _;
|
||||
} finally {
|
||||
yield (0, import_awaitAsyncGenerator.default)(_usingCtx$1.d());
|
||||
}
|
||||
})() } });
|
||||
break;
|
||||
}
|
||||
case "subscription": try {
|
||||
var _usingCtx3 = (0, import_usingCtx.default)();
|
||||
const connectionState = (0, __trpc_server_observable.behaviorSubject)({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
const connectionSub = connectionState.subscribe({ next(state) {
|
||||
observer.next({ result: state });
|
||||
} });
|
||||
let lastEventId = void 0;
|
||||
const _finally = _usingCtx3.u((0, __trpc_server_unstable_core_do_not_import.makeResource)({}, async () => {
|
||||
observer.complete();
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
connectionSub.unsubscribe();
|
||||
}));
|
||||
while (true) try {
|
||||
var _usingCtx4 = (0, import_usingCtx.default)();
|
||||
const result = await runProcedure(inputWithTrackedEventId(op.input, lastEventId));
|
||||
if (!(0, __trpc_server_unstable_core_do_not_import.isAsyncIterable)(result)) throw new Error("Expected an async iterable");
|
||||
const iterator = _usingCtx4.a((0, __trpc_server_unstable_core_do_not_import.iteratorResource)(result));
|
||||
observer.next({ result: { type: "started" } });
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
while (true) {
|
||||
let res;
|
||||
try {
|
||||
res = await Promise.race([iterator.next(), signalPromise]);
|
||||
} catch (cause) {
|
||||
if ((0, __trpc_server_unstable_core_do_not_import.isAbortError)(cause)) return;
|
||||
const error = (0, __trpc_server.getTRPCErrorFromUnknown)(cause);
|
||||
if (!__trpc_server_unstable_core_do_not_import.retryableRpcCodes.includes(__trpc_server_rpc.TRPC_ERROR_CODES_BY_KEY[error.code])) throw coerceToTRPCClientError(error);
|
||||
onErrorCallback(error);
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: coerceToTRPCClientError(error)
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (res.done) return;
|
||||
let chunk;
|
||||
if ((0, __trpc_server.isTrackedEnvelope)(res.value)) {
|
||||
lastEventId = res.value[0];
|
||||
chunk = {
|
||||
id: res.value[0],
|
||||
data: {
|
||||
id: res.value[0],
|
||||
data: res.value[1]
|
||||
}
|
||||
};
|
||||
} else chunk = { data: res.value };
|
||||
observer.next({ result: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, chunk), {}, { data: transformChunk(chunk.data) }) });
|
||||
}
|
||||
} catch (_) {
|
||||
_usingCtx4.e = _;
|
||||
} finally {
|
||||
await _usingCtx4.d();
|
||||
}
|
||||
break;
|
||||
} catch (_) {
|
||||
_usingCtx3.e = _;
|
||||
} finally {
|
||||
_usingCtx3.d();
|
||||
}
|
||||
}
|
||||
}).catch((cause) => {
|
||||
onErrorCallback(cause);
|
||||
observer.error(coerceToTRPCClientError(cause));
|
||||
});
|
||||
return () => {
|
||||
ac.abort();
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @deprecated Renamed to `unstable_localLink`. This alias will be removed in a future major release.
|
||||
*/
|
||||
const experimental_localLink = unstable_localLink;
|
||||
|
||||
//#endregion
|
||||
exports.TRPCClientError = require_TRPCClientError.TRPCClientError;
|
||||
exports.TRPCUntypedClient = TRPCUntypedClient;
|
||||
exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
|
||||
exports.createTRPCClient = createTRPCClient;
|
||||
exports.createTRPCClientProxy = createTRPCClientProxy;
|
||||
exports.createTRPCProxyClient = createTRPCClient;
|
||||
exports.createTRPCUntypedClient = createTRPCUntypedClient;
|
||||
exports.createWSClient = require_wsLink.createWSClient;
|
||||
exports.experimental_localLink = experimental_localLink;
|
||||
exports.getFetch = require_httpUtils.getFetch;
|
||||
exports.getUntypedClient = getUntypedClient;
|
||||
exports.httpBatchLink = require_httpBatchLink.httpBatchLink;
|
||||
exports.httpBatchStreamLink = httpBatchStreamLink;
|
||||
exports.httpLink = require_httpLink.httpLink;
|
||||
exports.httpSubscriptionLink = httpSubscriptionLink;
|
||||
exports.isFormData = require_httpLink.isFormData;
|
||||
exports.isNonJsonSerializable = require_httpLink.isNonJsonSerializable;
|
||||
exports.isOctetType = require_httpLink.isOctetType;
|
||||
exports.isTRPCClientError = require_TRPCClientError.isTRPCClientError;
|
||||
exports.jsonEncoder = require_wsLink.jsonEncoder;
|
||||
exports.loggerLink = require_loggerLink.loggerLink;
|
||||
exports.retryLink = retryLink;
|
||||
exports.splitLink = require_splitLink.splitLink;
|
||||
exports.unstable_httpBatchStreamLink = unstable_httpBatchStreamLink;
|
||||
exports.unstable_httpSubscriptionLink = unstable_httpSubscriptionLink;
|
||||
exports.unstable_localLink = unstable_localLink;
|
||||
exports.wsLink = require_wsLink.wsLink;
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Ciljg_dH.cjs";
|
||||
import { FetchEsque, HTTPHeaders, NativeFetchEsque, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError } from "./types.d-Dmmedc5G.cjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-kWsZTlQq.cjs";
|
||||
import "./httpUtils.d-BqmeKEGo.cjs";
|
||||
import { HTTPBatchLinkOptions, httpBatchLink } from "./httpBatchLink.d-7jyWtY5H.cjs";
|
||||
import { HTTPLinkOptions, httpLink } from "./httpLink.d-D5qR9haY.cjs";
|
||||
import { LoggerLinkOptions, loggerLink } from "./loggerLink.d-BxSIj5kx.cjs";
|
||||
import { splitLink } from "./splitLink.d-BBFK_mCw.cjs";
|
||||
import { Encoder, TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink } from "./wsLink.d-DzZZZGZQ.cjs";
|
||||
import { AnyClientTypes, AnyProcedure, AnyRouter, ErrorHandlerOptions, EventSourceLike, InferrableClientTypes, ProcedureType, RouterRecord, TypeError, inferAsyncIterableYield, inferClientTypes, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { Unsubscribable } from "@trpc/server/observable";
|
||||
import { AnyRouter as AnyRouter$1 } from "@trpc/server";
|
||||
|
||||
//#region src/internals/TRPCUntypedClient.d.ts
|
||||
interface TRPCRequestOptions {
|
||||
/**
|
||||
* Pass additional context to links
|
||||
*/
|
||||
context?: OperationContext;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
interface TRPCSubscriptionObserver<TValue, TError> {
|
||||
onStarted: (opts: {
|
||||
context: OperationContext | undefined;
|
||||
}) => void;
|
||||
onData: (value: inferAsyncIterableYield<TValue>) => void;
|
||||
onError: (err: TError) => void;
|
||||
onStopped: () => void;
|
||||
onComplete: () => void;
|
||||
onConnectionStateChange: (state: TRPCConnectionState<TError>) => void;
|
||||
}
|
||||
/** @internal */
|
||||
type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {
|
||||
links: TRPCLink<TRouter>[];
|
||||
transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;
|
||||
};
|
||||
declare class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
||||
private readonly links;
|
||||
readonly runtime: TRPCClientRuntime;
|
||||
private requestId;
|
||||
constructor(opts: CreateTRPCClientOptions<TInferrable>);
|
||||
private $request;
|
||||
private requestAsPromise;
|
||||
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
||||
mutation(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
||||
subscription(path: string, input: unknown, opts: Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>> & TRPCRequestOptions): Unsubscribable;
|
||||
}
|
||||
//# sourceMappingURL=TRPCUntypedClient.d.ts.map
|
||||
//#endregion
|
||||
//#region src/createTRPCUntypedClient.d.ts
|
||||
declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<TRouter>;
|
||||
//#endregion
|
||||
//#region src/createTRPCClient.d.ts
|
||||
/**
|
||||
* @public
|
||||
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
||||
**/
|
||||
type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
||||
**/
|
||||
type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
||||
declare const untypedClientSymbol: unique symbol;
|
||||
/**
|
||||
* @public
|
||||
**/
|
||||
type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<{
|
||||
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
||||
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
||||
}, TRouter['_def']['record']> & {
|
||||
[untypedClientSymbol]: TRPCUntypedClient<TRouter>;
|
||||
};
|
||||
/** @internal */
|
||||
type TRPCResolverDef = {
|
||||
input: any;
|
||||
output: any;
|
||||
transformer: boolean;
|
||||
errorShape: any;
|
||||
};
|
||||
type coerceAsyncGeneratorToIterable<T> = T extends AsyncGenerator<infer $T, infer $Return, infer $Next> ? AsyncIterable<$T, $Return, $Next> : T;
|
||||
/** @internal */
|
||||
type Resolver<TDef extends TRPCResolverDef> = (input: TDef['input'], opts?: TRPCProcedureOptions) => Promise<coerceAsyncGeneratorToIterable<TDef['output']>>;
|
||||
/** @internal */
|
||||
type SubscriptionResolver<TDef extends TRPCResolverDef> = (input: TDef['input'], opts: Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> & TRPCProcedureOptions) => Unsubscribable;
|
||||
type DecorateProcedure<TType extends ProcedureType, TDef extends TRPCResolverDef> = TType extends 'query' ? {
|
||||
query: Resolver<TDef>;
|
||||
} : TType extends 'mutation' ? {
|
||||
mutate: Resolver<TDef>;
|
||||
} : TType extends 'subscription' ? {
|
||||
subscribe: SubscriptionResolver<TDef>;
|
||||
} : never;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type DecoratedProcedureRecord<TRoot extends InferrableClientTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
||||
input: inferProcedureInput<$Value>;
|
||||
output: inferTransformedProcedureOutput<inferClientTypes<TRoot>, $Value>;
|
||||
errorShape: inferClientTypes<TRoot>['errorShape'];
|
||||
transformer: inferClientTypes<TRoot>['transformer'];
|
||||
}> : $Value extends RouterRecord ? DecoratedProcedureRecord<TRoot, $Value> : never : never };
|
||||
/** @internal */
|
||||
declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): TRPCClient<TRouter>;
|
||||
declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
|
||||
/**
|
||||
* Get an untyped client from a proxy client
|
||||
* @internal
|
||||
*/
|
||||
declare function getUntypedClient<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): TRPCUntypedClient<TRouter>;
|
||||
//#endregion
|
||||
//#region src/getFetch.d.ts
|
||||
declare function getFetch(customFetchImpl?: FetchEsque | NativeFetchEsque): FetchEsque;
|
||||
//# sourceMappingURL=getFetch.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchStreamLink.d.ts
|
||||
type HTTPBatchStreamLinkOptions<TRoot extends AnyClientTypes> = HTTPBatchLinkOptions<TRoot> & {
|
||||
/**
|
||||
* Which header to use to signal the server that the client wants a streaming response.
|
||||
* - `'trpc-accept'` (default): sends `trpc-accept: application/jsonl` header
|
||||
* - `'accept'`: sends `Accept: application/jsonl` header, which can avoid CORS preflight for cross-origin streaming queries. Be aware that `application/jsonl` is not an official MIME type and so this is not completely spec-compliant - you should test that your infrastructure supports this value.
|
||||
* @default 'trpc-accept'
|
||||
*/
|
||||
streamHeader?: 'trpc-accept' | 'accept';
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
||||
*/
|
||||
declare function httpBatchStreamLink<TRouter extends AnyRouter$1>(opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
/**
|
||||
* @deprecated use {@link httpBatchStreamLink} instead
|
||||
*/
|
||||
declare const unstable_httpBatchStreamLink: typeof httpBatchStreamLink;
|
||||
//# sourceMappingURL=httpBatchStreamLink.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/httpSubscriptionLink.d.ts
|
||||
type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes, TEventSource extends EventSourceLike.AnyConstructor = typeof EventSource> = {
|
||||
/**
|
||||
* EventSource ponyfill
|
||||
*/
|
||||
EventSource?: TEventSource;
|
||||
/**
|
||||
* EventSource options or a callback that returns them
|
||||
*/
|
||||
eventSourceOptions?: EventSourceLike.InitDictOf<TEventSource> | ((opts: {
|
||||
op: Operation;
|
||||
}) => EventSourceLike.InitDictOf<TEventSource> | Promise<EventSourceLike.InitDictOf<TEventSource>>);
|
||||
} & TransformerOptions<TRoot> & UrlOptionsWithConnectionParams;
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
||||
*/
|
||||
declare function httpSubscriptionLink<TInferrable extends InferrableClientTypes, TEventSource extends EventSourceLike.AnyConstructor>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>, TEventSource>): TRPCLink<TInferrable>;
|
||||
/**
|
||||
* @deprecated use {@link httpSubscriptionLink} instead
|
||||
*/
|
||||
declare const unstable_httpSubscriptionLink: typeof httpSubscriptionLink;
|
||||
//#endregion
|
||||
//#region src/links/retryLink.d.ts
|
||||
interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
|
||||
/**
|
||||
* The retry function
|
||||
*/
|
||||
retry: (opts: RetryFnOptions<TInferrable>) => boolean;
|
||||
/**
|
||||
* The delay between retries in ms (defaults to 0)
|
||||
*/
|
||||
retryDelayMs?: (attempt: number) => number;
|
||||
}
|
||||
interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
|
||||
/**
|
||||
* The operation that failed
|
||||
*/
|
||||
op: Operation;
|
||||
/**
|
||||
* The error that occurred
|
||||
*/
|
||||
error: TRPCClientError<TInferrable>;
|
||||
/**
|
||||
* The number of attempts that have been made (including the first call)
|
||||
*/
|
||||
attempts: number;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/retryLink
|
||||
*/
|
||||
declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable>;
|
||||
//#endregion
|
||||
//#region src/links/localLink.d.ts
|
||||
type LocalLinkOptions<TRouter extends AnyRouter> = {
|
||||
router: TRouter;
|
||||
createContext: () => Promise<inferRouterContext<TRouter>>;
|
||||
onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;
|
||||
} & TransformerOptions<inferClientTypes<TRouter>>;
|
||||
/**
|
||||
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
||||
*
|
||||
* @see https://trpc.io/docs/links/localLink
|
||||
*/
|
||||
declare function unstable_localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
/**
|
||||
* @deprecated Renamed to `unstable_localLink`. This alias will be removed in a future major release.
|
||||
*/
|
||||
declare const experimental_localLink: typeof unstable_localLink;
|
||||
//# sourceMappingURL=localLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { CreateTRPCClient, CreateTRPCClientOptions, Encoder, HTTPBatchLinkOptions, HTTPBatchStreamLinkOptions, HTTPHeaders, HTTPLinkOptions, LocalLinkOptions, LoggerLinkOptions, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, Resolver, SubscriptionResolver, TRPCClient, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, TRPCRequestOptions, TRPCResolverDef, TRPCUntypedClient, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, inferRouterClient, inferRouterClient as inferRouterProxyClient, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, jsonEncoder, loggerLink, retryLink, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, unstable_localLink, wsLink };
|
||||
//# sourceMappingURL=index.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"sourcesContent":[],"mappings":"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"}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Dlr1nWGD.mjs";
|
||||
import { FetchEsque, HTTPHeaders, NativeFetchEsque, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError } from "./types.d-sRNtuQA-.mjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-BOmV7EK1.mjs";
|
||||
import "./httpUtils.d-yYSKGhiS.mjs";
|
||||
import { HTTPBatchLinkOptions, httpBatchLink } from "./httpBatchLink.d-B6vCg-F-.mjs";
|
||||
import { HTTPLinkOptions, httpLink } from "./httpLink.d-CVOTlkUT.mjs";
|
||||
import { LoggerLinkOptions, loggerLink } from "./loggerLink.d-DBRq_5Gd.mjs";
|
||||
import { splitLink } from "./splitLink.d-BKr9eE0o.mjs";
|
||||
import { Encoder, TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink } from "./wsLink.d-DCqbZKOH.mjs";
|
||||
import { Unsubscribable } from "@trpc/server/observable";
|
||||
import { AnyClientTypes, AnyProcedure, AnyRouter, ErrorHandlerOptions, EventSourceLike, InferrableClientTypes, ProcedureType, RouterRecord, TypeError, inferAsyncIterableYield, inferClientTypes, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { AnyRouter as AnyRouter$1 } from "@trpc/server";
|
||||
|
||||
//#region src/internals/TRPCUntypedClient.d.ts
|
||||
interface TRPCRequestOptions {
|
||||
/**
|
||||
* Pass additional context to links
|
||||
*/
|
||||
context?: OperationContext;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
interface TRPCSubscriptionObserver<TValue, TError> {
|
||||
onStarted: (opts: {
|
||||
context: OperationContext | undefined;
|
||||
}) => void;
|
||||
onData: (value: inferAsyncIterableYield<TValue>) => void;
|
||||
onError: (err: TError) => void;
|
||||
onStopped: () => void;
|
||||
onComplete: () => void;
|
||||
onConnectionStateChange: (state: TRPCConnectionState<TError>) => void;
|
||||
}
|
||||
/** @internal */
|
||||
type CreateTRPCClientOptions<TRouter extends InferrableClientTypes> = {
|
||||
links: TRPCLink<TRouter>[];
|
||||
transformer?: TypeError<'The transformer property has moved to httpLink/httpBatchLink/wsLink'>;
|
||||
};
|
||||
declare class TRPCUntypedClient<TInferrable extends InferrableClientTypes> {
|
||||
private readonly links;
|
||||
readonly runtime: TRPCClientRuntime;
|
||||
private requestId;
|
||||
constructor(opts: CreateTRPCClientOptions<TInferrable>);
|
||||
private $request;
|
||||
private requestAsPromise;
|
||||
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
||||
mutation(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
||||
subscription(path: string, input: unknown, opts: Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>> & TRPCRequestOptions): Unsubscribable;
|
||||
}
|
||||
//# sourceMappingURL=TRPCUntypedClient.d.ts.map
|
||||
//#endregion
|
||||
//#region src/createTRPCUntypedClient.d.ts
|
||||
declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<TRouter>;
|
||||
//#endregion
|
||||
//#region src/createTRPCClient.d.ts
|
||||
/**
|
||||
* @public
|
||||
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
||||
**/
|
||||
type inferRouterClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated use {@link TRPCClient} instead, will be removed in v12
|
||||
**/
|
||||
type CreateTRPCClient<TRouter extends AnyRouter> = TRPCClient<TRouter>;
|
||||
declare const untypedClientSymbol: unique symbol;
|
||||
/**
|
||||
* @public
|
||||
**/
|
||||
type TRPCClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<{
|
||||
transformer: TRouter['_def']['_config']['$types']['transformer'];
|
||||
errorShape: TRouter['_def']['_config']['$types']['errorShape'];
|
||||
}, TRouter['_def']['record']> & {
|
||||
[untypedClientSymbol]: TRPCUntypedClient<TRouter>;
|
||||
};
|
||||
/** @internal */
|
||||
type TRPCResolverDef = {
|
||||
input: any;
|
||||
output: any;
|
||||
transformer: boolean;
|
||||
errorShape: any;
|
||||
};
|
||||
type coerceAsyncGeneratorToIterable<T> = T extends AsyncGenerator<infer $T, infer $Return, infer $Next> ? AsyncIterable<$T, $Return, $Next> : T;
|
||||
/** @internal */
|
||||
type Resolver<TDef extends TRPCResolverDef> = (input: TDef['input'], opts?: TRPCProcedureOptions) => Promise<coerceAsyncGeneratorToIterable<TDef['output']>>;
|
||||
/** @internal */
|
||||
type SubscriptionResolver<TDef extends TRPCResolverDef> = (input: TDef['input'], opts: Partial<TRPCSubscriptionObserver<TDef['output'], TRPCClientError<TDef>>> & TRPCProcedureOptions) => Unsubscribable;
|
||||
type DecorateProcedure<TType extends ProcedureType, TDef extends TRPCResolverDef> = TType extends 'query' ? {
|
||||
query: Resolver<TDef>;
|
||||
} : TType extends 'mutation' ? {
|
||||
mutate: Resolver<TDef>;
|
||||
} : TType extends 'subscription' ? {
|
||||
subscribe: SubscriptionResolver<TDef>;
|
||||
} : never;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type DecoratedProcedureRecord<TRoot extends InferrableClientTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
||||
input: inferProcedureInput<$Value>;
|
||||
output: inferTransformedProcedureOutput<inferClientTypes<TRoot>, $Value>;
|
||||
errorShape: inferClientTypes<TRoot>['errorShape'];
|
||||
transformer: inferClientTypes<TRoot>['transformer'];
|
||||
}> : $Value extends RouterRecord ? DecoratedProcedureRecord<TRoot, $Value> : never : never };
|
||||
/** @internal */
|
||||
declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCUntypedClient<TRouter>): TRPCClient<TRouter>;
|
||||
declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
|
||||
/**
|
||||
* Get an untyped client from a proxy client
|
||||
* @internal
|
||||
*/
|
||||
declare function getUntypedClient<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): TRPCUntypedClient<TRouter>;
|
||||
//#endregion
|
||||
//#region src/getFetch.d.ts
|
||||
declare function getFetch(customFetchImpl?: FetchEsque | NativeFetchEsque): FetchEsque;
|
||||
//# sourceMappingURL=getFetch.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchStreamLink.d.ts
|
||||
type HTTPBatchStreamLinkOptions<TRoot extends AnyClientTypes> = HTTPBatchLinkOptions<TRoot> & {
|
||||
/**
|
||||
* Which header to use to signal the server that the client wants a streaming response.
|
||||
* - `'trpc-accept'` (default): sends `trpc-accept: application/jsonl` header
|
||||
* - `'accept'`: sends `Accept: application/jsonl` header, which can avoid CORS preflight for cross-origin streaming queries. Be aware that `application/jsonl` is not an official MIME type and so this is not completely spec-compliant - you should test that your infrastructure supports this value.
|
||||
* @default 'trpc-accept'
|
||||
*/
|
||||
streamHeader?: 'trpc-accept' | 'accept';
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
||||
*/
|
||||
declare function httpBatchStreamLink<TRouter extends AnyRouter$1>(opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
||||
/**
|
||||
* @deprecated use {@link httpBatchStreamLink} instead
|
||||
*/
|
||||
declare const unstable_httpBatchStreamLink: typeof httpBatchStreamLink;
|
||||
//# sourceMappingURL=httpBatchStreamLink.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/httpSubscriptionLink.d.ts
|
||||
type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes, TEventSource extends EventSourceLike.AnyConstructor = typeof EventSource> = {
|
||||
/**
|
||||
* EventSource ponyfill
|
||||
*/
|
||||
EventSource?: TEventSource;
|
||||
/**
|
||||
* EventSource options or a callback that returns them
|
||||
*/
|
||||
eventSourceOptions?: EventSourceLike.InitDictOf<TEventSource> | ((opts: {
|
||||
op: Operation;
|
||||
}) => EventSourceLike.InitDictOf<TEventSource> | Promise<EventSourceLike.InitDictOf<TEventSource>>);
|
||||
} & TransformerOptions<TRoot> & UrlOptionsWithConnectionParams;
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
||||
*/
|
||||
declare function httpSubscriptionLink<TInferrable extends InferrableClientTypes, TEventSource extends EventSourceLike.AnyConstructor>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>, TEventSource>): TRPCLink<TInferrable>;
|
||||
/**
|
||||
* @deprecated use {@link httpSubscriptionLink} instead
|
||||
*/
|
||||
declare const unstable_httpSubscriptionLink: typeof httpSubscriptionLink;
|
||||
//#endregion
|
||||
//#region src/links/retryLink.d.ts
|
||||
interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
|
||||
/**
|
||||
* The retry function
|
||||
*/
|
||||
retry: (opts: RetryFnOptions<TInferrable>) => boolean;
|
||||
/**
|
||||
* The delay between retries in ms (defaults to 0)
|
||||
*/
|
||||
retryDelayMs?: (attempt: number) => number;
|
||||
}
|
||||
interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
|
||||
/**
|
||||
* The operation that failed
|
||||
*/
|
||||
op: Operation;
|
||||
/**
|
||||
* The error that occurred
|
||||
*/
|
||||
error: TRPCClientError<TInferrable>;
|
||||
/**
|
||||
* The number of attempts that have been made (including the first call)
|
||||
*/
|
||||
attempts: number;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/retryLink
|
||||
*/
|
||||
declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable>;
|
||||
//#endregion
|
||||
//#region src/links/localLink.d.ts
|
||||
type LocalLinkOptions<TRouter extends AnyRouter> = {
|
||||
router: TRouter;
|
||||
createContext: () => Promise<inferRouterContext<TRouter>>;
|
||||
onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;
|
||||
} & TransformerOptions<inferClientTypes<TRouter>>;
|
||||
/**
|
||||
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
||||
*
|
||||
* @see https://trpc.io/docs/links/localLink
|
||||
*/
|
||||
declare function unstable_localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
/**
|
||||
* @deprecated Renamed to `unstable_localLink`. This alias will be removed in a future major release.
|
||||
*/
|
||||
declare const experimental_localLink: typeof unstable_localLink;
|
||||
//# sourceMappingURL=localLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { CreateTRPCClient, CreateTRPCClientOptions, Encoder, HTTPBatchLinkOptions, HTTPBatchStreamLinkOptions, HTTPHeaders, HTTPLinkOptions, LocalLinkOptions, LoggerLinkOptions, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, Resolver, SubscriptionResolver, TRPCClient, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, TRPCRequestOptions, TRPCResolverDef, TRPCUntypedClient, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, inferRouterClient, inferRouterClient as inferRouterProxyClient, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, jsonEncoder, loggerLink, retryLink, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, unstable_localLink, wsLink };
|
||||
//# sourceMappingURL=index.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/internals/TRPCUntypedClient.ts","../src/createTRPCUntypedClient.ts","../src/createTRPCClient.ts","../src/getFetch.ts","../src/links/httpBatchStreamLink.ts","../src/links/httpSubscriptionLink.ts","../src/links/retryLink.ts","../src/links/localLink.ts"],"sourcesContent":[],"mappings":"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"}
|
||||
+886
@@ -0,0 +1,886 @@
|
||||
import { __commonJS, __toESM, require_defineProperty, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { createChain, splitLink } from "./splitLink-B7Cuf2c_.mjs";
|
||||
import { TRPCClientError, isTRPCClientError } from "./TRPCClientError-apv8gw59.mjs";
|
||||
import { fetchHTTPResponse, getBody, getFetch, getUrl, resolveHTTPLinkOptions } from "./httpUtils-pyf5RF99.mjs";
|
||||
import { httpLink, isFormData, isNonJsonSerializable, isOctetType } from "./httpLink-lG_6juPY.mjs";
|
||||
import { abortSignalToPromise, allAbortSignals, dataLoader, httpBatchLink, raceAbortSignals } from "./httpBatchLink-LhidKAPw.mjs";
|
||||
import { getTransformer } from "./unstable-internals-Bg7n9BBj.mjs";
|
||||
import { loggerLink } from "./loggerLink-ineCN1PO.mjs";
|
||||
import { createWSClient, jsonEncoder, resultOf, wsLink } from "./wsLink-DSf4KOdW.mjs";
|
||||
import { behaviorSubject, observable, observableToPromise, share } from "@trpc/server/observable";
|
||||
import { callProcedure, createFlatProxy, createRecursiveProxy, isAbortError, isAsyncIterable, iteratorResource, jsonlStreamConsumer, makeResource, retryableRpcCodes, run, sseStreamConsumer } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { getTRPCErrorFromUnknown, getTRPCErrorShape, isTrackedEnvelope } from "@trpc/server";
|
||||
import { TRPC_ERROR_CODES_BY_KEY } from "@trpc/server/rpc";
|
||||
|
||||
//#region src/internals/TRPCUntypedClient.ts
|
||||
var import_defineProperty = __toESM(require_defineProperty(), 1);
|
||||
var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
|
||||
var TRPCUntypedClient = class {
|
||||
constructor(opts) {
|
||||
(0, import_defineProperty.default)(this, "links", void 0);
|
||||
(0, import_defineProperty.default)(this, "runtime", void 0);
|
||||
(0, import_defineProperty.default)(this, "requestId", void 0);
|
||||
this.requestId = 0;
|
||||
this.runtime = {};
|
||||
this.links = opts.links.map((link) => link(this.runtime));
|
||||
}
|
||||
$request(opts) {
|
||||
var _opts$context;
|
||||
const chain$ = createChain({
|
||||
links: this.links,
|
||||
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
||||
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
||||
id: ++this.requestId
|
||||
})
|
||||
});
|
||||
return chain$.pipe(share());
|
||||
}
|
||||
async requestAsPromise(opts) {
|
||||
var _this = this;
|
||||
try {
|
||||
const req$ = _this.$request(opts);
|
||||
const envelope = await observableToPromise(req$);
|
||||
const data = envelope.result.data;
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw TRPCClientError.from(err);
|
||||
}
|
||||
}
|
||||
query(path, input, opts) {
|
||||
return this.requestAsPromise({
|
||||
type: "query",
|
||||
path,
|
||||
input,
|
||||
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
||||
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
||||
});
|
||||
}
|
||||
mutation(path, input, opts) {
|
||||
return this.requestAsPromise({
|
||||
type: "mutation",
|
||||
path,
|
||||
input,
|
||||
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
||||
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
||||
});
|
||||
}
|
||||
subscription(path, input, opts) {
|
||||
const observable$ = this.$request({
|
||||
type: "subscription",
|
||||
path,
|
||||
input,
|
||||
context: opts.context,
|
||||
signal: opts.signal
|
||||
});
|
||||
return observable$.subscribe({
|
||||
next(envelope) {
|
||||
switch (envelope.result.type) {
|
||||
case "state": {
|
||||
var _opts$onConnectionSta;
|
||||
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
||||
break;
|
||||
}
|
||||
case "started": {
|
||||
var _opts$onStarted;
|
||||
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
||||
break;
|
||||
}
|
||||
case "stopped": {
|
||||
var _opts$onStopped;
|
||||
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
||||
break;
|
||||
}
|
||||
case "data":
|
||||
case void 0: {
|
||||
var _opts$onData;
|
||||
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
error(err) {
|
||||
var _opts$onError;
|
||||
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
||||
},
|
||||
complete() {
|
||||
var _opts$onComplete;
|
||||
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/createTRPCUntypedClient.ts
|
||||
function createTRPCUntypedClient(opts) {
|
||||
return new TRPCUntypedClient(opts);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/createTRPCClient.ts
|
||||
const untypedClientSymbol = Symbol.for("trpc_untypedClient");
|
||||
const clientCallTypeMap = {
|
||||
query: "query",
|
||||
mutate: "mutation",
|
||||
subscribe: "subscription"
|
||||
};
|
||||
/** @internal */
|
||||
const clientCallTypeToProcedureType = (clientCallType) => {
|
||||
return clientCallTypeMap[clientCallType];
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function createTRPCClientProxy(client) {
|
||||
const proxy = createRecursiveProxy(({ path, args }) => {
|
||||
const pathCopy = [...path];
|
||||
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
||||
const fullPath = pathCopy.join(".");
|
||||
return client[procedureType](fullPath, ...args);
|
||||
});
|
||||
return createFlatProxy((key) => {
|
||||
if (key === untypedClientSymbol) return client;
|
||||
return proxy[key];
|
||||
});
|
||||
}
|
||||
function createTRPCClient(opts) {
|
||||
const client = new TRPCUntypedClient(opts);
|
||||
const proxy = createTRPCClientProxy(client);
|
||||
return proxy;
|
||||
}
|
||||
/**
|
||||
* Get an untyped client from a proxy client
|
||||
* @internal
|
||||
*/
|
||||
function getUntypedClient(client) {
|
||||
return client[untypedClientSymbol];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpBatchStreamLink.ts
|
||||
var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
||||
*/
|
||||
function httpBatchStreamLink(opts) {
|
||||
var _opts$maxURLLength, _opts$maxItems;
|
||||
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
||||
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
||||
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
||||
return () => {
|
||||
const batchLoader = (type) => {
|
||||
return {
|
||||
validate(batchOps) {
|
||||
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
||||
if (batchOps.length > maxItems) return false;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const url = getUrl((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
||||
type,
|
||||
path,
|
||||
inputs,
|
||||
signal: null
|
||||
}));
|
||||
return url.length <= maxURLLength;
|
||||
},
|
||||
async fetch(batchOps) {
|
||||
var _opts$streamHeader;
|
||||
const path = batchOps.map((op) => op.path).join(",");
|
||||
const inputs = batchOps.map((op) => op.input);
|
||||
const batchSignals = allAbortSignals(...batchOps.map((op) => op.signal));
|
||||
const abortController = new AbortController();
|
||||
const responsePromise = fetchHTTPResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
||||
signal: raceAbortSignals(batchSignals, abortController.signal),
|
||||
type,
|
||||
contentTypeHeader: "application/json",
|
||||
trpcAcceptHeader: "application/jsonl",
|
||||
trpcAcceptHeaderKey: (_opts$streamHeader = opts.streamHeader) !== null && _opts$streamHeader !== void 0 ? _opts$streamHeader : "trpc-accept",
|
||||
getUrl,
|
||||
getBody,
|
||||
inputs,
|
||||
path,
|
||||
headers() {
|
||||
if (!opts.headers) return {};
|
||||
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
||||
return opts.headers;
|
||||
}
|
||||
}));
|
||||
const res = await responsePromise;
|
||||
if (!res.ok) {
|
||||
const json = await res.json();
|
||||
if ("error" in json) json.error = resolvedOpts.transformer.output.deserialize(json.error);
|
||||
return batchOps.map(() => Promise.resolve({
|
||||
json,
|
||||
meta: { response: res }
|
||||
}));
|
||||
}
|
||||
const [head] = await jsonlStreamConsumer({
|
||||
from: res.body,
|
||||
deserialize: (data) => resolvedOpts.transformer.output.deserialize(data),
|
||||
formatError(opts$1) {
|
||||
const error = opts$1.error;
|
||||
return TRPCClientError.from({ error });
|
||||
},
|
||||
abortController
|
||||
});
|
||||
const promises = Object.keys(batchOps).map(async (key) => {
|
||||
let json = await Promise.resolve(head[key]);
|
||||
if ("result" in json) {
|
||||
/**
|
||||
* Not very pretty, but we need to unwrap nested data as promises
|
||||
* Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
|
||||
*/
|
||||
const result = await Promise.resolve(json.result);
|
||||
json = { result: { data: await Promise.resolve(result.data) } };
|
||||
}
|
||||
return {
|
||||
json,
|
||||
meta: { response: res }
|
||||
};
|
||||
});
|
||||
return promises;
|
||||
}
|
||||
};
|
||||
};
|
||||
const query = dataLoader(batchLoader("query"));
|
||||
const mutation = dataLoader(batchLoader("mutation"));
|
||||
const loaders = {
|
||||
query,
|
||||
mutation
|
||||
};
|
||||
return ({ op }) => {
|
||||
return observable((observer) => {
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`");
|
||||
const loader = loaders[op.type];
|
||||
const promise = loader.load(op);
|
||||
let _res = void 0;
|
||||
promise.then((res) => {
|
||||
_res = res;
|
||||
if ("error" in res.json) {
|
||||
observer.error(TRPCClientError.from(res.json, { meta: res.meta }));
|
||||
return;
|
||||
} else if ("result" in res.json) {
|
||||
observer.next({
|
||||
context: res.meta,
|
||||
result: res.json.result
|
||||
});
|
||||
observer.complete();
|
||||
return;
|
||||
}
|
||||
observer.complete();
|
||||
}).catch((err) => {
|
||||
observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
||||
});
|
||||
return () => {};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link httpBatchStreamLink} instead
|
||||
*/
|
||||
const unstable_httpBatchStreamLink = httpBatchStreamLink;
|
||||
|
||||
//#endregion
|
||||
//#region src/internals/inputWithTrackedEventId.ts
|
||||
var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
||||
function inputWithTrackedEventId(input, lastEventId) {
|
||||
if (!lastEventId) return input;
|
||||
if (input != null && typeof input !== "object") return input;
|
||||
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId });
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
|
||||
var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
|
||||
function _asyncIterator$1(r) {
|
||||
var n, t, o, e = 2;
|
||||
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
||||
if (t && null != (n = r[t])) return n.call(r);
|
||||
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
||||
t = "@@asyncIterator", o = "@@iterator";
|
||||
}
|
||||
throw new TypeError("Object is not async iterable");
|
||||
}
|
||||
function AsyncFromSyncIterator(r) {
|
||||
function AsyncFromSyncIteratorContinuation(r$1) {
|
||||
if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
|
||||
var n = r$1.done;
|
||||
return Promise.resolve(r$1.value).then(function(r$2) {
|
||||
return {
|
||||
value: r$2,
|
||||
done: n
|
||||
};
|
||||
});
|
||||
}
|
||||
return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
|
||||
this.s = r$1, this.n = r$1.next;
|
||||
}, AsyncFromSyncIterator.prototype = {
|
||||
s: null,
|
||||
n: null,
|
||||
next: function next() {
|
||||
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
||||
},
|
||||
"return": function _return(r$1) {
|
||||
var n = this.s["return"];
|
||||
return void 0 === n ? Promise.resolve({
|
||||
value: r$1,
|
||||
done: !0
|
||||
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
||||
},
|
||||
"throw": function _throw(r$1) {
|
||||
var n = this.s["return"];
|
||||
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
||||
}
|
||||
}, new AsyncFromSyncIterator(r);
|
||||
}
|
||||
module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region src/links/httpSubscriptionLink.ts
|
||||
var import_asyncIterator = __toESM(require_asyncIterator(), 1);
|
||||
async function urlWithConnectionParams(opts) {
|
||||
let url = await resultOf(opts.url);
|
||||
if (opts.connectionParams) {
|
||||
const params = await resultOf(opts.connectionParams);
|
||||
const prefix = url.includes("?") ? "&" : "?";
|
||||
url += prefix + "connectionParams=" + encodeURIComponent(JSON.stringify(params));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
||||
*/
|
||||
function httpSubscriptionLink(opts) {
|
||||
const transformer = getTransformer(opts.transformer);
|
||||
return () => {
|
||||
return ({ op }) => {
|
||||
return observable((observer) => {
|
||||
var _opts$EventSource;
|
||||
const { type, path, input } = op;
|
||||
/* istanbul ignore if -- @preserve */
|
||||
if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
|
||||
let lastEventId = void 0;
|
||||
const ac = new AbortController();
|
||||
const signal = raceAbortSignals(op.signal, ac.signal);
|
||||
const eventSourceStream = sseStreamConsumer({
|
||||
url: async () => getUrl({
|
||||
transformer,
|
||||
url: await urlWithConnectionParams(opts),
|
||||
input: inputWithTrackedEventId(input, lastEventId),
|
||||
path,
|
||||
type,
|
||||
signal: null
|
||||
}),
|
||||
init: () => resultOf(opts.eventSourceOptions, { op }),
|
||||
signal,
|
||||
deserialize: (data) => transformer.output.deserialize(data),
|
||||
EventSource: (_opts$EventSource = opts.EventSource) !== null && _opts$EventSource !== void 0 ? _opts$EventSource : globalThis.EventSource
|
||||
});
|
||||
const connectionState = behaviorSubject({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
const connectionSub = connectionState.subscribe({ next(state) {
|
||||
observer.next({ result: state });
|
||||
} });
|
||||
run(async () => {
|
||||
var _iteratorAbruptCompletion = false;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError;
|
||||
try {
|
||||
for (var _iterator = (0, import_asyncIterator.default)(eventSourceStream), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
||||
const chunk = _step.value;
|
||||
switch (chunk.type) {
|
||||
case "ping": break;
|
||||
case "data":
|
||||
const chunkData = chunk.data;
|
||||
let result;
|
||||
if (chunkData.id) {
|
||||
lastEventId = chunkData.id;
|
||||
result = {
|
||||
id: chunkData.id,
|
||||
data: chunkData
|
||||
};
|
||||
} else result = { data: chunkData.data };
|
||||
observer.next({
|
||||
result,
|
||||
context: { eventSource: chunk.eventSource }
|
||||
});
|
||||
break;
|
||||
case "connected": {
|
||||
observer.next({
|
||||
result: { type: "started" },
|
||||
context: { eventSource: chunk.eventSource }
|
||||
});
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "serialized-error": {
|
||||
const error = TRPCClientError.from({ error: chunk.error });
|
||||
if (retryableRpcCodes.includes(chunk.error.code)) {
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error
|
||||
});
|
||||
break;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
case "connecting": {
|
||||
const lastState = connectionState.get();
|
||||
const error = chunk.event && TRPCClientError.from(chunk.event);
|
||||
if (!error && lastState.state === "connecting") break;
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "timeout": connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: new TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
|
||||
} finally {
|
||||
if (_didIteratorError) throw _iteratorError;
|
||||
}
|
||||
}
|
||||
observer.next({ result: { type: "stopped" } });
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
observer.complete();
|
||||
}).catch((error) => {
|
||||
observer.error(TRPCClientError.from(error));
|
||||
});
|
||||
return () => {
|
||||
observer.complete();
|
||||
ac.abort();
|
||||
connectionSub.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link httpSubscriptionLink} instead
|
||||
*/
|
||||
const unstable_httpSubscriptionLink = httpSubscriptionLink;
|
||||
|
||||
//#endregion
|
||||
//#region src/links/retryLink.ts
|
||||
var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/retryLink
|
||||
*/
|
||||
function retryLink(opts) {
|
||||
return () => {
|
||||
return (callOpts) => {
|
||||
return observable((observer) => {
|
||||
let next$;
|
||||
let callNextTimeout = void 0;
|
||||
let lastEventId = void 0;
|
||||
attempt(1);
|
||||
function opWithLastEventId() {
|
||||
const op = callOpts.op;
|
||||
if (!lastEventId) return op;
|
||||
return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) });
|
||||
}
|
||||
function attempt(attempts) {
|
||||
const op = opWithLastEventId();
|
||||
next$ = callOpts.next(op).subscribe({
|
||||
error(error) {
|
||||
var _opts$retryDelayMs, _opts$retryDelayMs2;
|
||||
const shouldRetry = opts.retry({
|
||||
op,
|
||||
attempts,
|
||||
error
|
||||
});
|
||||
if (!shouldRetry) {
|
||||
observer.error(error);
|
||||
return;
|
||||
}
|
||||
const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0;
|
||||
if (delayMs <= 0) {
|
||||
attempt(attempts + 1);
|
||||
return;
|
||||
}
|
||||
callNextTimeout = setTimeout(() => attempt(attempts + 1), delayMs);
|
||||
},
|
||||
next(envelope) {
|
||||
if ((!envelope.result.type || envelope.result.type === "data") && envelope.result.id) lastEventId = envelope.result.id;
|
||||
observer.next(envelope);
|
||||
},
|
||||
complete() {
|
||||
observer.complete();
|
||||
}
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
next$.unsubscribe();
|
||||
clearTimeout(callNextTimeout);
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
||||
var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
||||
function _usingCtx() {
|
||||
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
||||
var n$1 = Error();
|
||||
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
||||
}, e = {}, n = [];
|
||||
function using(r$1, e$1) {
|
||||
if (null != e$1) {
|
||||
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
||||
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
||||
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
||||
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
||||
t && (o = function o$1() {
|
||||
try {
|
||||
t.call(e$1);
|
||||
} catch (r$2) {
|
||||
return Promise.reject(r$2);
|
||||
}
|
||||
}), n.push({
|
||||
v: e$1,
|
||||
d: o,
|
||||
a: r$1
|
||||
});
|
||||
} else r$1 && n.push({
|
||||
d: e$1,
|
||||
a: r$1
|
||||
});
|
||||
return e$1;
|
||||
}
|
||||
return {
|
||||
e,
|
||||
u: using.bind(null, !1),
|
||||
a: using.bind(null, !0),
|
||||
d: function d() {
|
||||
var o, t = this.e, s = 0;
|
||||
function next() {
|
||||
for (; o = n.pop();) try {
|
||||
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
||||
if (o.d) {
|
||||
var r$1 = o.d.call(o.v);
|
||||
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
||||
} else s |= 1;
|
||||
} catch (r$2) {
|
||||
return err(r$2);
|
||||
}
|
||||
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
||||
if (t !== e) throw t;
|
||||
}
|
||||
function err(n$1) {
|
||||
return t = t !== e ? new r(n$1, t) : n$1, next();
|
||||
}
|
||||
return next();
|
||||
}
|
||||
};
|
||||
}
|
||||
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js
|
||||
var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
|
||||
function _OverloadYield(e, d) {
|
||||
this.v = e, this.k = d;
|
||||
}
|
||||
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js
|
||||
var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
|
||||
var OverloadYield$1 = require_OverloadYield();
|
||||
function _awaitAsyncGenerator$1(e) {
|
||||
return new OverloadYield$1(e, 0);
|
||||
}
|
||||
module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js
|
||||
var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
|
||||
var OverloadYield = require_OverloadYield();
|
||||
function _wrapAsyncGenerator$1(e) {
|
||||
return function() {
|
||||
return new AsyncGenerator(e.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
function AsyncGenerator(e) {
|
||||
var r, t;
|
||||
function resume(r$1, t$1) {
|
||||
try {
|
||||
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
||||
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
||||
if (u) {
|
||||
var i = "return" === r$1 ? "return" : "next";
|
||||
if (!o.k || t$2.done) return resume(i, t$2);
|
||||
t$2 = e[i](t$2).value;
|
||||
}
|
||||
settle(n.done ? "return" : "normal", t$2);
|
||||
}, function(e$1) {
|
||||
resume("throw", e$1);
|
||||
});
|
||||
} catch (e$1) {
|
||||
settle("throw", e$1);
|
||||
}
|
||||
}
|
||||
function settle(e$1, n) {
|
||||
switch (e$1) {
|
||||
case "return":
|
||||
r.resolve({
|
||||
value: n,
|
||||
done: !0
|
||||
});
|
||||
break;
|
||||
case "throw":
|
||||
r.reject(n);
|
||||
break;
|
||||
default: r.resolve({
|
||||
value: n,
|
||||
done: !1
|
||||
});
|
||||
}
|
||||
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
||||
}
|
||||
this._invoke = function(e$1, n) {
|
||||
return new Promise(function(o, u) {
|
||||
var i = {
|
||||
key: e$1,
|
||||
arg: n,
|
||||
resolve: o,
|
||||
reject: u,
|
||||
next: null
|
||||
};
|
||||
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
||||
});
|
||||
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
||||
}
|
||||
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
||||
return this;
|
||||
}, AsyncGenerator.prototype.next = function(e) {
|
||||
return this._invoke("next", e);
|
||||
}, AsyncGenerator.prototype["throw"] = function(e) {
|
||||
return this._invoke("throw", e);
|
||||
}, AsyncGenerator.prototype["return"] = function(e) {
|
||||
return this._invoke("return", e);
|
||||
};
|
||||
module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region src/links/localLink.ts
|
||||
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
||||
var import_awaitAsyncGenerator = __toESM(require_awaitAsyncGenerator(), 1);
|
||||
var import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
/**
|
||||
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
||||
*
|
||||
* @see https://trpc.io/docs/links/localLink
|
||||
*/
|
||||
function unstable_localLink(opts) {
|
||||
const transformer = getTransformer(opts.transformer);
|
||||
const transformChunk = (chunk) => {
|
||||
if (opts.transformer) return chunk;
|
||||
if (chunk === void 0) return chunk;
|
||||
const serialized = JSON.stringify(transformer.input.serialize(chunk));
|
||||
const deserialized = JSON.parse(transformer.output.deserialize(serialized));
|
||||
return deserialized;
|
||||
};
|
||||
return () => ({ op }) => observable((observer) => {
|
||||
let ctx = void 0;
|
||||
const ac = new AbortController();
|
||||
const signal = raceAbortSignals(op.signal, ac.signal);
|
||||
const signalPromise = abortSignalToPromise(signal);
|
||||
signalPromise.catch(() => {});
|
||||
let input = op.input;
|
||||
async function runProcedure(newInput) {
|
||||
input = newInput;
|
||||
ctx = await opts.createContext();
|
||||
return callProcedure({
|
||||
router: opts.router,
|
||||
path: op.path,
|
||||
getRawInput: async () => newInput,
|
||||
ctx,
|
||||
type: op.type,
|
||||
signal,
|
||||
batchIndex: 0
|
||||
});
|
||||
}
|
||||
function onErrorCallback(cause) {
|
||||
var _opts$onError;
|
||||
if (isAbortError(cause)) return;
|
||||
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
||||
error: getTRPCErrorFromUnknown(cause),
|
||||
type: op.type,
|
||||
path: op.path,
|
||||
input,
|
||||
ctx
|
||||
});
|
||||
}
|
||||
function coerceToTRPCClientError(cause) {
|
||||
if (isTRPCClientError(cause)) return cause;
|
||||
const error = getTRPCErrorFromUnknown(cause);
|
||||
const shape = getTRPCErrorShape({
|
||||
config: opts.router._def._config,
|
||||
ctx,
|
||||
error,
|
||||
input,
|
||||
path: op.path,
|
||||
type: op.type
|
||||
});
|
||||
return TRPCClientError.from({ error: transformChunk(shape) }, { cause: cause instanceof Error ? cause : void 0 });
|
||||
}
|
||||
run(async () => {
|
||||
switch (op.type) {
|
||||
case "query":
|
||||
case "mutation": {
|
||||
const result = await runProcedure(op.input);
|
||||
if (!isAsyncIterable(result)) {
|
||||
observer.next({ result: { data: transformChunk(result) } });
|
||||
observer.complete();
|
||||
break;
|
||||
}
|
||||
observer.next({ result: { data: (0, import_wrapAsyncGenerator.default)(function* () {
|
||||
try {
|
||||
var _usingCtx$1 = (0, import_usingCtx.default)();
|
||||
const iterator = _usingCtx$1.a(iteratorResource(result));
|
||||
const _finally = _usingCtx$1.u(makeResource({}, () => {
|
||||
observer.complete();
|
||||
}));
|
||||
try {
|
||||
while (true) {
|
||||
const res = yield (0, import_awaitAsyncGenerator.default)(Promise.race([iterator.next(), signalPromise]));
|
||||
if (res.done) return transformChunk(res.value);
|
||||
yield transformChunk(res.value);
|
||||
}
|
||||
} catch (cause) {
|
||||
onErrorCallback(cause);
|
||||
throw coerceToTRPCClientError(cause);
|
||||
}
|
||||
} catch (_) {
|
||||
_usingCtx$1.e = _;
|
||||
} finally {
|
||||
yield (0, import_awaitAsyncGenerator.default)(_usingCtx$1.d());
|
||||
}
|
||||
})() } });
|
||||
break;
|
||||
}
|
||||
case "subscription": try {
|
||||
var _usingCtx3 = (0, import_usingCtx.default)();
|
||||
const connectionState = behaviorSubject({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
const connectionSub = connectionState.subscribe({ next(state) {
|
||||
observer.next({ result: state });
|
||||
} });
|
||||
let lastEventId = void 0;
|
||||
const _finally = _usingCtx3.u(makeResource({}, async () => {
|
||||
observer.complete();
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
connectionSub.unsubscribe();
|
||||
}));
|
||||
while (true) try {
|
||||
var _usingCtx4 = (0, import_usingCtx.default)();
|
||||
const result = await runProcedure(inputWithTrackedEventId(op.input, lastEventId));
|
||||
if (!isAsyncIterable(result)) throw new Error("Expected an async iterable");
|
||||
const iterator = _usingCtx4.a(iteratorResource(result));
|
||||
observer.next({ result: { type: "started" } });
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
while (true) {
|
||||
let res;
|
||||
try {
|
||||
res = await Promise.race([iterator.next(), signalPromise]);
|
||||
} catch (cause) {
|
||||
if (isAbortError(cause)) return;
|
||||
const error = getTRPCErrorFromUnknown(cause);
|
||||
if (!retryableRpcCodes.includes(TRPC_ERROR_CODES_BY_KEY[error.code])) throw coerceToTRPCClientError(error);
|
||||
onErrorCallback(error);
|
||||
connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: coerceToTRPCClientError(error)
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (res.done) return;
|
||||
let chunk;
|
||||
if (isTrackedEnvelope(res.value)) {
|
||||
lastEventId = res.value[0];
|
||||
chunk = {
|
||||
id: res.value[0],
|
||||
data: {
|
||||
id: res.value[0],
|
||||
data: res.value[1]
|
||||
}
|
||||
};
|
||||
} else chunk = { data: res.value };
|
||||
observer.next({ result: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, chunk), {}, { data: transformChunk(chunk.data) }) });
|
||||
}
|
||||
} catch (_) {
|
||||
_usingCtx4.e = _;
|
||||
} finally {
|
||||
await _usingCtx4.d();
|
||||
}
|
||||
break;
|
||||
} catch (_) {
|
||||
_usingCtx3.e = _;
|
||||
} finally {
|
||||
_usingCtx3.d();
|
||||
}
|
||||
}
|
||||
}).catch((cause) => {
|
||||
onErrorCallback(cause);
|
||||
observer.error(coerceToTRPCClientError(cause));
|
||||
});
|
||||
return () => {
|
||||
ac.abort();
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @deprecated Renamed to `unstable_localLink`. This alias will be removed in a future major release.
|
||||
*/
|
||||
const experimental_localLink = unstable_localLink;
|
||||
|
||||
//#endregion
|
||||
export { TRPCClientError, TRPCUntypedClient, clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, jsonEncoder, loggerLink, retryLink, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, unstable_localLink, wsLink };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+7
@@ -0,0 +1,7 @@
|
||||
require('../objectSpread2-Bsvh_OqM.cjs');
|
||||
require('../TRPCClientError-CQrTQLrk.cjs');
|
||||
require('../httpUtils-wv2o-njD.cjs');
|
||||
const require_httpBatchLink = require('../httpBatchLink-BGZRsGNf.cjs');
|
||||
require('../unstable-internals-M84gUQCV.cjs');
|
||||
|
||||
exports.httpBatchLink = require_httpBatchLink.httpBatchLink;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "../subscriptions.d-Ciljg_dH.cjs";
|
||||
import "../types.d-Dmmedc5G.cjs";
|
||||
import "../unstable-internals.d-kWsZTlQq.cjs";
|
||||
import "../httpUtils.d-BqmeKEGo.cjs";
|
||||
import { httpBatchLink } from "../httpBatchLink.d-7jyWtY5H.cjs";
|
||||
export { httpBatchLink };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "../subscriptions.d-Dlr1nWGD.mjs";
|
||||
import "../types.d-sRNtuQA-.mjs";
|
||||
import "../unstable-internals.d-BOmV7EK1.mjs";
|
||||
import "../httpUtils.d-yYSKGhiS.mjs";
|
||||
import { httpBatchLink } from "../httpBatchLink.d-B6vCg-F-.mjs";
|
||||
export { httpBatchLink };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import "../objectSpread2-BvkFp-_Y.mjs";
|
||||
import "../TRPCClientError-apv8gw59.mjs";
|
||||
import "../httpUtils-pyf5RF99.mjs";
|
||||
import { httpBatchLink } from "../httpBatchLink-LhidKAPw.mjs";
|
||||
import "../unstable-internals-Bg7n9BBj.mjs";
|
||||
|
||||
export { httpBatchLink };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
require('../objectSpread2-Bsvh_OqM.cjs');
|
||||
require('../TRPCClientError-CQrTQLrk.cjs');
|
||||
require('../httpUtils-wv2o-njD.cjs');
|
||||
const require_httpLink = require('../httpLink-B8Iv31Ee.cjs');
|
||||
require('../unstable-internals-M84gUQCV.cjs');
|
||||
|
||||
exports.httpLink = require_httpLink.httpLink;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "../subscriptions.d-Ciljg_dH.cjs";
|
||||
import "../types.d-Dmmedc5G.cjs";
|
||||
import "../unstable-internals.d-kWsZTlQq.cjs";
|
||||
import "../httpUtils.d-BqmeKEGo.cjs";
|
||||
import { HTTPLinkOptions, httpLink } from "../httpLink.d-D5qR9haY.cjs";
|
||||
export { HTTPLinkOptions, httpLink };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "../subscriptions.d-Dlr1nWGD.mjs";
|
||||
import "../types.d-sRNtuQA-.mjs";
|
||||
import "../unstable-internals.d-BOmV7EK1.mjs";
|
||||
import "../httpUtils.d-yYSKGhiS.mjs";
|
||||
import { HTTPLinkOptions, httpLink } from "../httpLink.d-CVOTlkUT.mjs";
|
||||
export { HTTPLinkOptions, httpLink };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import "../objectSpread2-BvkFp-_Y.mjs";
|
||||
import "../TRPCClientError-apv8gw59.mjs";
|
||||
import "../httpUtils-pyf5RF99.mjs";
|
||||
import { httpLink } from "../httpLink-lG_6juPY.mjs";
|
||||
import "../unstable-internals-Bg7n9BBj.mjs";
|
||||
|
||||
export { httpLink };
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
require('../objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_loggerLink = require('../loggerLink-CuYvRzyH.cjs');
|
||||
|
||||
exports.loggerLink = require_loggerLink.loggerLink;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import "../subscriptions.d-Ciljg_dH.cjs";
|
||||
import "../types.d-Dmmedc5G.cjs";
|
||||
import { LoggerLinkOptions, loggerLink } from "../loggerLink.d-BxSIj5kx.cjs";
|
||||
export { LoggerLinkOptions, loggerLink };
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import "../subscriptions.d-Dlr1nWGD.mjs";
|
||||
import "../types.d-sRNtuQA-.mjs";
|
||||
import { LoggerLinkOptions, loggerLink } from "../loggerLink.d-DBRq_5Gd.mjs";
|
||||
export { LoggerLinkOptions, loggerLink };
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import "../objectSpread2-BvkFp-_Y.mjs";
|
||||
import { loggerLink } from "../loggerLink-ineCN1PO.mjs";
|
||||
|
||||
export { loggerLink };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
const require_splitLink = require('../splitLink-BMgxggng.cjs');
|
||||
|
||||
exports.splitLink = require_splitLink.splitLink;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import "../subscriptions.d-Ciljg_dH.cjs";
|
||||
import "../types.d-Dmmedc5G.cjs";
|
||||
import { splitLink } from "../splitLink.d-BBFK_mCw.cjs";
|
||||
export { splitLink };
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import "../subscriptions.d-Dlr1nWGD.mjs";
|
||||
import "../types.d-sRNtuQA-.mjs";
|
||||
import { splitLink } from "../splitLink.d-BKr9eE0o.mjs";
|
||||
export { splitLink };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { splitLink } from "../splitLink-B7Cuf2c_.mjs";
|
||||
|
||||
export { splitLink };
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
require('../../objectSpread2-Bsvh_OqM.cjs');
|
||||
require('../../TRPCClientError-CQrTQLrk.cjs');
|
||||
require('../../unstable-internals-M84gUQCV.cjs');
|
||||
const require_wsLink = require('../../wsLink-CobRSm6C.cjs');
|
||||
|
||||
exports.createWSClient = require_wsLink.createWSClient;
|
||||
exports.jsonEncoder = require_wsLink.jsonEncoder;
|
||||
exports.wsLink = require_wsLink.wsLink;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import "../../subscriptions.d-Ciljg_dH.cjs";
|
||||
import "../../types.d-Dmmedc5G.cjs";
|
||||
import "../../unstable-internals.d-kWsZTlQq.cjs";
|
||||
import { Encoder, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink } from "../../wsLink.d-DzZZZGZQ.cjs";
|
||||
export { Encoder, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import "../../subscriptions.d-Dlr1nWGD.mjs";
|
||||
import "../../types.d-sRNtuQA-.mjs";
|
||||
import "../../unstable-internals.d-BOmV7EK1.mjs";
|
||||
import { Encoder, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink } from "../../wsLink.d-DCqbZKOH.mjs";
|
||||
export { Encoder, TRPCWebSocketClient, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink };
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import "../../objectSpread2-BvkFp-_Y.mjs";
|
||||
import "../../TRPCClientError-apv8gw59.mjs";
|
||||
import "../../unstable-internals-Bg7n9BBj.mjs";
|
||||
import { createWSClient, jsonEncoder, wsLink } from "../../wsLink-DSf4KOdW.mjs";
|
||||
|
||||
export { createWSClient, jsonEncoder, wsLink };
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
|
||||
//#region src/links/loggerLink.ts
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
function isFormData(value) {
|
||||
if (typeof FormData === "undefined") return false;
|
||||
return value instanceof FormData;
|
||||
}
|
||||
const palettes = {
|
||||
css: {
|
||||
query: ["72e3ff", "3fb0d8"],
|
||||
mutation: ["c5a3fc", "904dfc"],
|
||||
subscription: ["ff49e1", "d83fbe"]
|
||||
},
|
||||
ansi: {
|
||||
regular: {
|
||||
query: ["\x1B[30;46m", "\x1B[97;46m"],
|
||||
mutation: ["\x1B[30;45m", "\x1B[97;45m"],
|
||||
subscription: ["\x1B[30;42m", "\x1B[97;42m"]
|
||||
},
|
||||
bold: {
|
||||
query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
|
||||
mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
|
||||
subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
|
||||
}
|
||||
}
|
||||
};
|
||||
function constructPartsAndArgs(opts) {
|
||||
const { direction, type, withContext, path, id, input } = opts;
|
||||
const parts = [];
|
||||
const args = [];
|
||||
if (opts.colorMode === "none") parts.push(direction === "up" ? ">>" : "<<", type, `#${id}`, path);
|
||||
else if (opts.colorMode === "ansi") {
|
||||
const [lightRegular, darkRegular] = palettes.ansi.regular[type];
|
||||
const [lightBold, darkBold] = palettes.ansi.bold[type];
|
||||
const reset = "\x1B[0m";
|
||||
parts.push(direction === "up" ? lightRegular : darkRegular, direction === "up" ? ">>" : "<<", type, direction === "up" ? lightBold : darkBold, `#${id}`, path, reset);
|
||||
} else {
|
||||
const [light, dark] = palettes.css[type];
|
||||
const css = `
|
||||
background-color: #${direction === "up" ? light : dark};
|
||||
color: ${direction === "up" ? "black" : "white"};
|
||||
padding: 2px;
|
||||
`;
|
||||
parts.push("%c", direction === "up" ? ">>" : "<<", type, `#${id}`, `%c${path}%c`, "%O");
|
||||
args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
|
||||
}
|
||||
if (direction === "up") args.push(withContext ? {
|
||||
input,
|
||||
context: opts.context
|
||||
} : { input });
|
||||
else args.push((0, import_objectSpread2.default)({
|
||||
input,
|
||||
result: opts.result,
|
||||
elapsedMs: opts.elapsedMs
|
||||
}, withContext && { context: opts.context }));
|
||||
return {
|
||||
parts,
|
||||
args
|
||||
};
|
||||
}
|
||||
const defaultLogger = ({ c = console, colorMode = "css", withContext }) => (props) => {
|
||||
const rawInput = props.input;
|
||||
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
||||
const { parts, args } = constructPartsAndArgs((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, props), {}, {
|
||||
colorMode,
|
||||
input,
|
||||
withContext
|
||||
}));
|
||||
const fn = props.direction === "down" && props.result && (props.result instanceof Error || "error" in props.result.result && props.result.result.error) ? "error" : "log";
|
||||
c[fn].apply(null, [parts.join(" ")].concat(args));
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
||||
*/
|
||||
function loggerLink(opts = {}) {
|
||||
var _opts$colorMode, _opts$withContext;
|
||||
const { enabled = () => true } = opts;
|
||||
const colorMode = (_opts$colorMode = opts.colorMode) !== null && _opts$colorMode !== void 0 ? _opts$colorMode : typeof window === "undefined" ? "ansi" : "css";
|
||||
const withContext = (_opts$withContext = opts.withContext) !== null && _opts$withContext !== void 0 ? _opts$withContext : colorMode === "css";
|
||||
const { logger = defaultLogger({
|
||||
c: opts.console,
|
||||
colorMode,
|
||||
withContext
|
||||
}) } = opts;
|
||||
return () => {
|
||||
return ({ op, next }) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
if (enabled((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, { direction: "up" }))) logger((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, { direction: "up" }));
|
||||
const requestStartTime = Date.now();
|
||||
function logResult(result) {
|
||||
const elapsedMs = Date.now() - requestStartTime;
|
||||
if (enabled((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, {
|
||||
direction: "down",
|
||||
result
|
||||
}))) logger((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, {
|
||||
direction: "down",
|
||||
elapsedMs,
|
||||
result
|
||||
}));
|
||||
}
|
||||
return next(op).pipe((0, __trpc_server_observable.tap)({
|
||||
next(result) {
|
||||
logResult(result);
|
||||
},
|
||||
error(result) {
|
||||
logResult(result);
|
||||
}
|
||||
})).subscribe(observer);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'loggerLink', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return loggerLink;
|
||||
}
|
||||
});
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
import { __toESM, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { observable, tap } from "@trpc/server/observable";
|
||||
|
||||
//#region src/links/loggerLink.ts
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
function isFormData(value) {
|
||||
if (typeof FormData === "undefined") return false;
|
||||
return value instanceof FormData;
|
||||
}
|
||||
const palettes = {
|
||||
css: {
|
||||
query: ["72e3ff", "3fb0d8"],
|
||||
mutation: ["c5a3fc", "904dfc"],
|
||||
subscription: ["ff49e1", "d83fbe"]
|
||||
},
|
||||
ansi: {
|
||||
regular: {
|
||||
query: ["\x1B[30;46m", "\x1B[97;46m"],
|
||||
mutation: ["\x1B[30;45m", "\x1B[97;45m"],
|
||||
subscription: ["\x1B[30;42m", "\x1B[97;42m"]
|
||||
},
|
||||
bold: {
|
||||
query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
|
||||
mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
|
||||
subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
|
||||
}
|
||||
}
|
||||
};
|
||||
function constructPartsAndArgs(opts) {
|
||||
const { direction, type, withContext, path, id, input } = opts;
|
||||
const parts = [];
|
||||
const args = [];
|
||||
if (opts.colorMode === "none") parts.push(direction === "up" ? ">>" : "<<", type, `#${id}`, path);
|
||||
else if (opts.colorMode === "ansi") {
|
||||
const [lightRegular, darkRegular] = palettes.ansi.regular[type];
|
||||
const [lightBold, darkBold] = palettes.ansi.bold[type];
|
||||
const reset = "\x1B[0m";
|
||||
parts.push(direction === "up" ? lightRegular : darkRegular, direction === "up" ? ">>" : "<<", type, direction === "up" ? lightBold : darkBold, `#${id}`, path, reset);
|
||||
} else {
|
||||
const [light, dark] = palettes.css[type];
|
||||
const css = `
|
||||
background-color: #${direction === "up" ? light : dark};
|
||||
color: ${direction === "up" ? "black" : "white"};
|
||||
padding: 2px;
|
||||
`;
|
||||
parts.push("%c", direction === "up" ? ">>" : "<<", type, `#${id}`, `%c${path}%c`, "%O");
|
||||
args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
|
||||
}
|
||||
if (direction === "up") args.push(withContext ? {
|
||||
input,
|
||||
context: opts.context
|
||||
} : { input });
|
||||
else args.push((0, import_objectSpread2.default)({
|
||||
input,
|
||||
result: opts.result,
|
||||
elapsedMs: opts.elapsedMs
|
||||
}, withContext && { context: opts.context }));
|
||||
return {
|
||||
parts,
|
||||
args
|
||||
};
|
||||
}
|
||||
const defaultLogger = ({ c = console, colorMode = "css", withContext }) => (props) => {
|
||||
const rawInput = props.input;
|
||||
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
||||
const { parts, args } = constructPartsAndArgs((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, props), {}, {
|
||||
colorMode,
|
||||
input,
|
||||
withContext
|
||||
}));
|
||||
const fn = props.direction === "down" && props.result && (props.result instanceof Error || "error" in props.result.result && props.result.result.error) ? "error" : "log";
|
||||
c[fn].apply(null, [parts.join(" ")].concat(args));
|
||||
};
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
||||
*/
|
||||
function loggerLink(opts = {}) {
|
||||
var _opts$colorMode, _opts$withContext;
|
||||
const { enabled = () => true } = opts;
|
||||
const colorMode = (_opts$colorMode = opts.colorMode) !== null && _opts$colorMode !== void 0 ? _opts$colorMode : typeof window === "undefined" ? "ansi" : "css";
|
||||
const withContext = (_opts$withContext = opts.withContext) !== null && _opts$withContext !== void 0 ? _opts$withContext : colorMode === "css";
|
||||
const { logger = defaultLogger({
|
||||
c: opts.console,
|
||||
colorMode,
|
||||
withContext
|
||||
}) } = opts;
|
||||
return () => {
|
||||
return ({ op, next }) => {
|
||||
return observable((observer) => {
|
||||
if (enabled((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, { direction: "up" }))) logger((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, { direction: "up" }));
|
||||
const requestStartTime = Date.now();
|
||||
function logResult(result) {
|
||||
const elapsedMs = Date.now() - requestStartTime;
|
||||
if (enabled((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, {
|
||||
direction: "down",
|
||||
result
|
||||
}))) logger((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, op), {}, {
|
||||
direction: "down",
|
||||
elapsedMs,
|
||||
result
|
||||
}));
|
||||
}
|
||||
return next(op).pipe(tap({
|
||||
next(result) {
|
||||
logResult(result);
|
||||
},
|
||||
error(result) {
|
||||
logResult(result);
|
||||
}
|
||||
})).subscribe(observer);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { loggerLink };
|
||||
//# sourceMappingURL=loggerLink-ineCN1PO.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+54
@@ -0,0 +1,54 @@
|
||||
import { Operation, OperationResultEnvelope, TRPCClientError, TRPCLink } from "./types.d-Dmmedc5G.cjs";
|
||||
import { AnyRouter, InferrableClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/loggerLink.d.ts
|
||||
type ConsoleEsque = {
|
||||
log: (...args: any[]) => void;
|
||||
error: (...args: any[]) => void;
|
||||
};
|
||||
type EnableFnOptions<TRouter extends InferrableClientTypes> = {
|
||||
direction: 'down';
|
||||
result: OperationResultEnvelope<unknown, TRPCClientError<TRouter>> | TRPCClientError<TRouter>;
|
||||
} | (Operation & {
|
||||
direction: 'up';
|
||||
});
|
||||
type EnabledFn<TRouter extends AnyRouter> = (opts: EnableFnOptions<TRouter>) => boolean;
|
||||
type LoggerLinkFnOptions<TRouter extends AnyRouter> = Operation & ({
|
||||
/**
|
||||
* Request result
|
||||
*/
|
||||
direction: 'down';
|
||||
result: OperationResultEnvelope<unknown, TRPCClientError<TRouter>> | TRPCClientError<TRouter>;
|
||||
elapsedMs: number;
|
||||
} | {
|
||||
/**
|
||||
* Request was just initialized
|
||||
*/
|
||||
direction: 'up';
|
||||
});
|
||||
type LoggerLinkFn<TRouter extends AnyRouter> = (opts: LoggerLinkFnOptions<TRouter>) => void;
|
||||
type ColorMode = 'ansi' | 'css' | 'none';
|
||||
interface LoggerLinkOptions<TRouter extends AnyRouter> {
|
||||
logger?: LoggerLinkFn<TRouter>;
|
||||
enabled?: EnabledFn<TRouter>;
|
||||
/**
|
||||
* Used in the built-in defaultLogger
|
||||
*/
|
||||
console?: ConsoleEsque;
|
||||
/**
|
||||
* Color mode
|
||||
* @default typeof window === 'undefined' ? 'ansi' : 'css'
|
||||
*/
|
||||
colorMode?: ColorMode;
|
||||
/**
|
||||
* Include context in the log - defaults to false unless `colorMode` is 'css'
|
||||
*/
|
||||
withContext?: boolean;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
||||
*/
|
||||
declare function loggerLink<TRouter extends AnyRouter = AnyRouter>(opts?: LoggerLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
//#endregion
|
||||
export { LoggerLinkOptions, loggerLink };
|
||||
//# sourceMappingURL=loggerLink.d-BxSIj5kx.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"loggerLink.d-BxSIj5kx.d.cts","names":[],"sources":["../src/links/loggerLink.ts"],"sourcesContent":[],"mappings":";;;;KAeK,YAAA;EAAA,GAAA,EAAA,CAAA,GAAA,IAAA,EAAY,GAAA,EAAA,EAAA,GAAA,IAAA;EAKZ,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,GAAe,EAAA,EAAA,GAAA,IAAA;CAAA;KAAf,eAAgC,CAAA,gBAAA,qBAAA,CAAA,GAAA;EAAqB,SAIC,EAAA,MAAA;EAAO,MAAvB,EAAjC,uBAAiC,CAAA,OAAA,EAAA,eAAA,CAAgB,OAAhB,CAAA,CAAA,GACjC,eADiC,CACjB,OADiB,CAAA;CAAe,GAAA,CAGrD,SAHK,GAAA;EAAuB,SACP,EAAA,IAAA;CAAO,CAAA;KAK5B,SAHA,CAAA,gBAG0B,SAH1B,CAAA,GAAA,CAAA,IAAA,EAIG,eAJH,CAImB,OAJnB,CAAA,EAAA,GAAA,OAAA;AAAS,KAOT,mBAPS,CAAA,gBAO2B,SAP3B,CAAA,GAOwC,SAPxC,GAAA,CAAA;EAGT;;;EAAmC,SAChB,EAAA,MAAA;EAAO,MAAvB,EAWI,uBAXJ,CAAA,OAAA,EAWqC,eAXrC,CAWqD,OAXrD,CAAA,CAAA,GAYI,eAZJ,CAYoB,OAZpB,CAAA;EAAe,SAAA,EAAA,MAAA;AAAA,CAAA,GAGlB;EAAmB;;;EAAuC,SAQF,EAAA,IAAA;CAAO,CAAA;KAY/D,YAZO,CAAA,gBAYsB,SAZtB,CAAA,GAAA,CAAA,IAAA,EAaJ,mBAbI,CAagB,OAbhB,CAAA,EAAA,GAAA,IAAA;KAgBP,SAAA,GAfuB,MAAA,GAAA,KAAA,GAAA,MAAA;AAAhB,UAiBK,iBAjBL,CAAA,gBAiBuC,SAjBvC,CAAA,CAAA;EAAe,MAAA,CAAA,EAkBhB,YAlBgB,CAkBH,OAlBG,CAAA;EAWtB,OAAA,CAAA,EAQO,SARK,CAQK,OARL,CAAA;EAAA;;;EACkB,OAA3B,CAAA,EAWI,YAXJ;EAAmB;AAAA;AAK3B;;EAAkC,SAAiB,CAAA,EAWrC,SAXqC;EAAS;;;EAE/B,WAAjB,CAAA,EAAA,OAAA;;;AASW;AA8IvB;AAA0B,iBAAV,UAAU,CAAA,gBAAiB,SAAjB,GAA6B,SAA7B,CAAA,CAAA,IAAA,CAAA,EAClB,iBADkB,CACA,OADA,CAAA,CAAA,EAEvB,QAFuB,CAEd,OAFc,CAAA"}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import { Operation, OperationResultEnvelope, TRPCClientError, TRPCLink } from "./types.d-sRNtuQA-.mjs";
|
||||
import { AnyRouter, InferrableClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/loggerLink.d.ts
|
||||
type ConsoleEsque = {
|
||||
log: (...args: any[]) => void;
|
||||
error: (...args: any[]) => void;
|
||||
};
|
||||
type EnableFnOptions<TRouter extends InferrableClientTypes> = {
|
||||
direction: 'down';
|
||||
result: OperationResultEnvelope<unknown, TRPCClientError<TRouter>> | TRPCClientError<TRouter>;
|
||||
} | (Operation & {
|
||||
direction: 'up';
|
||||
});
|
||||
type EnabledFn<TRouter extends AnyRouter> = (opts: EnableFnOptions<TRouter>) => boolean;
|
||||
type LoggerLinkFnOptions<TRouter extends AnyRouter> = Operation & ({
|
||||
/**
|
||||
* Request result
|
||||
*/
|
||||
direction: 'down';
|
||||
result: OperationResultEnvelope<unknown, TRPCClientError<TRouter>> | TRPCClientError<TRouter>;
|
||||
elapsedMs: number;
|
||||
} | {
|
||||
/**
|
||||
* Request was just initialized
|
||||
*/
|
||||
direction: 'up';
|
||||
});
|
||||
type LoggerLinkFn<TRouter extends AnyRouter> = (opts: LoggerLinkFnOptions<TRouter>) => void;
|
||||
type ColorMode = 'ansi' | 'css' | 'none';
|
||||
interface LoggerLinkOptions<TRouter extends AnyRouter> {
|
||||
logger?: LoggerLinkFn<TRouter>;
|
||||
enabled?: EnabledFn<TRouter>;
|
||||
/**
|
||||
* Used in the built-in defaultLogger
|
||||
*/
|
||||
console?: ConsoleEsque;
|
||||
/**
|
||||
* Color mode
|
||||
* @default typeof window === 'undefined' ? 'ansi' : 'css'
|
||||
*/
|
||||
colorMode?: ColorMode;
|
||||
/**
|
||||
* Include context in the log - defaults to false unless `colorMode` is 'css'
|
||||
*/
|
||||
withContext?: boolean;
|
||||
}
|
||||
/**
|
||||
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
||||
*/
|
||||
declare function loggerLink<TRouter extends AnyRouter = AnyRouter>(opts?: LoggerLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
//#endregion
|
||||
export { LoggerLinkOptions, loggerLink };
|
||||
//# sourceMappingURL=loggerLink.d-DBRq_5Gd.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"loggerLink.d-DBRq_5Gd.d.mts","names":[],"sources":["../src/links/loggerLink.ts"],"sourcesContent":[],"mappings":";;;;KAeK,YAAA;EAAA,GAAA,EAAA,CAAA,GAAA,IAAA,EAAY,GAAA,EAAA,EAAA,GAAA,IAAA;EAKZ,KAAA,EAAA,CAAA,GAAA,IAAA,EAAA,GAAe,EAAA,EAAA,GAAA,IAAA;CAAA;KAAf,eAAgC,CAAA,gBAAA,qBAAA,CAAA,GAAA;EAAqB,SAIC,EAAA,MAAA;EAAO,MAAvB,EAAjC,uBAAiC,CAAA,OAAA,EAAA,eAAA,CAAgB,OAAhB,CAAA,CAAA,GACjC,eADiC,CACjB,OADiB,CAAA;CAAe,GAAA,CAGrD,SAHK,GAAA;EAAuB,SACP,EAAA,IAAA;CAAO,CAAA;KAK5B,SAHA,CAAA,gBAG0B,SAH1B,CAAA,GAAA,CAAA,IAAA,EAIG,eAJH,CAImB,OAJnB,CAAA,EAAA,GAAA,OAAA;AAAS,KAOT,mBAPS,CAAA,gBAO2B,SAP3B,CAAA,GAOwC,SAPxC,GAAA,CAAA;EAGT;;;EAAmC,SAChB,EAAA,MAAA;EAAO,MAAvB,EAWI,uBAXJ,CAAA,OAAA,EAWqC,eAXrC,CAWqD,OAXrD,CAAA,CAAA,GAYI,eAZJ,CAYoB,OAZpB,CAAA;EAAe,SAAA,EAAA,MAAA;AAAA,CAAA,GAGlB;EAAmB;;;EAAuC,SAQF,EAAA,IAAA;CAAO,CAAA;KAY/D,YAZO,CAAA,gBAYsB,SAZtB,CAAA,GAAA,CAAA,IAAA,EAaJ,mBAbI,CAagB,OAbhB,CAAA,EAAA,GAAA,IAAA;KAgBP,SAAA,GAfuB,MAAA,GAAA,KAAA,GAAA,MAAA;AAAhB,UAiBK,iBAjBL,CAAA,gBAiBuC,SAjBvC,CAAA,CAAA;EAAe,MAAA,CAAA,EAkBhB,YAlBgB,CAkBH,OAlBG,CAAA;EAWtB,OAAA,CAAA,EAQO,SARK,CAQK,OARL,CAAA;EAAA;;;EACkB,OAA3B,CAAA,EAWI,YAXJ;EAAmB;AAAA;AAK3B;;EAAkC,SAAiB,CAAA,EAWrC,SAXqC;EAAS;;;EAE/B,WAAjB,CAAA,EAAA,OAAA;;;AASW;AA8IvB;AAA0B,iBAAV,UAAU,CAAA,gBAAiB,SAAjB,GAA6B,SAA7B,CAAA,CAAA,IAAA,CAAA,EAClB,iBADkB,CACA,OADA,CAAA,CAAA,EAEvB,QAFuB,CAEd,OAFc,CAAA"}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
||||
var require_typeof = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
||||
function _typeof$2(o) {
|
||||
"@babel/helpers - typeof";
|
||||
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
||||
return typeof o$1;
|
||||
} : function(o$1) {
|
||||
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
||||
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
||||
}
|
||||
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
||||
var require_toPrimitive = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
||||
var _typeof$1 = require_typeof()["default"];
|
||||
function toPrimitive$1(t, r) {
|
||||
if ("object" != _typeof$1(t) || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r || "default");
|
||||
if ("object" != _typeof$1(i)) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return ("string" === r ? String : Number)(t);
|
||||
}
|
||||
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
||||
var require_toPropertyKey = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
||||
var _typeof = require_typeof()["default"];
|
||||
var toPrimitive = require_toPrimitive();
|
||||
function toPropertyKey$1(t) {
|
||||
var i = toPrimitive(t, "string");
|
||||
return "symbol" == _typeof(i) ? i : i + "";
|
||||
}
|
||||
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
||||
var require_defineProperty = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
||||
var toPropertyKey = require_toPropertyKey();
|
||||
function _defineProperty(e, r, t) {
|
||||
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
||||
value: t,
|
||||
enumerable: !0,
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
}) : e[r] = t, e;
|
||||
}
|
||||
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
||||
var require_objectSpread2 = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
||||
var defineProperty = require_defineProperty();
|
||||
function ownKeys(e, r) {
|
||||
var t = Object.keys(e);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var o = Object.getOwnPropertySymbols(e);
|
||||
r && (o = o.filter(function(r$1) {
|
||||
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
||||
})), t.push.apply(t, o);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function _objectSpread2(e) {
|
||||
for (var r = 1; r < arguments.length; r++) {
|
||||
var t = null != arguments[r] ? arguments[r] : {};
|
||||
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
||||
defineProperty(e, r$1, t[r$1]);
|
||||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
||||
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
||||
});
|
||||
}
|
||||
return e;
|
||||
}
|
||||
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'require_defineProperty', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return require_defineProperty;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'require_objectSpread2', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return require_objectSpread2;
|
||||
}
|
||||
});
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
//#region rolldown:runtime
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
||||
value: mod,
|
||||
enumerable: true
|
||||
}) : target, mod));
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
||||
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
||||
function _typeof$2(o) {
|
||||
"@babel/helpers - typeof";
|
||||
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
||||
return typeof o$1;
|
||||
} : function(o$1) {
|
||||
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
||||
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
||||
}
|
||||
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
||||
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
||||
var _typeof$1 = require_typeof()["default"];
|
||||
function toPrimitive$1(t, r) {
|
||||
if ("object" != _typeof$1(t) || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r || "default");
|
||||
if ("object" != _typeof$1(i)) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return ("string" === r ? String : Number)(t);
|
||||
}
|
||||
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
||||
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
||||
var _typeof = require_typeof()["default"];
|
||||
var toPrimitive = require_toPrimitive();
|
||||
function toPropertyKey$1(t) {
|
||||
var i = toPrimitive(t, "string");
|
||||
return "symbol" == _typeof(i) ? i : i + "";
|
||||
}
|
||||
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
||||
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
||||
var toPropertyKey = require_toPropertyKey();
|
||||
function _defineProperty(e, r, t) {
|
||||
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
||||
value: t,
|
||||
enumerable: !0,
|
||||
configurable: !0,
|
||||
writable: !0
|
||||
}) : e[r] = t, e;
|
||||
}
|
||||
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
||||
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
||||
var defineProperty = require_defineProperty();
|
||||
function ownKeys(e, r) {
|
||||
var t = Object.keys(e);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var o = Object.getOwnPropertySymbols(e);
|
||||
r && (o = o.filter(function(r$1) {
|
||||
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
||||
})), t.push.apply(t, o);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function _objectSpread2(e) {
|
||||
for (var r = 1; r < arguments.length; r++) {
|
||||
var t = null != arguments[r] ? arguments[r] : {};
|
||||
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
||||
defineProperty(e, r$1, t[r$1]);
|
||||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
||||
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
||||
});
|
||||
}
|
||||
return e;
|
||||
}
|
||||
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
} });
|
||||
|
||||
//#endregion
|
||||
export { __commonJS, __toESM, require_defineProperty, require_objectSpread2 };
|
||||
//# sourceMappingURL=objectSpread2-BvkFp-_Y.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+47
@@ -0,0 +1,47 @@
|
||||
import { observable } from "@trpc/server/observable";
|
||||
|
||||
//#region src/links/internals/createChain.ts
|
||||
/** @internal */
|
||||
function createChain(opts) {
|
||||
return observable((observer) => {
|
||||
function execute(index = 0, op = opts.op) {
|
||||
const next = opts.links[index];
|
||||
if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
|
||||
const subscription = next({
|
||||
op,
|
||||
next(nextOp) {
|
||||
const nextObserver = execute(index + 1, nextOp);
|
||||
return nextObserver;
|
||||
}
|
||||
});
|
||||
return subscription;
|
||||
}
|
||||
const obs$ = execute();
|
||||
return obs$.subscribe(observer);
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/splitLink.ts
|
||||
function asArray(value) {
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
function splitLink(opts) {
|
||||
return (runtime) => {
|
||||
const yes = asArray(opts.true).map((link) => link(runtime));
|
||||
const no = asArray(opts.false).map((link) => link(runtime));
|
||||
return (props) => {
|
||||
return observable((observer) => {
|
||||
const links = opts.condition(props.op) ? yes : no;
|
||||
return createChain({
|
||||
op: props.op,
|
||||
links
|
||||
}).subscribe(observer);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createChain, splitLink };
|
||||
//# sourceMappingURL=splitLink-B7Cuf2c_.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"splitLink-B7Cuf2c_.mjs","names":["opts: {\n links: OperationLink<TRouter, TInput, TOutput>[];\n op: Operation<TInput>;\n}","value: TType | TType[]","opts: {\n condition: (op: Operation) => boolean;\n /**\n * The link to execute next if the test function returns `true`.\n */\n true: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n /**\n * The link to execute next if the test function returns `false`.\n */\n false: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n}"],"sources":["../src/links/internals/createChain.ts","../src/links/splitLink.ts"],"sourcesContent":["import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport type {\n Operation,\n OperationLink,\n OperationResultObservable,\n} from '../types';\n\n/** @internal */\nexport function createChain<\n TRouter extends AnyRouter,\n TInput = unknown,\n TOutput = unknown,\n>(opts: {\n links: OperationLink<TRouter, TInput, TOutput>[];\n op: Operation<TInput>;\n}): OperationResultObservable<TRouter, TOutput> {\n return observable((observer) => {\n function execute(index = 0, op = opts.op) {\n const next = opts.links[index];\n if (!next) {\n throw new Error(\n 'No more links to execute - did you forget to add an ending link?',\n );\n }\n const subscription = next({\n op,\n next(nextOp) {\n const nextObserver = execute(index + 1, nextOp);\n\n return nextObserver;\n },\n });\n return subscription;\n }\n\n const obs$ = execute();\n return obs$.subscribe(observer);\n });\n}\n","import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport { createChain } from './internals/createChain';\nimport type { Operation, TRPCLink } from './types';\n\nfunction asArray<TType>(value: TType | TType[]) {\n return Array.isArray(value) ? value : [value];\n}\nexport function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {\n condition: (op: Operation) => boolean;\n /**\n * The link to execute next if the test function returns `true`.\n */\n true: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n /**\n * The link to execute next if the test function returns `false`.\n */\n false: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n}): TRPCLink<TRouter> {\n return (runtime) => {\n const yes = asArray(opts.true).map((link) => link(runtime));\n const no = asArray(opts.false).map((link) => link(runtime));\n return (props) => {\n return observable((observer) => {\n const links = opts.condition(props.op) ? yes : no;\n return createChain({ op: props.op, links }).subscribe(observer);\n });\n };\n };\n}\n"],"mappings":";;;;AASA,SAAgB,YAIdA,MAG8C;AAC9C,QAAO,WAAW,CAAC,aAAa;EAC9B,SAAS,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI;GACxC,MAAM,OAAO,KAAK,MAAM;AACxB,QAAK,KACH,OAAM,IAAI,MACR;GAGJ,MAAM,eAAe,KAAK;IACxB;IACA,KAAK,QAAQ;KACX,MAAM,eAAe,QAAQ,QAAQ,GAAG,OAAO;AAE/C,YAAO;IACR;GACF,EAAC;AACF,UAAO;EACR;EAED,MAAM,OAAO,SAAS;AACtB,SAAO,KAAK,UAAU,SAAS;CAChC,EAAC;AACH;;;;AClCD,SAAS,QAAeC,OAAwB;AAC9C,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,KAAM;AAC9C;AACD,SAAgB,UAAiDC,MAU3C;AACpB,QAAO,CAAC,YAAY;EAClB,MAAM,MAAM,QAAQ,KAAK,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC;EAC3D,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC;AAC3D,SAAO,CAAC,UAAU;AAChB,UAAO,WAAW,CAAC,aAAa;IAC9B,MAAM,QAAQ,KAAK,UAAU,MAAM,GAAG,GAAG,MAAM;AAC/C,WAAO,YAAY;KAAE,IAAI,MAAM;KAAI;IAAO,EAAC,CAAC,UAAU,SAAS;GAChE,EAAC;EACH;CACF;AACF"}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
|
||||
//#region src/links/internals/createChain.ts
|
||||
/** @internal */
|
||||
function createChain(opts) {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
function execute(index = 0, op = opts.op) {
|
||||
const next = opts.links[index];
|
||||
if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
|
||||
const subscription = next({
|
||||
op,
|
||||
next(nextOp) {
|
||||
const nextObserver = execute(index + 1, nextOp);
|
||||
return nextObserver;
|
||||
}
|
||||
});
|
||||
return subscription;
|
||||
}
|
||||
const obs$ = execute();
|
||||
return obs$.subscribe(observer);
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/splitLink.ts
|
||||
function asArray(value) {
|
||||
return Array.isArray(value) ? value : [value];
|
||||
}
|
||||
function splitLink(opts) {
|
||||
return (runtime) => {
|
||||
const yes = asArray(opts.true).map((link) => link(runtime));
|
||||
const no = asArray(opts.false).map((link) => link(runtime));
|
||||
return (props) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
const links = opts.condition(props.op) ? yes : no;
|
||||
return createChain({
|
||||
op: props.op,
|
||||
links
|
||||
}).subscribe(observer);
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'createChain', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createChain;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'splitLink', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return splitLink;
|
||||
}
|
||||
});
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { Operation, TRPCLink } from "./types.d-Dmmedc5G.cjs";
|
||||
import { AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/splitLink.d.ts
|
||||
declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
||||
condition: (op: Operation) => boolean;
|
||||
/**
|
||||
* The link to execute next if the test function returns `true`.
|
||||
*/
|
||||
true: TRPCLink<TRouter> | TRPCLink<TRouter>[];
|
||||
/**
|
||||
* The link to execute next if the test function returns `false`.
|
||||
*/
|
||||
false: TRPCLink<TRouter> | TRPCLink<TRouter>[];
|
||||
}): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=splitLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { splitLink };
|
||||
//# sourceMappingURL=splitLink.d-BBFK_mCw.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"splitLink.d-BBFK_mCw.d.cts","names":[],"sources":["../src/links/splitLink.ts"],"sourcesContent":[],"mappings":";;;;iBAQgB,0BAA0B,YAAY;kBACpC;EADF;;;EAAmC,IAAG,EAK9C,QAL8C,CAKrC,OALqC,CAAA,GAK1B,QAL0B,CAKjB,OALiB,CAAA,EAAA;EAAS;;;EAK/C,KAAqB,EAI5B,QAJ4B,CAInB,OAJmB,CAAA,GAIR,QAJQ,CAIC,OAJD,CAAA,EAAA;CAAO,CAAA,EAKxC,QALwB,CAKf,OALe,CAAA"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { Operation, TRPCLink } from "./types.d-sRNtuQA-.mjs";
|
||||
import { AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/splitLink.d.ts
|
||||
declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
||||
condition: (op: Operation) => boolean;
|
||||
/**
|
||||
* The link to execute next if the test function returns `true`.
|
||||
*/
|
||||
true: TRPCLink<TRouter> | TRPCLink<TRouter>[];
|
||||
/**
|
||||
* The link to execute next if the test function returns `false`.
|
||||
*/
|
||||
false: TRPCLink<TRouter> | TRPCLink<TRouter>[];
|
||||
}): TRPCLink<TRouter>;
|
||||
//# sourceMappingURL=splitLink.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { splitLink };
|
||||
//# sourceMappingURL=splitLink.d-BKr9eE0o.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"splitLink.d-BKr9eE0o.d.mts","names":[],"sources":["../src/links/splitLink.ts"],"sourcesContent":[],"mappings":";;;;iBAQgB,0BAA0B,YAAY;kBACpC;EADF;;;EAAmC,IAAG,EAK9C,QAL8C,CAKrC,OALqC,CAAA,GAK1B,QAL0B,CAKjB,OALiB,CAAA,EAAA;EAAS;;;EAK/C,KAAqB,EAI5B,QAJ4B,CAInB,OAJmB,CAAA,GAIR,QAJQ,CAIC,OAJD,CAAA,EAAA;CAAO,CAAA,EAKxC,QALwB,CAKf,OALe,CAAA"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//#region src/links/internals/subscriptions.d.ts
|
||||
interface ConnectionStateBase<TError> {
|
||||
type: 'state';
|
||||
data?: never;
|
||||
error: TError | null;
|
||||
}
|
||||
interface ConnectionIdleState extends ConnectionStateBase<null> {
|
||||
state: 'idle';
|
||||
}
|
||||
interface ConnectionConnectingState<TError> extends ConnectionStateBase<TError | null> {
|
||||
state: 'connecting';
|
||||
}
|
||||
interface ConnectionPendingState extends ConnectionStateBase<null> {
|
||||
state: 'pending';
|
||||
}
|
||||
type TRPCConnectionState<TError> = ConnectionIdleState | ConnectionConnectingState<TError> | ConnectionPendingState;
|
||||
//#endregion
|
||||
export { TRPCConnectionState };
|
||||
//# sourceMappingURL=subscriptions.d-Ciljg_dH.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscriptions.d-Ciljg_dH.d.cts","names":[],"sources":["../src/links/internals/subscriptions.ts"],"sourcesContent":[],"mappings":";UAAU;EAAA,IAAA,EAAA,OAAA;EAMA,IAAA,CAAA,EAAA,KAAA;EAIA,KAAA,EAPD,MAOC,GAAA,IAAA;;UAJA,mBAAA,SAA4B,mBAKR,CAAA,IAAA,CAAA,CAAA;EAAM,KAA1B,EAAA,MAAA;AAAmB;AAAA,UADnB,yBAKuB,CAAA,MAAQ,CAAA,SAJ/B,mBAIkD,CAJ9B,MAI8B,GAAA,IAAA,CAAA,CAAA;EAIhD,KAAA,EAAA,YAAA;;UAJF,sBAAA,SAA+B,mBAKrC,CAAA,IAAA,CAAA,CAAA;EAAmB,KACO,EAAA,SAAA;;AAC1B,KAHQ,mBAGR,CAAA,MAAA,CAAA,GAFA,mBAEA,GADA,yBACA,CAD0B,MAC1B,CAAA,GAAA,sBAAA"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//#region src/links/internals/subscriptions.d.ts
|
||||
interface ConnectionStateBase<TError> {
|
||||
type: 'state';
|
||||
data?: never;
|
||||
error: TError | null;
|
||||
}
|
||||
interface ConnectionIdleState extends ConnectionStateBase<null> {
|
||||
state: 'idle';
|
||||
}
|
||||
interface ConnectionConnectingState<TError> extends ConnectionStateBase<TError | null> {
|
||||
state: 'connecting';
|
||||
}
|
||||
interface ConnectionPendingState extends ConnectionStateBase<null> {
|
||||
state: 'pending';
|
||||
}
|
||||
type TRPCConnectionState<TError> = ConnectionIdleState | ConnectionConnectingState<TError> | ConnectionPendingState;
|
||||
//#endregion
|
||||
export { TRPCConnectionState };
|
||||
//# sourceMappingURL=subscriptions.d-Dlr1nWGD.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscriptions.d-Dlr1nWGD.d.mts","names":[],"sources":["../src/links/internals/subscriptions.ts"],"sourcesContent":[],"mappings":";UAAU;EAAA,IAAA,EAAA,OAAA;EAMA,IAAA,CAAA,EAAA,KAAA;EAIA,KAAA,EAPD,MAOC,GAAA,IAAA;;UAJA,mBAAA,SAA4B,mBAKR,CAAA,IAAA,CAAA,CAAA;EAAM,KAA1B,EAAA,MAAA;AAAmB;AAAA,UADnB,yBAKuB,CAAA,MAAQ,CAAA,SAJ/B,mBAIkD,CAJ9B,MAI8B,GAAA,IAAA,CAAA,CAAA;EAIhD,KAAA,EAAA,YAAA;;UAJF,sBAAA,SAA+B,mBAKrC,CAAA,IAAA,CAAA,CAAA;EAAmB,KACO,EAAA,SAAA;;AAC1B,KAHQ,mBAGR,CAAA,MAAA,CAAA,GAFA,mBAEA,GADA,yBACA,CAD0B,MAC1B,CAAA,GAAA,sBAAA"}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Ciljg_dH.cjs";
|
||||
import { DefaultErrorShape, InferrableClientTypes, Maybe, TRPCErrorResponse, TRPCResultMessage, TRPCSuccessResponse, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { Observable, Observer } from "@trpc/server/observable";
|
||||
|
||||
//#region src/internals/types.d.ts
|
||||
|
||||
/**
|
||||
* A subset of the standard fetch function type needed by tRPC internally.
|
||||
* @see fetch from lib.dom.d.ts
|
||||
* @remarks
|
||||
* If you need a property that you know exists but doesn't exist on this
|
||||
* interface, go ahead and add it.
|
||||
*/
|
||||
type FetchEsque = (input: RequestInfo | URL | string, init?: RequestInit | RequestInitEsque) => Promise<ResponseEsque>;
|
||||
/**
|
||||
* A simpler version of the native fetch function's type for packages with
|
||||
* their own fetch types, such as undici and node-fetch.
|
||||
*/
|
||||
type NativeFetchEsque = (url: URL | string, init?: NodeFetchRequestInitEsque) => Promise<ResponseEsque>;
|
||||
interface NodeFetchRequestInitEsque {
|
||||
body?: string;
|
||||
}
|
||||
/**
|
||||
* A subset of the standard RequestInit properties needed by tRPC internally.
|
||||
* @see RequestInit from lib.dom.d.ts
|
||||
* @remarks
|
||||
* If you need a property that you know exists but doesn't exist on this
|
||||
* interface, go ahead and add it.
|
||||
*/
|
||||
interface RequestInitEsque {
|
||||
/**
|
||||
* Sets the request's body.
|
||||
*/
|
||||
body?: FormData | string | null | Uint8Array<ArrayBuffer> | Blob | File;
|
||||
/**
|
||||
* Sets the request's associated headers.
|
||||
*/
|
||||
headers?: [string, string][] | Record<string, string>;
|
||||
/**
|
||||
* The request's HTTP-style method.
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* Sets the request's signal.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
/**
|
||||
* A subset of the standard ReadableStream properties needed by tRPC internally.
|
||||
* @see ReadableStream from lib.dom.d.ts
|
||||
*/
|
||||
type WebReadableStreamEsque = {
|
||||
getReader: () => ReadableStreamDefaultReader<Uint8Array>;
|
||||
};
|
||||
type NodeJSReadableStreamEsque = {
|
||||
on(eventName: string | symbol, listener: (...args: any[]) => void): NodeJSReadableStreamEsque;
|
||||
};
|
||||
/**
|
||||
* A subset of the standard Response properties needed by tRPC internally.
|
||||
* @see Response from lib.dom.d.ts
|
||||
*/
|
||||
interface ResponseEsque {
|
||||
readonly ok: boolean;
|
||||
readonly body?: NodeJSReadableStreamEsque | WebReadableStreamEsque | null;
|
||||
/**
|
||||
* @remarks
|
||||
* The built-in Response::json() method returns Promise<any>, but
|
||||
* that's not as type-safe as unknown. We use unknown because we're
|
||||
* more type-safe. You do want more type safety, right? 😉
|
||||
*/
|
||||
json(): Promise<unknown>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type NonEmptyArray<TItem> = [TItem, ...TItem[]];
|
||||
type ClientContext = Record<string, unknown>;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
interface TRPCProcedureOptions {
|
||||
/**
|
||||
* Client-side context
|
||||
*/
|
||||
context?: ClientContext;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/TRPCClientError.d.ts
|
||||
type inferErrorShape<TInferrable extends InferrableClientTypes> = inferClientTypes<TInferrable>['errorShape'];
|
||||
interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
||||
readonly message: string;
|
||||
readonly shape: Maybe<TShape>;
|
||||
readonly data: Maybe<TShape['data']>;
|
||||
}
|
||||
type TRPCClientErrorLike<TInferrable extends InferrableClientTypes> = TRPCClientErrorBase<inferErrorShape<TInferrable>>;
|
||||
declare function isTRPCClientError<TInferrable extends InferrableClientTypes>(cause: unknown): cause is TRPCClientError<TInferrable>;
|
||||
declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
||||
readonly cause: Error | undefined;
|
||||
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
||||
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
||||
/**
|
||||
* Additional meta data about the error
|
||||
* In the case of HTTP-errors, we'll have `response` and potentially `responseJSON` here
|
||||
*/
|
||||
meta: Record<string, unknown> | undefined;
|
||||
constructor(message: string, opts?: {
|
||||
result?: Maybe<TRPCErrorResponse<inferErrorShape<TRouterOrProcedure>>>;
|
||||
cause?: Error;
|
||||
meta?: Record<string, unknown>;
|
||||
});
|
||||
static from<TRouterOrProcedure extends InferrableClientTypes>(_cause: Error | TRPCErrorResponse<any> | object, opts?: {
|
||||
meta?: Record<string, unknown>;
|
||||
cause?: Error;
|
||||
}): TRPCClientError<TRouterOrProcedure>;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/links/internals/contentTypes.d.ts
|
||||
declare function isOctetType(input: unknown): input is Uint8Array<ArrayBuffer> | Blob;
|
||||
declare function isFormData(input: unknown): input is FormData;
|
||||
declare function isNonJsonSerializable(input: unknown): input is Blob | FormData | Uint8Array<ArrayBuffer>;
|
||||
//# sourceMappingURL=contentTypes.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/types.d.ts
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface OperationContext extends Record<string, unknown> {}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Operation<TInput = unknown> = {
|
||||
id: number;
|
||||
type: 'mutation' | 'query' | 'subscription';
|
||||
input: TInput;
|
||||
path: string;
|
||||
context: OperationContext;
|
||||
signal: Maybe<AbortSignal>;
|
||||
};
|
||||
interface HeadersInitEsque {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>;
|
||||
/**
|
||||
* The default `fetch` implementation has an overloaded signature. By convention this library
|
||||
* only uses the overload taking a string and options object.
|
||||
*/
|
||||
type TRPCFetch = (url: string, options?: RequestInit) => Promise<ResponseEsque>;
|
||||
interface TRPCClientRuntime {}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface OperationResultEnvelope<TOutput, TError> {
|
||||
result: TRPCResultMessage<TOutput>['result'] | TRPCSuccessResponse<TOutput>['result'] | TRPCConnectionState<TError>;
|
||||
context?: OperationContext;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationResultObservable<TInferrable extends InferrableClientTypes, TOutput> = Observable<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationResultObserver<TInferrable extends InferrableClientTypes, TOutput> = Observer<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown> = (opts: {
|
||||
op: Operation<TInput>;
|
||||
next: (op: Operation<TInput>) => OperationResultObservable<TInferrable, TOutput>;
|
||||
}) => OperationResultObservable<TInferrable, TOutput>;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { FetchEsque, HTTPHeaders, NativeFetchEsque, NonEmptyArray, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError };
|
||||
//# sourceMappingURL=types.d-Dmmedc5G.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d-Dmmedc5G.d.cts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/internals/contentTypes.ts","../src/links/types.ts"],"sourcesContent":[],"mappings":"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"}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Dlr1nWGD.mjs";
|
||||
import { Observable, Observer } from "@trpc/server/observable";
|
||||
import { DefaultErrorShape, InferrableClientTypes, Maybe, TRPCErrorResponse, TRPCResultMessage, TRPCSuccessResponse, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/internals/types.d.ts
|
||||
|
||||
/**
|
||||
* A subset of the standard fetch function type needed by tRPC internally.
|
||||
* @see fetch from lib.dom.d.ts
|
||||
* @remarks
|
||||
* If you need a property that you know exists but doesn't exist on this
|
||||
* interface, go ahead and add it.
|
||||
*/
|
||||
type FetchEsque = (input: RequestInfo | URL | string, init?: RequestInit | RequestInitEsque) => Promise<ResponseEsque>;
|
||||
/**
|
||||
* A simpler version of the native fetch function's type for packages with
|
||||
* their own fetch types, such as undici and node-fetch.
|
||||
*/
|
||||
type NativeFetchEsque = (url: URL | string, init?: NodeFetchRequestInitEsque) => Promise<ResponseEsque>;
|
||||
interface NodeFetchRequestInitEsque {
|
||||
body?: string;
|
||||
}
|
||||
/**
|
||||
* A subset of the standard RequestInit properties needed by tRPC internally.
|
||||
* @see RequestInit from lib.dom.d.ts
|
||||
* @remarks
|
||||
* If you need a property that you know exists but doesn't exist on this
|
||||
* interface, go ahead and add it.
|
||||
*/
|
||||
interface RequestInitEsque {
|
||||
/**
|
||||
* Sets the request's body.
|
||||
*/
|
||||
body?: FormData | string | null | Uint8Array<ArrayBuffer> | Blob | File;
|
||||
/**
|
||||
* Sets the request's associated headers.
|
||||
*/
|
||||
headers?: [string, string][] | Record<string, string>;
|
||||
/**
|
||||
* The request's HTTP-style method.
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* Sets the request's signal.
|
||||
*/
|
||||
signal?: AbortSignal | undefined;
|
||||
}
|
||||
/**
|
||||
* A subset of the standard ReadableStream properties needed by tRPC internally.
|
||||
* @see ReadableStream from lib.dom.d.ts
|
||||
*/
|
||||
type WebReadableStreamEsque = {
|
||||
getReader: () => ReadableStreamDefaultReader<Uint8Array>;
|
||||
};
|
||||
type NodeJSReadableStreamEsque = {
|
||||
on(eventName: string | symbol, listener: (...args: any[]) => void): NodeJSReadableStreamEsque;
|
||||
};
|
||||
/**
|
||||
* A subset of the standard Response properties needed by tRPC internally.
|
||||
* @see Response from lib.dom.d.ts
|
||||
*/
|
||||
interface ResponseEsque {
|
||||
readonly ok: boolean;
|
||||
readonly body?: NodeJSReadableStreamEsque | WebReadableStreamEsque | null;
|
||||
/**
|
||||
* @remarks
|
||||
* The built-in Response::json() method returns Promise<any>, but
|
||||
* that's not as type-safe as unknown. We use unknown because we're
|
||||
* more type-safe. You do want more type safety, right? 😉
|
||||
*/
|
||||
json(): Promise<unknown>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type NonEmptyArray<TItem> = [TItem, ...TItem[]];
|
||||
type ClientContext = Record<string, unknown>;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
interface TRPCProcedureOptions {
|
||||
/**
|
||||
* Client-side context
|
||||
*/
|
||||
context?: ClientContext;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/TRPCClientError.d.ts
|
||||
type inferErrorShape<TInferrable extends InferrableClientTypes> = inferClientTypes<TInferrable>['errorShape'];
|
||||
interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
||||
readonly message: string;
|
||||
readonly shape: Maybe<TShape>;
|
||||
readonly data: Maybe<TShape['data']>;
|
||||
}
|
||||
type TRPCClientErrorLike<TInferrable extends InferrableClientTypes> = TRPCClientErrorBase<inferErrorShape<TInferrable>>;
|
||||
declare function isTRPCClientError<TInferrable extends InferrableClientTypes>(cause: unknown): cause is TRPCClientError<TInferrable>;
|
||||
declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
||||
readonly cause: Error | undefined;
|
||||
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
||||
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
||||
/**
|
||||
* Additional meta data about the error
|
||||
* In the case of HTTP-errors, we'll have `response` and potentially `responseJSON` here
|
||||
*/
|
||||
meta: Record<string, unknown> | undefined;
|
||||
constructor(message: string, opts?: {
|
||||
result?: Maybe<TRPCErrorResponse<inferErrorShape<TRouterOrProcedure>>>;
|
||||
cause?: Error;
|
||||
meta?: Record<string, unknown>;
|
||||
});
|
||||
static from<TRouterOrProcedure extends InferrableClientTypes>(_cause: Error | TRPCErrorResponse<any> | object, opts?: {
|
||||
meta?: Record<string, unknown>;
|
||||
cause?: Error;
|
||||
}): TRPCClientError<TRouterOrProcedure>;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/links/internals/contentTypes.d.ts
|
||||
declare function isOctetType(input: unknown): input is Uint8Array<ArrayBuffer> | Blob;
|
||||
declare function isFormData(input: unknown): input is FormData;
|
||||
declare function isNonJsonSerializable(input: unknown): input is Blob | FormData | Uint8Array<ArrayBuffer>;
|
||||
//# sourceMappingURL=contentTypes.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/types.d.ts
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface OperationContext extends Record<string, unknown> {}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type Operation<TInput = unknown> = {
|
||||
id: number;
|
||||
type: 'mutation' | 'query' | 'subscription';
|
||||
input: TInput;
|
||||
path: string;
|
||||
context: OperationContext;
|
||||
signal: Maybe<AbortSignal>;
|
||||
};
|
||||
interface HeadersInitEsque {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>;
|
||||
/**
|
||||
* The default `fetch` implementation has an overloaded signature. By convention this library
|
||||
* only uses the overload taking a string and options object.
|
||||
*/
|
||||
type TRPCFetch = (url: string, options?: RequestInit) => Promise<ResponseEsque>;
|
||||
interface TRPCClientRuntime {}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface OperationResultEnvelope<TOutput, TError> {
|
||||
result: TRPCResultMessage<TOutput>['result'] | TRPCSuccessResponse<TOutput>['result'] | TRPCConnectionState<TError>;
|
||||
context?: OperationContext;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationResultObservable<TInferrable extends InferrableClientTypes, TOutput> = Observable<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationResultObserver<TInferrable extends InferrableClientTypes, TOutput> = Observer<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown> = (opts: {
|
||||
op: Operation<TInput>;
|
||||
next: (op: Operation<TInput>) => OperationResultObservable<TInferrable, TOutput>;
|
||||
}) => OperationResultObservable<TInferrable, TOutput>;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
|
||||
//#endregion
|
||||
export { FetchEsque, HTTPHeaders, NativeFetchEsque, NonEmptyArray, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError };
|
||||
//# sourceMappingURL=types.d-sRNtuQA-.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d-sRNtuQA-.d.mts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/internals/contentTypes.ts","../src/links/types.ts"],"sourcesContent":[],"mappings":"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"}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
//#region src/internals/transformer.ts
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getTransformer(transformer) {
|
||||
const _transformer = transformer;
|
||||
if (!_transformer) return {
|
||||
input: {
|
||||
serialize: (data) => data,
|
||||
deserialize: (data) => data
|
||||
},
|
||||
output: {
|
||||
serialize: (data) => data,
|
||||
deserialize: (data) => data
|
||||
}
|
||||
};
|
||||
if ("input" in _transformer) return _transformer;
|
||||
return {
|
||||
input: _transformer,
|
||||
output: _transformer
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { getTransformer };
|
||||
//# sourceMappingURL=unstable-internals-Bg7n9BBj.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unstable-internals-Bg7n9BBj.mjs","names":["transformer:\n | TransformerOptions<{ transformer: false }>['transformer']\n | TransformerOptions<{ transformer: true }>['transformer']\n | undefined"],"sources":["../src/internals/transformer.ts"],"sourcesContent":["import type {\n AnyClientTypes,\n CombinedDataTransformer,\n DataTransformerOptions,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type CoercedTransformerParameters = {\n transformer?: DataTransformerOptions;\n};\n\ntype TransformerOptionYes = {\n /**\n * Data transformer\n *\n * You must use the same transformer on the backend and frontend\n * @see https://trpc.io/docs/v11/data-transformers\n **/\n transformer: DataTransformerOptions;\n};\ntype TransformerOptionNo = {\n /**\n * Data transformer\n *\n * You must use the same transformer on the backend and frontend\n * @see https://trpc.io/docs/v11/data-transformers\n **/\n transformer?: TypeError<'You must define a transformer on your your `initTRPC`-object first'>;\n};\n\n/**\n * @internal\n */\nexport type TransformerOptions<\n TRoot extends Pick<AnyClientTypes, 'transformer'>,\n> = TRoot['transformer'] extends true\n ? TransformerOptionYes\n : TransformerOptionNo;\n/**\n * @internal\n */\n\n/**\n * @internal\n */\nexport function getTransformer(\n transformer:\n | TransformerOptions<{ transformer: false }>['transformer']\n | TransformerOptions<{ transformer: true }>['transformer']\n | undefined,\n): CombinedDataTransformer {\n const _transformer =\n transformer as CoercedTransformerParameters['transformer'];\n if (!_transformer) {\n return {\n input: {\n serialize: (data) => data,\n deserialize: (data) => data,\n },\n output: {\n serialize: (data) => data,\n deserialize: (data) => data,\n },\n };\n }\n if ('input' in _transformer) {\n return _transformer;\n }\n return {\n input: _transformer,\n output: _transformer,\n };\n}\n"],"mappings":";;;;;;;AAgDA,SAAgB,eACdA,aAIyB;CACzB,MAAM,eACJ;AACF,MAAK,aACH,QAAO;EACL,OAAO;GACL,WAAW,CAAC,SAAS;GACrB,aAAa,CAAC,SAAS;EACxB;EACD,QAAQ;GACN,WAAW,CAAC,SAAS;GACrB,aAAa,CAAC,SAAS;EACxB;CACF;AAEH,KAAI,WAAW,aACb,QAAO;AAET,QAAO;EACL,OAAO;EACP,QAAQ;CACT;AACF"}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
|
||||
//#region src/internals/transformer.ts
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getTransformer(transformer) {
|
||||
const _transformer = transformer;
|
||||
if (!_transformer) return {
|
||||
input: {
|
||||
serialize: (data) => data,
|
||||
deserialize: (data) => data
|
||||
},
|
||||
output: {
|
||||
serialize: (data) => data,
|
||||
deserialize: (data) => data
|
||||
}
|
||||
};
|
||||
if ("input" in _transformer) return _transformer;
|
||||
return {
|
||||
input: _transformer,
|
||||
output: _transformer
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'getTransformer', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return getTransformer;
|
||||
}
|
||||
});
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
|
||||
|
||||
exports.getTransformer = require_unstable_internals.getTransformer;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import { AnyClientTypes, CombinedDataTransformer, DataTransformerOptions, TypeError } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/internals/transformer.d.ts
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type CoercedTransformerParameters = {
|
||||
transformer?: DataTransformerOptions;
|
||||
};
|
||||
type TransformerOptionYes = {
|
||||
/**
|
||||
* Data transformer
|
||||
*
|
||||
* You must use the same transformer on the backend and frontend
|
||||
* @see https://trpc.io/docs/v11/data-transformers
|
||||
**/
|
||||
transformer: DataTransformerOptions;
|
||||
};
|
||||
type TransformerOptionNo = {
|
||||
/**
|
||||
* Data transformer
|
||||
*
|
||||
* You must use the same transformer on the backend and frontend
|
||||
* @see https://trpc.io/docs/v11/data-transformers
|
||||
**/
|
||||
transformer?: TypeError<'You must define a transformer on your your `initTRPC`-object first'>;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type TransformerOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = TRoot['transformer'] extends true ? TransformerOptionYes : TransformerOptionNo;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare function getTransformer(transformer: TransformerOptions<{
|
||||
transformer: false;
|
||||
}>['transformer'] | TransformerOptions<{
|
||||
transformer: true;
|
||||
}>['transformer'] | undefined): CombinedDataTransformer;
|
||||
//#endregion
|
||||
export { CoercedTransformerParameters, TransformerOptions, getTransformer };
|
||||
//# sourceMappingURL=unstable-internals.d-BOmV7EK1.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unstable-internals.d-BOmV7EK1.d.mts","names":[],"sources":["../src/internals/transformer.ts"],"sourcesContent":[],"mappings":";;;;;;AAUA;AAIK,KAJO,4BAAA,GAWG;EAEV,WAAA,CAAA,EAZW,sBAmBA;AAMhB,CAAA;KAtBK,oBAAA,GAsByB;EAAA;;;;;AAIP;EAQP,WAAA,EA3BD,sBA2Be;CAAA;KAzBzB,mBAAA,GA2BC;EAAkB;;AAGE;;;;gBAvBV;;;;;KAMJ,iCACI,KAAK,kCACjB,oCACA,uBACA;;;;;;;iBAQY,cAAA,cAEV;;oBACA;;gCAEH"}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import { AnyClientTypes, CombinedDataTransformer, DataTransformerOptions, TypeError } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/internals/transformer.d.ts
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type CoercedTransformerParameters = {
|
||||
transformer?: DataTransformerOptions;
|
||||
};
|
||||
type TransformerOptionYes = {
|
||||
/**
|
||||
* Data transformer
|
||||
*
|
||||
* You must use the same transformer on the backend and frontend
|
||||
* @see https://trpc.io/docs/v11/data-transformers
|
||||
**/
|
||||
transformer: DataTransformerOptions;
|
||||
};
|
||||
type TransformerOptionNo = {
|
||||
/**
|
||||
* Data transformer
|
||||
*
|
||||
* You must use the same transformer on the backend and frontend
|
||||
* @see https://trpc.io/docs/v11/data-transformers
|
||||
**/
|
||||
transformer?: TypeError<'You must define a transformer on your your `initTRPC`-object first'>;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type TransformerOptions<TRoot extends Pick<AnyClientTypes, 'transformer'>> = TRoot['transformer'] extends true ? TransformerOptionYes : TransformerOptionNo;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare function getTransformer(transformer: TransformerOptions<{
|
||||
transformer: false;
|
||||
}>['transformer'] | TransformerOptions<{
|
||||
transformer: true;
|
||||
}>['transformer'] | undefined): CombinedDataTransformer;
|
||||
//#endregion
|
||||
export { CoercedTransformerParameters, TransformerOptions, getTransformer };
|
||||
//# sourceMappingURL=unstable-internals.d-kWsZTlQq.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unstable-internals.d-kWsZTlQq.d.cts","names":[],"sources":["../src/internals/transformer.ts"],"sourcesContent":[],"mappings":";;;;;;AAUA;AAIK,KAJO,4BAAA,GAWG;EAEV,WAAA,CAAA,EAZW,sBAmBA;AAMhB,CAAA;KAtBK,oBAAA,GAsByB;EAAA;;;;;AAIP;EAQP,WAAA,EA3BD,sBA2Be;CAAA;KAzBzB,mBAAA,GA2BC;EAAkB;;AAGE;;;;gBAvBV;;;;;KAMJ,iCACI,KAAK,kCACjB,oCACA,uBACA;;;;;;;iBAQY,cAAA,cAEV;;oBACA;;gCAEH"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Ciljg_dH.cjs";
|
||||
import { CoercedTransformerParameters, TransformerOptions, getTransformer } from "./unstable-internals.d-kWsZTlQq.cjs";
|
||||
export { CoercedTransformerParameters, TRPCConnectionState, TransformerOptions, getTransformer };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Dlr1nWGD.mjs";
|
||||
import { CoercedTransformerParameters, TransformerOptions, getTransformer } from "./unstable-internals.d-BOmV7EK1.mjs";
|
||||
export { CoercedTransformerParameters, TRPCConnectionState, TransformerOptions, getTransformer };
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { getTransformer } from "./unstable-internals-Bg7n9BBj.mjs";
|
||||
|
||||
export { getTransformer };
|
||||
+724
@@ -0,0 +1,724 @@
|
||||
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
||||
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
||||
const require_TRPCClientError = require('./TRPCClientError-CQrTQLrk.cjs');
|
||||
const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
|
||||
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
||||
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
||||
|
||||
//#region src/links/wsLink/wsClient/encoder.ts
|
||||
const jsonEncoder = {
|
||||
encode: (data) => JSON.stringify(data),
|
||||
decode: (data) => {
|
||||
if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
|
||||
return JSON.parse(data);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/options.ts
|
||||
const lazyDefaults = {
|
||||
enabled: false,
|
||||
closeMs: 0
|
||||
};
|
||||
const keepAliveDefaults = {
|
||||
enabled: false,
|
||||
pongTimeoutMs: 1e3,
|
||||
intervalMs: 5e3
|
||||
};
|
||||
/**
|
||||
* Calculates a delay for exponential backoff based on the retry attempt index.
|
||||
* The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
|
||||
* capped at 30 seconds.
|
||||
*/
|
||||
const exponentialBackoff = (attemptIndex) => {
|
||||
return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/urlWithConnectionParams.ts
|
||||
/**
|
||||
* Get the result of a value or function that returns a value
|
||||
* It also optionally accepts typesafe arguments for the function
|
||||
*/
|
||||
const resultOf = (value, ...args) => {
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/utils.ts
|
||||
var import_defineProperty$3 = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
var TRPCWebSocketClosedError = class TRPCWebSocketClosedError extends Error {
|
||||
constructor(opts) {
|
||||
super(opts.message, { cause: opts.cause });
|
||||
this.name = "TRPCWebSocketClosedError";
|
||||
Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Utility class for managing a timeout that can be started, stopped, and reset.
|
||||
* Useful for scenarios where the timeout duration is reset dynamically based on events.
|
||||
*/
|
||||
var ResettableTimeout = class {
|
||||
constructor(onTimeout, timeoutMs) {
|
||||
this.onTimeout = onTimeout;
|
||||
this.timeoutMs = timeoutMs;
|
||||
(0, import_defineProperty$3.default)(this, "timeout", void 0);
|
||||
}
|
||||
/**
|
||||
* Resets the current timeout, restarting it with the same duration.
|
||||
* Does nothing if no timeout is active.
|
||||
*/
|
||||
reset() {
|
||||
if (!this.timeout) return;
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
||||
}
|
||||
start() {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
||||
}
|
||||
stop() {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = void 0;
|
||||
}
|
||||
};
|
||||
function withResolvers() {
|
||||
let resolve;
|
||||
let reject;
|
||||
const promise = new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
return {
|
||||
promise,
|
||||
resolve,
|
||||
reject
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resolves a WebSocket URL and optionally appends connection parameters.
|
||||
*
|
||||
* If connectionParams are provided, appends 'connectionParams=1' query parameter.
|
||||
*/
|
||||
async function prepareUrl(urlOptions) {
|
||||
const url = await resultOf(urlOptions.url);
|
||||
if (!urlOptions.connectionParams) return url;
|
||||
const prefix = url.includes("?") ? "&" : "?";
|
||||
const connectionParams = `${prefix}connectionParams=1`;
|
||||
return url + connectionParams;
|
||||
}
|
||||
async function buildConnectionMessage(connectionParams, encoder) {
|
||||
const message = {
|
||||
method: "connectionParams",
|
||||
data: await resultOf(connectionParams)
|
||||
};
|
||||
return encoder.encode(message);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/requestManager.ts
|
||||
var import_defineProperty$2 = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
/**
|
||||
* Manages WebSocket requests, tracking their lifecycle and providing utility methods
|
||||
* for handling outgoing and pending requests.
|
||||
*
|
||||
* - **Outgoing requests**: Requests that are queued and waiting to be sent.
|
||||
* - **Pending requests**: Requests that have been sent and are in flight awaiting a response.
|
||||
* For subscriptions, multiple responses may be received until the subscription is closed.
|
||||
*/
|
||||
var RequestManager = class {
|
||||
constructor() {
|
||||
(0, import_defineProperty$2.default)(this, "outgoingRequests", new Array());
|
||||
(0, import_defineProperty$2.default)(this, "pendingRequests", {});
|
||||
}
|
||||
/**
|
||||
* Registers a new request by adding it to the outgoing queue and setting up
|
||||
* callbacks for lifecycle events such as completion or error.
|
||||
*
|
||||
* @param message - The outgoing message to be sent.
|
||||
* @param callbacks - Callback functions to observe the request's state.
|
||||
* @returns A cleanup function to manually remove the request.
|
||||
*/
|
||||
register(message, callbacks) {
|
||||
const { promise: end, resolve } = withResolvers();
|
||||
this.outgoingRequests.push({
|
||||
id: String(message.id),
|
||||
message,
|
||||
end,
|
||||
callbacks: {
|
||||
next: callbacks.next,
|
||||
complete: () => {
|
||||
callbacks.complete();
|
||||
resolve();
|
||||
},
|
||||
error: (e) => {
|
||||
callbacks.error(e);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
this.delete(message.id);
|
||||
callbacks.complete();
|
||||
resolve();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Deletes a request from both the outgoing and pending collections, if it exists.
|
||||
*/
|
||||
delete(messageId) {
|
||||
if (messageId === null) return;
|
||||
this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
|
||||
delete this.pendingRequests[String(messageId)];
|
||||
}
|
||||
/**
|
||||
* Moves all outgoing requests to the pending state and clears the outgoing queue.
|
||||
*
|
||||
* The caller is expected to handle the actual sending of the requests
|
||||
* (e.g., sending them over the network) after this method is called.
|
||||
*
|
||||
* @returns The list of requests that were transitioned to the pending state.
|
||||
*/
|
||||
flush() {
|
||||
const requests = this.outgoingRequests;
|
||||
this.outgoingRequests = [];
|
||||
for (const request of requests) this.pendingRequests[request.id] = request;
|
||||
return requests;
|
||||
}
|
||||
/**
|
||||
* Retrieves all currently pending requests, which are in flight awaiting responses
|
||||
* or handling ongoing subscriptions.
|
||||
*/
|
||||
getPendingRequests() {
|
||||
return Object.values(this.pendingRequests);
|
||||
}
|
||||
/**
|
||||
* Retrieves a specific pending request by its message ID.
|
||||
*/
|
||||
getPendingRequest(messageId) {
|
||||
if (messageId === null) return null;
|
||||
return this.pendingRequests[String(messageId)];
|
||||
}
|
||||
/**
|
||||
* Retrieves all outgoing requests, which are waiting to be sent.
|
||||
*/
|
||||
getOutgoingRequests() {
|
||||
return this.outgoingRequests;
|
||||
}
|
||||
/**
|
||||
* Retrieves all requests, both outgoing and pending, with their respective states.
|
||||
*
|
||||
* @returns An array of all requests with their state ("outgoing" or "pending").
|
||||
*/
|
||||
getRequests() {
|
||||
return [...this.getOutgoingRequests().map((request) => ({
|
||||
state: "outgoing",
|
||||
message: request.message,
|
||||
end: request.end,
|
||||
callbacks: request.callbacks
|
||||
})), ...this.getPendingRequests().map((request) => ({
|
||||
state: "pending",
|
||||
message: request.message,
|
||||
end: request.end,
|
||||
callbacks: request.callbacks
|
||||
}))];
|
||||
}
|
||||
/**
|
||||
* Checks if there are any pending requests, including ongoing subscriptions.
|
||||
*/
|
||||
hasPendingRequests() {
|
||||
return this.getPendingRequests().length > 0;
|
||||
}
|
||||
/**
|
||||
* Checks if there are any pending subscriptions
|
||||
*/
|
||||
hasPendingSubscriptions() {
|
||||
return this.getPendingRequests().some((request) => request.message.method === "subscription");
|
||||
}
|
||||
/**
|
||||
* Checks if there are any outgoing requests waiting to be sent.
|
||||
*/
|
||||
hasOutgoingRequests() {
|
||||
return this.outgoingRequests.length > 0;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsConnection.ts
|
||||
var import_defineProperty$1 = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
/**
|
||||
* Opens a WebSocket connection asynchronously and returns a promise
|
||||
* that resolves when the connection is successfully established.
|
||||
* The promise rejects if an error occurs during the connection attempt.
|
||||
*/
|
||||
function asyncWsOpen(ws) {
|
||||
const { promise, resolve, reject } = withResolvers();
|
||||
ws.addEventListener("open", () => {
|
||||
ws.removeEventListener("error", reject);
|
||||
resolve();
|
||||
});
|
||||
ws.addEventListener("error", reject);
|
||||
return promise;
|
||||
}
|
||||
/**
|
||||
* Sets up a periodic ping-pong mechanism to keep the WebSocket connection alive.
|
||||
*
|
||||
* - Sends "PING" messages at regular intervals defined by `intervalMs`.
|
||||
* - If a "PONG" response is not received within the `pongTimeoutMs`, the WebSocket is closed.
|
||||
* - The ping timer resets upon receiving any message to maintain activity.
|
||||
* - Automatically starts the ping process when the WebSocket connection is opened.
|
||||
* - Cleans up timers when the WebSocket is closed.
|
||||
*
|
||||
* @param ws - The WebSocket instance to manage.
|
||||
* @param options - Configuration options for ping-pong intervals and timeouts.
|
||||
*/
|
||||
function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
|
||||
let pingTimeout;
|
||||
let pongTimeout;
|
||||
function start() {
|
||||
pingTimeout = setTimeout(() => {
|
||||
ws.send("PING");
|
||||
pongTimeout = setTimeout(() => {
|
||||
ws.close();
|
||||
}, pongTimeoutMs);
|
||||
}, intervalMs);
|
||||
}
|
||||
function reset() {
|
||||
clearTimeout(pingTimeout);
|
||||
start();
|
||||
}
|
||||
function pong() {
|
||||
clearTimeout(pongTimeout);
|
||||
reset();
|
||||
}
|
||||
ws.addEventListener("open", start);
|
||||
ws.addEventListener("message", ({ data }) => {
|
||||
clearTimeout(pingTimeout);
|
||||
start();
|
||||
if (data === "PONG") pong();
|
||||
});
|
||||
ws.addEventListener("close", () => {
|
||||
clearTimeout(pingTimeout);
|
||||
clearTimeout(pongTimeout);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Manages a WebSocket connection with support for reconnection, keep-alive mechanisms,
|
||||
* and observable state tracking.
|
||||
*/
|
||||
var WsConnection = class WsConnection {
|
||||
constructor(opts) {
|
||||
var _opts$WebSocketPonyfi;
|
||||
(0, import_defineProperty$1.default)(this, "id", ++WsConnection.connectCount);
|
||||
(0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "urlOptions", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "encoder", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "wsObservable", (0, __trpc_server_observable.behaviorSubject)(null));
|
||||
(0, import_defineProperty$1.default)(this, "openPromise", null);
|
||||
this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
|
||||
if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
||||
this.urlOptions = opts.urlOptions;
|
||||
this.keepAliveOpts = opts.keepAlive;
|
||||
this.encoder = opts.encoder;
|
||||
}
|
||||
get ws() {
|
||||
return this.wsObservable.get();
|
||||
}
|
||||
set ws(ws) {
|
||||
this.wsObservable.next(ws);
|
||||
}
|
||||
/**
|
||||
* Checks if the WebSocket connection is open and ready to communicate.
|
||||
*/
|
||||
isOpen() {
|
||||
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
||||
}
|
||||
/**
|
||||
* Checks if the WebSocket connection is closed or in the process of closing.
|
||||
*/
|
||||
isClosed() {
|
||||
return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
|
||||
}
|
||||
async open() {
|
||||
var _this = this;
|
||||
if (_this.openPromise) return _this.openPromise;
|
||||
_this.id = ++WsConnection.connectCount;
|
||||
const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
|
||||
_this.openPromise = wsPromise.then(async (ws) => {
|
||||
_this.ws = ws;
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.addEventListener("message", function({ data }) {
|
||||
if (data === "PING") this.send("PONG");
|
||||
});
|
||||
if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
|
||||
ws.addEventListener("close", () => {
|
||||
if (_this.ws === ws) _this.ws = null;
|
||||
});
|
||||
await asyncWsOpen(ws);
|
||||
if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
|
||||
});
|
||||
try {
|
||||
await _this.openPromise;
|
||||
} finally {
|
||||
_this.openPromise = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Closes the WebSocket connection gracefully.
|
||||
* Waits for any ongoing open operation to complete before closing.
|
||||
*/
|
||||
async close() {
|
||||
var _this2 = this;
|
||||
try {
|
||||
await _this2.openPromise;
|
||||
} finally {
|
||||
var _this$ws;
|
||||
(_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
(0, import_defineProperty$1.default)(WsConnection, "connectCount", 0);
|
||||
/**
|
||||
* Provides a backward-compatible representation of the connection state.
|
||||
*/
|
||||
function backwardCompatibility(connection) {
|
||||
if (connection.isOpen()) return {
|
||||
id: connection.id,
|
||||
state: "open",
|
||||
ws: connection.ws
|
||||
};
|
||||
if (connection.isClosed()) return {
|
||||
id: connection.id,
|
||||
state: "closed",
|
||||
ws: connection.ws
|
||||
};
|
||||
if (!connection.ws) return null;
|
||||
return {
|
||||
id: connection.id,
|
||||
state: "connecting",
|
||||
ws: connection.ws
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsClient.ts
|
||||
var import_defineProperty = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
||||
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
||||
/**
|
||||
* A WebSocket client for managing TRPC operations, supporting lazy initialization,
|
||||
* reconnection, keep-alive, and request management.
|
||||
*/
|
||||
var WsClient = class {
|
||||
constructor(opts) {
|
||||
var _opts$experimental_en, _opts$retryDelayMs;
|
||||
(0, import_defineProperty.default)(this, "connectionState", void 0);
|
||||
(0, import_defineProperty.default)(this, "allowReconnect", false);
|
||||
(0, import_defineProperty.default)(this, "requestManager", new RequestManager());
|
||||
(0, import_defineProperty.default)(this, "activeConnection", void 0);
|
||||
(0, import_defineProperty.default)(this, "reconnectRetryDelay", void 0);
|
||||
(0, import_defineProperty.default)(this, "inactivityTimeout", void 0);
|
||||
(0, import_defineProperty.default)(this, "callbacks", void 0);
|
||||
(0, import_defineProperty.default)(this, "lazyMode", void 0);
|
||||
(0, import_defineProperty.default)(this, "encoder", void 0);
|
||||
(0, import_defineProperty.default)(this, "reconnecting", null);
|
||||
this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder;
|
||||
this.callbacks = {
|
||||
onOpen: opts.onOpen,
|
||||
onClose: opts.onClose,
|
||||
onError: opts.onError
|
||||
};
|
||||
const lazyOptions = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, lazyDefaults), opts.lazy);
|
||||
this.inactivityTimeout = new ResettableTimeout(() => {
|
||||
if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
|
||||
this.inactivityTimeout.reset();
|
||||
return;
|
||||
}
|
||||
this.close().catch(() => null);
|
||||
}, lazyOptions.closeMs);
|
||||
this.activeConnection = new WsConnection({
|
||||
WebSocketPonyfill: opts.WebSocket,
|
||||
urlOptions: opts,
|
||||
keepAlive: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, keepAliveDefaults), opts.keepAlive),
|
||||
encoder: this.encoder
|
||||
});
|
||||
this.activeConnection.wsObservable.subscribe({ next: (ws) => {
|
||||
if (!ws) return;
|
||||
this.setupWebSocketListeners(ws);
|
||||
} });
|
||||
this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff;
|
||||
this.lazyMode = lazyOptions.enabled;
|
||||
this.connectionState = (0, __trpc_server_observable.behaviorSubject)({
|
||||
type: "state",
|
||||
state: lazyOptions.enabled ? "idle" : "connecting",
|
||||
error: null
|
||||
});
|
||||
if (!this.lazyMode) this.open().catch(() => null);
|
||||
}
|
||||
/**
|
||||
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
||||
* the connection state accordingly.
|
||||
*/
|
||||
async open() {
|
||||
var _this = this;
|
||||
_this.allowReconnect = true;
|
||||
if (_this.connectionState.get().state === "idle") _this.connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
try {
|
||||
await _this.activeConnection.open();
|
||||
} catch (error) {
|
||||
_this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "Initialization error",
|
||||
cause: error
|
||||
}));
|
||||
return _this.reconnecting;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Closes the WebSocket connection and stops managing requests.
|
||||
* Ensures all outgoing and pending requests are properly finalized.
|
||||
*/
|
||||
async close() {
|
||||
var _this2 = this;
|
||||
_this2.allowReconnect = false;
|
||||
_this2.inactivityTimeout.stop();
|
||||
const requestsToAwait = [];
|
||||
for (const request of _this2.requestManager.getRequests()) if (request.message.method === "subscription") request.callbacks.complete();
|
||||
else if (request.state === "outgoing") request.callbacks.error(require_TRPCClientError.TRPCClientError.from(new TRPCWebSocketClosedError({ message: "Closed before connection was established" })));
|
||||
else requestsToAwait.push(request.end);
|
||||
await Promise.all(requestsToAwait).catch(() => null);
|
||||
await _this2.activeConnection.close().catch(() => null);
|
||||
_this2.connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Method to request the server.
|
||||
* Handles data transformation, batching of requests, and subscription lifecycle.
|
||||
*
|
||||
* @param op - The operation details including id, type, path, input and signal
|
||||
* @param transformer - Data transformer for serializing requests and deserializing responses
|
||||
* @param lastEventId - Optional ID of the last received event for subscriptions
|
||||
*
|
||||
* @returns An observable that emits operation results and handles cleanup
|
||||
*/
|
||||
request({ op: { id, type, path, input, signal }, transformer, lastEventId }) {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
const abort = this.batchSend({
|
||||
id,
|
||||
method: type,
|
||||
params: {
|
||||
input: transformer.input.serialize(input),
|
||||
path,
|
||||
lastEventId
|
||||
}
|
||||
}, (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, observer), {}, { next(event) {
|
||||
const transformed = (0, __trpc_server_unstable_core_do_not_import.transformResult)(event, transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(require_TRPCClientError.TRPCClientError.from(transformed.error));
|
||||
return;
|
||||
}
|
||||
observer.next({ result: transformed.result });
|
||||
} }));
|
||||
return () => {
|
||||
abort();
|
||||
if (type === "subscription" && this.activeConnection.isOpen()) this.send({
|
||||
id,
|
||||
method: "subscription.stop"
|
||||
});
|
||||
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
||||
};
|
||||
});
|
||||
}
|
||||
get connection() {
|
||||
return backwardCompatibility(this.activeConnection);
|
||||
}
|
||||
reconnect(closedError) {
|
||||
var _this3 = this;
|
||||
this.connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: require_TRPCClientError.TRPCClientError.from(closedError)
|
||||
});
|
||||
if (this.reconnecting) return;
|
||||
const tryReconnect = async (attemptIndex) => {
|
||||
try {
|
||||
await (0, __trpc_server_unstable_core_do_not_import.sleep)(_this3.reconnectRetryDelay(attemptIndex));
|
||||
if (_this3.allowReconnect) {
|
||||
await _this3.activeConnection.close();
|
||||
await _this3.activeConnection.open();
|
||||
if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message));
|
||||
}
|
||||
_this3.reconnecting = null;
|
||||
} catch (_unused) {
|
||||
await tryReconnect(attemptIndex + 1);
|
||||
}
|
||||
};
|
||||
this.reconnecting = tryReconnect(0);
|
||||
}
|
||||
setupWebSocketListeners(ws) {
|
||||
var _this4 = this;
|
||||
const handleCloseOrError = (cause) => {
|
||||
const reqs = this.requestManager.getPendingRequests();
|
||||
for (const { message, callbacks } of reqs) {
|
||||
if (message.method === "subscription") continue;
|
||||
callbacks.error(require_TRPCClientError.TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause
|
||||
})));
|
||||
this.requestManager.delete(message.id);
|
||||
}
|
||||
};
|
||||
ws.addEventListener("open", () => {
|
||||
(0, __trpc_server_unstable_core_do_not_import.run)(async () => {
|
||||
var _this$callbacks$onOpe, _this$callbacks;
|
||||
if (_this4.lazyMode) _this4.inactivityTimeout.start();
|
||||
(_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks);
|
||||
_this4.connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
}).catch((error) => {
|
||||
ws.close(3e3);
|
||||
handleCloseOrError(error);
|
||||
});
|
||||
});
|
||||
ws.addEventListener("message", ({ data }) => {
|
||||
this.inactivityTimeout.reset();
|
||||
if (["PING", "PONG"].includes(data)) return;
|
||||
const incomingMessage = this.encoder.decode(data);
|
||||
if ("method" in incomingMessage) {
|
||||
this.handleIncomingRequest(incomingMessage);
|
||||
return;
|
||||
}
|
||||
this.handleResponseMessage(incomingMessage);
|
||||
});
|
||||
ws.addEventListener("close", (event) => {
|
||||
var _this$callbacks$onClo, _this$callbacks2;
|
||||
handleCloseOrError(event);
|
||||
(_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event);
|
||||
if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause: event
|
||||
}));
|
||||
});
|
||||
ws.addEventListener("error", (event) => {
|
||||
var _this$callbacks$onErr, _this$callbacks3;
|
||||
handleCloseOrError(event);
|
||||
(_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event);
|
||||
this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause: event
|
||||
}));
|
||||
});
|
||||
}
|
||||
handleResponseMessage(message) {
|
||||
const request = this.requestManager.getPendingRequest(message.id);
|
||||
if (!request) return;
|
||||
request.callbacks.next(message);
|
||||
let completed = true;
|
||||
if ("result" in message && request.message.method === "subscription") {
|
||||
if (message.result.type === "data") request.message.params.lastEventId = message.result.id;
|
||||
if (message.result.type !== "stopped") completed = false;
|
||||
}
|
||||
if (completed) {
|
||||
request.callbacks.complete();
|
||||
this.requestManager.delete(message.id);
|
||||
}
|
||||
}
|
||||
handleIncomingRequest(message) {
|
||||
if (message.method === "reconnect") this.reconnect(new TRPCWebSocketClosedError({ message: "Server requested reconnect" }));
|
||||
}
|
||||
/**
|
||||
* Sends a message or batch of messages directly to the server.
|
||||
*/
|
||||
send(messageOrMessages) {
|
||||
if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
|
||||
const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages];
|
||||
this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages));
|
||||
}
|
||||
/**
|
||||
* Groups requests for batch sending.
|
||||
*
|
||||
* @returns A function to abort the batched request.
|
||||
*/
|
||||
batchSend(message, callbacks) {
|
||||
var _this5 = this;
|
||||
this.inactivityTimeout.reset();
|
||||
(0, __trpc_server_unstable_core_do_not_import.run)(async () => {
|
||||
if (!_this5.activeConnection.isOpen()) await _this5.open();
|
||||
await (0, __trpc_server_unstable_core_do_not_import.sleep)(0);
|
||||
if (!_this5.requestManager.hasOutgoingRequests()) return;
|
||||
_this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1));
|
||||
}).catch((err) => {
|
||||
this.requestManager.delete(message.id);
|
||||
callbacks.error(require_TRPCClientError.TRPCClientError.from(err));
|
||||
});
|
||||
return this.requestManager.register(message, callbacks);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/createWsClient.ts
|
||||
function createWSClient(opts) {
|
||||
return new WsClient(opts);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsLink.ts
|
||||
function wsLink(opts) {
|
||||
const { client } = opts;
|
||||
const transformer = require_unstable_internals.getTransformer(opts.transformer);
|
||||
return () => {
|
||||
return ({ op }) => {
|
||||
return (0, __trpc_server_observable.observable)((observer) => {
|
||||
const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) {
|
||||
observer.next({
|
||||
result,
|
||||
context: op.context
|
||||
});
|
||||
} }) : null;
|
||||
const requestSubscription = client.request({
|
||||
op,
|
||||
transformer
|
||||
}).subscribe(observer);
|
||||
return () => {
|
||||
requestSubscription.unsubscribe();
|
||||
connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'createWSClient', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createWSClient;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'jsonEncoder', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return jsonEncoder;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'resultOf', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return resultOf;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'wsLink', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return wsLink;
|
||||
}
|
||||
});
|
||||
+701
@@ -0,0 +1,701 @@
|
||||
import { __toESM, require_defineProperty, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
|
||||
import { TRPCClientError } from "./TRPCClientError-apv8gw59.mjs";
|
||||
import { getTransformer } from "./unstable-internals-Bg7n9BBj.mjs";
|
||||
import { behaviorSubject, observable } from "@trpc/server/observable";
|
||||
import { run, sleep, transformResult } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
//#region src/links/wsLink/wsClient/encoder.ts
|
||||
const jsonEncoder = {
|
||||
encode: (data) => JSON.stringify(data),
|
||||
decode: (data) => {
|
||||
if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
|
||||
return JSON.parse(data);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/options.ts
|
||||
const lazyDefaults = {
|
||||
enabled: false,
|
||||
closeMs: 0
|
||||
};
|
||||
const keepAliveDefaults = {
|
||||
enabled: false,
|
||||
pongTimeoutMs: 1e3,
|
||||
intervalMs: 5e3
|
||||
};
|
||||
/**
|
||||
* Calculates a delay for exponential backoff based on the retry attempt index.
|
||||
* The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
|
||||
* capped at 30 seconds.
|
||||
*/
|
||||
const exponentialBackoff = (attemptIndex) => {
|
||||
return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/urlWithConnectionParams.ts
|
||||
/**
|
||||
* Get the result of a value or function that returns a value
|
||||
* It also optionally accepts typesafe arguments for the function
|
||||
*/
|
||||
const resultOf = (value, ...args) => {
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/utils.ts
|
||||
var import_defineProperty$3 = __toESM(require_defineProperty(), 1);
|
||||
var TRPCWebSocketClosedError = class TRPCWebSocketClosedError extends Error {
|
||||
constructor(opts) {
|
||||
super(opts.message, { cause: opts.cause });
|
||||
this.name = "TRPCWebSocketClosedError";
|
||||
Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Utility class for managing a timeout that can be started, stopped, and reset.
|
||||
* Useful for scenarios where the timeout duration is reset dynamically based on events.
|
||||
*/
|
||||
var ResettableTimeout = class {
|
||||
constructor(onTimeout, timeoutMs) {
|
||||
this.onTimeout = onTimeout;
|
||||
this.timeoutMs = timeoutMs;
|
||||
(0, import_defineProperty$3.default)(this, "timeout", void 0);
|
||||
}
|
||||
/**
|
||||
* Resets the current timeout, restarting it with the same duration.
|
||||
* Does nothing if no timeout is active.
|
||||
*/
|
||||
reset() {
|
||||
if (!this.timeout) return;
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
||||
}
|
||||
start() {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
||||
}
|
||||
stop() {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = void 0;
|
||||
}
|
||||
};
|
||||
function withResolvers() {
|
||||
let resolve;
|
||||
let reject;
|
||||
const promise = new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
return {
|
||||
promise,
|
||||
resolve,
|
||||
reject
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resolves a WebSocket URL and optionally appends connection parameters.
|
||||
*
|
||||
* If connectionParams are provided, appends 'connectionParams=1' query parameter.
|
||||
*/
|
||||
async function prepareUrl(urlOptions) {
|
||||
const url = await resultOf(urlOptions.url);
|
||||
if (!urlOptions.connectionParams) return url;
|
||||
const prefix = url.includes("?") ? "&" : "?";
|
||||
const connectionParams = `${prefix}connectionParams=1`;
|
||||
return url + connectionParams;
|
||||
}
|
||||
async function buildConnectionMessage(connectionParams, encoder) {
|
||||
const message = {
|
||||
method: "connectionParams",
|
||||
data: await resultOf(connectionParams)
|
||||
};
|
||||
return encoder.encode(message);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/requestManager.ts
|
||||
var import_defineProperty$2 = __toESM(require_defineProperty(), 1);
|
||||
/**
|
||||
* Manages WebSocket requests, tracking their lifecycle and providing utility methods
|
||||
* for handling outgoing and pending requests.
|
||||
*
|
||||
* - **Outgoing requests**: Requests that are queued and waiting to be sent.
|
||||
* - **Pending requests**: Requests that have been sent and are in flight awaiting a response.
|
||||
* For subscriptions, multiple responses may be received until the subscription is closed.
|
||||
*/
|
||||
var RequestManager = class {
|
||||
constructor() {
|
||||
(0, import_defineProperty$2.default)(this, "outgoingRequests", new Array());
|
||||
(0, import_defineProperty$2.default)(this, "pendingRequests", {});
|
||||
}
|
||||
/**
|
||||
* Registers a new request by adding it to the outgoing queue and setting up
|
||||
* callbacks for lifecycle events such as completion or error.
|
||||
*
|
||||
* @param message - The outgoing message to be sent.
|
||||
* @param callbacks - Callback functions to observe the request's state.
|
||||
* @returns A cleanup function to manually remove the request.
|
||||
*/
|
||||
register(message, callbacks) {
|
||||
const { promise: end, resolve } = withResolvers();
|
||||
this.outgoingRequests.push({
|
||||
id: String(message.id),
|
||||
message,
|
||||
end,
|
||||
callbacks: {
|
||||
next: callbacks.next,
|
||||
complete: () => {
|
||||
callbacks.complete();
|
||||
resolve();
|
||||
},
|
||||
error: (e) => {
|
||||
callbacks.error(e);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
this.delete(message.id);
|
||||
callbacks.complete();
|
||||
resolve();
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Deletes a request from both the outgoing and pending collections, if it exists.
|
||||
*/
|
||||
delete(messageId) {
|
||||
if (messageId === null) return;
|
||||
this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
|
||||
delete this.pendingRequests[String(messageId)];
|
||||
}
|
||||
/**
|
||||
* Moves all outgoing requests to the pending state and clears the outgoing queue.
|
||||
*
|
||||
* The caller is expected to handle the actual sending of the requests
|
||||
* (e.g., sending them over the network) after this method is called.
|
||||
*
|
||||
* @returns The list of requests that were transitioned to the pending state.
|
||||
*/
|
||||
flush() {
|
||||
const requests = this.outgoingRequests;
|
||||
this.outgoingRequests = [];
|
||||
for (const request of requests) this.pendingRequests[request.id] = request;
|
||||
return requests;
|
||||
}
|
||||
/**
|
||||
* Retrieves all currently pending requests, which are in flight awaiting responses
|
||||
* or handling ongoing subscriptions.
|
||||
*/
|
||||
getPendingRequests() {
|
||||
return Object.values(this.pendingRequests);
|
||||
}
|
||||
/**
|
||||
* Retrieves a specific pending request by its message ID.
|
||||
*/
|
||||
getPendingRequest(messageId) {
|
||||
if (messageId === null) return null;
|
||||
return this.pendingRequests[String(messageId)];
|
||||
}
|
||||
/**
|
||||
* Retrieves all outgoing requests, which are waiting to be sent.
|
||||
*/
|
||||
getOutgoingRequests() {
|
||||
return this.outgoingRequests;
|
||||
}
|
||||
/**
|
||||
* Retrieves all requests, both outgoing and pending, with their respective states.
|
||||
*
|
||||
* @returns An array of all requests with their state ("outgoing" or "pending").
|
||||
*/
|
||||
getRequests() {
|
||||
return [...this.getOutgoingRequests().map((request) => ({
|
||||
state: "outgoing",
|
||||
message: request.message,
|
||||
end: request.end,
|
||||
callbacks: request.callbacks
|
||||
})), ...this.getPendingRequests().map((request) => ({
|
||||
state: "pending",
|
||||
message: request.message,
|
||||
end: request.end,
|
||||
callbacks: request.callbacks
|
||||
}))];
|
||||
}
|
||||
/**
|
||||
* Checks if there are any pending requests, including ongoing subscriptions.
|
||||
*/
|
||||
hasPendingRequests() {
|
||||
return this.getPendingRequests().length > 0;
|
||||
}
|
||||
/**
|
||||
* Checks if there are any pending subscriptions
|
||||
*/
|
||||
hasPendingSubscriptions() {
|
||||
return this.getPendingRequests().some((request) => request.message.method === "subscription");
|
||||
}
|
||||
/**
|
||||
* Checks if there are any outgoing requests waiting to be sent.
|
||||
*/
|
||||
hasOutgoingRequests() {
|
||||
return this.outgoingRequests.length > 0;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsConnection.ts
|
||||
var import_defineProperty$1 = __toESM(require_defineProperty(), 1);
|
||||
/**
|
||||
* Opens a WebSocket connection asynchronously and returns a promise
|
||||
* that resolves when the connection is successfully established.
|
||||
* The promise rejects if an error occurs during the connection attempt.
|
||||
*/
|
||||
function asyncWsOpen(ws) {
|
||||
const { promise, resolve, reject } = withResolvers();
|
||||
ws.addEventListener("open", () => {
|
||||
ws.removeEventListener("error", reject);
|
||||
resolve();
|
||||
});
|
||||
ws.addEventListener("error", reject);
|
||||
return promise;
|
||||
}
|
||||
/**
|
||||
* Sets up a periodic ping-pong mechanism to keep the WebSocket connection alive.
|
||||
*
|
||||
* - Sends "PING" messages at regular intervals defined by `intervalMs`.
|
||||
* - If a "PONG" response is not received within the `pongTimeoutMs`, the WebSocket is closed.
|
||||
* - The ping timer resets upon receiving any message to maintain activity.
|
||||
* - Automatically starts the ping process when the WebSocket connection is opened.
|
||||
* - Cleans up timers when the WebSocket is closed.
|
||||
*
|
||||
* @param ws - The WebSocket instance to manage.
|
||||
* @param options - Configuration options for ping-pong intervals and timeouts.
|
||||
*/
|
||||
function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
|
||||
let pingTimeout;
|
||||
let pongTimeout;
|
||||
function start() {
|
||||
pingTimeout = setTimeout(() => {
|
||||
ws.send("PING");
|
||||
pongTimeout = setTimeout(() => {
|
||||
ws.close();
|
||||
}, pongTimeoutMs);
|
||||
}, intervalMs);
|
||||
}
|
||||
function reset() {
|
||||
clearTimeout(pingTimeout);
|
||||
start();
|
||||
}
|
||||
function pong() {
|
||||
clearTimeout(pongTimeout);
|
||||
reset();
|
||||
}
|
||||
ws.addEventListener("open", start);
|
||||
ws.addEventListener("message", ({ data }) => {
|
||||
clearTimeout(pingTimeout);
|
||||
start();
|
||||
if (data === "PONG") pong();
|
||||
});
|
||||
ws.addEventListener("close", () => {
|
||||
clearTimeout(pingTimeout);
|
||||
clearTimeout(pongTimeout);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Manages a WebSocket connection with support for reconnection, keep-alive mechanisms,
|
||||
* and observable state tracking.
|
||||
*/
|
||||
var WsConnection = class WsConnection {
|
||||
constructor(opts) {
|
||||
var _opts$WebSocketPonyfi;
|
||||
(0, import_defineProperty$1.default)(this, "id", ++WsConnection.connectCount);
|
||||
(0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "urlOptions", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "encoder", void 0);
|
||||
(0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null));
|
||||
(0, import_defineProperty$1.default)(this, "openPromise", null);
|
||||
this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
|
||||
if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
||||
this.urlOptions = opts.urlOptions;
|
||||
this.keepAliveOpts = opts.keepAlive;
|
||||
this.encoder = opts.encoder;
|
||||
}
|
||||
get ws() {
|
||||
return this.wsObservable.get();
|
||||
}
|
||||
set ws(ws) {
|
||||
this.wsObservable.next(ws);
|
||||
}
|
||||
/**
|
||||
* Checks if the WebSocket connection is open and ready to communicate.
|
||||
*/
|
||||
isOpen() {
|
||||
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
||||
}
|
||||
/**
|
||||
* Checks if the WebSocket connection is closed or in the process of closing.
|
||||
*/
|
||||
isClosed() {
|
||||
return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
|
||||
}
|
||||
async open() {
|
||||
var _this = this;
|
||||
if (_this.openPromise) return _this.openPromise;
|
||||
_this.id = ++WsConnection.connectCount;
|
||||
const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
|
||||
_this.openPromise = wsPromise.then(async (ws) => {
|
||||
_this.ws = ws;
|
||||
ws.binaryType = "arraybuffer";
|
||||
ws.addEventListener("message", function({ data }) {
|
||||
if (data === "PING") this.send("PONG");
|
||||
});
|
||||
if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
|
||||
ws.addEventListener("close", () => {
|
||||
if (_this.ws === ws) _this.ws = null;
|
||||
});
|
||||
await asyncWsOpen(ws);
|
||||
if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
|
||||
});
|
||||
try {
|
||||
await _this.openPromise;
|
||||
} finally {
|
||||
_this.openPromise = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Closes the WebSocket connection gracefully.
|
||||
* Waits for any ongoing open operation to complete before closing.
|
||||
*/
|
||||
async close() {
|
||||
var _this2 = this;
|
||||
try {
|
||||
await _this2.openPromise;
|
||||
} finally {
|
||||
var _this$ws;
|
||||
(_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
(0, import_defineProperty$1.default)(WsConnection, "connectCount", 0);
|
||||
/**
|
||||
* Provides a backward-compatible representation of the connection state.
|
||||
*/
|
||||
function backwardCompatibility(connection) {
|
||||
if (connection.isOpen()) return {
|
||||
id: connection.id,
|
||||
state: "open",
|
||||
ws: connection.ws
|
||||
};
|
||||
if (connection.isClosed()) return {
|
||||
id: connection.id,
|
||||
state: "closed",
|
||||
ws: connection.ws
|
||||
};
|
||||
if (!connection.ws) return null;
|
||||
return {
|
||||
id: connection.id,
|
||||
state: "connecting",
|
||||
ws: connection.ws
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsClient.ts
|
||||
var import_defineProperty = __toESM(require_defineProperty(), 1);
|
||||
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
||||
/**
|
||||
* A WebSocket client for managing TRPC operations, supporting lazy initialization,
|
||||
* reconnection, keep-alive, and request management.
|
||||
*/
|
||||
var WsClient = class {
|
||||
constructor(opts) {
|
||||
var _opts$experimental_en, _opts$retryDelayMs;
|
||||
(0, import_defineProperty.default)(this, "connectionState", void 0);
|
||||
(0, import_defineProperty.default)(this, "allowReconnect", false);
|
||||
(0, import_defineProperty.default)(this, "requestManager", new RequestManager());
|
||||
(0, import_defineProperty.default)(this, "activeConnection", void 0);
|
||||
(0, import_defineProperty.default)(this, "reconnectRetryDelay", void 0);
|
||||
(0, import_defineProperty.default)(this, "inactivityTimeout", void 0);
|
||||
(0, import_defineProperty.default)(this, "callbacks", void 0);
|
||||
(0, import_defineProperty.default)(this, "lazyMode", void 0);
|
||||
(0, import_defineProperty.default)(this, "encoder", void 0);
|
||||
(0, import_defineProperty.default)(this, "reconnecting", null);
|
||||
this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder;
|
||||
this.callbacks = {
|
||||
onOpen: opts.onOpen,
|
||||
onClose: opts.onClose,
|
||||
onError: opts.onError
|
||||
};
|
||||
const lazyOptions = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, lazyDefaults), opts.lazy);
|
||||
this.inactivityTimeout = new ResettableTimeout(() => {
|
||||
if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
|
||||
this.inactivityTimeout.reset();
|
||||
return;
|
||||
}
|
||||
this.close().catch(() => null);
|
||||
}, lazyOptions.closeMs);
|
||||
this.activeConnection = new WsConnection({
|
||||
WebSocketPonyfill: opts.WebSocket,
|
||||
urlOptions: opts,
|
||||
keepAlive: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, keepAliveDefaults), opts.keepAlive),
|
||||
encoder: this.encoder
|
||||
});
|
||||
this.activeConnection.wsObservable.subscribe({ next: (ws) => {
|
||||
if (!ws) return;
|
||||
this.setupWebSocketListeners(ws);
|
||||
} });
|
||||
this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff;
|
||||
this.lazyMode = lazyOptions.enabled;
|
||||
this.connectionState = behaviorSubject({
|
||||
type: "state",
|
||||
state: lazyOptions.enabled ? "idle" : "connecting",
|
||||
error: null
|
||||
});
|
||||
if (!this.lazyMode) this.open().catch(() => null);
|
||||
}
|
||||
/**
|
||||
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
||||
* the connection state accordingly.
|
||||
*/
|
||||
async open() {
|
||||
var _this = this;
|
||||
_this.allowReconnect = true;
|
||||
if (_this.connectionState.get().state === "idle") _this.connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: null
|
||||
});
|
||||
try {
|
||||
await _this.activeConnection.open();
|
||||
} catch (error) {
|
||||
_this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "Initialization error",
|
||||
cause: error
|
||||
}));
|
||||
return _this.reconnecting;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Closes the WebSocket connection and stops managing requests.
|
||||
* Ensures all outgoing and pending requests are properly finalized.
|
||||
*/
|
||||
async close() {
|
||||
var _this2 = this;
|
||||
_this2.allowReconnect = false;
|
||||
_this2.inactivityTimeout.stop();
|
||||
const requestsToAwait = [];
|
||||
for (const request of _this2.requestManager.getRequests()) if (request.message.method === "subscription") request.callbacks.complete();
|
||||
else if (request.state === "outgoing") request.callbacks.error(TRPCClientError.from(new TRPCWebSocketClosedError({ message: "Closed before connection was established" })));
|
||||
else requestsToAwait.push(request.end);
|
||||
await Promise.all(requestsToAwait).catch(() => null);
|
||||
await _this2.activeConnection.close().catch(() => null);
|
||||
_this2.connectionState.next({
|
||||
type: "state",
|
||||
state: "idle",
|
||||
error: null
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Method to request the server.
|
||||
* Handles data transformation, batching of requests, and subscription lifecycle.
|
||||
*
|
||||
* @param op - The operation details including id, type, path, input and signal
|
||||
* @param transformer - Data transformer for serializing requests and deserializing responses
|
||||
* @param lastEventId - Optional ID of the last received event for subscriptions
|
||||
*
|
||||
* @returns An observable that emits operation results and handles cleanup
|
||||
*/
|
||||
request({ op: { id, type, path, input, signal }, transformer, lastEventId }) {
|
||||
return observable((observer) => {
|
||||
const abort = this.batchSend({
|
||||
id,
|
||||
method: type,
|
||||
params: {
|
||||
input: transformer.input.serialize(input),
|
||||
path,
|
||||
lastEventId
|
||||
}
|
||||
}, (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, observer), {}, { next(event) {
|
||||
const transformed = transformResult(event, transformer.output);
|
||||
if (!transformed.ok) {
|
||||
observer.error(TRPCClientError.from(transformed.error));
|
||||
return;
|
||||
}
|
||||
observer.next({ result: transformed.result });
|
||||
} }));
|
||||
return () => {
|
||||
abort();
|
||||
if (type === "subscription" && this.activeConnection.isOpen()) this.send({
|
||||
id,
|
||||
method: "subscription.stop"
|
||||
});
|
||||
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
||||
};
|
||||
});
|
||||
}
|
||||
get connection() {
|
||||
return backwardCompatibility(this.activeConnection);
|
||||
}
|
||||
reconnect(closedError) {
|
||||
var _this3 = this;
|
||||
this.connectionState.next({
|
||||
type: "state",
|
||||
state: "connecting",
|
||||
error: TRPCClientError.from(closedError)
|
||||
});
|
||||
if (this.reconnecting) return;
|
||||
const tryReconnect = async (attemptIndex) => {
|
||||
try {
|
||||
await sleep(_this3.reconnectRetryDelay(attemptIndex));
|
||||
if (_this3.allowReconnect) {
|
||||
await _this3.activeConnection.close();
|
||||
await _this3.activeConnection.open();
|
||||
if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message));
|
||||
}
|
||||
_this3.reconnecting = null;
|
||||
} catch (_unused) {
|
||||
await tryReconnect(attemptIndex + 1);
|
||||
}
|
||||
};
|
||||
this.reconnecting = tryReconnect(0);
|
||||
}
|
||||
setupWebSocketListeners(ws) {
|
||||
var _this4 = this;
|
||||
const handleCloseOrError = (cause) => {
|
||||
const reqs = this.requestManager.getPendingRequests();
|
||||
for (const { message, callbacks } of reqs) {
|
||||
if (message.method === "subscription") continue;
|
||||
callbacks.error(TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause
|
||||
})));
|
||||
this.requestManager.delete(message.id);
|
||||
}
|
||||
};
|
||||
ws.addEventListener("open", () => {
|
||||
run(async () => {
|
||||
var _this$callbacks$onOpe, _this$callbacks;
|
||||
if (_this4.lazyMode) _this4.inactivityTimeout.start();
|
||||
(_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks);
|
||||
_this4.connectionState.next({
|
||||
type: "state",
|
||||
state: "pending",
|
||||
error: null
|
||||
});
|
||||
}).catch((error) => {
|
||||
ws.close(3e3);
|
||||
handleCloseOrError(error);
|
||||
});
|
||||
});
|
||||
ws.addEventListener("message", ({ data }) => {
|
||||
this.inactivityTimeout.reset();
|
||||
if (["PING", "PONG"].includes(data)) return;
|
||||
const incomingMessage = this.encoder.decode(data);
|
||||
if ("method" in incomingMessage) {
|
||||
this.handleIncomingRequest(incomingMessage);
|
||||
return;
|
||||
}
|
||||
this.handleResponseMessage(incomingMessage);
|
||||
});
|
||||
ws.addEventListener("close", (event) => {
|
||||
var _this$callbacks$onClo, _this$callbacks2;
|
||||
handleCloseOrError(event);
|
||||
(_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event);
|
||||
if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause: event
|
||||
}));
|
||||
});
|
||||
ws.addEventListener("error", (event) => {
|
||||
var _this$callbacks$onErr, _this$callbacks3;
|
||||
handleCloseOrError(event);
|
||||
(_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event);
|
||||
this.reconnect(new TRPCWebSocketClosedError({
|
||||
message: "WebSocket closed",
|
||||
cause: event
|
||||
}));
|
||||
});
|
||||
}
|
||||
handleResponseMessage(message) {
|
||||
const request = this.requestManager.getPendingRequest(message.id);
|
||||
if (!request) return;
|
||||
request.callbacks.next(message);
|
||||
let completed = true;
|
||||
if ("result" in message && request.message.method === "subscription") {
|
||||
if (message.result.type === "data") request.message.params.lastEventId = message.result.id;
|
||||
if (message.result.type !== "stopped") completed = false;
|
||||
}
|
||||
if (completed) {
|
||||
request.callbacks.complete();
|
||||
this.requestManager.delete(message.id);
|
||||
}
|
||||
}
|
||||
handleIncomingRequest(message) {
|
||||
if (message.method === "reconnect") this.reconnect(new TRPCWebSocketClosedError({ message: "Server requested reconnect" }));
|
||||
}
|
||||
/**
|
||||
* Sends a message or batch of messages directly to the server.
|
||||
*/
|
||||
send(messageOrMessages) {
|
||||
if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
|
||||
const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages];
|
||||
this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages));
|
||||
}
|
||||
/**
|
||||
* Groups requests for batch sending.
|
||||
*
|
||||
* @returns A function to abort the batched request.
|
||||
*/
|
||||
batchSend(message, callbacks) {
|
||||
var _this5 = this;
|
||||
this.inactivityTimeout.reset();
|
||||
run(async () => {
|
||||
if (!_this5.activeConnection.isOpen()) await _this5.open();
|
||||
await sleep(0);
|
||||
if (!_this5.requestManager.hasOutgoingRequests()) return;
|
||||
_this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1));
|
||||
}).catch((err) => {
|
||||
this.requestManager.delete(message.id);
|
||||
callbacks.error(TRPCClientError.from(err));
|
||||
});
|
||||
return this.requestManager.register(message, callbacks);
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/createWsClient.ts
|
||||
function createWSClient(opts) {
|
||||
return new WsClient(opts);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsLink.ts
|
||||
function wsLink(opts) {
|
||||
const { client } = opts;
|
||||
const transformer = getTransformer(opts.transformer);
|
||||
return () => {
|
||||
return ({ op }) => {
|
||||
return observable((observer) => {
|
||||
const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) {
|
||||
observer.next({
|
||||
result,
|
||||
context: op.context
|
||||
});
|
||||
} }) : null;
|
||||
const requestSubscription = client.request({
|
||||
op,
|
||||
transformer
|
||||
}).subscribe(observer);
|
||||
return () => {
|
||||
requestSubscription.unsubscribe();
|
||||
connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createWSClient, jsonEncoder, resultOf, wsLink };
|
||||
//# sourceMappingURL=wsLink-DSf4KOdW.mjs.map
|
||||
+1
File diff suppressed because one or more lines are too long
+206
@@ -0,0 +1,206 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Dlr1nWGD.mjs";
|
||||
import { Operation, OperationResultEnvelope, TRPCClientError, TRPCLink } from "./types.d-sRNtuQA-.mjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-BOmV7EK1.mjs";
|
||||
import * as _trpc_server_observable0 from "@trpc/server/observable";
|
||||
import { BehaviorSubject } from "@trpc/server/observable";
|
||||
import { AnyRouter, CombinedDataTransformer, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
import { AnyTRPCRouter } from "@trpc/server";
|
||||
import { Encoder } from "@trpc/server/adapters/ws";
|
||||
import { TRPCRequestInfo } from "@trpc/server/http";
|
||||
|
||||
//#region src/links/wsLink/wsClient/encoder.d.ts
|
||||
declare const jsonEncoder: Encoder;
|
||||
//# sourceMappingURL=encoder.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/urlWithConnectionParams.d.ts
|
||||
/**
|
||||
* A value that can be wrapped in callback
|
||||
*/
|
||||
type CallbackOrValue<T> = T | (() => T | Promise<T>);
|
||||
interface UrlOptionsWithConnectionParams {
|
||||
/**
|
||||
* The URL to connect to (can be a function that returns a URL)
|
||||
*/
|
||||
url: CallbackOrValue<string>;
|
||||
/**
|
||||
* Connection params that are available in `createContext()`
|
||||
* - For `wsLink`/`wsClient`, these are sent as the first message
|
||||
* - For `httpSubscriptionLink`, these are serialized as part of the URL under the `connectionParams` query
|
||||
*/
|
||||
connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;
|
||||
}
|
||||
//# sourceMappingURL=urlWithConnectionParams.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/options.d.ts
|
||||
interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
|
||||
/**
|
||||
* Ponyfill which WebSocket implementation to use
|
||||
*/
|
||||
WebSocket?: typeof WebSocket;
|
||||
/**
|
||||
* The number of milliseconds before a reconnect is attempted.
|
||||
* @default {@link exponentialBackoff}
|
||||
*/
|
||||
retryDelayMs?: (attemptIndex: number) => number;
|
||||
/**
|
||||
* Triggered when a WebSocket connection is established
|
||||
*/
|
||||
onOpen?: () => void;
|
||||
/**
|
||||
* Triggered when a WebSocket connection encounters an error
|
||||
*/
|
||||
onError?: (evt?: Event) => void;
|
||||
/**
|
||||
* Triggered when a WebSocket connection is closed
|
||||
*/
|
||||
onClose?: (cause?: {
|
||||
code?: number;
|
||||
}) => void;
|
||||
/**
|
||||
* Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
|
||||
*/
|
||||
lazy?: {
|
||||
/**
|
||||
* Enable lazy mode
|
||||
* @default false
|
||||
*/
|
||||
enabled: boolean;
|
||||
/**
|
||||
* Close the WebSocket after this many milliseconds
|
||||
* @default 0
|
||||
*/
|
||||
closeMs: number;
|
||||
};
|
||||
/**
|
||||
* Send ping messages to the server and kill the connection if no pong message is returned
|
||||
*/
|
||||
keepAlive?: {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
enabled: boolean;
|
||||
/**
|
||||
* Send a ping message every this many milliseconds
|
||||
* @default 5_000
|
||||
*/
|
||||
intervalMs?: number;
|
||||
/**
|
||||
* Close the WebSocket after this many milliseconds if the server does not respond
|
||||
* @default 1_000
|
||||
*/
|
||||
pongTimeoutMs?: number;
|
||||
};
|
||||
/**
|
||||
* Custom encoder for wire encoding (e.g. custom binary formats)
|
||||
* @default jsonEncoder
|
||||
*/
|
||||
experimental_encoder?: Encoder;
|
||||
}
|
||||
/**
|
||||
* Default options for lazy WebSocket connections.
|
||||
* Determines whether the connection should be established lazily and defines the delay before closure.
|
||||
*/
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsClient.d.ts
|
||||
/**
|
||||
* A WebSocket client for managing TRPC operations, supporting lazy initialization,
|
||||
* reconnection, keep-alive, and request management.
|
||||
*/
|
||||
declare class WsClient {
|
||||
/**
|
||||
* Observable tracking the current connection state, including errors.
|
||||
*/
|
||||
readonly connectionState: BehaviorSubject<TRPCConnectionState<TRPCClientError<AnyTRPCRouter>>>;
|
||||
private allowReconnect;
|
||||
private requestManager;
|
||||
private readonly activeConnection;
|
||||
private readonly reconnectRetryDelay;
|
||||
private inactivityTimeout;
|
||||
private readonly callbacks;
|
||||
private readonly lazyMode;
|
||||
private readonly encoder;
|
||||
constructor(opts: WebSocketClientOptions);
|
||||
/**
|
||||
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
||||
* the connection state accordingly.
|
||||
*/
|
||||
private open;
|
||||
/**
|
||||
* Closes the WebSocket connection and stops managing requests.
|
||||
* Ensures all outgoing and pending requests are properly finalized.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Method to request the server.
|
||||
* Handles data transformation, batching of requests, and subscription lifecycle.
|
||||
*
|
||||
* @param op - The operation details including id, type, path, input and signal
|
||||
* @param transformer - Data transformer for serializing requests and deserializing responses
|
||||
* @param lastEventId - Optional ID of the last received event for subscriptions
|
||||
*
|
||||
* @returns An observable that emits operation results and handles cleanup
|
||||
*/
|
||||
request({
|
||||
op: {
|
||||
id,
|
||||
type,
|
||||
path,
|
||||
input,
|
||||
signal
|
||||
},
|
||||
transformer,
|
||||
lastEventId
|
||||
}: {
|
||||
op: Pick<Operation, 'id' | 'type' | 'path' | 'input' | 'signal'>;
|
||||
transformer: CombinedDataTransformer;
|
||||
lastEventId?: string;
|
||||
}): _trpc_server_observable0.Observable<OperationResultEnvelope<unknown, TRPCClientError<AnyTRPCRouter>>, TRPCClientError<AnyTRPCRouter>>;
|
||||
get connection(): {
|
||||
readonly id: number;
|
||||
readonly state: "open";
|
||||
readonly ws: WebSocket;
|
||||
} | {
|
||||
readonly id: number;
|
||||
readonly state: "closed";
|
||||
readonly ws: WebSocket;
|
||||
} | {
|
||||
readonly id: number;
|
||||
readonly state: "connecting";
|
||||
readonly ws: WebSocket;
|
||||
} | null;
|
||||
/**
|
||||
* Manages the reconnection process for the WebSocket using retry logic.
|
||||
* Ensures that only one reconnection attempt is active at a time by tracking the current
|
||||
* reconnection state in the `reconnecting` promise.
|
||||
*/
|
||||
private reconnecting;
|
||||
private reconnect;
|
||||
private setupWebSocketListeners;
|
||||
private handleResponseMessage;
|
||||
private handleIncomingRequest;
|
||||
/**
|
||||
* Sends a message or batch of messages directly to the server.
|
||||
*/
|
||||
private send;
|
||||
/**
|
||||
* Groups requests for batch sending.
|
||||
*
|
||||
* @returns A function to abort the batched request.
|
||||
*/
|
||||
private batchSend;
|
||||
}
|
||||
//# sourceMappingURL=wsClient.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/wsLink/createWsClient.d.ts
|
||||
declare function createWSClient(opts: WebSocketClientOptions): WsClient;
|
||||
type TRPCWebSocketClient = ReturnType<typeof createWSClient>;
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsLink.d.ts
|
||||
type WebSocketLinkOptions<TRouter extends AnyRouter> = {
|
||||
client: TRPCWebSocketClient;
|
||||
} & TransformerOptions<inferClientTypes<TRouter>>;
|
||||
declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
//#endregion
|
||||
export { Encoder, TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink };
|
||||
//# sourceMappingURL=wsLink.d-DCqbZKOH.d.mts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"wsLink.d-DCqbZKOH.d.mts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","../src/links/wsLink/wsLink.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAIa,aAAa;;;;;;;;KCcd,qBAAqB,WAAW,IAAI,QAAQ;UAEvC,8BAAA;EDhBJ;;;OCoBN;EANK;;;;;EAA6C,gBAAT,CAAA,EAa3B,eAb2B,CAaX,eAbW,CAAA,kBAAA,CAAA,CAAA;AAAO;AAEvD;;;UCjBiB,sBAAA,SAA+B;;;;qBAI3B;;;;;EFHR,YAAA,CAAA,EAWZ,CAAA,YAXyB,EAAA,MAWzB,EAAA,GAAA,MAAA;;;;ECGW,MAAA,CAAA,EAAA,GAAA,GAAA,IAAe;EAAA;;;EAAkB,OAAW,CAAA,EAAA,CAAA,GAAA,CAAA,ECErC,KDFqC,EAAA,GAAA,IAAA;EAAC;AAAF;AAEvD;EAA+C,OAAA,CAAA,EAAA,CAAA,KAIzB,CAJyB,EAAA;IAIxC,IAAA,CAAA,EAAA,MAAA;EAAe,CAAA,EAOe,GAAA,IAAA;EAAe;AAAhB;;;;AC5BpC;;;IAiBmB,OAAA,EAAA,OAAA;IA2CM;;AA5DqD;;;;EC4BjE;;;EAKwC,SAA7B,CAAA,EAAA;IAApB;;;IA2GgB,OAAA,EAAA,OAAA;IA0CV;;;;IAAuB,UAAA,CAAA,EAAA,MAAA;IAC7B;;;;IAIa,aAAA,CAAA,EAAA,MAAA;EAAuB,CAAA;EAErC;;;;EAAA,oBAAA,CAAA,EDjIsB,OCiItB;;;;;;;;;;;;AH5LU,cG2BA,QAAA,CH3Ba;;;;ECcd,SAAA,eAAe,EEiBQ,eFjBR,CEkBvB,mBFlBuB,CEkBH,eFlBG,CEkBa,aFlBb,CAAA,CAAA,CAAA;EAAA,QAAA,cAAA;EAAA,QAAM,cAAA;EAAC,iBAAU,gBAAA;EAAC,iBAAW,mBAAA;EAAC,QAAT,iBAAA;EAAO,iBAAA,SAAA;EAEtC,iBAAA,QAAA;EAA8B,iBAAA,OAAA;EAAA,WAIxC,CAAA,IAAA,EE2Ba,sBF3Bb;EAAe;;AAOc;;;;AC5BpC;;;EAI8B,KAaX,CAAA,CAAA,EC2HC,OD3HD,CAAA,IAAA,CAAA;EAAK;;AAjBsD;;;;AC4B9E;;;;EAKuC,OAAnC,CAAA;IAAA,EAAA,EAAA;MAAA,EAAA;MAAA,IAAA;MAAA,IAAA;MAAA,KAAA;MAAA;IAAA,CAAA;IAAA,WAAA;IAAA;EA2GgB,CA3GhB,EAAA;IAD+B,EAAA,EA0J3B,IA1J2B,CA0JtB,SA1JsB,EAAA,IAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,QAAA,CAAA;IAgBf,WAAA,EA2IH,uBA3IG;IA4FA,WAAA,CAAA,EAAA,MAAA;EAAA,CAAA,CAAA,EAiDjB,wBAAA,CAAA,UAPO,CAOP,uBAPO,CAAA,OAAA,EAOP,eAPO,CAOP,aAPO,CAAA,CAAA,EAOP,eAPO,CAOP,aAPO,CAAA,CAAA;EAAE,IAAE,UAAA,CAAA,CAAA,EAAA;IAAM,SAAA,EAAA,EAAA,MAAA;IAAM,SAAA,KAAA,EAAA,MAAA;IAAO,SAAA,EAAA,EAO9B,SAP8B;EAAM,CAAA,GACnC;IACA,SAAA,EAAA,EAAA,MAAA;IAES,SAAA,KAAA,EAAA,QAAA;IAAL,SAAA,EAAA,WAAA;EAAI,CAAA,GACK;IAEd,SAAA,EAAA,EAAA,MAAA;IAAA,SAAA,KAAA,EAAA,YAAA;IAAA,SAAA,EAAA,WAAA;EAAA,CAAA,GAAA,IAAA;EAAA;;;;;;;;;EC3La,QAAA,qBAAc;EAAA;;;EAA6B,QAAA,IAAA;EAI/C;;;;AAAgC;;;;;;iBAJ5B,cAAA,OAAqB,yBAAsB;KAI/C,mBAAA,GAAsB,kBAAkB;;;KCMxC,qCAAqC;UACvC;IACN,mBAAmB,iBAAiB;iBAExB,uBAAuB,iBAC/B,qBAAqB,WAC1B,SAAS"}
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
import { TRPCConnectionState } from "./subscriptions.d-Ciljg_dH.cjs";
|
||||
import { Operation, OperationResultEnvelope, TRPCClientError, TRPCLink } from "./types.d-Dmmedc5G.cjs";
|
||||
import { TransformerOptions } from "./unstable-internals.d-kWsZTlQq.cjs";
|
||||
import { AnyRouter, CombinedDataTransformer, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
||||
import * as _trpc_server_observable0 from "@trpc/server/observable";
|
||||
import { BehaviorSubject } from "@trpc/server/observable";
|
||||
import { AnyTRPCRouter } from "@trpc/server";
|
||||
import { Encoder } from "@trpc/server/adapters/ws";
|
||||
import { TRPCRequestInfo } from "@trpc/server/http";
|
||||
|
||||
//#region src/links/wsLink/wsClient/encoder.d.ts
|
||||
declare const jsonEncoder: Encoder;
|
||||
//# sourceMappingURL=encoder.d.ts.map
|
||||
|
||||
//#endregion
|
||||
//#region src/links/internals/urlWithConnectionParams.d.ts
|
||||
/**
|
||||
* A value that can be wrapped in callback
|
||||
*/
|
||||
type CallbackOrValue<T> = T | (() => T | Promise<T>);
|
||||
interface UrlOptionsWithConnectionParams {
|
||||
/**
|
||||
* The URL to connect to (can be a function that returns a URL)
|
||||
*/
|
||||
url: CallbackOrValue<string>;
|
||||
/**
|
||||
* Connection params that are available in `createContext()`
|
||||
* - For `wsLink`/`wsClient`, these are sent as the first message
|
||||
* - For `httpSubscriptionLink`, these are serialized as part of the URL under the `connectionParams` query
|
||||
*/
|
||||
connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;
|
||||
}
|
||||
//# sourceMappingURL=urlWithConnectionParams.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/options.d.ts
|
||||
interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
|
||||
/**
|
||||
* Ponyfill which WebSocket implementation to use
|
||||
*/
|
||||
WebSocket?: typeof WebSocket;
|
||||
/**
|
||||
* The number of milliseconds before a reconnect is attempted.
|
||||
* @default {@link exponentialBackoff}
|
||||
*/
|
||||
retryDelayMs?: (attemptIndex: number) => number;
|
||||
/**
|
||||
* Triggered when a WebSocket connection is established
|
||||
*/
|
||||
onOpen?: () => void;
|
||||
/**
|
||||
* Triggered when a WebSocket connection encounters an error
|
||||
*/
|
||||
onError?: (evt?: Event) => void;
|
||||
/**
|
||||
* Triggered when a WebSocket connection is closed
|
||||
*/
|
||||
onClose?: (cause?: {
|
||||
code?: number;
|
||||
}) => void;
|
||||
/**
|
||||
* Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
|
||||
*/
|
||||
lazy?: {
|
||||
/**
|
||||
* Enable lazy mode
|
||||
* @default false
|
||||
*/
|
||||
enabled: boolean;
|
||||
/**
|
||||
* Close the WebSocket after this many milliseconds
|
||||
* @default 0
|
||||
*/
|
||||
closeMs: number;
|
||||
};
|
||||
/**
|
||||
* Send ping messages to the server and kill the connection if no pong message is returned
|
||||
*/
|
||||
keepAlive?: {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
enabled: boolean;
|
||||
/**
|
||||
* Send a ping message every this many milliseconds
|
||||
* @default 5_000
|
||||
*/
|
||||
intervalMs?: number;
|
||||
/**
|
||||
* Close the WebSocket after this many milliseconds if the server does not respond
|
||||
* @default 1_000
|
||||
*/
|
||||
pongTimeoutMs?: number;
|
||||
};
|
||||
/**
|
||||
* Custom encoder for wire encoding (e.g. custom binary formats)
|
||||
* @default jsonEncoder
|
||||
*/
|
||||
experimental_encoder?: Encoder;
|
||||
}
|
||||
/**
|
||||
* Default options for lazy WebSocket connections.
|
||||
* Determines whether the connection should be established lazily and defines the delay before closure.
|
||||
*/
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsClient/wsClient.d.ts
|
||||
/**
|
||||
* A WebSocket client for managing TRPC operations, supporting lazy initialization,
|
||||
* reconnection, keep-alive, and request management.
|
||||
*/
|
||||
declare class WsClient {
|
||||
/**
|
||||
* Observable tracking the current connection state, including errors.
|
||||
*/
|
||||
readonly connectionState: BehaviorSubject<TRPCConnectionState<TRPCClientError<AnyTRPCRouter>>>;
|
||||
private allowReconnect;
|
||||
private requestManager;
|
||||
private readonly activeConnection;
|
||||
private readonly reconnectRetryDelay;
|
||||
private inactivityTimeout;
|
||||
private readonly callbacks;
|
||||
private readonly lazyMode;
|
||||
private readonly encoder;
|
||||
constructor(opts: WebSocketClientOptions);
|
||||
/**
|
||||
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
||||
* the connection state accordingly.
|
||||
*/
|
||||
private open;
|
||||
/**
|
||||
* Closes the WebSocket connection and stops managing requests.
|
||||
* Ensures all outgoing and pending requests are properly finalized.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Method to request the server.
|
||||
* Handles data transformation, batching of requests, and subscription lifecycle.
|
||||
*
|
||||
* @param op - The operation details including id, type, path, input and signal
|
||||
* @param transformer - Data transformer for serializing requests and deserializing responses
|
||||
* @param lastEventId - Optional ID of the last received event for subscriptions
|
||||
*
|
||||
* @returns An observable that emits operation results and handles cleanup
|
||||
*/
|
||||
request({
|
||||
op: {
|
||||
id,
|
||||
type,
|
||||
path,
|
||||
input,
|
||||
signal
|
||||
},
|
||||
transformer,
|
||||
lastEventId
|
||||
}: {
|
||||
op: Pick<Operation, 'id' | 'type' | 'path' | 'input' | 'signal'>;
|
||||
transformer: CombinedDataTransformer;
|
||||
lastEventId?: string;
|
||||
}): _trpc_server_observable0.Observable<OperationResultEnvelope<unknown, TRPCClientError<AnyTRPCRouter>>, TRPCClientError<AnyTRPCRouter>>;
|
||||
get connection(): {
|
||||
readonly id: number;
|
||||
readonly state: "open";
|
||||
readonly ws: WebSocket;
|
||||
} | {
|
||||
readonly id: number;
|
||||
readonly state: "closed";
|
||||
readonly ws: WebSocket;
|
||||
} | {
|
||||
readonly id: number;
|
||||
readonly state: "connecting";
|
||||
readonly ws: WebSocket;
|
||||
} | null;
|
||||
/**
|
||||
* Manages the reconnection process for the WebSocket using retry logic.
|
||||
* Ensures that only one reconnection attempt is active at a time by tracking the current
|
||||
* reconnection state in the `reconnecting` promise.
|
||||
*/
|
||||
private reconnecting;
|
||||
private reconnect;
|
||||
private setupWebSocketListeners;
|
||||
private handleResponseMessage;
|
||||
private handleIncomingRequest;
|
||||
/**
|
||||
* Sends a message or batch of messages directly to the server.
|
||||
*/
|
||||
private send;
|
||||
/**
|
||||
* Groups requests for batch sending.
|
||||
*
|
||||
* @returns A function to abort the batched request.
|
||||
*/
|
||||
private batchSend;
|
||||
}
|
||||
//# sourceMappingURL=wsClient.d.ts.map
|
||||
//#endregion
|
||||
//#region src/links/wsLink/createWsClient.d.ts
|
||||
declare function createWSClient(opts: WebSocketClientOptions): WsClient;
|
||||
type TRPCWebSocketClient = ReturnType<typeof createWSClient>;
|
||||
//#endregion
|
||||
//#region src/links/wsLink/wsLink.d.ts
|
||||
type WebSocketLinkOptions<TRouter extends AnyRouter> = {
|
||||
client: TRPCWebSocketClient;
|
||||
} & TransformerOptions<inferClientTypes<TRouter>>;
|
||||
declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TRouter>): TRPCLink<TRouter>;
|
||||
//#endregion
|
||||
export { Encoder, TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, jsonEncoder, wsLink };
|
||||
//# sourceMappingURL=wsLink.d-DzZZZGZQ.d.cts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"wsLink.d-DzZZZGZQ.d.cts","names":[],"sources":["../src/links/wsLink/wsClient/encoder.ts","../src/links/internals/urlWithConnectionParams.ts","../src/links/wsLink/wsClient/options.ts","../src/links/wsLink/wsClient/wsClient.ts","../src/links/wsLink/createWsClient.ts","../src/links/wsLink/wsLink.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAIa,aAAa;;;;;;;;KCcd,qBAAqB,WAAW,IAAI,QAAQ;UAEvC,8BAAA;EDhBJ;;;OCoBN;EANK;;;;;EAA6C,gBAAT,CAAA,EAa3B,eAb2B,CAaX,eAbW,CAAA,kBAAA,CAAA,CAAA;AAAO;AAEvD;;;UCjBiB,sBAAA,SAA+B;;;;qBAI3B;;;;;EFHR,YAAA,CAAA,EAWZ,CAAA,YAXyB,EAAA,MAWzB,EAAA,GAAA,MAAA;;;;ECGW,MAAA,CAAA,EAAA,GAAA,GAAA,IAAe;EAAA;;;EAAkB,OAAW,CAAA,EAAA,CAAA,GAAA,CAAA,ECErC,KDFqC,EAAA,GAAA,IAAA;EAAC;AAAF;AAEvD;EAA+C,OAAA,CAAA,EAAA,CAAA,KAIzB,CAJyB,EAAA;IAIxC,IAAA,CAAA,EAAA,MAAA;EAAe,CAAA,EAOe,GAAA,IAAA;EAAe;AAAhB;;;;AC5BpC;;;IAiBmB,OAAA,EAAA,OAAA;IA2CM;;AA5DqD;;;;EC4BjE;;;EAKwC,SAA7B,CAAA,EAAA;IAApB;;;IA2GgB,OAAA,EAAA,OAAA;IA0CV;;;;IAAuB,UAAA,CAAA,EAAA,MAAA;IAC7B;;;;IAIa,aAAA,CAAA,EAAA,MAAA;EAAuB,CAAA;EAErC;;;;EAAA,oBAAA,CAAA,EDjIsB,OCiItB;;;;;;;;;;;;AH5LU,cG2BA,QAAA,CH3Ba;;;;ECcd,SAAA,eAAe,EEiBQ,eFjBR,CEkBvB,mBFlBuB,CEkBH,eFlBG,CEkBa,aFlBb,CAAA,CAAA,CAAA;EAAA,QAAA,cAAA;EAAA,QAAM,cAAA;EAAC,iBAAU,gBAAA;EAAC,iBAAW,mBAAA;EAAC,QAAT,iBAAA;EAAO,iBAAA,SAAA;EAEtC,iBAAA,QAAA;EAA8B,iBAAA,OAAA;EAAA,WAIxC,CAAA,IAAA,EE2Ba,sBF3Bb;EAAe;;AAOc;;;;AC5BpC;;;EAI8B,KAaX,CAAA,CAAA,EC2HC,OD3HD,CAAA,IAAA,CAAA;EAAK;;AAjBsD;;;;AC4B9E;;;;EAKuC,OAAnC,CAAA;IAAA,EAAA,EAAA;MAAA,EAAA;MAAA,IAAA;MAAA,IAAA;MAAA,KAAA;MAAA;IAAA,CAAA;IAAA,WAAA;IAAA;EA2GgB,CA3GhB,EAAA;IAD+B,EAAA,EA0J3B,IA1J2B,CA0JtB,SA1JsB,EAAA,IAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,QAAA,CAAA;IAgBf,WAAA,EA2IH,uBA3IG;IA4FA,WAAA,CAAA,EAAA,MAAA;EAAA,CAAA,CAAA,EAiDjB,wBAAA,CAAA,UAPO,CAOP,uBAPO,CAAA,OAAA,EAOP,eAPO,CAOP,aAPO,CAAA,CAAA,EAOP,eAPO,CAOP,aAPO,CAAA,CAAA;EAAE,IAAE,UAAA,CAAA,CAAA,EAAA;IAAM,SAAA,EAAA,EAAA,MAAA;IAAM,SAAA,KAAA,EAAA,MAAA;IAAO,SAAA,EAAA,EAO9B,SAP8B;EAAM,CAAA,GACnC;IACA,SAAA,EAAA,EAAA,MAAA;IAES,SAAA,KAAA,EAAA,QAAA;IAAL,SAAA,EAAA,WAAA;EAAI,CAAA,GACK;IAEd,SAAA,EAAA,EAAA,MAAA;IAAA,SAAA,KAAA,EAAA,YAAA;IAAA,SAAA,EAAA,WAAA;EAAA,CAAA,GAAA,IAAA;EAAA;;;;;;;;;EC3La,QAAA,qBAAc;EAAA;;;EAA6B,QAAA,IAAA;EAI/C;;;;AAAgC;;;;;;iBAJ5B,cAAA,OAAqB,yBAAsB;KAI/C,mBAAA,GAAsB,kBAAkB;;;KCMxC,qCAAqC;UACvC;IACN,mBAAmB,iBAAiB;iBAExB,uBAAuB,iBAC/B,qBAAqB,WAC1B,SAAS"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"main":"../../dist/links/httpBatchLink.cjs","module":"../../dist/links/httpBatchLink.mjs","types":"../../dist/links/httpBatchLink.d.cts"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"main":"../../dist/links/httpLink.cjs","module":"../../dist/links/httpLink.mjs","types":"../../dist/links/httpLink.d.cts"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user