modelence 0.12.6 → 0.13.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/{chunk-AZC772WG.js → chunk-BTLFMWYE.js} +3 -3
- package/dist/{chunk-AZC772WG.js.map → chunk-BTLFMWYE.js.map} +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{package-YKGI6QBH.js → package-KT24PVKP.js} +2 -2
- package/dist/{package-YKGI6QBH.js.map → package-KT24PVKP.js.map} +1 -1
- package/dist/server.d.ts +11 -4
- package/dist/server.js +7 -7
- package/dist/server.js.map +1 -1
- package/dist/{types-l1amQvLa.d.ts → types-BkwhamTw.d.ts} +43 -8
- package/dist/{types-Dr14pZxy.d.ts → types-D4VeJMYX.d.ts} +26 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './index-CwdohC5n.js';
|
|
2
|
-
import { i as Context } from './types-
|
|
2
|
+
import { i as Context } from './types-D4VeJMYX.js';
|
|
3
3
|
import * as mongodb from 'mongodb';
|
|
4
|
-
import { WithId, IndexDescription, SearchIndexDescription, MongoClient, Collection, FilterOperators, Document, FindOptions, ObjectId, OptionalUnlessRequiredId, InsertOneResult, InsertManyResult, UpdateFilter, UpdateResult, ClientSession, DeleteResult, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteResult } from 'mongodb';
|
|
4
|
+
import { WithId, IndexDescription, SearchIndexDescription, MongoClient, Collection, FilterOperators, Document, FindOptions, ObjectId, SortDirection, OptionalUnlessRequiredId, InsertOneResult, InsertManyResult, UpdateFilter, UpdateResult, ClientSession, DeleteResult, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteResult } from 'mongodb';
|
|
5
5
|
import { z, ZodNumber, ZodArray } from 'zod';
|
|
6
6
|
import { Request, Response, NextFunction } from 'express';
|
|
7
7
|
|
|
@@ -146,6 +146,26 @@ type EnhancedFilterOperators<T> = Omit<FilterOperators<T>, '$in' | '$nin'> & {
|
|
|
146
146
|
$in?: ArrayLikeOfUnion<T>;
|
|
147
147
|
$nin?: ArrayLikeOfUnion<T>;
|
|
148
148
|
};
|
|
149
|
+
type TypedFieldSelection<T, TValue> = {
|
|
150
|
+
[K in keyof WithId<T> & string]?: TValue;
|
|
151
|
+
} & {
|
|
152
|
+
[key: `${string}.${string}`]: TValue;
|
|
153
|
+
};
|
|
154
|
+
type ProjectionValue = 0 | 1 | boolean | {
|
|
155
|
+
$meta: string;
|
|
156
|
+
} | {
|
|
157
|
+
$slice: number | [number, number];
|
|
158
|
+
} | {
|
|
159
|
+
$elemMatch: Document;
|
|
160
|
+
};
|
|
161
|
+
type TypedSort<T> = TypedFieldSelection<T, SortDirection>;
|
|
162
|
+
type TypedProjection<T> = TypedFieldSelection<T, ProjectionValue>;
|
|
163
|
+
type FetchOptions<T> = {
|
|
164
|
+
sort?: TypedSort<T>;
|
|
165
|
+
limit?: number;
|
|
166
|
+
skip?: number;
|
|
167
|
+
projection?: TypedProjection<T>;
|
|
168
|
+
};
|
|
149
169
|
type IndexCreationMode = 'blocking' | 'background';
|
|
150
170
|
/**
|
|
151
171
|
* Custom filter value type that handles array fields specially:
|
|
@@ -381,14 +401,29 @@ declare class Store<TSchema extends ModelSchema, TMethods extends Record<string,
|
|
|
381
401
|
* Fetches multiple documents, equivalent to Node.js MongoDB driver's `find` and `toArray` methods combined.
|
|
382
402
|
*
|
|
383
403
|
* @param query - The query to filter documents
|
|
384
|
-
* @param options -
|
|
404
|
+
* @param options - Optional fetch options
|
|
405
|
+
* @param options.projection - Fields to include or exclude in the result documents
|
|
406
|
+
* @param options.sort - Sort order for matching documents
|
|
407
|
+
* @param options.limit - Maximum number of documents to return
|
|
408
|
+
* @param options.skip - Number of matching documents to skip
|
|
385
409
|
* @returns The documents
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* // Include only selected fields
|
|
414
|
+
* const docs = await store.fetch(
|
|
415
|
+
* { userId: user.id },
|
|
416
|
+
* { projection: { framework: 1, title: 1 }, sort: { createdAt: -1 }, limit: 50 }
|
|
417
|
+
* );
|
|
418
|
+
*
|
|
419
|
+
* // Exclude large fields when not needed
|
|
420
|
+
* const chunks = await store.fetch(
|
|
421
|
+
* { documentId },
|
|
422
|
+
* { projection: { embedding: 0 } }
|
|
423
|
+
* );
|
|
424
|
+
* ```
|
|
386
425
|
*/
|
|
387
|
-
fetch(query: TypedFilter<this['_type']>, options?:
|
|
388
|
-
sort?: Document;
|
|
389
|
-
limit?: number;
|
|
390
|
-
skip?: number;
|
|
391
|
-
}): Promise<this['_doc'][]>;
|
|
426
|
+
fetch(query: TypedFilter<this['_type']>, options?: FetchOptions<this['_type']>): Promise<this['_doc'][]>;
|
|
392
427
|
/**
|
|
393
428
|
* Inserts a single document
|
|
394
429
|
*
|
|
@@ -19,7 +19,31 @@ type ConfigSchema = {
|
|
|
19
19
|
type Configs = Record<ConfigKey, AppConfig>;
|
|
20
20
|
type ValueType<T> = T extends 'number' ? number : T extends 'string' ? string : T extends 'text' ? string : T extends 'boolean' ? boolean : T extends 'secret' ? string : never;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
interface UserEmail {
|
|
23
|
+
address: string;
|
|
24
|
+
verified: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface User extends Document {
|
|
27
|
+
_id: ObjectId;
|
|
28
|
+
handle: string;
|
|
29
|
+
emails?: UserEmail[];
|
|
30
|
+
status?: 'active' | 'disabled' | 'deleted';
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
disabledAt?: Date;
|
|
33
|
+
deletedAt?: Date;
|
|
34
|
+
roles?: string[];
|
|
35
|
+
authMethods: {
|
|
36
|
+
password?: {
|
|
37
|
+
hash: string;
|
|
38
|
+
};
|
|
39
|
+
google?: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
github?: {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
23
47
|
type UserInfo = {
|
|
24
48
|
/** The user's unique identifier. */
|
|
25
49
|
id: string;
|
|
@@ -179,4 +203,4 @@ interface WebsocketClientProvider {
|
|
|
179
203
|
}): void;
|
|
180
204
|
}
|
|
181
205
|
|
|
182
|
-
export { type AuthSuccessProps as A, type ConfigSchema as C, type DefaultRoles as D, type Handler as H, type MethodDefinition as M, type Permission as P, type RoleDefinition as R, ServerChannel as S, type User as U, type WebsocketServerProvider as W, type WebsocketClientProvider as a, type ConfigKey as b, ClientChannel as c, type AuthErrorProps as d, type AppConfig as e, type Session as f, type UserInfo as g, type Role as h, type Context as i, type ClientInfo as j, type ConnectionInfo as k, type Args as l, type MethodType as m, type Method as n, type ConfigType as o, type Configs as p, type
|
|
206
|
+
export { type AuthSuccessProps as A, type ConfigSchema as C, type DefaultRoles as D, type Handler as H, type MethodDefinition as M, type Permission as P, type RoleDefinition as R, ServerChannel as S, type User as U, type WebsocketServerProvider as W, type WebsocketClientProvider as a, type ConfigKey as b, ClientChannel as c, type AuthErrorProps as d, type AppConfig as e, type Session as f, type UserInfo as g, type Role as h, type Context as i, type ClientInfo as j, type ConnectionInfo as k, type Args as l, type MethodType as m, type Method as n, type ConfigType as o, type Configs as p, type UserEmail as q, type AuthProvider as r };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { A as AppServer, E as ExpressMiddleware, M as ModelenceConfig } from './index-CwdohC5n.js';
|
|
2
|
-
export { e as AppConfig, l as Args, d as AuthErrorProps,
|
|
3
|
-
export { B as BodyConfig, h as CronJob, C as CronJobInputParams, i as CronJobMetadata, g as EmailAttachment, c as EmailPayload, E as EmailProvider, k as ExpressHandler, H as HttpMethod, I as InferDocumentType, M as ModelSchema, a as RateLimitRule, b as RateLimitType, R as RouteDefinition, d as RouteHandler, j as RouteHandlers, e as RouteParams, f as RouteResponse, s as schema } from './types-
|
|
2
|
+
export { e as AppConfig, l as Args, d as AuthErrorProps, r as AuthProvider, A as AuthSuccessProps, j as ClientInfo, b as ConfigKey, C as ConfigSchema, o as ConfigType, p as Configs, k as ConnectionInfo, i as Context, D as DefaultRoles, H as Handler, n as Method, M as MethodDefinition, m as MethodType, P as Permission, h as Role, R as RoleDefinition, f as Session, U as User, q as UserEmail, g as UserInfo, a as WebsocketClientProvider, W as WebsocketServerProvider } from './types-D4VeJMYX.js';
|
|
3
|
+
export { B as BodyConfig, h as CronJob, C as CronJobInputParams, i as CronJobMetadata, g as EmailAttachment, c as EmailPayload, E as EmailProvider, k as ExpressHandler, H as HttpMethod, I as InferDocumentType, M as ModelSchema, a as RateLimitRule, b as RateLimitType, R as RouteDefinition, d as RouteHandler, j as RouteHandlers, e as RouteParams, f as RouteResponse, s as schema } from './types-BkwhamTw.js';
|
|
4
4
|
import 'express';
|
|
5
5
|
import 'http';
|
|
6
6
|
import 'mongodb';
|