modelence 0.17.0-dev.0 → 0.17.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.
@@ -1,5 +1,6 @@
1
1
  import { Server } from 'http';
2
2
  import { Document, ObjectId } from 'mongodb';
3
+ import { Request, Response } from 'express';
3
4
 
4
5
  /**
5
6
  * The available types for module configuration values.
@@ -189,6 +190,10 @@ type Context = {
189
190
  clientInfo: ClientInfo;
190
191
  connectionInfo: ConnectionInfo;
191
192
  };
193
+ type HttpContext = Context & {
194
+ req: Request;
195
+ res: Response;
196
+ };
192
197
  type Args = Record<string, unknown>;
193
198
  type UpdateProfileProps = {
194
199
  firstName?: string;
@@ -200,7 +205,7 @@ type SignupProps = UpdateProfileProps & {
200
205
  email: string;
201
206
  password: string;
202
207
  };
203
- type Handler<T = unknown> = (args: Args, context: Context) => Promise<T> | T;
208
+ type Handler<T = unknown> = (args: Args, context: Context | HttpContext) => Promise<T> | T;
204
209
  type AnyMethodShape = ((...args: any[]) => any) | {
205
210
  handler: (...args: any[]) => any;
206
211
  };
@@ -280,4 +285,4 @@ interface WebsocketClientProvider {
280
285
  }): void;
281
286
  }
282
287
 
283
- export { type AnyMethodShape as A, type ConfigSchema as C, type DefaultRoles as D, type Handler as H, type MethodDefinition as M, type OAuthProvider as O, type Permission as P, type RoleDefinition as R, ServerChannel as S, type UpdateProfileProps as U, type ValueType as V, type WebsocketClientProvider as W, type WebsocketServerProvider as a, type ConfigKey as b, type ConfigParams as c, type ConfigType as d, ClientChannel as e, type SignupProps as f, type AuthSuccessProps as g, type AuthErrorProps as h, type User as i, type OAuthErrorInfo as j, type AppConfig as k, type Session as l, type UserInfo as m, type Role as n, type Context as o, type Args as p, type AuthProvider as q, type ClientInfo as r, type Configs as s, type ConnectionInfo as t, type Method as u, type MethodType as v, SUPPORTED_OAUTH_PROVIDERS as w, type UserEmail as x };
288
+ export { type AnyMethodShape as A, type ConfigSchema as C, type DefaultRoles as D, type Handler as H, type MethodDefinition as M, type OAuthProvider as O, type Permission as P, type RoleDefinition as R, ServerChannel as S, type UpdateProfileProps as U, type ValueType as V, type WebsocketClientProvider as W, type WebsocketServerProvider as a, type ConfigKey as b, type ConfigParams as c, type ConfigType as d, ClientChannel as e, type SignupProps as f, type AuthSuccessProps as g, type AuthErrorProps as h, type ConnectionInfo as i, type User as j, type OAuthErrorInfo as k, type AppConfig as l, type Session as m, type UserInfo as n, type Role as o, type Context as p, type Args as q, type AuthProvider as r, type ClientInfo as s, type Configs as t, type HttpContext as u, type Method as v, type MethodType as w, SUPPORTED_OAUTH_PROVIDERS as x, type UserEmail as y };
@@ -1,5 +1,5 @@
1
1
  import './index-CLpVWWuj.js';
2
- import { o as Context } from './types-CTjq1HaP.js';
2
+ import { p as Context } from './types-Ba-XOoJD.js';
3
3
  import * as mongodb from 'mongodb';
4
4
  import { WithId, IndexDescription, SearchIndexDescription, MongoClient, Collection, FilterOperators, Document, FindOptions, ObjectId, SortDirection, OptionalUnlessRequiredId, ClientSession, InsertOneResult, InsertManyResult, UpdateFilter, UpdateResult, DeleteResult, FindOneAndUpdateOptions, FindOneAndDeleteOptions, WithoutId, FindOneAndReplaceOptions, ReplaceOptions, DistinctOptions, ChangeStreamOptions, ChangeStream, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteResult } from 'mongodb';
5
5
  import { z, ZodNumber, ZodArray } from 'zod';
@@ -507,7 +507,7 @@ declare class Store<TSchema extends ModelSchema, TMethods extends Record<string,
507
507
  * @param selector - The selector to find the document to delete
508
508
  * @returns The result of the delete operation
509
509
  */
510
- deleteOne(selector: TypedFilter<this['_type']>, options?: {
510
+ deleteOne(selector: TypedFilter<this['_type']> | string | ObjectId, options?: {
511
511
  session?: ClientSession;
512
512
  }): Promise<DeleteResult>;
513
513
  /**
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { A as AppServer, a as AppServerInitOptions, E as ExpressMiddleware, M as ModelenceConfig } from './index-CLpVWWuj.js';
2
- export { A as AnyMethodShape, k as AppConfig, p as Args, h as AuthErrorProps, q as AuthProvider, g as AuthSuccessProps, r as ClientInfo, b as ConfigKey, c as ConfigParams, C as ConfigSchema, d as ConfigType, s as Configs, t as ConnectionInfo, o as Context, D as DefaultRoles, H as Handler, u as Method, M as MethodDefinition, v as MethodType, j as OAuthErrorInfo, O as OAuthProvider, P as Permission, n as Role, R as RoleDefinition, w as SUPPORTED_OAUTH_PROVIDERS, l as Session, f as SignupProps, U as UpdateProfileProps, i as User, x as UserEmail, m as UserInfo, V as ValueType, W as WebsocketClientProvider, a as WebsocketServerProvider } from './types-CTjq1HaP.js';
3
- export { B as BodyConfig, g as CronJob, C as CronJobInputParams, h as CronJobMetadata, i as EmailAttachment, c as EmailPayload, E as EmailProvider, j as ExpressHandler, H as HttpMethod, I as InferDocumentType, M as ModelSchema, a as RateLimitRule, b as RateLimitType, R as RouteDefinition, d as RouteHandler, k as RouteHandlers, e as RouteParams, f as RouteResponse, s as schema } from './types-DNZiaNSs.js';
2
+ export { A as AnyMethodShape, l as AppConfig, q as Args, h as AuthErrorProps, r as AuthProvider, g as AuthSuccessProps, s as ClientInfo, b as ConfigKey, c as ConfigParams, C as ConfigSchema, d as ConfigType, t as Configs, i as ConnectionInfo, p as Context, D as DefaultRoles, H as Handler, u as HttpContext, v as Method, M as MethodDefinition, w as MethodType, k as OAuthErrorInfo, O as OAuthProvider, P as Permission, o as Role, R as RoleDefinition, x as SUPPORTED_OAUTH_PROVIDERS, m as Session, f as SignupProps, U as UpdateProfileProps, j as User, y as UserEmail, n as UserInfo, V as ValueType, W as WebsocketClientProvider, a as WebsocketServerProvider } from './types-Ba-XOoJD.js';
3
+ export { B as BodyConfig, g as CronJob, C as CronJobInputParams, h as CronJobMetadata, i as EmailAttachment, c as EmailPayload, E as EmailProvider, j as ExpressHandler, H as HttpMethod, I as InferDocumentType, M as ModelSchema, a as RateLimitRule, b as RateLimitType, R as RouteDefinition, d as RouteHandler, k as RouteHandlers, e as RouteParams, f as RouteResponse, s as schema } from './types-BrUcinD0.js';
4
4
  import 'express';
5
5
  import 'http';
6
6
  import 'mongodb';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "modelence",
4
- "version": "0.17.0-dev.0",
4
+ "version": "0.17.0",
5
5
  "description": "The Node.js Framework for Real-Time MongoDB Apps",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/global.d.ts",
@@ -32,9 +32,9 @@
32
32
  "lint:check": "eslint src --ext .ts,.tsx",
33
33
  "prepublishOnly": "npm run build",
34
34
  "bench": "tsx src/bench/index.ts",
35
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
36
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
37
- "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "test:coverage": "vitest run --coverage",
38
38
  "postversion": "git push && git push --tags",
39
39
  "prepare": "cd ../.. && git config core.hooksPath .husky"
40
40
  },
@@ -57,7 +57,6 @@
57
57
  "@types/cookie-parser": "^1.4.9",
58
58
  "@types/express": "^5.0.0",
59
59
  "@types/fs-extra": "^11.0.4",
60
- "@types/jest": "^30.0.0",
61
60
  "@types/node": "^22.5.1",
62
61
  "@types/react": "^19.0.0",
63
62
  "@types/react-dom": "^19.0.1",
@@ -66,13 +65,14 @@
66
65
  "@typescript-eslint/parser": "^8.17.0",
67
66
  "eslint": "^9.37.0",
68
67
  "husky": "^9.1.7",
69
- "jest": "^30.2.0",
70
68
  "lint-staged": "^16.2.7",
71
69
  "prettier": "^3.6.2",
72
70
  "react": "^19.0.0",
73
71
  "react-dom": "^19.0.0",
74
- "ts-jest": "^29.4.5",
75
- "ts-node": "^10.9.2"
72
+ "ts-node": "^10.9.2",
73
+ "vitest": "^2.1.8",
74
+ "@vitest/coverage-v8": "^2.1.8",
75
+ "vite-tsconfig-paths": "^5.1.4"
76
76
  },
77
77
  "dependencies": {
78
78
  "@socket.io/mongo-adapter": "^0.4.0",
@@ -1,3 +0,0 @@
1
- var s="module",i="modelence",r="0.17.0-dev.0",o="The Node.js Framework for Real-Time MongoDB Apps",n="dist/index.js",c="dist/global.d.ts",p={".":"./dist/index.js","./client":"./dist/client.js","./server":"./dist/server.js","./telemetry":"./dist/telemetry.js","./mongodb":"./dist/mongo.js","./types":{types:"./dist/types.d.ts",default:"./dist/types.js"}},d=["dist","dist/bin"],l={modelence:"./dist/bin/modelence.js"},a={build:"tsup",dev:"tsup --watch",format:'prettier --write "src/**/*.{ts,tsx,js,jsx,json,css,md}"',"format:check":'prettier --check "src/**/*.{ts,tsx,js,jsx,json,css,md}"',lint:"eslint src --ext .ts,.tsx --fix","lint:check":"eslint src --ext .ts,.tsx",prepublishOnly:"npm run build",bench:"tsx src/bench/index.ts",test:"NODE_OPTIONS=--experimental-vm-modules jest","test:watch":"NODE_OPTIONS=--experimental-vm-modules jest --watch","test:coverage":"NODE_OPTIONS=--experimental-vm-modules jest --coverage",postversion:"git push && git push --tags",prepare:"cd ../.. && git config core.hooksPath .husky"},m={type:"git",url:"git+https://github.com/modelence/modelence.git"},y="Modelence",u="SEE LICENSE IN LICENSE",h={url:"https://github.com/modelence/modelence/issues"},j="https://modelence.com",g={"@types/archiver":"^6.0.3","@types/bcrypt":"^6.0.0","@types/cookie-parser":"^1.4.9","@types/express":"^5.0.0","@types/fs-extra":"^11.0.4","@types/jest":"^30.0.0","@types/node":"^22.5.1","@types/react":"^19.0.0","@types/react-dom":"^19.0.1","@types/socket.io":"^3.0.1","@typescript-eslint/eslint-plugin":"^8.17.0","@typescript-eslint/parser":"^8.17.0",eslint:"^9.37.0",husky:"^9.1.7",jest:"^30.2.0","lint-staged":"^16.2.7",prettier:"^3.6.2",react:"^19.0.0","react-dom":"^19.0.0","ts-jest":"^29.4.5","ts-node":"^10.9.2"},x={"@socket.io/mongo-adapter":"^0.4.0","@vitejs/plugin-react":"^4.3.4",archiver:"^7.0.1",bcrypt:"^6.0.0",commander:"^12.0.0","cookie-parser":"^1.4.7",dotenv:"^16.4.5","elastic-apm-node":"^4.15.0",express:"^4.21.0","fs-extra":"^11.2.0",jiti:"^2.4.2",mongodb:"^6.8.1",open:"^10.1.0","socket.io":"^4.8.1","socket.io-client":"^4.8.1",tsup:"^8.3.6",tsx:"^4.19.3",typescript:"^5.7.2",vite:"^6.0.3","vite-plugin-eslint":"^1.8.1",winston:"^3.15.0","winston-elasticsearch":"^0.19.0",zod:"^3.23.8",zustand:"^5.0.2"},v={react:">=18.0.0","react-dom":">=18.0.0"},b={type:s,name:i,version:r,description:o,main:n,types:c,exports:p,files:d,bin:l,scripts:a,"lint-staged":{"src/**/*.{ts,tsx,js,jsx,json,css,md}":"prettier --write"},repository:m,author:y,license:u,bugs:h,homepage:j,devDependencies:g,dependencies:x,peerDependencies:v};
2
- export{s as a,i as b,r as c,o as d,n as e,c as f,p as g,d as h,l as i,a as j,m as k,y as l,u as m,h as n,j as o,g as p,x as q,v as r,b as s};//# sourceMappingURL=chunk-52CM66XJ.js.map
3
- //# sourceMappingURL=chunk-52CM66XJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json"],"names":["type","name","version","description","main","types","exports","files","bin","scripts","repository","author","license","bugs","homepage","devDependencies","dependencies","peerDependencies","package_default"],"mappings":"AACE,IAAAA,CAAAA,CAAQ,QAAA,CACRC,CAAAA,CAAQ,WAAA,CACRC,CAAAA,CAAW,eACXC,CAAAA,CAAe,kDAAA,CACfC,CAAAA,CAAQ,eAAA,CACRC,CAAAA,CAAS,kBAAA,CACTC,EAAW,CACT,GAAA,CAAK,iBAAA,CACL,UAAA,CAAY,kBAAA,CACZ,UAAA,CAAY,kBAAA,CACZ,aAAA,CAAe,qBAAA,CACf,WAAA,CAAa,iBAAA,CACb,SAAA,CAAW,CACT,KAAA,CAAS,oBACT,OAAA,CAAW,iBACb,CACF,CAAA,CACAC,CAAAA,CAAS,CACP,MAAA,CACA,UACF,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CAAa,SAAA,CACb,gBAAiB,QAAA,CACjB,MAAA,CAAU,SAAA,CACV,kBAAA,CAAoB,SAAA,CACpB,OAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,IAAA,CAAQ,QAAA,CACR,OAAA,CAAW,QAAA,CACX,IAAA,CAAQ,UACR,WAAA,CAAa,QAAA,CACb,kBAAA,CAAoB,QAAA,CACpB,IAAA,CAAQ,QAAA,CACR,GAAA,CAAO,SAAA,CACP,UAAA,CAAc,QAAA,CACd,IAAA,CAAQ,QAAA,CACR,oBAAA,CAAsB,QAAA,CACtB,QAAW,SAAA,CACX,uBAAA,CAAyB,SAAA,CACzB,GAAA,CAAO,SAAA,CACP,OAAA,CAAW,QACb,CAAA,CACAC,CAAAA,CAAoB,CAClB,KAAA,CAAS,UAAA,CACT,WAAA,CAAa,UACf,EAzGFC,CAAAA,CAAA,CACE,IAAA,CAAAlB,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CAWA,KAAA,CAAAC,CAAAA,CAIA,GAAA,CAAAC,CAAAA,CAGA,OAAA,CAAAC,CAAAA,CAeA,aAAA,CAAe,CACb,sCAAA,CAAwC,kBAC1C,CAAA,CACA,UAAA,CAAAC,CAAAA,CAIA,OAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CAGA,QAAA,CAAAC,CAAAA,CACA,eAAA,CAAAC,CAAAA,CAuBA,YAAA,CAAAC,CAAAA,CA0BA,gBAAA,CAAAC,CAIF","file":"chunk-52CM66XJ.js","sourcesContent":["{\n \"type\": \"module\",\n \"name\": \"modelence\",\n \"version\": \"0.17.0-dev.0\",\n \"description\": \"The Node.js Framework for Real-Time MongoDB Apps\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/global.d.ts\",\n \"exports\": {\n \".\": \"./dist/index.js\",\n \"./client\": \"./dist/client.js\",\n \"./server\": \"./dist/server.js\",\n \"./telemetry\": \"./dist/telemetry.js\",\n \"./mongodb\": \"./dist/mongo.js\",\n \"./types\": {\n \"types\": \"./dist/types.d.ts\",\n \"default\": \"./dist/types.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"dist/bin\"\n ],\n \"bin\": {\n \"modelence\": \"./dist/bin/modelence.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx,js,jsx,json,css,md}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx,js,jsx,json,css,md}\\\"\",\n \"lint\": \"eslint src --ext .ts,.tsx --fix\",\n \"lint:check\": \"eslint src --ext .ts,.tsx\",\n \"prepublishOnly\": \"npm run build\",\n \"bench\": \"tsx src/bench/index.ts\",\n \"test\": \"NODE_OPTIONS=--experimental-vm-modules jest\",\n \"test:watch\": \"NODE_OPTIONS=--experimental-vm-modules jest --watch\",\n \"test:coverage\": \"NODE_OPTIONS=--experimental-vm-modules jest --coverage\",\n \"postversion\": \"git push && git push --tags\",\n \"prepare\": \"cd ../.. && git config core.hooksPath .husky\"\n },\n \"lint-staged\": {\n \"src/**/*.{ts,tsx,js,jsx,json,css,md}\": \"prettier --write\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/modelence/modelence.git\"\n },\n \"author\": \"Modelence\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"bugs\": {\n \"url\": \"https://github.com/modelence/modelence/issues\"\n },\n \"homepage\": \"https://modelence.com\",\n \"devDependencies\": {\n \"@types/archiver\": \"^6.0.3\",\n \"@types/bcrypt\": \"^6.0.0\",\n \"@types/cookie-parser\": \"^1.4.9\",\n \"@types/express\": \"^5.0.0\",\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/jest\": \"^30.0.0\",\n \"@types/node\": \"^22.5.1\",\n \"@types/react\": \"^19.0.0\",\n \"@types/react-dom\": \"^19.0.1\",\n \"@types/socket.io\": \"^3.0.1\",\n \"@typescript-eslint/eslint-plugin\": \"^8.17.0\",\n \"@typescript-eslint/parser\": \"^8.17.0\",\n \"eslint\": \"^9.37.0\",\n \"husky\": \"^9.1.7\",\n \"jest\": \"^30.2.0\",\n \"lint-staged\": \"^16.2.7\",\n \"prettier\": \"^3.6.2\",\n \"react\": \"^19.0.0\",\n \"react-dom\": \"^19.0.0\",\n \"ts-jest\": \"^29.4.5\",\n \"ts-node\": \"^10.9.2\"\n },\n \"dependencies\": {\n \"@socket.io/mongo-adapter\": \"^0.4.0\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"archiver\": \"^7.0.1\",\n \"bcrypt\": \"^6.0.0\",\n \"commander\": \"^12.0.0\",\n \"cookie-parser\": \"^1.4.7\",\n \"dotenv\": \"^16.4.5\",\n \"elastic-apm-node\": \"^4.15.0\",\n \"express\": \"^4.21.0\",\n \"fs-extra\": \"^11.2.0\",\n \"jiti\": \"^2.4.2\",\n \"mongodb\": \"^6.8.1\",\n \"open\": \"^10.1.0\",\n \"socket.io\": \"^4.8.1\",\n \"socket.io-client\": \"^4.8.1\",\n \"tsup\": \"^8.3.6\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.7.2\",\n \"vite\": \"^6.0.3\",\n \"vite-plugin-eslint\": \"^1.8.1\",\n \"winston\": \"^3.15.0\",\n \"winston-elasticsearch\": \"^0.19.0\",\n \"zod\": \"^3.23.8\",\n \"zustand\": \"^5.0.2\"\n },\n \"peerDependencies\": {\n \"react\": \">=18.0.0\",\n \"react-dom\": \">=18.0.0\"\n }\n}\n"]}