@rpcbase/server 0.518.0 → 0.520.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { dirname, posix, sep } from "path";
9
9
  import fs, { createReadStream, readFileSync } from "node:fs";
10
10
  import { createInterface } from "node:readline";
11
11
  import { AsyncLocalStorage } from "node:async_hooks";
12
- import { g as getDerivedKey, r as resolveRtsRequestTenantId, i as isRtsRequestAuthorized, b as buildRtsAbilityFromRequest, n as normalizeRtsQueryOptions, a as runRtsQuery } from "./queryExecutor-B7lb2FR1.js";
12
+ import { g as getDerivedKey, r as resolveRtsRequestTenantId, i as isRtsRequestAuthorized, b as buildRtsAbilityFromRequest, n as normalizeRtsQueryOptions, a as runRtsQuery } from "./queryExecutor-Bg1GGL3j.js";
13
13
  import httpProxy from "http-proxy-3";
14
14
  import fsPromises from "node:fs/promises";
15
15
  import inspector from "node:inspector";
@@ -4563,6 +4563,13 @@ const hasSessionUser = (req) => {
4563
4563
  const escapeForInlineScript = (value) => {
4564
4564
  return value.replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
4565
4565
  };
4566
+ const toSerializedHydrationPayload = (payload) => {
4567
+ try {
4568
+ return JSON.parse(JSON.stringify(payload));
4569
+ } catch {
4570
+ return null;
4571
+ }
4572
+ };
4566
4573
  const createRtsSsrCollector = (req, opts) => {
4567
4574
  const maxQueries = DEFAULT_MAX_QUERIES;
4568
4575
  const maxDocsPerQuery = DEFAULT_MAX_DOCS_PER_QUERY;
@@ -4570,6 +4577,7 @@ const createRtsSsrCollector = (req, opts) => {
4570
4577
  const registrations = /* @__PURE__ */ new Map();
4571
4578
  const resolved = /* @__PURE__ */ new Map();
4572
4579
  const resolvedPageInfo = /* @__PURE__ */ new Map();
4580
+ const resolvedTotalCount = /* @__PURE__ */ new Map();
4573
4581
  const runtime = {
4574
4582
  registerQuery(query) {
4575
4583
  const modelName = typeof query.modelName === "string" ? query.modelName.trim() : "";
@@ -4590,6 +4598,9 @@ const createRtsSsrCollector = (req, opts) => {
4590
4598
  },
4591
4599
  getQueryPageInfo(modelName, queryKey) {
4592
4600
  return resolvedPageInfo.get(makeRegistrationKey(modelName, queryKey));
4601
+ },
4602
+ getQueryTotalCount(modelName, queryKey) {
4603
+ return resolvedTotalCount.get(makeRegistrationKey(modelName, queryKey));
4593
4604
  }
4594
4605
  };
4595
4606
  const resolve = async () => {
@@ -4621,6 +4632,9 @@ const createRtsSsrCollector = (req, opts) => {
4621
4632
  data: boundedData,
4622
4633
  ...result.pageInfo ? {
4623
4634
  pageInfo: result.pageInfo
4635
+ } : {},
4636
+ ...typeof result.totalCount === "number" ? {
4637
+ totalCount: result.totalCount
4624
4638
  } : {}
4625
4639
  });
4626
4640
  } catch {
@@ -4642,13 +4656,17 @@ const createRtsSsrCollector = (req, opts) => {
4642
4656
  break;
4643
4657
  }
4644
4658
  }
4659
+ const serializedPayload = toSerializedHydrationPayload(payload);
4660
+ if (!serializedPayload?.queries.length) return null;
4645
4661
  resolved.clear();
4646
4662
  resolvedPageInfo.clear();
4647
- for (const entry of payload.queries) {
4663
+ resolvedTotalCount.clear();
4664
+ for (const entry of serializedPayload.queries) {
4648
4665
  resolved.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.data);
4649
4666
  resolvedPageInfo.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.pageInfo);
4667
+ resolvedTotalCount.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.totalCount);
4650
4668
  }
4651
- return payload.queries.length ? payload : null;
4669
+ return serializedPayload;
4652
4670
  };
4653
4671
  const hasRegistrations = () => registrations.size > 0;
4654
4672
  return {