@rpcbase/server 0.531.0 → 0.533.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 +68 -24
- package/dist/index.js.map +1 -1
- package/dist/{queryExecutor-DYVlCvns.js → queryExecutor-JadZcQSQ.js} +29 -6
- package/dist/queryExecutor-JadZcQSQ.js.map +1 -0
- package/dist/rts/index.d.ts.map +1 -1
- package/dist/rts/index.js +261 -61
- package/dist/rts/index.js.map +1 -1
- package/dist/rts/queryExecutor.d.ts +7 -0
- package/dist/rts/queryExecutor.d.ts.map +1 -1
- package/dist/rts/ssrHydration.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/queryExecutor-DYVlCvns.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __commonJSMin, r as __toESM, t as sendEmail } from "./email-Dzauaq11.js";
|
|
2
|
-
import { a as normalizeRtsQueryOptions, c as
|
|
2
|
+
import { a as normalizeRtsQueryOptions, c as runRtsCount, i as isRtsRequestAuthorized, l as runRtsQuery, r as buildRtsAbilityFromRequest, s as resolveRtsRequestTenantId, u as getDerivedKey } from "./queryExecutor-JadZcQSQ.js";
|
|
3
3
|
import session from "express-session";
|
|
4
4
|
import { RedisStore } from "connect-redis";
|
|
5
5
|
import MongoStore from "connect-mongo";
|
|
@@ -220,6 +220,20 @@ var parsePayload = (response) => {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
//#endregion
|
|
223
|
+
//#region ../../node_modules/@posthog/core/dist/gzip.mjs
|
|
224
|
+
function isGzipSupported() {
|
|
225
|
+
return "CompressionStream" in globalThis;
|
|
226
|
+
}
|
|
227
|
+
async function gzipCompress(input, isDebug = true) {
|
|
228
|
+
try {
|
|
229
|
+
const compressedStream = new Blob([input], { type: "text/plain" }).stream().pipeThrough(new CompressionStream("gzip"));
|
|
230
|
+
return await new Response(compressedStream).blob();
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (isDebug) console.error("Failed to gzip compress data", error);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
223
237
|
//#region ../../node_modules/@posthog/core/dist/vendor/uuidv7.mjs
|
|
224
238
|
/*! For license information please see uuidv7.mjs.LICENSE.txt */
|
|
225
239
|
/**
|
|
@@ -764,20 +778,6 @@ var SimpleEventEmitter = class {
|
|
|
764
778
|
}
|
|
765
779
|
};
|
|
766
780
|
//#endregion
|
|
767
|
-
//#region ../../node_modules/@posthog/core/dist/gzip.mjs
|
|
768
|
-
function isGzipSupported() {
|
|
769
|
-
return "CompressionStream" in globalThis;
|
|
770
|
-
}
|
|
771
|
-
async function gzipCompress(input, isDebug = true) {
|
|
772
|
-
try {
|
|
773
|
-
const compressedStream = new Blob([input], { type: "text/plain" }).stream().pipeThrough(new CompressionStream("gzip"));
|
|
774
|
-
return await new Response(compressedStream).blob();
|
|
775
|
-
} catch (error) {
|
|
776
|
-
if (isDebug) console.error("Failed to gzip compress data", error);
|
|
777
|
-
return null;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
//#endregion
|
|
781
781
|
//#region ../../node_modules/@posthog/core/dist/posthog-core-stateless.mjs
|
|
782
782
|
var PostHogFetchHttpError = class extends Error {
|
|
783
783
|
constructor(response, reqByteLength) {
|
|
@@ -2040,12 +2040,11 @@ var ErrorTracking = class ErrorTracking {
|
|
|
2040
2040
|
}
|
|
2041
2041
|
static async buildEventMessage(error, hint, distinctId, additionalProperties) {
|
|
2042
2042
|
const properties = { ...additionalProperties };
|
|
2043
|
-
if (!distinctId) properties.$process_person_profile = false;
|
|
2044
2043
|
const exceptionProperties = this.errorPropertiesBuilder.buildFromUnknown(error, hint);
|
|
2045
2044
|
exceptionProperties.$exception_list = await this.errorPropertiesBuilder.modifyFrames(exceptionProperties.$exception_list);
|
|
2046
2045
|
return {
|
|
2047
2046
|
event: "$exception",
|
|
2048
|
-
distinctId
|
|
2047
|
+
distinctId,
|
|
2049
2048
|
properties: {
|
|
2050
2049
|
...exceptionProperties,
|
|
2051
2050
|
...properties
|
|
@@ -2083,7 +2082,7 @@ var ErrorTracking = class ErrorTracking {
|
|
|
2083
2082
|
};
|
|
2084
2083
|
//#endregion
|
|
2085
2084
|
//#region ../../node_modules/posthog-node/dist/version.mjs
|
|
2086
|
-
var version = "5.28.
|
|
2085
|
+
var version = "5.28.7";
|
|
2087
2086
|
//#endregion
|
|
2088
2087
|
//#region ../../node_modules/posthog-node/dist/types.mjs
|
|
2089
2088
|
var FeatureFlagError = {
|
|
@@ -4611,9 +4610,11 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4611
4610
|
const maxDocsPerQuery = typeof opts?.maxDocsPerQuery === "number" && opts.maxDocsPerQuery > 0 ? Math.floor(opts.maxDocsPerQuery) : DEFAULT_MAX_DOCS_PER_QUERY;
|
|
4612
4611
|
const maxSerializedBytes = typeof opts?.maxSerializedBytes === "number" && opts.maxSerializedBytes > 0 ? Math.floor(opts.maxSerializedBytes) : DEFAULT_MAX_SERIALIZED_BYTES;
|
|
4613
4612
|
const registrations = /* @__PURE__ */ new Map();
|
|
4613
|
+
const countRegistrations = /* @__PURE__ */ new Map();
|
|
4614
4614
|
const resolved = /* @__PURE__ */ new Map();
|
|
4615
4615
|
const resolvedPageInfo = /* @__PURE__ */ new Map();
|
|
4616
4616
|
const resolvedTotalCount = /* @__PURE__ */ new Map();
|
|
4617
|
+
const resolvedCounts = /* @__PURE__ */ new Map();
|
|
4617
4618
|
const runtime = {
|
|
4618
4619
|
registerQuery(query) {
|
|
4619
4620
|
const modelName = typeof query.modelName === "string" ? query.modelName.trim() : "";
|
|
@@ -4621,7 +4622,7 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4621
4622
|
if (!modelName || !queryKey) return;
|
|
4622
4623
|
const key = makeRegistrationKey(modelName, queryKey);
|
|
4623
4624
|
if (registrations.has(key)) return;
|
|
4624
|
-
if (registrations.size >= maxQueries) return;
|
|
4625
|
+
if (registrations.size + countRegistrations.size >= maxQueries) return;
|
|
4625
4626
|
registrations.set(key, {
|
|
4626
4627
|
modelName,
|
|
4627
4628
|
queryKey,
|
|
@@ -4629,6 +4630,20 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4629
4630
|
options: query.options ?? {}
|
|
4630
4631
|
});
|
|
4631
4632
|
},
|
|
4633
|
+
registerCount(query) {
|
|
4634
|
+
const modelName = typeof query.modelName === "string" ? query.modelName.trim() : "";
|
|
4635
|
+
const queryKey = typeof query.queryKey === "string" ? query.queryKey.trim() : "";
|
|
4636
|
+
if (!modelName || !queryKey) return;
|
|
4637
|
+
const key = makeRegistrationKey(modelName, queryKey);
|
|
4638
|
+
if (countRegistrations.has(key)) return;
|
|
4639
|
+
if (registrations.size + countRegistrations.size >= maxQueries) return;
|
|
4640
|
+
countRegistrations.set(key, {
|
|
4641
|
+
modelName,
|
|
4642
|
+
queryKey,
|
|
4643
|
+
query: query.query ?? {},
|
|
4644
|
+
options: query.options ?? {}
|
|
4645
|
+
});
|
|
4646
|
+
},
|
|
4632
4647
|
getQueryData(modelName, queryKey) {
|
|
4633
4648
|
return resolved.get(makeRegistrationKey(modelName, queryKey));
|
|
4634
4649
|
},
|
|
@@ -4637,15 +4652,19 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4637
4652
|
},
|
|
4638
4653
|
getQueryTotalCount(modelName, queryKey) {
|
|
4639
4654
|
return resolvedTotalCount.get(makeRegistrationKey(modelName, queryKey));
|
|
4655
|
+
},
|
|
4656
|
+
getCount(modelName, queryKey) {
|
|
4657
|
+
return resolvedCounts.get(makeRegistrationKey(modelName, queryKey));
|
|
4640
4658
|
}
|
|
4641
4659
|
};
|
|
4642
4660
|
const resolve = async () => {
|
|
4643
|
-
if (!registrations.size) return null;
|
|
4661
|
+
if (!registrations.size && !countRegistrations.size) return null;
|
|
4644
4662
|
const tenantId = resolveRtsRequestTenantId(req);
|
|
4645
4663
|
if (!tenantId) return null;
|
|
4646
4664
|
if (hasSessionUser(req) && !isRtsRequestAuthorized(req, tenantId)) return null;
|
|
4647
4665
|
const { ability, userId } = await buildRtsAbilityFromRequest(req, tenantId);
|
|
4648
4666
|
const queryEntries = [];
|
|
4667
|
+
const countEntries = [];
|
|
4649
4668
|
for (const registration of registrations.values()) {
|
|
4650
4669
|
const options = normalizeRtsQueryOptions(registration.options);
|
|
4651
4670
|
try {
|
|
@@ -4668,12 +4687,28 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4668
4687
|
continue;
|
|
4669
4688
|
}
|
|
4670
4689
|
}
|
|
4671
|
-
|
|
4690
|
+
for (const registration of countRegistrations.values()) try {
|
|
4691
|
+
const count = await runRtsCount({
|
|
4692
|
+
tenantId,
|
|
4693
|
+
ability,
|
|
4694
|
+
modelName: registration.modelName,
|
|
4695
|
+
query: registration.query
|
|
4696
|
+
});
|
|
4697
|
+
countEntries.push({
|
|
4698
|
+
modelName: registration.modelName,
|
|
4699
|
+
queryKey: registration.queryKey,
|
|
4700
|
+
count
|
|
4701
|
+
});
|
|
4702
|
+
} catch {
|
|
4703
|
+
continue;
|
|
4704
|
+
}
|
|
4705
|
+
if (!queryEntries.length && !countEntries.length) return null;
|
|
4672
4706
|
const payload = {
|
|
4673
4707
|
v: 1,
|
|
4674
4708
|
tenantId,
|
|
4675
4709
|
uid: userId,
|
|
4676
|
-
queries: []
|
|
4710
|
+
queries: [],
|
|
4711
|
+
counts: []
|
|
4677
4712
|
};
|
|
4678
4713
|
for (const entry of queryEntries) {
|
|
4679
4714
|
payload.queries.push(entry);
|
|
@@ -4682,19 +4717,28 @@ var createRtsSsrCollector = (req, opts) => {
|
|
|
4682
4717
|
break;
|
|
4683
4718
|
}
|
|
4684
4719
|
}
|
|
4720
|
+
for (const entry of countEntries) {
|
|
4721
|
+
payload.counts.push(entry);
|
|
4722
|
+
if (Buffer.byteLength(JSON.stringify(payload), "utf8") > maxSerializedBytes) {
|
|
4723
|
+
payload.counts.pop();
|
|
4724
|
+
break;
|
|
4725
|
+
}
|
|
4726
|
+
}
|
|
4685
4727
|
const serializedPayload = toSerializedHydrationPayload(payload);
|
|
4686
|
-
if (!serializedPayload
|
|
4728
|
+
if (!serializedPayload || !serializedPayload.queries.length && !serializedPayload.counts.length) return null;
|
|
4687
4729
|
resolved.clear();
|
|
4688
4730
|
resolvedPageInfo.clear();
|
|
4689
4731
|
resolvedTotalCount.clear();
|
|
4732
|
+
resolvedCounts.clear();
|
|
4690
4733
|
for (const entry of serializedPayload.queries) {
|
|
4691
4734
|
resolved.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.data);
|
|
4692
4735
|
resolvedPageInfo.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.pageInfo);
|
|
4693
4736
|
resolvedTotalCount.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.totalCount);
|
|
4694
4737
|
}
|
|
4738
|
+
for (const entry of serializedPayload.counts) resolvedCounts.set(makeRegistrationKey(entry.modelName, entry.queryKey), entry.count);
|
|
4695
4739
|
return serializedPayload;
|
|
4696
4740
|
};
|
|
4697
|
-
const hasRegistrations = () => registrations.size > 0;
|
|
4741
|
+
const hasRegistrations = () => registrations.size > 0 || countRegistrations.size > 0;
|
|
4698
4742
|
return {
|
|
4699
4743
|
runtime,
|
|
4700
4744
|
hasRegistrations,
|