@rpcbase/server 0.582.0 → 0.584.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import { Request, RequestHandler } from 'express';
2
+ export declare const isDevelopmentAssetRequest: (req: Request) => boolean;
3
+ export declare const developmentSessionMiddleware: (sessionMiddleware: RequestHandler) => RequestHandler;
4
+ //# sourceMappingURL=developmentSessionMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"developmentSessionMiddleware.d.ts","sourceRoot":"","sources":["../src/developmentSessionMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAwCpD,eAAO,MAAM,yBAAyB,GAAI,KAAK,OAAO,KAAG,OAQxD,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI,mBAAmB,cAAc,KAAG,cAShF,CAAA"}
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { posix, dirname, sep, isAbsolute, relative } from "path";
10
10
  import fs, { createReadStream, readFileSync } from "node:fs";
11
11
  import { createInterface } from "node:readline";
12
12
  import { AsyncLocalStorage } from "node:async_hooks";
13
- import { g as getDerivedKey, s as syncAuthenticatedSessionMiddleware, r as resolveRtsRequestTenantId, i as isRtsRequestAuthorized, b as buildRtsAbilityFromRequest, n as normalizeRtsQueryOptions, a as runRtsQuery, c as runRtsCount } from "./queryExecutor-DW7iAdRY.js";
13
+ import { g as getDerivedKey, s as syncAuthenticatedSessionMiddleware, r as resolveRtsRequestTenantId, i as isRtsRequestAuthorized, b as buildRtsAbilityFromRequest, n as normalizeRtsQueryOptions, a as runRtsQuery, R as RTS_QUERY_WINDOW_MAX_COUNT, c as runRtsCount } from "./queryWindow-Cdr7K-S1.js";
14
14
  import httpProxy from "http-proxy-3";
15
15
  import fsPromises from "node:fs/promises";
16
16
  import inspector from "node:inspector";
@@ -4254,6 +4254,32 @@ function registerDevCoverageEndpoints(app) {
4254
4254
  }
4255
4255
  });
4256
4256
  }
4257
+ const vitePathPrefixes = ["/@fs", "/@id", "/@react-refresh", "/@vite", "/node_modules", "/src"];
4258
+ const assetDestinations = /* @__PURE__ */ new Set(["audio", "audioworklet", "embed", "font", "image", "manifest", "object", "paintworklet", "script", "serviceworker", "sharedworker", "style", "track", "video", "worker", "xslt"]);
4259
+ const isPathAtOrBelow = (requestPath, prefix) => {
4260
+ return requestPath === prefix || requestPath.startsWith(`${prefix}/`);
4261
+ };
4262
+ const getHeader = (req, name) => {
4263
+ const value = req.headers[name];
4264
+ return Array.isArray(value) ? value[0] ?? "" : value ?? "";
4265
+ };
4266
+ const isDevelopmentAssetRequest = (req) => {
4267
+ if (req.method !== "GET" && req.method !== "HEAD") return false;
4268
+ if (isPathAtOrBelow(req.path, "/api")) return false;
4269
+ if (getHeader(req, "accept") === "text/x-vite-ping") return true;
4270
+ if (vitePathPrefixes.some((prefix) => isPathAtOrBelow(req.path, prefix))) return true;
4271
+ const destination = getHeader(req, "sec-fetch-dest").toLowerCase();
4272
+ return assetDestinations.has(destination) && path.posix.extname(req.path) !== "";
4273
+ };
4274
+ const developmentSessionMiddleware = (sessionMiddleware) => {
4275
+ return (req, res, next) => {
4276
+ if (isDevelopmentAssetRequest(req)) {
4277
+ next();
4278
+ return;
4279
+ }
4280
+ sessionMiddleware(req, res, next);
4281
+ };
4282
+ };
4257
4283
  process.env = {
4258
4284
  ...env,
4259
4285
  ...__rb_env__,
@@ -4377,7 +4403,7 @@ const initServer = async (app, serverEnv) => {
4377
4403
  if (!isProduction$1) {
4378
4404
  registerDevCoverageEndpoints(app);
4379
4405
  }
4380
- app.use(sessionMiddleware);
4406
+ app.use(isProduction$1 ? sessionMiddleware : developmentSessionMiddleware(sessionMiddleware));
4381
4407
  app.use(syncAuthenticatedSessionMiddleware);
4382
4408
  return {
4383
4409
  sessionMiddleware
@@ -5021,7 +5047,11 @@ const createRtsSsrCollector = (req, opts) => {
5021
5047
  ability,
5022
5048
  modelName: registration.modelName,
5023
5049
  query: registration.query,
5024
- options
5050
+ options,
5051
+ ...options.pagination ? {
5052
+ paginationMaxLimit: RTS_QUERY_WINDOW_MAX_COUNT,
5053
+ includePaginationCursors: false
5054
+ } : {}
5025
5055
  });
5026
5056
  const boundedData = maxDocsPerQuery > 0 ? result.data.slice(0, maxDocsPerQuery) : result.data;
5027
5057
  queryEntries.push({