@classytic/mongokit 3.38.1 → 3.39.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-CBS1XGzp.d.mts → PaginationEngine-D-P19Y9m.d.mts} +34 -9
- package/dist/PaginationEngine-DQ7beTCR.mjs +1182 -0
- package/dist/{Repository-Ck5x43wF.mjs → Repository-D7fDpyFx.mjs} +400 -37
- package/dist/{Repository-BdSkQ8vc.d.mts → Repository-IxI983_m.d.mts} +55 -8
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +1 -1
- package/dist/adapter/index.d.mts +21 -0
- package/dist/adapter/index.mjs +1 -1
- package/dist/{adapter-Bfqz8yHE.mjs → adapter-BrVfPFSW.mjs} +45 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/better-auth/index.mjs +2 -2
- package/dist/{create-repository-BU4x9Kb0.d.mts → create-repository-CRXjDa3N.d.mts} +5 -5
- package/dist/{create-repository-B5EulQ31.mjs → create-repository-DOe9E_5F.mjs} +3 -3
- package/dist/{index-DKEql4cL.d.mts → index-CmjNyulu.d.mts} +67 -8
- package/dist/index.d.mts +77 -13
- package/dist/index.mjs +8 -8
- package/dist/{method-registry.plugin-DblM7V6j.mjs → method-registry.plugin-C63pGn1d.mjs} +54 -4
- package/dist/{multi-tenant.plugin-BwSvTirB.d.mts → multi-tenant.plugin-B-tzNeYL.d.mts} +60 -4
- package/dist/{operations-DZodvjC-.d.mts → operations-CrRIoc8Z.d.mts} +22 -7
- package/dist/outbox/index.d.mts +1 -1
- package/dist/outbox/index.mjs +2 -2
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +1 -1
- package/dist/pagination/utils/limits.d.mts +1 -1
- package/dist/pagination/utils/limits.mjs +22 -1
- package/dist/pagination-BpIv2bdS.d.mts +364 -0
- package/dist/{plugin-options-DXnlKM3B.d.mts → plugin-options-BuvtOSZf.d.mts} +2 -2
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.mjs +3 -3
- package/dist/{repository-H_ffGgpE.d.mts → repository-ZbLtL7Nk.d.mts} +30 -4
- package/dist/tenant/index.d.mts +89 -0
- package/dist/tenant/index.mjs +94 -0
- package/dist/testkit/index.d.mts +2 -2
- package/dist/testkit/index.mjs +1 -1
- package/dist/{timestamp.plugin-CBQukQzV.mjs → timestamp.plugin-B5eiaItQ.mjs} +31 -8
- package/dist/{to-plain-Dyz_qvuo.d.mts → to-plain-B8ufk3Qz.d.mts} +2 -2
- package/dist/{update-jSXp3nu3.mjs → update-c_01A0if.mjs} +126 -73
- package/dist/utils/index.d.mts +1 -1
- package/dist/{validation-chain.plugin-DhNyxNCw.mjs → validation-chain.plugin-Bju1D1Sn.mjs} +2 -2
- package/dist/{validation-chain.plugin-yQRob3Av.d.mts → validation-chain.plugin-DvrLJIbJ.d.mts} +3 -19
- package/package.json +7 -3
- package/dist/PaginationEngine-BX9o_-4R.mjs +0 -735
- package/dist/core-62oo3N1C.d.mts +0 -50
- package/dist/pagination-jSUdrACK.d.mts +0 -158
package/dist/core-62oo3N1C.d.mts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Document, Model, PopulateOptions, Types } from "mongoose";
|
|
2
|
-
//#region src/types/core.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Core query/document primitives shared across every mongokit module —
|
|
5
|
-
* sort/select/populate/filter specs and the mongoose-facing aliases.
|
|
6
|
-
*
|
|
7
|
-
* Also the home of the `softRequired` Mongoose declaration merge (this file
|
|
8
|
-
* is loaded by every module, so the augmentation is always in the program).
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Global declaration merge: adds `softRequired` to Mongoose's SchemaTypeOptions
|
|
12
|
-
* so consumers can annotate paths type-safely without importing anything.
|
|
13
|
-
*
|
|
14
|
-
* A path with `softRequired: true` keeps its DB-level `required: true`
|
|
15
|
-
* invariant but is excluded from the auto-generated CRUD body `required[]`
|
|
16
|
-
* array (see buildCrudSchemasFromModel).
|
|
17
|
-
*/
|
|
18
|
-
declare module 'mongoose' {
|
|
19
|
-
interface SchemaTypeOptions<T, EnforcedDocType = any, THydratedDocumentType = HydratedDocument<EnforcedDocType>> {
|
|
20
|
-
/** mongokit: omit from auto-generated CRUD body `required` array. */
|
|
21
|
-
softRequired?: boolean;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** Read Preference Type for replica sets */
|
|
25
|
-
type ReadPreferenceType = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest' | (string & {});
|
|
26
|
-
/** Re-export mongoose ObjectId */
|
|
27
|
-
type ObjectId = Types.ObjectId;
|
|
28
|
-
/** Generic document type */
|
|
29
|
-
type AnyDocument = Document & Record<string, unknown>;
|
|
30
|
-
/** Generic model type */
|
|
31
|
-
type AnyModel = Model<AnyDocument>;
|
|
32
|
-
/** Sort direction */
|
|
33
|
-
type SortDirection = 1 | -1;
|
|
34
|
-
/** Sort specification for MongoDB queries */
|
|
35
|
-
type SortSpec = Record<string, SortDirection>;
|
|
36
|
-
/** Populate specification */
|
|
37
|
-
type PopulateSpec = string | string[] | PopulateOptions | PopulateOptions[];
|
|
38
|
-
/**
|
|
39
|
-
* Select specification. `readonly string[]` widens the legacy `string[]`
|
|
40
|
-
* form to also accept the immutable variant repo-core's contract uses
|
|
41
|
-
* (`LookupPopulateOptions.select: readonly string[] | Record<string, 0
|
|
42
|
-
* | 1>`), so `Repository<TDoc>` assigns to `StandardRepo<TDoc>` without
|
|
43
|
-
* TS2322 on the `select` field. Any existing mutable-array caller stays
|
|
44
|
-
* compatible — `string[]` is assignable to `readonly string[]`.
|
|
45
|
-
*/
|
|
46
|
-
type SelectSpec = string | readonly string[] | Record<string, 0 | 1>;
|
|
47
|
-
/** Filter query type for MongoDB queries (compatible with Mongoose 8 & 9) */
|
|
48
|
-
type FilterQuery<_T = unknown> = Record<string, unknown>;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { PopulateSpec as a, SortDirection as c, ObjectId as i, SortSpec as l, AnyModel as n, ReadPreferenceType as o, FilterQuery as r, SelectSpec as s, AnyDocument as t };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { a as PopulateSpec, i as ObjectId, l as SortSpec, o as ReadPreferenceType, r as FilterQuery, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
|
|
2
|
-
import { PipelineStage } from "mongoose";
|
|
3
|
-
//#region src/types/pagination.d.ts
|
|
4
|
-
/** Pagination configuration */
|
|
5
|
-
interface PaginationConfig {
|
|
6
|
-
/** Default number of documents per page (default: 10) */
|
|
7
|
-
defaultLimit?: number;
|
|
8
|
-
/** Maximum allowed limit (default: 100) */
|
|
9
|
-
maxLimit?: number;
|
|
10
|
-
/** Maximum allowed page number (default: 10000) */
|
|
11
|
-
maxPage?: number;
|
|
12
|
-
/** Page number that triggers performance warning (default: 100) */
|
|
13
|
-
deepPageThreshold?: number;
|
|
14
|
-
/** Cursor version for forward compatibility (default: 1) */
|
|
15
|
-
cursorVersion?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Minimum cursor version accepted. Bump alongside `cursorVersion` when a
|
|
18
|
-
* breaking format change ships so stale client cursors are rejected with a
|
|
19
|
-
* clear error instead of silently paginating from the wrong position.
|
|
20
|
-
* Default: 1 (accept any cursor <= cursorVersion).
|
|
21
|
-
*/
|
|
22
|
-
minCursorVersion?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Allowlist of primary sort fields for keyset pagination. When set, any
|
|
25
|
-
* `getAll({ sort })` whose primary (non-_id) field is not in this list
|
|
26
|
-
* throws at validation time.
|
|
27
|
-
*
|
|
28
|
-
* Use this to lock down keyset pagination to fields that are structurally
|
|
29
|
-
* guaranteed non-null in your schema — keyset sort across null/non-null
|
|
30
|
-
* boundaries is lossy (MongoDB's `$lt/$gt` semantics leave a gap at the
|
|
31
|
-
* type boundary, so not every doc is reachable).
|
|
32
|
-
*
|
|
33
|
-
* `_id` is always allowed regardless of this list.
|
|
34
|
-
* Undefined (default) = no allowlist, any sort field accepted.
|
|
35
|
-
*/
|
|
36
|
-
strictKeysetSortFields?: string[];
|
|
37
|
-
/** Use estimatedDocumentCount for faster counts on large collections */
|
|
38
|
-
useEstimatedCount?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/** MongoDB collation options for locale-aware string comparison */
|
|
41
|
-
interface CollationOptions {
|
|
42
|
-
locale: string;
|
|
43
|
-
caseLevel?: boolean;
|
|
44
|
-
caseFirst?: 'upper' | 'lower' | 'off';
|
|
45
|
-
strength?: 1 | 2 | 3 | 4 | 5;
|
|
46
|
-
numericOrdering?: boolean;
|
|
47
|
-
alternate?: 'non-ignorable' | 'shifted';
|
|
48
|
-
maxVariable?: 'punct' | 'space';
|
|
49
|
-
backwards?: boolean;
|
|
50
|
-
}
|
|
51
|
-
/** Base pagination options */
|
|
52
|
-
interface BasePaginationOptions {
|
|
53
|
-
/** Pagination mode (explicit override) */
|
|
54
|
-
mode?: 'offset' | 'keyset';
|
|
55
|
-
/** MongoDB query filters */
|
|
56
|
-
filters?: FilterQuery<AnyDocument>;
|
|
57
|
-
/** Sort specification */
|
|
58
|
-
sort?: SortSpec;
|
|
59
|
-
/** Number of documents per page */
|
|
60
|
-
limit?: number;
|
|
61
|
-
/** Fields to select */
|
|
62
|
-
select?: SelectSpec;
|
|
63
|
-
/** Fields to populate */
|
|
64
|
-
populate?: PopulateSpec;
|
|
65
|
-
/** Return plain JavaScript objects */
|
|
66
|
-
lean?: boolean;
|
|
67
|
-
/** MongoDB session for transactions */
|
|
68
|
-
session?: unknown;
|
|
69
|
-
/** Query hint (index name or document) */
|
|
70
|
-
hint?: string | Record<string, 1 | -1>;
|
|
71
|
-
/** Maximum execution time in milliseconds */
|
|
72
|
-
maxTimeMS?: number;
|
|
73
|
-
/** Read preference for replica sets (e.g. 'secondaryPreferred') */
|
|
74
|
-
readPreference?: ReadPreferenceType;
|
|
75
|
-
/** Collation for locale-aware string comparison and case-insensitive sorting */
|
|
76
|
-
collation?: CollationOptions;
|
|
77
|
-
}
|
|
78
|
-
/** Offset pagination options */
|
|
79
|
-
interface OffsetPaginationOptions extends BasePaginationOptions {
|
|
80
|
-
/** Page number (1-indexed) */
|
|
81
|
-
page?: number;
|
|
82
|
-
/** Count strategy for filtered queries (default: 'exact') */
|
|
83
|
-
countStrategy?: 'exact' | 'estimated' | 'none';
|
|
84
|
-
/**
|
|
85
|
-
* Optional alternate filter used for the count query only. The primary
|
|
86
|
-
* `filters` is still used for `.find()`. Lets callers (Repository) run a
|
|
87
|
-
* sort-only query like `$near` for results while counting with a
|
|
88
|
-
* count-compatible rewrite (e.g. `$geoWithin: $centerSphere`) that
|
|
89
|
-
* returns the same document set but works with `countDocuments`.
|
|
90
|
-
*/
|
|
91
|
-
countFilters?: FilterQuery<AnyDocument>;
|
|
92
|
-
}
|
|
93
|
-
/** Keyset (cursor) pagination options */
|
|
94
|
-
interface KeysetPaginationOptions extends BasePaginationOptions {
|
|
95
|
-
/** Cursor token for next page */
|
|
96
|
-
after?: string;
|
|
97
|
-
/** Sort is required for keyset pagination */
|
|
98
|
-
sort: SortSpec;
|
|
99
|
-
}
|
|
100
|
-
/** Aggregate pagination options */
|
|
101
|
-
interface AggregatePaginationOptions {
|
|
102
|
-
/** Aggregation pipeline stages */
|
|
103
|
-
pipeline?: PipelineStage[];
|
|
104
|
-
/** Page number (1-indexed) */
|
|
105
|
-
page?: number;
|
|
106
|
-
/** Number of documents per page */
|
|
107
|
-
limit?: number;
|
|
108
|
-
/** MongoDB session for transactions */
|
|
109
|
-
session?: unknown;
|
|
110
|
-
/** Query hint (index name or document) for aggregation */
|
|
111
|
-
hint?: string | Record<string, 1 | -1>;
|
|
112
|
-
/** Maximum execution time in milliseconds */
|
|
113
|
-
maxTimeMS?: number;
|
|
114
|
-
/** Count strategy (default: 'exact' via $facet).
|
|
115
|
-
* 'estimated' is accepted but treated as 'exact' in aggregation context
|
|
116
|
-
* since estimatedDocumentCount is not available inside pipelines. */
|
|
117
|
-
countStrategy?: 'exact' | 'estimated' | 'none';
|
|
118
|
-
/** Pagination mode (reserved for API consistency) */
|
|
119
|
-
mode?: 'offset';
|
|
120
|
-
/** Read preference for replica sets (e.g. 'secondaryPreferred') */
|
|
121
|
-
readPreference?: ReadPreferenceType;
|
|
122
|
-
}
|
|
123
|
-
/** Value type identifier for cursor serialization */
|
|
124
|
-
type ValueType = 'date' | 'objectid' | 'boolean' | 'number' | 'string' | 'null' | 'unknown';
|
|
125
|
-
/** Cursor payload */
|
|
126
|
-
interface CursorPayload {
|
|
127
|
-
/** Primary sort field value (legacy single-field) */
|
|
128
|
-
v: string | number | boolean | null;
|
|
129
|
-
/** Value type identifier (legacy single-field) */
|
|
130
|
-
t: ValueType;
|
|
131
|
-
/** Document ID */
|
|
132
|
-
id: string;
|
|
133
|
-
/** ID type identifier */
|
|
134
|
-
idType: ValueType;
|
|
135
|
-
/** Sort specification */
|
|
136
|
-
sort: SortSpec;
|
|
137
|
-
/** Cursor version */
|
|
138
|
-
ver: number;
|
|
139
|
-
/** Compound sort field values (multi-field keyset) */
|
|
140
|
-
vals?: Record<string, string | number | boolean | null>;
|
|
141
|
-
/** Compound sort value types */
|
|
142
|
-
types?: Record<string, ValueType>;
|
|
143
|
-
}
|
|
144
|
-
/** Decoded cursor */
|
|
145
|
-
interface DecodedCursor {
|
|
146
|
-
/** Primary sort field value (rehydrated) — legacy compat */
|
|
147
|
-
value: unknown;
|
|
148
|
-
/** Document ID (rehydrated) */
|
|
149
|
-
id: ObjectId | string;
|
|
150
|
-
/** Sort specification */
|
|
151
|
-
sort: SortSpec;
|
|
152
|
-
/** Cursor version */
|
|
153
|
-
version: number;
|
|
154
|
-
/** All sort field values (rehydrated) — for compound sort */
|
|
155
|
-
values?: Record<string, unknown>;
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
export { DecodedCursor as a, PaginationConfig as c, CursorPayload as i, ValueType as l, BasePaginationOptions as n, KeysetPaginationOptions as o, CollationOptions as r, OffsetPaginationOptions as s, AggregatePaginationOptions as t };
|