@gravito/dark-matter 1.1.1 → 2.0.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/README.md CHANGED
@@ -35,18 +35,30 @@ const users = await Mongo.collection('users')
35
35
  await Mongo.disconnect()
36
36
  ```
37
37
 
38
- ## Features
39
-
40
- - 🚀 **Bun Native** - Optimized for Bun runtime
41
- - 🎯 **Laravel-style API** - Familiar fluent interface
42
- - 🔍 **Query Builder** - Type-safe query building
43
- - 📊 **Aggregation Pipeline** - Fluent aggregation API
44
- - 🔌 **Multi-connection** - Named connections support
45
- - 🛡️ **Transactions** - ACID transactions with convenient API
46
- - 🗑️ **Soft Deletes** - Built-in soft delete support with restore capability
47
- - 📦 **GridFS** - Handle large file uploads/downloads
48
- - ⚡ **Change Streams** - Real-time database event listening
49
- - **Schema Validation** - Type-safe Schema Builder API for MongoDB validation
38
+ ## Features
39
+
40
+ - 🚀 **Bun Native Performance**: Optimized for the Bun runtime with zero-copy data handling.
41
+ - 🌌 **Galaxy-Ready Persistence**: Native integration with PlanetCore for universal NoSQL data management.
42
+ - 🎯 **Laravel-style API**: Familiar, fluent interface for MongoDB collections and aggregation pipelines.
43
+ - 🛡️ **Distributed Document State**: ACID transactions and robust multi-connection management across the Galaxy.
44
+ - 🗑️ **Soft Deletes**: Built-in logic for logical record deletion with restoration support.
45
+ - 📦 **GridFS & Streams**: Specialized support for large-scale file storage and real-time change listening.
46
+
47
+ ## 🌌 Role in Galaxy Architecture
48
+
49
+ In the **Gravito Galaxy Architecture**, Dark Matter acts as the **MongoDB Gravity Core (NoSQL Persistence)**.
50
+
51
+ - **Document Focus**: Provides an alternative gravity core for Satellites that require schema-less flexibility or massive-scale document storage.
52
+ - **Micro-State Bridge**: Enables real-time reactive logic via MongoDB Change Streams, allowing one Satellite to react instantly to data changes in another.
53
+ - **File Distribution**: Leverages GridFS to provide a distributed file storage layer that works alongside `@gravito/nebula`.
54
+
55
+ ```mermaid
56
+ graph TD
57
+ S1[Satellite: Analytics] -- "Save" --> DM{Dark Matter}
58
+ S2[Satellite: Logs] -- "Query" --> DM
59
+ DM -->|Native Driver| MongoDB[(MongoDB Atlas)]
60
+ DM -.->|Watch| Realtime[Real-time Events]
61
+ ```
50
62
 
51
63
  ## API Reference
52
64
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -30,6 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
29
  // src/index.ts
31
30
  var index_exports = {};
32
31
  __export(index_exports, {
32
+ DarkMatterError: () => DarkMatterError,
33
+ DarkMatterErrorCodes: () => DarkMatterErrorCodes,
33
34
  Mongo: () => Mongo,
34
35
  MongoAggregateBuilder: () => MongoAggregateBuilder,
35
36
  MongoClient: () => MongoClient,
@@ -42,6 +43,25 @@ __export(index_exports, {
42
43
  });
43
44
  module.exports = __toCommonJS(index_exports);
44
45
 
46
+ // src/errors/DarkMatterError.ts
47
+ var import_core = require("@gravito/core");
48
+ var DarkMatterError = class extends import_core.InfrastructureException {
49
+ constructor(status, code, options = {}) {
50
+ super(status, code, options);
51
+ this.name = "DarkMatterError";
52
+ Object.setPrototypeOf(this, new.target.prototype);
53
+ }
54
+ };
55
+
56
+ // src/errors/codes.ts
57
+ var DarkMatterErrorCodes = {
58
+ CONNECTION_FAILED: "dark_matter.connection_failed",
59
+ NOT_CONNECTED: "dark_matter.not_connected",
60
+ CONNECTION_NOT_CONFIGURED: "dark_matter.connection_not_configured",
61
+ GRIDFS_NOT_INITIALIZED: "dark_matter.gridfs_not_initialized",
62
+ OPERATION_FAILED: "dark_matter.operation_failed"
63
+ };
64
+
45
65
  // src/MongoQueryBuilder.ts
46
66
  var MongoQueryBuilder = class _MongoQueryBuilder {
47
67
  constructor(nativeCollection, collectionName, session) {
@@ -1146,26 +1166,38 @@ var MongoClient = class {
1146
1166
  if (this.config.socketTimeoutMS) {
1147
1167
  options.socketTimeoutMS = this.config.socketTimeoutMS;
1148
1168
  }
1149
- this.client = new this.mongodb.MongoClient(uri, options);
1150
1169
  let lastError = null;
1151
1170
  for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
1171
+ const client = new this.mongodb.MongoClient(uri, options);
1172
+ this.client = client;
1152
1173
  try {
1153
- await this.client.connect();
1174
+ await client.connect();
1154
1175
  const dbName = this.config.database ?? "test";
1155
- this.db = this.client.db(dbName);
1176
+ this.db = client.db(dbName);
1156
1177
  this.connected = true;
1157
1178
  return;
1158
1179
  } catch (error) {
1159
1180
  lastError = error;
1181
+ this.connected = false;
1182
+ this.db = null;
1183
+ try {
1184
+ await client.close();
1185
+ } catch {
1186
+ }
1187
+ if (this.client === client) {
1188
+ this.client = null;
1189
+ }
1160
1190
  if (attempt < config.maxRetries) {
1161
1191
  const delay = config.retryDelayMs * config.backoffMultiplier ** attempt;
1162
1192
  await new Promise((resolve) => setTimeout(resolve, delay));
1163
1193
  }
1164
1194
  }
1165
1195
  }
1166
- throw new Error(
1167
- `Failed to connect to MongoDB after ${config.maxRetries + 1} attempts: ${lastError?.message}`
1168
- );
1196
+ throw new DarkMatterError(503, DarkMatterErrorCodes.CONNECTION_FAILED, {
1197
+ message: `Failed to connect to MongoDB after ${config.maxRetries + 1} attempts: ${lastError?.message}`,
1198
+ cause: lastError,
1199
+ retryable: true
1200
+ });
1169
1201
  }
1170
1202
  /**
1171
1203
  * Closes the connection to the MongoDB server.
@@ -1355,20 +1387,24 @@ var MongoClient = class {
1355
1387
  const mongodb = await import("mongodb");
1356
1388
  return mongodb;
1357
1389
  } catch {
1358
- throw new Error(
1359
- 'MongoDB client requires the "mongodb" package. Please install it: bun add mongodb'
1360
- );
1390
+ throw new DarkMatterError(500, DarkMatterErrorCodes.CONNECTION_FAILED, {
1391
+ message: 'MongoDB client requires the "mongodb" package. Please install it: bun add mongodb'
1392
+ });
1361
1393
  }
1362
1394
  }
1363
1395
  getClient() {
1364
1396
  if (!this.client) {
1365
- throw new Error("MongoDB client not connected. Call connect() first.");
1397
+ throw new DarkMatterError(503, DarkMatterErrorCodes.NOT_CONNECTED, {
1398
+ message: "MongoDB client not connected. Call connect() first."
1399
+ });
1366
1400
  }
1367
1401
  return this.client;
1368
1402
  }
1369
1403
  getDatabase() {
1370
1404
  if (!this.db) {
1371
- throw new Error("MongoDB client not connected. Call connect() first.");
1405
+ throw new DarkMatterError(503, DarkMatterErrorCodes.NOT_CONNECTED, {
1406
+ message: "MongoDB client not connected. Call connect() first."
1407
+ });
1372
1408
  }
1373
1409
  return this.db;
1374
1410
  }
@@ -1491,7 +1527,9 @@ var MongoManager = class {
1491
1527
  if (!this.connections.has(connectionName)) {
1492
1528
  const config = this.configs.get(connectionName);
1493
1529
  if (!config) {
1494
- throw new Error(`MongoDB connection "${connectionName}" not configured`);
1530
+ throw new DarkMatterError(500, DarkMatterErrorCodes.CONNECTION_NOT_CONFIGURED, {
1531
+ message: `MongoDB connection "${connectionName}" not configured`
1532
+ });
1495
1533
  }
1496
1534
  this.connections.set(connectionName, new MongoClient(config));
1497
1535
  }
@@ -1995,7 +2033,10 @@ var MongoGridFS = class {
1995
2033
  }
1996
2034
  async ensureBucket() {
1997
2035
  if (!this.bucket) {
1998
- throw new Error("GridFS bucket not initialized. Please wait a moment after creation.");
2036
+ throw new DarkMatterError(503, DarkMatterErrorCodes.GRIDFS_NOT_INITIALIZED, {
2037
+ message: "GridFS bucket not initialized. Please wait a moment after creation.",
2038
+ retryable: true
2039
+ });
1999
2040
  }
2000
2041
  }
2001
2042
  };
@@ -2305,6 +2346,8 @@ function schema() {
2305
2346
  }
2306
2347
  // Annotate the CommonJS export names for ESM import in node:
2307
2348
  0 && (module.exports = {
2349
+ DarkMatterError,
2350
+ DarkMatterErrorCodes,
2308
2351
  Mongo,
2309
2352
  MongoAggregateBuilder,
2310
2353
  MongoClient,
package/dist/index.d.cts CHANGED
@@ -1,3 +1,27 @@
1
+ import { InfrastructureException, InfrastructureExceptionOptions } from '@gravito/core';
2
+
3
+ /**
4
+ * Error codes for the dark-matter package.
5
+ * @public
6
+ */
7
+ declare const DarkMatterErrorCodes: {
8
+ readonly CONNECTION_FAILED: "dark_matter.connection_failed";
9
+ readonly NOT_CONNECTED: "dark_matter.not_connected";
10
+ readonly CONNECTION_NOT_CONFIGURED: "dark_matter.connection_not_configured";
11
+ readonly GRIDFS_NOT_INITIALIZED: "dark_matter.gridfs_not_initialized";
12
+ readonly OPERATION_FAILED: "dark_matter.operation_failed";
13
+ };
14
+ type DarkMatterErrorCode = (typeof DarkMatterErrorCodes)[keyof typeof DarkMatterErrorCodes];
15
+
16
+ /**
17
+ * Concrete error class for the dark-matter (MongoDB) package.
18
+ * Extends InfrastructureException to participate in the GravitoException hierarchy.
19
+ * @public
20
+ */
21
+ declare class DarkMatterError extends InfrastructureException {
22
+ constructor(status: number, code: DarkMatterErrorCode, options?: InfrastructureExceptionOptions);
23
+ }
24
+
1
25
  /**
2
26
  * @gravito/dark-matter - Type Definitions
3
27
  */
@@ -1035,7 +1059,7 @@ declare class MongoQueryBuilder<T = Document> implements MongoCollectionContract
1035
1059
  private limitCount;
1036
1060
  private skipCount;
1037
1061
  private softDeleteMode;
1038
- constructor(nativeCollection: MongoNativeCollection, collectionName: string, session?: unknown | undefined);
1062
+ constructor(nativeCollection: MongoNativeCollection, collectionName: string, session?: unknown);
1039
1063
  /**
1040
1064
  * Adds a basic WHERE clause to the query.
1041
1065
  *
@@ -1953,4 +1977,4 @@ declare class MongoSchemaBuilder {
1953
1977
  */
1954
1978
  declare function schema(): MongoSchemaBuilder;
1955
1979
 
1956
- export { type BulkWriteOperation, type BulkWriteResult, type DeleteResult, type Document$1 as Document, type FilterDocument, type FilterOperator, type GridFSFile, type GridFSUploadOptions, type GridFSUploadProgress, type InsertManyResult, type InsertResult, type LookupOptions, Mongo, MongoAggregateBuilder, type MongoAggregateContract, MongoClient, type MongoClientContract, type MongoCollectionContract, type MongoConfig, type MongoDatabaseContract, MongoGridFS, MongoManager, type MongoManagerConfig, MongoPoolMonitor, MongoQueryBuilder, MongoSchemaBuilder, type MongoSession, type PipelineStage, type PoolMetrics, type Projection, type RetryConfig, type SchemaValidationOptions, type SoftDeletableDocument, type SortDirection, type SortSpec, type TransactionOptions, type UpdateDocument, type UpdateResult, schema };
1980
+ export { type BulkWriteOperation, type BulkWriteResult, DarkMatterError, type DarkMatterErrorCode, DarkMatterErrorCodes, type DeleteResult, type Document$1 as Document, type FilterDocument, type FilterOperator, type GridFSFile, type GridFSUploadOptions, type GridFSUploadProgress, type InsertManyResult, type InsertResult, type LookupOptions, Mongo, MongoAggregateBuilder, type MongoAggregateContract, MongoClient, type MongoClientContract, type MongoCollectionContract, type MongoConfig, type MongoDatabaseContract, MongoGridFS, MongoManager, type MongoManagerConfig, MongoPoolMonitor, MongoQueryBuilder, MongoSchemaBuilder, type MongoSession, type PipelineStage, type PoolMetrics, type Projection, type RetryConfig, type SchemaValidationOptions, type SoftDeletableDocument, type SortDirection, type SortSpec, type TransactionOptions, type UpdateDocument, type UpdateResult, schema };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,27 @@
1
+ import { InfrastructureException, InfrastructureExceptionOptions } from '@gravito/core';
2
+
3
+ /**
4
+ * Error codes for the dark-matter package.
5
+ * @public
6
+ */
7
+ declare const DarkMatterErrorCodes: {
8
+ readonly CONNECTION_FAILED: "dark_matter.connection_failed";
9
+ readonly NOT_CONNECTED: "dark_matter.not_connected";
10
+ readonly CONNECTION_NOT_CONFIGURED: "dark_matter.connection_not_configured";
11
+ readonly GRIDFS_NOT_INITIALIZED: "dark_matter.gridfs_not_initialized";
12
+ readonly OPERATION_FAILED: "dark_matter.operation_failed";
13
+ };
14
+ type DarkMatterErrorCode = (typeof DarkMatterErrorCodes)[keyof typeof DarkMatterErrorCodes];
15
+
16
+ /**
17
+ * Concrete error class for the dark-matter (MongoDB) package.
18
+ * Extends InfrastructureException to participate in the GravitoException hierarchy.
19
+ * @public
20
+ */
21
+ declare class DarkMatterError extends InfrastructureException {
22
+ constructor(status: number, code: DarkMatterErrorCode, options?: InfrastructureExceptionOptions);
23
+ }
24
+
1
25
  /**
2
26
  * @gravito/dark-matter - Type Definitions
3
27
  */
@@ -1035,7 +1059,7 @@ declare class MongoQueryBuilder<T = Document> implements MongoCollectionContract
1035
1059
  private limitCount;
1036
1060
  private skipCount;
1037
1061
  private softDeleteMode;
1038
- constructor(nativeCollection: MongoNativeCollection, collectionName: string, session?: unknown | undefined);
1062
+ constructor(nativeCollection: MongoNativeCollection, collectionName: string, session?: unknown);
1039
1063
  /**
1040
1064
  * Adds a basic WHERE clause to the query.
1041
1065
  *
@@ -1953,4 +1977,4 @@ declare class MongoSchemaBuilder {
1953
1977
  */
1954
1978
  declare function schema(): MongoSchemaBuilder;
1955
1979
 
1956
- export { type BulkWriteOperation, type BulkWriteResult, type DeleteResult, type Document$1 as Document, type FilterDocument, type FilterOperator, type GridFSFile, type GridFSUploadOptions, type GridFSUploadProgress, type InsertManyResult, type InsertResult, type LookupOptions, Mongo, MongoAggregateBuilder, type MongoAggregateContract, MongoClient, type MongoClientContract, type MongoCollectionContract, type MongoConfig, type MongoDatabaseContract, MongoGridFS, MongoManager, type MongoManagerConfig, MongoPoolMonitor, MongoQueryBuilder, MongoSchemaBuilder, type MongoSession, type PipelineStage, type PoolMetrics, type Projection, type RetryConfig, type SchemaValidationOptions, type SoftDeletableDocument, type SortDirection, type SortSpec, type TransactionOptions, type UpdateDocument, type UpdateResult, schema };
1980
+ export { type BulkWriteOperation, type BulkWriteResult, DarkMatterError, type DarkMatterErrorCode, DarkMatterErrorCodes, type DeleteResult, type Document$1 as Document, type FilterDocument, type FilterOperator, type GridFSFile, type GridFSUploadOptions, type GridFSUploadProgress, type InsertManyResult, type InsertResult, type LookupOptions, Mongo, MongoAggregateBuilder, type MongoAggregateContract, MongoClient, type MongoClientContract, type MongoCollectionContract, type MongoConfig, type MongoDatabaseContract, MongoGridFS, MongoManager, type MongoManagerConfig, MongoPoolMonitor, MongoQueryBuilder, MongoSchemaBuilder, type MongoSession, type PipelineStage, type PoolMetrics, type Projection, type RetryConfig, type SchemaValidationOptions, type SoftDeletableDocument, type SortDirection, type SortSpec, type TransactionOptions, type UpdateDocument, type UpdateResult, schema };
package/dist/index.js CHANGED
@@ -1,3 +1,22 @@
1
+ // src/errors/DarkMatterError.ts
2
+ import { InfrastructureException } from "@gravito/core";
3
+ var DarkMatterError = class extends InfrastructureException {
4
+ constructor(status, code, options = {}) {
5
+ super(status, code, options);
6
+ this.name = "DarkMatterError";
7
+ Object.setPrototypeOf(this, new.target.prototype);
8
+ }
9
+ };
10
+
11
+ // src/errors/codes.ts
12
+ var DarkMatterErrorCodes = {
13
+ CONNECTION_FAILED: "dark_matter.connection_failed",
14
+ NOT_CONNECTED: "dark_matter.not_connected",
15
+ CONNECTION_NOT_CONFIGURED: "dark_matter.connection_not_configured",
16
+ GRIDFS_NOT_INITIALIZED: "dark_matter.gridfs_not_initialized",
17
+ OPERATION_FAILED: "dark_matter.operation_failed"
18
+ };
19
+
1
20
  // src/MongoQueryBuilder.ts
2
21
  var MongoQueryBuilder = class _MongoQueryBuilder {
3
22
  constructor(nativeCollection, collectionName, session) {
@@ -1102,26 +1121,38 @@ var MongoClient = class {
1102
1121
  if (this.config.socketTimeoutMS) {
1103
1122
  options.socketTimeoutMS = this.config.socketTimeoutMS;
1104
1123
  }
1105
- this.client = new this.mongodb.MongoClient(uri, options);
1106
1124
  let lastError = null;
1107
1125
  for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
1126
+ const client = new this.mongodb.MongoClient(uri, options);
1127
+ this.client = client;
1108
1128
  try {
1109
- await this.client.connect();
1129
+ await client.connect();
1110
1130
  const dbName = this.config.database ?? "test";
1111
- this.db = this.client.db(dbName);
1131
+ this.db = client.db(dbName);
1112
1132
  this.connected = true;
1113
1133
  return;
1114
1134
  } catch (error) {
1115
1135
  lastError = error;
1136
+ this.connected = false;
1137
+ this.db = null;
1138
+ try {
1139
+ await client.close();
1140
+ } catch {
1141
+ }
1142
+ if (this.client === client) {
1143
+ this.client = null;
1144
+ }
1116
1145
  if (attempt < config.maxRetries) {
1117
1146
  const delay = config.retryDelayMs * config.backoffMultiplier ** attempt;
1118
1147
  await new Promise((resolve) => setTimeout(resolve, delay));
1119
1148
  }
1120
1149
  }
1121
1150
  }
1122
- throw new Error(
1123
- `Failed to connect to MongoDB after ${config.maxRetries + 1} attempts: ${lastError?.message}`
1124
- );
1151
+ throw new DarkMatterError(503, DarkMatterErrorCodes.CONNECTION_FAILED, {
1152
+ message: `Failed to connect to MongoDB after ${config.maxRetries + 1} attempts: ${lastError?.message}`,
1153
+ cause: lastError,
1154
+ retryable: true
1155
+ });
1125
1156
  }
1126
1157
  /**
1127
1158
  * Closes the connection to the MongoDB server.
@@ -1311,20 +1342,24 @@ var MongoClient = class {
1311
1342
  const mongodb = await import("mongodb");
1312
1343
  return mongodb;
1313
1344
  } catch {
1314
- throw new Error(
1315
- 'MongoDB client requires the "mongodb" package. Please install it: bun add mongodb'
1316
- );
1345
+ throw new DarkMatterError(500, DarkMatterErrorCodes.CONNECTION_FAILED, {
1346
+ message: 'MongoDB client requires the "mongodb" package. Please install it: bun add mongodb'
1347
+ });
1317
1348
  }
1318
1349
  }
1319
1350
  getClient() {
1320
1351
  if (!this.client) {
1321
- throw new Error("MongoDB client not connected. Call connect() first.");
1352
+ throw new DarkMatterError(503, DarkMatterErrorCodes.NOT_CONNECTED, {
1353
+ message: "MongoDB client not connected. Call connect() first."
1354
+ });
1322
1355
  }
1323
1356
  return this.client;
1324
1357
  }
1325
1358
  getDatabase() {
1326
1359
  if (!this.db) {
1327
- throw new Error("MongoDB client not connected. Call connect() first.");
1360
+ throw new DarkMatterError(503, DarkMatterErrorCodes.NOT_CONNECTED, {
1361
+ message: "MongoDB client not connected. Call connect() first."
1362
+ });
1328
1363
  }
1329
1364
  return this.db;
1330
1365
  }
@@ -1447,7 +1482,9 @@ var MongoManager = class {
1447
1482
  if (!this.connections.has(connectionName)) {
1448
1483
  const config = this.configs.get(connectionName);
1449
1484
  if (!config) {
1450
- throw new Error(`MongoDB connection "${connectionName}" not configured`);
1485
+ throw new DarkMatterError(500, DarkMatterErrorCodes.CONNECTION_NOT_CONFIGURED, {
1486
+ message: `MongoDB connection "${connectionName}" not configured`
1487
+ });
1451
1488
  }
1452
1489
  this.connections.set(connectionName, new MongoClient(config));
1453
1490
  }
@@ -1951,7 +1988,10 @@ var MongoGridFS = class {
1951
1988
  }
1952
1989
  async ensureBucket() {
1953
1990
  if (!this.bucket) {
1954
- throw new Error("GridFS bucket not initialized. Please wait a moment after creation.");
1991
+ throw new DarkMatterError(503, DarkMatterErrorCodes.GRIDFS_NOT_INITIALIZED, {
1992
+ message: "GridFS bucket not initialized. Please wait a moment after creation.",
1993
+ retryable: true
1994
+ });
1955
1995
  }
1956
1996
  }
1957
1997
  };
@@ -2260,6 +2300,8 @@ function schema() {
2260
2300
  return new MongoSchemaBuilder();
2261
2301
  }
2262
2302
  export {
2303
+ DarkMatterError,
2304
+ DarkMatterErrorCodes,
2263
2305
  Mongo,
2264
2306
  MongoAggregateBuilder,
2265
2307
  MongoClient,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@gravito/dark-matter",
3
- "version": "1.1.1",
3
+ "sideEffects": false,
4
+ "version": "2.0.0",
4
5
  "description": "MongoDB client for Gravito - Bun native, Laravel-style API",
5
6
  "type": "module",
6
7
  "main": "./dist/index.js",
@@ -14,6 +15,7 @@
14
15
  },
15
16
  "scripts": {
16
17
  "build": "bun run build.ts",
18
+ "build:dts": "bun run build.ts --dts-only",
17
19
  "test": "bun test --timeout=10000",
18
20
  "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
19
21
  "test:coverage": "bun test --timeout=10000 --coverage --coverage-reporter=lcov --coverage-dir coverage && bun run --bun scripts/check-coverage.ts",
@@ -26,7 +28,7 @@
26
28
  "bench:schema": "MONGODB_URI=mongodb://localhost:27017 bun test benchmarks/schema-validation.bench.ts",
27
29
  "bench:transactions": "MONGODB_URI=mongodb://localhost:27017 bun test benchmarks/transactions.bench.ts",
28
30
  "bench:change-streams": "MONGODB_URI=mongodb://localhost:27017 bun test benchmarks/change-streams.bench.ts",
29
- "test:unit": "bun test tests/ --timeout=10000",
31
+ "test:unit": "bun test $(find tests -name '*.test.ts' ! -name '*.integration.test.ts' 2>/dev/null | tr '\\n' ' ') --timeout=10000",
30
32
  "test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'"
31
33
  },
32
34
  "files": [