@classytic/mongokit 3.19.0 → 3.21.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/{PaginationEngine-BcvaXBQ-.mjs → PaginationEngine-BT1ywu9k.mjs} +327 -6
- package/dist/{PaginationEngine-4SjzfBQE.d.mts → PaginationEngine-DYpOD2wY.d.mts} +1 -2
- package/dist/{Repository-B01VW_fU.mjs → Repository-dbbgOGjK.mjs} +85 -11
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +2 -2
- package/dist/adapter/index.d.mts +27 -12
- package/dist/adapter/index.mjs +1 -1
- package/dist/{adapter-BSxhT0Ip.mjs → adapter-rTPLUrAV.mjs} +12 -2
- package/dist/ai/index.d.mts +1 -2
- package/dist/ai/index.mjs +3 -2
- package/dist/better-auth/index.d.mts +0 -1
- package/dist/better-auth/index.mjs +2 -2
- package/dist/{create-repository-K0yft2ht.d.mts → create-repository-0TkQhcv-.d.mts} +107 -13
- package/dist/{create-repository-D5YX0wGs.mjs → create-repository-CJATiAKX.mjs} +2 -2
- package/dist/{id-resolution-CnN0YA8t.mjs → id-resolution-P2OzcyRl.mjs} +10 -5
- package/dist/{index-BgSBwlWu.d.mts → index-Cg3SWugF.d.mts} +1 -3
- package/dist/index.d.mts +9 -10
- package/dist/index.mjs +52 -13
- package/dist/lock/index.d.mts +0 -1
- package/dist/memory-cache-DI1jb4dz.mjs +67 -0
- package/dist/{mongooseToJsonSchema-ChtXSrLT.mjs → mongooseToJsonSchema-CVnrKFDq.mjs} +2 -68
- package/dist/{mongooseToJsonSchema-Bz47aMfH.d.mts → mongooseToJsonSchema-D2CyAMIC.d.mts} +9 -5
- package/dist/{multi-tenant.plugin-D6lw3BsI.d.mts → multi-tenant.plugin-CTsWz0XK.d.mts} +1 -2
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +1 -1
- package/dist/plugins/index.d.mts +3 -4
- package/dist/plugins/index.mjs +2 -2
- package/dist/query/primitives/coercion.d.mts +1 -1
- package/dist/query/primitives/coercion.mjs +1 -1
- package/dist/query/primitives/geo.d.mts +1 -1
- package/dist/query/primitives/indexes.d.mts +1 -1
- package/dist/testkit/index.d.mts +1 -2
- package/dist/testkit/index.mjs +1 -1
- package/dist/{timestamp.plugin-B1A9U-P7.mjs → timestamp.plugin-nG9Z1JEk.mjs} +4 -4
- package/dist/{types-BA8oXjFe.d.mts → types-DNFMofHy.d.mts} +51 -22
- package/dist/{update-CvCMv5Cl.mjs → update-1Lq9OMD2.mjs} +5 -5
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +6 -5
- package/dist/{validation-chain.plugin-DHZbpb4t.mjs → validation-chain.plugin-Dn_wZYLA.mjs} +6 -6
- package/dist/{validation-chain.plugin-CYOPfFGF.d.mts → validation-chain.plugin-buy3uvyk.d.mts} +1 -2
- package/package.json +8 -7
- package/dist/cursor-_SbWVAn-.mjs +0 -254
- package/dist/sort-Ca1BPfvE.mjs +0 -72
- /package/dist/{coercion-BxxHyLjP.d.mts → coercion-BjdPX3YF.d.mts} +0 -0
- /package/dist/{error-BTeepSNL.mjs → error-BuByZwKU.mjs} +0 -0
- /package/dist/{field-selection-d1qdRiMr.mjs → field-selection-FSQFLpsU.mjs} +0 -0
- /package/dist/{indexes-3eHBWNZ2.d.mts → indexes-DIjMpYES.d.mts} +0 -0
- /package/dist/{logger-B8wf-Mtb.mjs → logger-K7dPmu2U.mjs} +0 -0
- /package/dist/{chunk-CfYAbeIz.mjs → rolldown-runtime-D7D4PA-g.mjs} +0 -0
package/dist/sort-Ca1BPfvE.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
|
-
//#region src/pagination/utils/sort.ts
|
|
3
|
-
var sort_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
-
getPrimaryField: () => getPrimaryField,
|
|
5
|
-
normalizeSort: () => normalizeSort,
|
|
6
|
-
validateKeysetSort: () => validateKeysetSort
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* Normalizes sort object to ensure stable key order
|
|
10
|
-
* Primary fields first, _id last (not alphabetical)
|
|
11
|
-
*
|
|
12
|
-
* @param sort - Sort specification
|
|
13
|
-
* @returns Normalized sort with stable key order
|
|
14
|
-
*/
|
|
15
|
-
function normalizeSort(sort) {
|
|
16
|
-
const normalized = {};
|
|
17
|
-
Object.keys(sort).forEach((key) => {
|
|
18
|
-
if (key !== "_id") normalized[key] = sort[key];
|
|
19
|
-
});
|
|
20
|
-
if (sort._id !== void 0) normalized._id = sort._id;
|
|
21
|
-
return normalized;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Validates and normalizes sort for keyset pagination.
|
|
25
|
-
* Auto-adds `_id` tie-breaker if needed; ensures `_id` direction matches the
|
|
26
|
-
* primary field.
|
|
27
|
-
*
|
|
28
|
-
* **Known limitation (MongoDB mixed-type sort):** keyset pagination across a
|
|
29
|
-
* field that can hold both typed values (Date, Number) and `null`/`undefined`
|
|
30
|
-
* is lossy — `$lt/$gt` don't cross the type boundary in BSON comparison, so
|
|
31
|
-
* some docs at the null/non-null boundary are unreachable. If your sort field
|
|
32
|
-
* is nullable, either:
|
|
33
|
-
* - sort by `_id` alone (always safe), or
|
|
34
|
-
* - use `allowedPrimaryFields` to lock keyset sort to fields your schema
|
|
35
|
-
* guarantees non-null (see `PaginationConfig.strictKeysetSortFields`).
|
|
36
|
-
*
|
|
37
|
-
* @param sort - Sort specification
|
|
38
|
-
* @param allowedPrimaryFields - Optional allowlist of primary (non-_id) sort
|
|
39
|
-
* field names. When set, rejects sorts whose primary field isn't listed.
|
|
40
|
-
* `_id` is always allowed.
|
|
41
|
-
* @returns Validated and normalized sort
|
|
42
|
-
* @throws Error if sort is invalid for keyset pagination
|
|
43
|
-
*/
|
|
44
|
-
function validateKeysetSort(sort, allowedPrimaryFields) {
|
|
45
|
-
const keys = Object.keys(sort);
|
|
46
|
-
if (keys.length === 0) throw new Error("Keyset pagination requires at least one sort field");
|
|
47
|
-
if (keys.length === 1 && keys[0] === "_id") return normalizeSort(sort);
|
|
48
|
-
for (const key of keys) if (sort[key] !== 1 && sort[key] !== -1) throw new Error(`Invalid sort direction for "${key}": must be 1 or -1, got ${sort[key]}`);
|
|
49
|
-
const nonIdKeys = keys.filter((k) => k !== "_id");
|
|
50
|
-
const primaryDirection = sort[nonIdKeys[0]];
|
|
51
|
-
if (allowedPrimaryFields && allowedPrimaryFields.length > 0) {
|
|
52
|
-
for (const key of nonIdKeys) if (!allowedPrimaryFields.includes(key)) throw new Error(`Keyset sort field "${key}" is not in the strictKeysetSortFields allowlist. Allowed: ${allowedPrimaryFields.join(", ")}. (See PaginationConfig.strictKeysetSortFields — protects against lossy null/non-null keyset boundaries.)`);
|
|
53
|
-
}
|
|
54
|
-
for (const key of nonIdKeys) if (sort[key] !== primaryDirection) throw new Error("All sort fields must share the same direction for keyset pagination");
|
|
55
|
-
if (keys.includes("_id") && sort._id !== primaryDirection) throw new Error("_id direction must match primary field direction");
|
|
56
|
-
if (!keys.includes("_id")) return normalizeSort({
|
|
57
|
-
...sort,
|
|
58
|
-
_id: primaryDirection
|
|
59
|
-
});
|
|
60
|
-
return normalizeSort(sort);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Extracts primary sort field (first non-_id field)
|
|
64
|
-
*
|
|
65
|
-
* @param sort - Sort specification
|
|
66
|
-
* @returns Primary field name
|
|
67
|
-
*/
|
|
68
|
-
function getPrimaryField(sort) {
|
|
69
|
-
return Object.keys(sort).find((k) => k !== "_id") || "_id";
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { sort_exports as n, validateKeysetSort as r, getPrimaryField as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|