@modelence/react-query 1.2.3 → 1.2.5

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.
Files changed (42) hide show
  1. package/package.json +2 -2
  2. package/.yalc/modelence/README.md +0 -86
  3. package/.yalc/modelence/dist/bin/modelence.js +0 -5
  4. package/.yalc/modelence/dist/bin/modelence.js.map +0 -1
  5. package/.yalc/modelence/dist/chunk-3S2FFBNS.js +0 -2
  6. package/.yalc/modelence/dist/chunk-3S2FFBNS.js.map +0 -1
  7. package/.yalc/modelence/dist/chunk-55J6XMHW.js +0 -2
  8. package/.yalc/modelence/dist/chunk-55J6XMHW.js.map +0 -1
  9. package/.yalc/modelence/dist/chunk-C3UESBRX.js +0 -2
  10. package/.yalc/modelence/dist/chunk-C3UESBRX.js.map +0 -1
  11. package/.yalc/modelence/dist/chunk-DO5TZLF5.js +0 -2
  12. package/.yalc/modelence/dist/chunk-DO5TZLF5.js.map +0 -1
  13. package/.yalc/modelence/dist/chunk-KTGXKFME.js +0 -3
  14. package/.yalc/modelence/dist/chunk-KTGXKFME.js.map +0 -1
  15. package/.yalc/modelence/dist/chunk-PB6WQQ4L.js +0 -3
  16. package/.yalc/modelence/dist/chunk-PB6WQQ4L.js.map +0 -1
  17. package/.yalc/modelence/dist/client.d.ts +0 -135
  18. package/.yalc/modelence/dist/client.js +0 -2
  19. package/.yalc/modelence/dist/client.js.map +0 -1
  20. package/.yalc/modelence/dist/index-CwdohC5n.d.ts +0 -15
  21. package/.yalc/modelence/dist/index.d.ts +0 -31
  22. package/.yalc/modelence/dist/index.js +0 -2
  23. package/.yalc/modelence/dist/index.js.map +0 -1
  24. package/.yalc/modelence/dist/mongo.d.ts +0 -5
  25. package/.yalc/modelence/dist/mongo.js +0 -2
  26. package/.yalc/modelence/dist/mongo.js.map +0 -1
  27. package/.yalc/modelence/dist/package-46B3WEOU.js +0 -2
  28. package/.yalc/modelence/dist/package-46B3WEOU.js.map +0 -1
  29. package/.yalc/modelence/dist/server.d.ts +0 -599
  30. package/.yalc/modelence/dist/server.js +0 -19
  31. package/.yalc/modelence/dist/server.js.map +0 -1
  32. package/.yalc/modelence/dist/telemetry.d.ts +0 -11
  33. package/.yalc/modelence/dist/telemetry.js +0 -2
  34. package/.yalc/modelence/dist/telemetry.js.map +0 -1
  35. package/.yalc/modelence/dist/types-BOFsm7A2.d.ts +0 -155
  36. package/.yalc/modelence/dist/types-V9eDnP35.d.ts +0 -646
  37. package/.yalc/modelence/dist/types.d.ts +0 -7
  38. package/.yalc/modelence/dist/types.js +0 -2
  39. package/.yalc/modelence/dist/types.js.map +0 -1
  40. package/.yalc/modelence/package.json +0 -83
  41. package/.yalc/modelence/yalc.sig +0 -1
  42. package/yalc.lock +0 -10
@@ -1,646 +0,0 @@
1
- import './index-CwdohC5n.js';
2
- import { i as Context } from './types-BOFsm7A2.js';
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';
5
- import { z, ZodNumber, ZodArray } from 'zod';
6
- import { Request, Response, NextFunction } from 'express';
7
-
8
- type EmailAttachment = {
9
- filename: string;
10
- content: Buffer | string;
11
- contentType: string;
12
- };
13
- type EmailPayload = {
14
- from: string;
15
- to: string | string[];
16
- subject: string;
17
- html?: string;
18
- text?: string;
19
- cc?: string | string[];
20
- bcc?: string | string[];
21
- replyTo?: string | string[];
22
- headers?: Record<string, string>;
23
- attachments?: EmailAttachment[];
24
- } & ({
25
- html: string;
26
- } | {
27
- text: string;
28
- });
29
- interface EmailProvider {
30
- sendEmail(data: EmailPayload): Promise<void>;
31
- }
32
-
33
- type RateLimitType = 'ip' | 'user';
34
- type RateLimitRule = {
35
- /** Logical action being limited, e.g. "signup" */
36
- bucket: string;
37
- /** Identifier type of the actor this rule applies to */
38
- type: RateLimitType;
39
- /** Time window size in milliseconds */
40
- window: number;
41
- /** Maximum allowed hits within the window */
42
- limit: number;
43
- };
44
-
45
- type CronJobHandler = () => Promise<void>;
46
- type CronJob = {
47
- alias: string;
48
- params: {
49
- description: string;
50
- interval: number;
51
- timeout: number;
52
- };
53
- handler: CronJobHandler;
54
- state: {
55
- startTs?: number;
56
- scheduledRunTs?: number;
57
- isRunning: boolean;
58
- };
59
- };
60
- type CronJobInputParams = {
61
- description?: string;
62
- interval: number;
63
- timeout?: number;
64
- handler: CronJobHandler;
65
- };
66
- type CronJobMetadata = {
67
- alias: string;
68
- description: string;
69
- interval: number;
70
- timeout: number;
71
- };
72
-
73
- interface SerializedModelSchema {
74
- [key: string]: SerializedSchema | (SerializedSchema | SerializedModelSchema)[] | SerializedModelSchema | 'v2';
75
- }
76
- type BaseSerializedSchema = {
77
- type: 'string';
78
- } | {
79
- type: 'number';
80
- } | {
81
- type: 'boolean';
82
- } | {
83
- type: 'date';
84
- } | {
85
- type: 'array';
86
- items: SerializedSchema;
87
- } | {
88
- type: 'object';
89
- items: Record<string, SerializedSchema>;
90
- } | {
91
- type: 'enum';
92
- items: readonly string[];
93
- } | {
94
- type: 'union';
95
- items: SerializedSchema[];
96
- } | {
97
- type: 'custom';
98
- typeName: string;
99
- };
100
- type SerializedSchema = BaseSerializedSchema | (BaseSerializedSchema & {
101
- optional: true;
102
- });
103
-
104
- /**
105
- * Top-level query operators (logical and evaluation) - custom version without Document index signature
106
- * Based on MongoDB's RootFilterOperators but without the [key: string]: any from Document
107
- * @internal
108
- */
109
- type StrictRootFilterOperators<TSchema> = {
110
- $and?: TypedFilter<TSchema>[];
111
- $or?: TypedFilter<TSchema>[];
112
- $nor?: TypedFilter<TSchema>[];
113
- $not?: TypedFilter<TSchema>;
114
- $text?: {
115
- $search: string;
116
- $language?: string;
117
- $caseSensitive?: boolean;
118
- $diacriticSensitive?: boolean;
119
- };
120
- $where?: string | ((this: TSchema) => boolean);
121
- $comment?: string | Document;
122
- $expr?: any;
123
- $jsonSchema?: any;
124
- };
125
- /**
126
- * Helper type to extract array element type
127
- * @internal
128
- */
129
- type ArrayElement<T> = T extends (infer E)[] ? E : never;
130
- /**
131
- * Helper type for $in/$nin that accepts any array/tuple where elements are assignable to T
132
- * This solves the issue where TypeScript infers ['a', 'b'] as a tuple instead of ('a' | 'b')[]
133
- * and where Array<Union> gets distributed into Union1[] | Union2[] | ...
134
- * We wrap the Exclude in a tuple check to prevent distribution
135
- * @internal
136
- */
137
- type NonUndefined<T> = T extends undefined ? never : T;
138
- type ArrayLikeOfUnion<T> = [NonUndefined<T>] extends [never] ? never : ReadonlyArray<NonUndefined<T>> | Array<NonUndefined<T>>;
139
- /**
140
- * Enhanced FilterOperators that fixes $in and $nin to properly accept arrays of union types
141
- * MongoDB's native FilterOperators has issues with union types in $in/$nin arrays
142
- * because TypeScript distributes Array<Union> into Array1 | Array2 | ...
143
- * @internal
144
- */
145
- type EnhancedFilterOperators<T> = Omit<FilterOperators<T>, '$in' | '$nin'> & {
146
- $in?: ArrayLikeOfUnion<T>;
147
- $nin?: ArrayLikeOfUnion<T>;
148
- };
149
- /**
150
- * Custom filter value type that handles array fields specially:
151
- * - For array fields: allows element type, full array type, or FilterOperators
152
- * - For non-array fields: allows exact type or FilterOperators
153
- * We use [T] to prevent distribution when T is a union type
154
- * @internal
155
- */
156
- type FilterValue<T> = [T] extends [unknown[]] ? ArrayElement<T> | T | EnhancedFilterOperators<T> : [T] extends [never] ? never : T | EnhancedFilterOperators<[T] extends [never] ? never : T>;
157
- /**
158
- * Type-safe MongoDB filter that ensures only schema fields can be queried
159
- * while supporting all MongoDB query operators and dot notation for nested fields.
160
- *
161
- * This type combines:
162
- * - MongoDB's native `FilterOperators<T>` for field-level operators (comprehensive operator support)
163
- * - Custom `StrictRootFilterOperators<T>` for top-level operators without index signature
164
- * - Custom array field handling: allows passing single element when field is an array
165
- * - Custom restriction: only strings containing dots are allowed for nested field queries
166
- *
167
- * @example
168
- * ```ts
169
- * const dbUsers = new Store('users', {
170
- * schema: {
171
- * name: schema.string(),
172
- * age: schema.number(),
173
- * tags: schema.array(schema.string()),
174
- * collections: schema.array(schema.string()),
175
- * address: schema.object({
176
- * street: schema.string(),
177
- * city: schema.string(),
178
- * }),
179
- * },
180
- * indexes: []
181
- * });
182
- *
183
- * // ✅ Valid - field exists in schema
184
- * await dbUsers.findOne({ name: 'John' });
185
- *
186
- * // ✅ Valid - using MongoDB operators (from FilterOperators)
187
- * await dbUsers.findOne({ age: { $gt: 18 } });
188
- * await dbUsers.findOne({ tags: { $in: ['typescript', 'mongodb'] } });
189
- * await dbUsers.findOne({ $or: [{ name: 'John' }, { name: 'Jane' }] });
190
- *
191
- * // ✅ Valid - array field with single element (checks if array contains the element)
192
- * await dbUsers.findOne({ collections: 'users' });
193
- *
194
- * // ✅ Valid - dot notation for nested fields (must contain a dot)
195
- * await dbUsers.findOne({ 'address.city': 'New York' });
196
- * await dbUsers.findOne({ 'emails.0.address': 'test@example.com' });
197
- *
198
- * // ❌ TypeScript error - 'id' is not in schema and doesn't contain a dot
199
- * await dbUsers.findOne({ id: '123' });
200
- * ```
201
- */
202
- type TypedFilter<T> = {
203
- [K in keyof WithId<T>]?: FilterValue<WithId<T>[K]>;
204
- } & StrictRootFilterOperators<T> & {
205
- [K: `${string}.${string}`]: any;
206
- };
207
- /**
208
- * Helper type to preserve method types when extending a store.
209
- * Maps each method to work with the extended schema while preserving signatures.
210
- * @internal
211
- */
212
- type PreserveMethodsForExtendedSchema<TBaseMethods extends Record<string, (...args: never[]) => unknown>, TExtendedSchema extends ModelSchema> = {
213
- [K in keyof TBaseMethods]: TBaseMethods[K] extends (this: any, ...args: infer Args) => infer Return ? (this: WithId<InferDocumentType<TExtendedSchema>> & any, ...args: Args) => Return : never;
214
- };
215
- /**
216
- * The Store class provides a type-safe interface for MongoDB collections with built-in schema validation and helper methods.
217
- *
218
- * @category Store
219
- * @typeParam TSchema - The document schema type
220
- * @typeParam TMethods - Custom methods that will be added to documents
221
- *
222
- * @example
223
- * ```ts
224
- * const dbTodos = new Store('todos', {
225
- * schema: {
226
- * title: schema.string(),
227
- * completed: schema.boolean(),
228
- * dueDate: schema.date().optional(),
229
- * userId: schema.userId(),
230
- * },
231
- * methods: {
232
- * isOverdue() {
233
- * return this.dueDate < new Date();
234
- * }
235
- * }
236
- * });
237
- * ```
238
- */
239
- declare class Store<TSchema extends ModelSchema, TMethods extends Record<string, (this: WithId<InferDocumentType<TSchema>> & TMethods, ...args: any[]) => any>> {
240
- /** @internal */
241
- readonly _type: InferDocumentType<TSchema>;
242
- /** @internal */
243
- readonly _rawDoc: WithId<this['_type']>;
244
- /** @internal */
245
- readonly _doc: this['_rawDoc'] & TMethods;
246
- readonly Doc: this['_doc'];
247
- private name;
248
- private readonly schema;
249
- private readonly methods?;
250
- private readonly indexes;
251
- private readonly searchIndexes;
252
- private collection?;
253
- private client?;
254
- /**
255
- * Creates a new Store instance
256
- *
257
- * @param name - The collection name in MongoDB
258
- * @param options - Store configuration
259
- */
260
- constructor(name: string, options: {
261
- /** Document schema using Modelence schema types */
262
- schema: TSchema;
263
- /** Custom methods to add to documents */
264
- methods?: TMethods;
265
- /** MongoDB indexes to create */
266
- indexes: IndexDescription[];
267
- /** MongoDB Atlas Search */
268
- searchIndexes?: SearchIndexDescription[];
269
- });
270
- getName(): string;
271
- /** @internal */
272
- getSchema(): TSchema;
273
- /** @internal */
274
- getSerializedSchema(): SerializedModelSchema;
275
- /**
276
- * Extends the store with additional schema fields, indexes, methods, and search indexes.
277
- * Returns a new Store instance with the extended schema and updated types.
278
- * Methods from the original store are preserved with updated type signatures.
279
- *
280
- * @param config - Additional schema fields, indexes, methods, and search indexes to add
281
- * @returns A new Store instance with the extended schema
282
- *
283
- * @example
284
- * ```ts
285
- * // Extend the users collection
286
- * export const dbUsers = baseUsersCollection.extend({
287
- * schema: {
288
- * firstName: schema.string(),
289
- * lastName: schema.string(),
290
- * companyId: schema.objectId().optional(),
291
- * },
292
- * indexes: [
293
- * { key: { companyId: 1 } },
294
- * { key: { lastName: 1, firstName: 1 } },
295
- * ],
296
- * methods: {
297
- * getFullName() {
298
- * return `${this.firstName} ${this.lastName}`;
299
- * }
300
- * }
301
- * });
302
- *
303
- * // Now fully typed with new fields
304
- * const user = await dbUsers.findOne({ firstName: 'John' });
305
- * console.log(user?.getFullName());
306
- * ```
307
- */
308
- extend<TExtendedSchema extends ModelSchema, TExtendedMethods extends Record<string, (this: WithId<InferDocumentType<TSchema & TExtendedSchema>> & any, ...args: any[]) => any> = Record<string, never>>(config: {
309
- schema?: TExtendedSchema;
310
- indexes?: IndexDescription[];
311
- methods?: TExtendedMethods;
312
- searchIndexes?: SearchIndexDescription[];
313
- }): Store<TSchema & TExtendedSchema, PreserveMethodsForExtendedSchema<TMethods, TSchema & TExtendedSchema> & TExtendedMethods>;
314
- /** @internal */
315
- init(client: MongoClient): void;
316
- /** @internal */
317
- createIndexes(): Promise<void>;
318
- private wrapDocument;
319
- /**
320
- * For convenience, to also allow directy passing a string or ObjectId as the selector
321
- */
322
- private getSelector;
323
- /** @internal */
324
- requireCollection(): Collection<this["_type"]>;
325
- /** @internal */
326
- requireClient(): MongoClient;
327
- /**
328
- * Finds a single document matching the query
329
- *
330
- * @param query - Type-safe query filter. Only schema fields, MongoDB operators, and dot notation are allowed.
331
- * @param options - Find options
332
- * @returns The document, or null if not found
333
- *
334
- * @example
335
- * ```ts
336
- * // ✅ Valid queries:
337
- * await store.findOne({ name: 'John' })
338
- * await store.findOne({ age: { $gt: 18 } })
339
- * await store.findOne({ _id: new ObjectId('...') })
340
- * await store.findOne({ tags: { $in: ['typescript', 'mongodb'] } })
341
- * await store.findOne({ $or: [{ name: 'John' }, { name: 'Jane' }] })
342
- * await store.findOne({ 'emails.address': 'test@example.com' }) // dot notation
343
- *
344
- * // ❌ TypeScript error - 'id' is not in schema:
345
- * await store.findOne({ id: '123' })
346
- * ```
347
- */
348
- findOne(query: TypedFilter<this['_type']>, options?: FindOptions): Promise<this["_doc"] | null>;
349
- requireOne(query: TypedFilter<this['_type']>, options?: FindOptions, errorHandler?: () => Error): Promise<this['_doc']>;
350
- private find;
351
- /**
352
- * Fetches a single document by its ID
353
- *
354
- * @param id - The ID of the document to find
355
- * @returns The document, or null if not found
356
- */
357
- findById(id: string | ObjectId): Promise<this['_doc'] | null>;
358
- /**
359
- * Fetches a single document by its ID, or throws an error if not found
360
- *
361
- * @param id - The ID of the document to find
362
- * @param errorHandler - Optional error handler to return a custom error if the document is not found
363
- * @returns The document
364
- */
365
- requireById(id: string | ObjectId, errorHandler?: () => Error): Promise<this['_doc']>;
366
- /**
367
- * Counts the number of documents that match a query
368
- *
369
- * @param query - The query to filter documents
370
- * @returns The number of documents that match the query
371
- */
372
- countDocuments(query: TypedFilter<this['_type']>): Promise<number>;
373
- /**
374
- * Fetches multiple documents, equivalent to Node.js MongoDB driver's `find` and `toArray` methods combined.
375
- *
376
- * @param query - The query to filter documents
377
- * @param options - Options
378
- * @returns The documents
379
- */
380
- fetch(query: TypedFilter<this['_type']>, options?: {
381
- sort?: Document;
382
- limit?: number;
383
- skip?: number;
384
- }): Promise<this['_doc'][]>;
385
- /**
386
- * Inserts a single document
387
- *
388
- * @param document - The document to insert
389
- * @returns The result of the insert operation
390
- */
391
- insertOne(document: OptionalUnlessRequiredId<InferDocumentType<TSchema>>): Promise<InsertOneResult>;
392
- /**
393
- * Inserts multiple documents
394
- *
395
- * @param documents - The documents to insert
396
- * @returns The result of the insert operation
397
- */
398
- insertMany(documents: OptionalUnlessRequiredId<InferDocumentType<TSchema>>[]): Promise<InsertManyResult>;
399
- /**
400
- * Updates a single document
401
- *
402
- * @param selector - The selector to find the document to update
403
- * @param update - The update to apply to the document
404
- * @returns The result of the update operation
405
- */
406
- updateOne(selector: TypedFilter<this['_type']> | string | ObjectId, update: UpdateFilter<this['_type']>): Promise<UpdateResult>;
407
- /**
408
- * Updates a single document, or inserts it if it doesn't exist
409
- *
410
- * @param selector - The selector to find the document to update
411
- * @param update - The MongoDB modifier to apply to the document
412
- * @returns The result of the update operation
413
- */
414
- upsertOne(selector: TypedFilter<this['_type']> | string | ObjectId, update: UpdateFilter<this['_type']>): Promise<UpdateResult>;
415
- /**
416
- * Updates multiple documents
417
- *
418
- * @param selector - The selector to find the documents to update
419
- * @param update - The MongoDB modifier to apply to the documents
420
- * @returns The result of the update operation
421
- */
422
- updateMany(selector: TypedFilter<this['_type']>, update: UpdateFilter<this['_type']>, options?: {
423
- session?: ClientSession;
424
- }): Promise<UpdateResult>;
425
- /**
426
- * Updates multiple documents, or inserts them if they don't exist
427
- *
428
- * @param selector - The selector to find the documents to update
429
- * @param update - The MongoDB modifier to apply to the documents
430
- * @returns The result of the update operation
431
- */
432
- upsertMany(selector: TypedFilter<this['_type']>, update: UpdateFilter<this['_type']>): Promise<UpdateResult>;
433
- /**
434
- * Deletes a single document
435
- *
436
- * @param selector - The selector to find the document to delete
437
- * @returns The result of the delete operation
438
- */
439
- deleteOne(selector: TypedFilter<this['_type']>): Promise<DeleteResult>;
440
- /**
441
- * Deletes multiple documents
442
- *
443
- * @param selector - The selector to find the documents to delete
444
- * @returns The result of the delete operation
445
- */
446
- deleteMany(selector: TypedFilter<this['_type']>): Promise<DeleteResult>;
447
- /**
448
- * Aggregates documents using MongoDB's aggregation framework
449
- *
450
- * @param pipeline - The aggregation pipeline
451
- * @param options - Optional options
452
- * @returns The aggregation cursor
453
- */
454
- aggregate(pipeline: Document[], options?: AggregateOptions): AggregationCursor<Document>;
455
- /**
456
- * Performs a bulk write operation on the collection
457
- *
458
- * @param operations - The operations to perform
459
- * @returns The result of the bulk write operation
460
- */
461
- bulkWrite(operations: AnyBulkWriteOperation<this['_type']>[]): Promise<BulkWriteResult>;
462
- /**
463
- * Returns the raw MongoDB database instance for advanced operations
464
- * @returns The MongoDB database instance
465
- * @throws Error if the store is not provisioned
466
- */
467
- getDatabase(): mongodb.Db;
468
- /**
469
- * Returns the raw MongoDB collection instance for advanced operations
470
- * @returns The MongoDB collection instance
471
- * @throws Error if the store is not provisioned
472
- */
473
- rawCollection(): Collection<this["_type"]>;
474
- /**
475
- * Renames an existing collection to this store's name, used for migrations
476
- * @param oldName - The previous name of the collection
477
- * @throws Error if the old collection doesn't exist or if this store's collection already exists
478
- */
479
- renameFrom(oldName: string, options?: {
480
- session?: ClientSession;
481
- }): Promise<void>;
482
- /**
483
- * Performs a vector similarity search using MongoDB Atlas Vector Search
484
- *
485
- * @param params - Vector search parameters
486
- * @param params.field - The field name containing the vector embeddings
487
- * @param params.embedding - The query vector to search for
488
- * @param params.numCandidates - Number of nearest neighbors to consider (default: 100)
489
- * @param params.limit - Maximum number of results to return (default: 10)
490
- * @param params.projection - Additional fields to include in the results
491
- * @param params.indexName - Name of index (default: field + VectorSearch)
492
- * @returns An aggregation cursor with search results and scores
493
- *
494
- * @example
495
- * ```ts
496
- * const results = await store.vectorSearch({
497
- * field: 'embedding',
498
- * embedding: [0.1, 0.2, 0.3, ...],
499
- * numCandidates: 100,
500
- * limit: 10,
501
- * projection: { title: 1, description: 1 }
502
- * });
503
- * ```
504
- */
505
- vectorSearch({ field, embedding, numCandidates, limit, projection, indexName, }: {
506
- field: string;
507
- embedding: number[];
508
- numCandidates?: number;
509
- limit?: number;
510
- projection?: Document;
511
- indexName?: string;
512
- }): Promise<AggregationCursor<Document>>;
513
- /**
514
- * Creates a MongoDB Atlas Vector Search index definition
515
- *
516
- * @param params - Vector index parameters
517
- * @param params.field - The field name to create the vector index on
518
- * @param params.dimensions - The number of dimensions in the vector embeddings
519
- * @param params.similarity - The similarity metric to use (default: 'cosine')
520
- * @param params.indexName - Name of index (default: field + VectorSearch)
521
- * @returns A search index description object
522
- *
523
- * @example
524
- * ```ts
525
- * const store = new Store('documents', {
526
- * schema: {
527
- * title: schema.string(),
528
- * embedding: schema.array(schema.number()),
529
- * },
530
- * indexes: [],
531
- * searchIndexes: [
532
- * Store.vectorIndex({
533
- * field: 'embedding',
534
- * dimensions: 1536,
535
- * similarity: 'cosine'
536
- * })
537
- * ]
538
- * });
539
- * ```
540
- */
541
- static vectorIndex({ field, dimensions, similarity, indexName, }: {
542
- field: string;
543
- dimensions: number;
544
- similarity?: 'cosine' | 'euclidean' | 'dotProduct';
545
- indexName?: string;
546
- }): {
547
- type: string;
548
- name: string;
549
- definition: {
550
- fields: {
551
- type: string;
552
- path: string;
553
- numDimensions: number;
554
- similarity: "cosine" | "euclidean" | "dotProduct";
555
- }[];
556
- };
557
- };
558
- }
559
-
560
- type ObjectTypeDefinition = {
561
- [key: string]: SchemaTypeDefinition;
562
- };
563
- type SingularSchemaTypeDefinition = z.ZodType | ObjectTypeDefinition;
564
- type SchemaTypeDefinition = SingularSchemaTypeDefinition | Array<SingularSchemaTypeDefinition>;
565
- type ModelSchema = {
566
- [key: string]: SchemaTypeDefinition;
567
- };
568
- type InferDocumentType<T extends SchemaTypeDefinition> = {
569
- [K in keyof T as T[K] extends z.ZodOptional<z.ZodTypeAny> ? K : never]?: T[K] extends z.ZodType ? z.infer<T[K]> : never;
570
- } & {
571
- [K in keyof T as T[K] extends z.ZodOptional<z.ZodTypeAny> ? never : K]: T[K] extends z.ZodType ? z.infer<T[K]> : T[K] extends Array<infer ElementType extends SchemaTypeDefinition> ? Array<InferDocumentType<ElementType>> : T[K] extends ObjectTypeDefinition ? InferDocumentType<T[K]> : never;
572
- };
573
- declare const schema: {
574
- readonly string: (params?: z.RawCreateParams & {
575
- coerce?: true;
576
- }) => z.ZodString;
577
- readonly number: (params?: z.RawCreateParams & {
578
- coerce?: boolean;
579
- }) => ZodNumber;
580
- readonly date: (params?: z.RawCreateParams & {
581
- coerce?: boolean;
582
- }) => z.ZodDate;
583
- readonly boolean: (params?: z.RawCreateParams & {
584
- coerce?: boolean;
585
- }) => z.ZodBoolean;
586
- readonly array: <El extends z.ZodTypeAny>(schema: El, params?: z.RawCreateParams) => ZodArray<El>;
587
- readonly object: <Shape extends z.ZodRawShape>(shape: Shape, params?: z.RawCreateParams) => z.ZodObject<Shape, "strip", z.ZodTypeAny, z.objectOutputType<Shape, z.ZodTypeAny, "strip">, z.objectInputType<Shape, z.ZodTypeAny, "strip">>;
588
- readonly enum: {
589
- <U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: z.RawCreateParams): z.ZodEnum<z.Writeable<T>>;
590
- <U extends string, T extends [U, ...U[]]>(values: T, params?: z.RawCreateParams): z.ZodEnum<T>;
591
- };
592
- readonly embedding: () => ZodArray<ZodNumber>;
593
- readonly objectId: () => z.ZodType<ObjectId>;
594
- readonly userId: () => z.ZodType<ObjectId>;
595
- readonly ref: <T extends ModelSchema>(_collection: string | Store<T, InferDocumentType<T>>) => z.ZodType<ObjectId>;
596
- readonly union: <Options extends Readonly<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>>(types: Options, params?: z.RawCreateParams) => z.ZodUnion<Options>;
597
- readonly infer: <T extends SchemaTypeDefinition>(_schema: T) => InferDocumentType<T>;
598
- };
599
- declare namespace schema {
600
- type infer<T extends SchemaTypeDefinition> = InferDocumentType<T>;
601
- }
602
-
603
- type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head' | 'all' | 'use';
604
- type RouteParams<T = unknown> = {
605
- query: Record<string, string>;
606
- body: T;
607
- params: Record<string, string>;
608
- headers: Record<string, string>;
609
- cookies: Record<string, string>;
610
- rawBody?: Buffer;
611
- req: Request;
612
- res: Response;
613
- next: NextFunction;
614
- };
615
- type RouteResponse<T = unknown> = {
616
- data?: T;
617
- status?: number;
618
- headers?: Record<string, string>;
619
- redirect?: string;
620
- } | null;
621
- type RouteHandler<T = unknown> = (params: RouteParams, context: Pick<Context, 'session' | 'user'>) => Promise<RouteResponse<T>> | RouteResponse<T>;
622
- type RouteHandlers = {
623
- [key in HttpMethod]?: RouteHandler;
624
- };
625
- type BodyConfig = {
626
- json?: boolean | {
627
- limit?: string;
628
- };
629
- urlencoded?: boolean | {
630
- limit?: string;
631
- extended?: boolean;
632
- };
633
- raw?: boolean | {
634
- limit?: string;
635
- type?: string | string[];
636
- };
637
- };
638
- type RouteDefinition = {
639
- path: string;
640
- handlers: RouteHandlers;
641
- errorHandler?: RouteHandler;
642
- body?: BodyConfig;
643
- };
644
- type ExpressHandler = (req: Request, res: Response) => Promise<void> | void;
645
-
646
- export { type BodyConfig as B, type CronJobInputParams as C, type EmailProvider as E, type HttpMethod as H, type InferDocumentType as I, type ModelSchema as M, type RouteDefinition as R, Store as S, type RateLimitRule as a, type RateLimitType as b, type EmailPayload as c, type RouteHandler as d, type RouteParams as e, type RouteResponse as f, type EmailAttachment as g, type CronJob as h, type CronJobMetadata as i, type RouteHandlers as j, type ExpressHandler as k, schema as s };
@@ -1,7 +0,0 @@
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, q 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, g as UserInfo, a as WebsocketClientProvider, W as WebsocketServerProvider } from './types-BOFsm7A2.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-V9eDnP35.js';
4
- import 'express';
5
- import 'http';
6
- import 'mongodb';
7
- import 'zod';
@@ -1,2 +0,0 @@
1
- import'./chunk-55J6XMHW.js';//# sourceMappingURL=types.js.map
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}