@modelence/react-query 1.0.1 → 1.2.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.
Files changed (46) hide show
  1. package/.yalc/modelence/README.md +86 -0
  2. package/.yalc/modelence/dist/bin/modelence.js +5 -0
  3. package/.yalc/modelence/dist/bin/modelence.js.map +1 -0
  4. package/.yalc/modelence/dist/chunk-3S2FFBNS.js +2 -0
  5. package/.yalc/modelence/dist/chunk-3S2FFBNS.js.map +1 -0
  6. package/.yalc/modelence/dist/chunk-3YAV3UUU.js +3 -0
  7. package/.yalc/modelence/dist/chunk-3YAV3UUU.js.map +1 -0
  8. package/.yalc/modelence/dist/chunk-55J6XMHW.js +2 -0
  9. package/.yalc/modelence/dist/chunk-55J6XMHW.js.map +1 -0
  10. package/.yalc/modelence/dist/chunk-C3UESBRX.js +2 -0
  11. package/.yalc/modelence/dist/chunk-C3UESBRX.js.map +1 -0
  12. package/.yalc/modelence/dist/chunk-DO5TZLF5.js +2 -0
  13. package/.yalc/modelence/dist/chunk-DO5TZLF5.js.map +1 -0
  14. package/.yalc/modelence/dist/chunk-DVECB2TP.js +3 -0
  15. package/.yalc/modelence/dist/chunk-DVECB2TP.js.map +1 -0
  16. package/.yalc/modelence/dist/client.d.ts +135 -0
  17. package/.yalc/modelence/dist/client.js +2 -0
  18. package/.yalc/modelence/dist/client.js.map +1 -0
  19. package/.yalc/modelence/dist/index-CwdohC5n.d.ts +15 -0
  20. package/.yalc/modelence/dist/index.d.ts +31 -0
  21. package/.yalc/modelence/dist/index.js +2 -0
  22. package/.yalc/modelence/dist/index.js.map +1 -0
  23. package/.yalc/modelence/dist/mongo.d.ts +5 -0
  24. package/.yalc/modelence/dist/mongo.js +2 -0
  25. package/.yalc/modelence/dist/mongo.js.map +1 -0
  26. package/.yalc/modelence/dist/package-3YQBVIVQ.js +2 -0
  27. package/.yalc/modelence/dist/package-3YQBVIVQ.js.map +1 -0
  28. package/.yalc/modelence/dist/server.d.ts +569 -0
  29. package/.yalc/modelence/dist/server.js +19 -0
  30. package/.yalc/modelence/dist/server.js.map +1 -0
  31. package/.yalc/modelence/dist/telemetry.d.ts +11 -0
  32. package/.yalc/modelence/dist/telemetry.js +2 -0
  33. package/.yalc/modelence/dist/telemetry.js.map +1 -0
  34. package/.yalc/modelence/dist/types-Ds1ESQSs.d.ts +106 -0
  35. package/.yalc/modelence/dist/types-WgRbQ-tj.d.ts +645 -0
  36. package/.yalc/modelence/dist/types.d.ts +7 -0
  37. package/.yalc/modelence/dist/types.js +2 -0
  38. package/.yalc/modelence/dist/types.js.map +1 -0
  39. package/.yalc/modelence/package.json +80 -0
  40. package/.yalc/modelence/yalc.sig +1 -0
  41. package/dist/index.d.ts +68 -1
  42. package/dist/index.js +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/package.json +3 -2
  45. package/src/index.ts +158 -1
  46. package/yalc.lock +10 -0
@@ -0,0 +1,31 @@
1
+ export { C as ConfigSchema, a as WebsocketClientProvider, W as WebsocketServerProvider } from './types-Ds1ESQSs.js';
2
+ export { M as ModelenceConfig } from './index-CwdohC5n.js';
3
+ import 'http';
4
+ import 'mongodb';
5
+ import 'express';
6
+
7
+ declare const time: {
8
+ seconds: (x: number) => number;
9
+ minutes: (x: number) => number;
10
+ hours: (x: number) => number;
11
+ days: (x: number) => number;
12
+ weeks: (x: number) => number;
13
+ };
14
+
15
+ declare abstract class ModelenceError extends Error {
16
+ abstract status: number;
17
+ }
18
+ declare class AuthError extends ModelenceError {
19
+ status: number;
20
+ constructor(message: string);
21
+ }
22
+ declare class ValidationError extends ModelenceError {
23
+ status: number;
24
+ constructor(message: string);
25
+ }
26
+ declare class RateLimitError extends ModelenceError {
27
+ status: number;
28
+ constructor(message: string);
29
+ }
30
+
31
+ export { AuthError, RateLimitError, ValidationError, time };
@@ -0,0 +1,2 @@
1
+ export{b as AuthError,d as RateLimitError,c as ValidationError}from'./chunk-C3UESBRX.js';export{a as time}from'./chunk-DO5TZLF5.js';import'./chunk-55J6XMHW.js';//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,5 @@
1
+ export { ClientSession, ObjectId } from 'mongodb';
2
+
3
+ declare const _default: {};
4
+
5
+ export { _default as default };
@@ -0,0 +1,2 @@
1
+ export{ClientSession,ObjectId}from'mongodb';var e={};export{e as default};//# sourceMappingURL=mongo.js.map
2
+ //# sourceMappingURL=mongo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mongo.ts"],"names":["mongo_default"],"mappings":"4CAEA,IAAOA,EAAQ","file":"mongo.js","sourcesContent":["export { ClientSession, ObjectId } from 'mongodb';\n\nexport default {};\n"]}
@@ -0,0 +1,2 @@
1
+ export{l as author,i as bin,n as bugs,s as default,q as dependencies,d as description,p as devDependencies,g as exports,h as files,o as homepage,m as license,e as main,b as name,r as peerDependencies,k as repository,j as scripts,a as type,f as types,c as version}from'./chunk-3YAV3UUU.js';//# sourceMappingURL=package-3YQBVIVQ.js.map
2
+ //# sourceMappingURL=package-3YQBVIVQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"package-3YQBVIVQ.js"}
@@ -0,0 +1,569 @@
1
+ import { A as AppServer } from './index-CwdohC5n.js';
2
+ import { C as ConfigSchema, S as ServerChannel, U as User, d as Session, W as WebsocketServerProvider, R as RoleDefinition, b as ConfigKey, A as AppConfig, e as UserInfo, f as Role } from './types-Ds1ESQSs.js';
3
+ import { S as Store, M as MethodDefinition, R as RouteDefinition, C as CronJobInputParams, a as RateLimitRule, E as EmailProvider, b as ConnectionInfo, I as InferDocumentType, c as RateLimitType, d as EmailPayload } from './types-WgRbQ-tj.js';
4
+ export { H as HttpMethod, e as RouteHandler, f as RouteParams, g as RouteResponse, s as schema } from './types-WgRbQ-tj.js';
5
+ import { ObjectId as ObjectId$1 } from 'mongodb';
6
+ export { ObjectId } from 'mongodb';
7
+ import * as zod from 'zod';
8
+ import 'express';
9
+ import 'http';
10
+
11
+ /** Array of Store instances that will be provisioned when the module is loaded */
12
+ type Stores = Store<any, any>[];
13
+ /** Record of query methods that can be called from the client */
14
+ type Queries = Record<string, MethodDefinition<any>>;
15
+ /** Record of mutation methods that can be called from the client */
16
+ type Mutations = Record<string, MethodDefinition<any>>;
17
+ /**
18
+ * The Module class is a core building block of a Modelence application that encapsulates related functionality.
19
+ * Modules can contain stores, queries, mutations, routes, cron jobs and configurations.
20
+ *
21
+ * @category Module
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const todoModule = new Module('todo', {
26
+ * stores: [dbTodos],
27
+ * queries: {
28
+ * async getAll() {
29
+ * // Fetch and return all Todo items
30
+ * }
31
+ * },
32
+ * mutations: {
33
+ * async create({ title }, { user }) {
34
+ * // Create a new Todo item
35
+ * }
36
+ * }
37
+ * });
38
+ * ```
39
+ */
40
+ declare class Module {
41
+ /** @internal */
42
+ readonly name: string;
43
+ /** @internal */
44
+ readonly stores: Stores;
45
+ /** @internal */
46
+ readonly queries: Queries;
47
+ /** @internal */
48
+ readonly mutations: Mutations;
49
+ /** @internal */
50
+ readonly routes: RouteDefinition[];
51
+ /** @internal */
52
+ readonly cronJobs: Record<string, CronJobInputParams>;
53
+ /** @internal */
54
+ readonly configSchema: ConfigSchema;
55
+ /** @internal */
56
+ readonly rateLimits: RateLimitRule[];
57
+ /** @internal */
58
+ readonly channels: ServerChannel[];
59
+ /**
60
+ * Creates a new Module instance
61
+ *
62
+ * @param name - The unique name of the module.
63
+ * This name is used to namespace queries, mutations,
64
+ * cron jobs and configuration values with a prefix (e.g. "todo.create")
65
+ *
66
+ * @param options - Module configuration options
67
+ */
68
+ constructor(name: string, { stores, queries, mutations, routes, cronJobs, configSchema, rateLimits, channels, }: {
69
+ stores?: Store<any, any>[];
70
+ queries?: Queries;
71
+ mutations?: Mutations;
72
+ routes?: RouteDefinition[];
73
+ cronJobs?: Record<string, CronJobInputParams>;
74
+ configSchema?: ConfigSchema;
75
+ rateLimits?: RateLimitRule[];
76
+ channels?: ServerChannel[];
77
+ });
78
+ }
79
+
80
+ type MigrationScript = {
81
+ version: number;
82
+ description: string;
83
+ handler: () => Promise<string | void>;
84
+ };
85
+
86
+ type EmailConfig = {
87
+ provider?: EmailProvider;
88
+ from?: string;
89
+ verification?: {
90
+ subject?: string;
91
+ template?: (props: {
92
+ name: string;
93
+ email: string;
94
+ verificationUrl: string;
95
+ }) => string;
96
+ redirectUrl?: string;
97
+ };
98
+ passwordReset?: {
99
+ subject?: string;
100
+ template?: (props: {
101
+ name: string;
102
+ email: string;
103
+ resetUrl: string;
104
+ }) => string;
105
+ redirectUrl?: string;
106
+ };
107
+ emailVerifiedRedirectUrl?: string;
108
+ };
109
+
110
+ /**
111
+ * Callback options for authentication operations
112
+ */
113
+ type AuthOption = {
114
+ /** Callback executed when authentication succeeds */
115
+ onSuccess?: (user: User) => void;
116
+ /** Callback executed when authentication fails */
117
+ onError?: (error: Error) => void;
118
+ };
119
+ /**
120
+ * Authentication configuration for the application
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { startApp } from 'modelence/server';
125
+ *
126
+ * startApp({
127
+ * auth: {
128
+ * onAfterLogin: ({ user }) => {
129
+ * console.log('User logged in:', user.name);
130
+ * // Redirect to dashboard
131
+ * },
132
+ * onLoginError: ({ error }) => {
133
+ * console.error('Login failed:', error.message);
134
+ * // Show error toast
135
+ * },
136
+ * onAfterSignup: ({ user }) => {
137
+ * console.log('User signed up:', user.email);
138
+ * // Send welcome email
139
+ * },
140
+ * onSignupError: ({ error }) => {
141
+ * console.error('Signup failed:', error.message);
142
+ * }
143
+ * }
144
+ * });
145
+ * ```
146
+ */
147
+ type AuthConfig = {
148
+ onAfterLogin?: (props: {
149
+ user: User;
150
+ session: Session | null;
151
+ connectionInfo: ConnectionInfo;
152
+ }) => void;
153
+ onLoginError?: (props: {
154
+ error: Error;
155
+ session: Session | null;
156
+ connectionInfo: ConnectionInfo;
157
+ }) => void;
158
+ onAfterSignup?: (props: {
159
+ user: User;
160
+ session: Session | null;
161
+ connectionInfo: ConnectionInfo;
162
+ }) => void;
163
+ onSignupError?: (props: {
164
+ error: Error;
165
+ session: Session | null;
166
+ connectionInfo: ConnectionInfo;
167
+ }) => void;
168
+ /** deprecated: use onAfterLogin and onLoginError */
169
+ login?: AuthOption;
170
+ /** deprecated: user onAfterSignup and onSignupError */
171
+ signup?: AuthOption;
172
+ };
173
+
174
+ type WebsocketConfig = {
175
+ provider?: WebsocketServerProvider;
176
+ };
177
+
178
+ type AppOptions = {
179
+ modules?: Module[];
180
+ server?: AppServer;
181
+ email?: EmailConfig;
182
+ auth?: AuthConfig;
183
+ roles?: Record<string, RoleDefinition>;
184
+ defaultRoles?: Record<string, string>;
185
+ migrations?: Array<MigrationScript>;
186
+ websocket?: WebsocketConfig;
187
+ };
188
+ declare function startApp({ modules, roles, defaultRoles, server, migrations, email, auth, websocket, }: AppOptions): Promise<void>;
189
+
190
+ /**
191
+ * Publish function provided to live query handlers.
192
+ * Call this to send data to the subscribed client.
193
+ */
194
+ type LiveQueryPublish<T = unknown> = (data: T) => void;
195
+ /**
196
+ * Cleanup function returned by live query handlers.
197
+ * Called when the client unsubscribes.
198
+ */
199
+ type LiveQueryCleanup = () => void;
200
+ /**
201
+ * Context provided to live query handlers.
202
+ */
203
+ interface LiveQueryContext {
204
+ publish: LiveQueryPublish;
205
+ }
206
+
207
+ declare function createQuery<T extends unknown[]>(name: string, methodDef: MethodDefinition<T>): void;
208
+
209
+ /** @public */
210
+ declare abstract class BSONValue {
211
+ /** @public */
212
+ abstract get _bsontype(): string;
213
+ /* Excluded from this release type: [BSON_VERSION_SYMBOL] */
214
+ /**
215
+ * @public
216
+ * Prints a human-readable string of BSON value information
217
+ * If invoked manually without node.js.inspect function, this will default to a modified JSON.stringify
218
+ */
219
+ abstract inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
220
+ /* Excluded from this release type: toExtendedJSON */
221
+ }
222
+
223
+ declare type InspectFn = (x: unknown, options?: unknown) => string;
224
+
225
+ /**
226
+ * A class representation of the BSON ObjectId type.
227
+ * @public
228
+ * @category BSONType
229
+ */
230
+ declare class ObjectId extends BSONValue {
231
+ get _bsontype(): 'ObjectId';
232
+ /* Excluded from this release type: index */
233
+ static cacheHexString: boolean;
234
+ /* Excluded from this release type: buffer */
235
+ /**
236
+ * Create ObjectId from a number.
237
+ *
238
+ * @param inputId - A number.
239
+ * @deprecated Instead, use `static createFromTime()` to set a numeric value for the new ObjectId.
240
+ */
241
+ constructor(inputId: number);
242
+ /**
243
+ * Create ObjectId from a 24 character hex string.
244
+ *
245
+ * @param inputId - A 24 character hex string.
246
+ */
247
+ constructor(inputId: string);
248
+ /**
249
+ * Create ObjectId from the BSON ObjectId type.
250
+ *
251
+ * @param inputId - The BSON ObjectId type.
252
+ */
253
+ constructor(inputId: ObjectId);
254
+ /**
255
+ * Create ObjectId from the object type that has the toHexString method.
256
+ *
257
+ * @param inputId - The ObjectIdLike type.
258
+ */
259
+ constructor(inputId: ObjectIdLike);
260
+ /**
261
+ * Create ObjectId from a 12 byte binary Buffer.
262
+ *
263
+ * @param inputId - A 12 byte binary Buffer.
264
+ */
265
+ constructor(inputId: Uint8Array);
266
+ /** To generate a new ObjectId, use ObjectId() with no argument. */
267
+ constructor();
268
+ /**
269
+ * Implementation overload.
270
+ *
271
+ * @param inputId - All input types that are used in the constructor implementation.
272
+ */
273
+ constructor(inputId?: string | number | ObjectId | ObjectIdLike | Uint8Array);
274
+ /**
275
+ * The ObjectId bytes
276
+ * @readonly
277
+ */
278
+ get id(): Uint8Array;
279
+ set id(value: Uint8Array);
280
+ /* Excluded from this release type: validateHexString */
281
+ /** Returns the ObjectId id as a 24 lowercase character hex string representation */
282
+ toHexString(): string;
283
+ /* Excluded from this release type: getInc */
284
+ /**
285
+ * Generate a 12 byte id buffer used in ObjectId's
286
+ *
287
+ * @param time - pass in a second based timestamp.
288
+ */
289
+ static generate(time?: number): Uint8Array;
290
+ /**
291
+ * Converts the id into a 24 character hex string for printing, unless encoding is provided.
292
+ * @param encoding - hex or base64
293
+ */
294
+ toString(encoding?: 'hex' | 'base64'): string;
295
+ /** Converts to its JSON the 24 character hex string representation. */
296
+ toJSON(): string;
297
+ /* Excluded from this release type: is */
298
+ /**
299
+ * Compares the equality of this ObjectId with `otherID`.
300
+ *
301
+ * @param otherId - ObjectId instance to compare against.
302
+ */
303
+ equals(otherId: string | ObjectId | ObjectIdLike | undefined | null): boolean;
304
+ /** Returns the generation date (accurate up to the second) that this ID was generated. */
305
+ getTimestamp(): Date;
306
+ /* Excluded from this release type: createPk */
307
+ /* Excluded from this release type: serializeInto */
308
+ /**
309
+ * Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
310
+ *
311
+ * @param time - an integer number representing a number of seconds.
312
+ */
313
+ static createFromTime(time: number): ObjectId;
314
+ /**
315
+ * Creates an ObjectId from a hex string representation of an ObjectId.
316
+ *
317
+ * @param hexString - create a ObjectId from a passed in 24 character hexstring.
318
+ */
319
+ static createFromHexString(hexString: string): ObjectId;
320
+ /** Creates an ObjectId instance from a base64 string */
321
+ static createFromBase64(base64: string): ObjectId;
322
+ /**
323
+ * Checks if a value can be used to create a valid bson ObjectId
324
+ * @param id - any JS value
325
+ */
326
+ static isValid(id: string | number | ObjectId | ObjectIdLike | Uint8Array): boolean;
327
+ /* Excluded from this release type: toExtendedJSON */
328
+ /* Excluded from this release type: fromExtendedJSON */
329
+ /* Excluded from this release type: isCached */
330
+ /**
331
+ * Converts to a string representation of this Id.
332
+ *
333
+ * @returns return the 24 character hex string representation.
334
+ */
335
+ inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
336
+ }
337
+
338
+ /** @public */
339
+ declare interface ObjectIdLike {
340
+ id: string | Uint8Array;
341
+ __id?: string;
342
+ toHexString(): string;
343
+ }
344
+
345
+ /**
346
+ * Database collection for storing user accounts with authentication methods and profile information.
347
+ *
348
+ * This is where **signupWithPassword** automatically creates new users.
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * // Find user by email
353
+ * const user = await dbUsers.findOne(
354
+ * { 'emails.address': 'john@example.com' }
355
+ * );
356
+ * ```
357
+ *
358
+ */
359
+ declare const usersCollection: Store<{
360
+ handle: zod.ZodString;
361
+ emails: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
362
+ address: zod.ZodString;
363
+ verified: zod.ZodBoolean;
364
+ }, "strip", zod.ZodTypeAny, {
365
+ address: string;
366
+ verified: boolean;
367
+ }, {
368
+ address: string;
369
+ verified: boolean;
370
+ }>, "many">>;
371
+ status: zod.ZodOptional<zod.ZodEnum<["active", "disabled", "deleted"]>>;
372
+ createdAt: zod.ZodDate;
373
+ disabledAt: zod.ZodOptional<zod.ZodDate>;
374
+ deletedAt: zod.ZodOptional<zod.ZodDate>;
375
+ roles: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
376
+ authMethods: zod.ZodObject<{
377
+ password: zod.ZodOptional<zod.ZodObject<{
378
+ hash: zod.ZodString;
379
+ }, "strip", zod.ZodTypeAny, {
380
+ hash: string;
381
+ }, {
382
+ hash: string;
383
+ }>>;
384
+ google: zod.ZodOptional<zod.ZodObject<{
385
+ id: zod.ZodString;
386
+ }, "strip", zod.ZodTypeAny, {
387
+ id: string;
388
+ }, {
389
+ id: string;
390
+ }>>;
391
+ github: zod.ZodOptional<zod.ZodObject<{
392
+ id: zod.ZodString;
393
+ }, "strip", zod.ZodTypeAny, {
394
+ id: string;
395
+ }, {
396
+ id: string;
397
+ }>>;
398
+ }, "strip", zod.ZodTypeAny, {
399
+ password?: {
400
+ hash: string;
401
+ } | undefined;
402
+ google?: {
403
+ id: string;
404
+ } | undefined;
405
+ github?: {
406
+ id: string;
407
+ } | undefined;
408
+ }, {
409
+ password?: {
410
+ hash: string;
411
+ } | undefined;
412
+ google?: {
413
+ id: string;
414
+ } | undefined;
415
+ github?: {
416
+ id: string;
417
+ } | undefined;
418
+ }>;
419
+ }, Record<string, (this: Pick<InferDocumentType<{
420
+ handle: zod.ZodString;
421
+ emails: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
422
+ address: zod.ZodString;
423
+ verified: zod.ZodBoolean;
424
+ }, "strip", zod.ZodTypeAny, {
425
+ address: string;
426
+ verified: boolean;
427
+ }, {
428
+ address: string;
429
+ verified: boolean;
430
+ }>, "many">>;
431
+ status: zod.ZodOptional<zod.ZodEnum<["active", "disabled", "deleted"]>>;
432
+ createdAt: zod.ZodDate;
433
+ disabledAt: zod.ZodOptional<zod.ZodDate>;
434
+ deletedAt: zod.ZodOptional<zod.ZodDate>;
435
+ roles: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
436
+ authMethods: zod.ZodObject<{
437
+ password: zod.ZodOptional<zod.ZodObject<{
438
+ hash: zod.ZodString;
439
+ }, "strip", zod.ZodTypeAny, {
440
+ hash: string;
441
+ }, {
442
+ hash: string;
443
+ }>>;
444
+ google: zod.ZodOptional<zod.ZodObject<{
445
+ id: zod.ZodString;
446
+ }, "strip", zod.ZodTypeAny, {
447
+ id: string;
448
+ }, {
449
+ id: string;
450
+ }>>;
451
+ github: zod.ZodOptional<zod.ZodObject<{
452
+ id: zod.ZodString;
453
+ }, "strip", zod.ZodTypeAny, {
454
+ id: string;
455
+ }, {
456
+ id: string;
457
+ }>>;
458
+ }, "strip", zod.ZodTypeAny, {
459
+ password?: {
460
+ hash: string;
461
+ } | undefined;
462
+ google?: {
463
+ id: string;
464
+ } | undefined;
465
+ github?: {
466
+ id: string;
467
+ } | undefined;
468
+ }, {
469
+ password?: {
470
+ hash: string;
471
+ } | undefined;
472
+ google?: {
473
+ id: string;
474
+ } | undefined;
475
+ github?: {
476
+ id: string;
477
+ } | undefined;
478
+ }>;
479
+ }>, "handle" | "roles" | "status" | "createdAt" | "emails" | "disabledAt" | "deletedAt" | "authMethods"> & {
480
+ _id: ObjectId;
481
+ }, ...args: any[]) => any>>;
482
+
483
+ declare function disableUser(userId: ObjectId$1): Promise<void>;
484
+ declare function deleteUser(userId: ObjectId$1): Promise<void>;
485
+
486
+ /**
487
+ * This function will check all rate limit rules on the specified bucket and type,
488
+ * throw an error if any of them are exceeded and increase the count of the rate limit record.
489
+ *
490
+ * @category Rate Limits
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * await consumeRateLimit({ bucket: 'api', type: 'ip', value: '127.0.0.1' });
495
+ * ```
496
+ * @param options.bucket - The bucket for the rate limit.
497
+ * @param options.type - The type of the rate limit.
498
+ * @param options.value - The value for the rate limit.
499
+ */
500
+ declare function consumeRateLimit(options: {
501
+ bucket: string;
502
+ type: RateLimitType;
503
+ value: string;
504
+ }): Promise<void>;
505
+
506
+ /**
507
+ * @sidebarTitle getConfig (server)
508
+ *
509
+ * @param key - The configuration key to retrieve
510
+ * @returns The configuration value (string, number, or boolean)
511
+ *
512
+ * @example
513
+ * ```ts
514
+ * import { getConfig } from 'modelence/server';
515
+ *
516
+ * // Get the site URL
517
+ * const siteUrl = getConfig('_system.site.url');
518
+ * ```
519
+ *
520
+ * Set via environment variable:
521
+ * ```bash
522
+ * MODELENCE_SITE_URL=https://myapp.com
523
+ * ```
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * import { getConfig } from 'modelence/server';
528
+ *
529
+ * // Get the current environment (e.g., 'development', 'staging', 'production')
530
+ * const env = getConfig('_system.env');
531
+ *
532
+ * if (env === 'production') {
533
+ * // Enable production features
534
+ * }
535
+ * ```
536
+ *
537
+ * Set via environment variable:
538
+ * ```bash
539
+ * MODELENCE_SITE_ENV=production
540
+ * ```
541
+ */
542
+ declare function getConfig(key: ConfigKey): string | number | boolean;
543
+
544
+ type CloudBackendConnectOkResponse = {
545
+ status: 'ok';
546
+ configs: AppConfig[];
547
+ environmentId: string;
548
+ appAlias: string;
549
+ environmentAlias: string;
550
+ telemetry: {
551
+ isEnabled: boolean;
552
+ serviceName: string;
553
+ };
554
+ };
555
+ type CloudBackendConnectErrorResponse = {
556
+ status: 'error';
557
+ error: string;
558
+ };
559
+ type CloudBackendConnectResponse = CloudBackendConnectOkResponse | CloudBackendConnectErrorResponse;
560
+
561
+ declare function authenticate(authToken: string | null): Promise<{
562
+ session: Session;
563
+ user: UserInfo | null;
564
+ roles: Role[];
565
+ }>;
566
+
567
+ declare function sendEmail(payload: EmailPayload): Promise<void> | undefined;
568
+
569
+ export { type AppOptions, type AuthConfig, type AuthOption, type CloudBackendConnectResponse, CronJobInputParams, type LiveQueryCleanup, type LiveQueryContext, type LiveQueryPublish, Module, RateLimitRule, RateLimitType, RouteDefinition, ServerChannel, Store, UserInfo, authenticate, consumeRateLimit, createQuery, usersCollection as dbUsers, deleteUser, disableUser, getConfig, sendEmail, startApp };