@ignex/ninox 0.1.3 → 0.1.4

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
@@ -195,7 +195,7 @@ A quick tour — each entry links to the full guide further down.
195
195
  | 🔄 | [Background refresh](#background-refresh-system) | Self-updating standalone cache — reads never block |
196
196
  | 🧹 | [Data invalidation](#data-invalidation-react-query-style) | React Query-style — invalidate by name, params, or collection |
197
197
  | 🛡️ | [Error handling](#error-handling) | `BadRequest` / `DomainError` / `InfraError` + HTTP mapping |
198
- | ✅ | [Validation & drift](#validation) | DB `$jsonSchema` (strict) + opt-in drift detection |
198
+ | ✅ | [Validation & drift](#error-handling) | DB `$jsonSchema` (strict) + opt-in drift detection |
199
199
  | 🪝 | [Mongo hooks](#hooks) | `before/after` create/update/delete + `afterRead` |
200
200
  | 🩺 | [Health & multi-DB](#operations-health--multi-db) | Per-DB pings, multi-client services, change-stream watch |
201
201
 
@@ -465,7 +465,7 @@ const users = defineCollection('users', userSchema, {
465
465
  const runner = createMongoMigrationRunner(service, { migrationDir: './migrations' });
466
466
  await runner.up(); // apply pending migrations in numeric order
467
467
  await runner.down('001_seed'); // roll back to a target migration
468
- await runner.scaffold('add_tags'); // create a new NNN_add_tags.ts template
468
+ await runner.create('add_tags'); // create a new NNN_add_tags.ts template
469
469
  ```
470
470
 
471
471
  ## Performance by default
@@ -937,14 +937,11 @@ and a perf-by-default comparison. Run any of them with
937
937
 
938
938
  ## Performance
939
939
 
940
- | scenario | naive | optimized |
941
- | --- | --- | --- |
942
- | populate 100 orders | 17,000 queries (N+1) | **340 queries** (~50× fewer round trips) |
943
- | paginate | count + find (2 round trips) | `$facet` **1 round trip** |
944
- | cache hit | 1 driver call | **0 driver calls** |
945
- | 50 concurrent identical reads | 50 server queries, 17 ms | **1 server query**, 1.5 ms |
940
+ The headline numbers are in the ["ninox vs native MongoDB vs Mongoose" table](#ninox-vs-native-mongodb-vs-mongoose)
941
+ above (N+1 population, concurrent-read dedup, cache hits, aggregation).
946
942
 
947
- Run the full harness (requires local MongoDB, see `.env`):
943
+ Run the full harness (requires local MongoDB, see `.env`) to reproduce or
944
+ extend them:
948
945
 
949
946
  ```bash
950
947
  bun run bench # → bench/results/summary.json
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as mongodb from 'mongodb';
2
2
  import { Db, MongoClient, ClientSession, Document, Filter, Hint, CollationOptions, ReadPreferenceLike, ReadConcern, WriteConcern, WithId, Condition, RootFilterOperators, Collection, FindOptions, Sort, FindCursor, ObjectId, Decimal128, ReadConcernLike, AggregateOptions, AggregationCursor, CreateCollectionOptions, TransactionOptions, InsertOneOptions, InsertOneResult, InsertManyResult, UpdateOptions, UpdateResult, FindOneAndUpdateOptions, DeleteResult, ChangeStreamOptions, ChangeStream } from 'mongodb';
3
- import { L as LoggerLike } from './timeout-BgrqtMnd.js';
4
- export { C as CacheOptions, a as LRU, b as LRUOptions, c as LogFn, d as LogLevel, e as createCachedAsyncFactory, f as createCachedFactory, g as createConsoleLogger, h as createNoopLogger, i as hashString, s as sleep, j as sleepJittered, k as stableHash, l as stableStringify, w as withTimeout } from './timeout-BgrqtMnd.js';
3
+ import { L as LoggerLike } from './timeout-BE_ULjdG.js';
4
+ export { C as CacheOptions, a as LRU, b as LRUOptions, c as LogFn, d as LogLevel, e as createCachedAsyncFactory, f as createCachedFactory, g as createConsoleLogger, h as createNoopLogger, i as hashString, s as sleep, j as sleepJittered, k as stableHash, l as stableStringify, w as withTimeout } from './timeout-BE_ULjdG.js';
5
5
  import * as bson from 'bson';
6
6
 
7
7
  /**
@@ -150,7 +150,7 @@ declare class HotCache {
150
150
  private startAttempted;
151
151
  private stopped;
152
152
  private disposed;
153
- private startPromise?;
153
+ private startPromise;
154
154
  constructor(options?: HotCacheOptions);
155
155
  /** Number of cached entries across all registered queries. */
156
156
  get size(): number;
@@ -2144,7 +2144,7 @@ interface PaginationConfig {
2144
2144
  postPipeline?: Document[];
2145
2145
  queryOptions?: QueryOptions;
2146
2146
  }
2147
- interface CursorPaginationConfig<T = Document> {
2147
+ interface CursorPaginationConfig {
2148
2148
  limit?: number;
2149
2149
  /**
2150
2150
  * Sort keys (1 ascending / -1 descending). MUST include a unique tiebreaker —
@@ -2190,7 +2190,7 @@ interface PaginationOpsOptions {
2190
2190
  * and stays uncached (its opaque cursor pages are largely unique).
2191
2191
  */
2192
2192
  declare const makePaginationOps: <TClients extends DbClientsDefinition, TDb extends ExtractDbNames<TClients>>(client: Db, dbLabel: string, logger: LoggerLike, opts: PaginationOpsOptions) => {
2193
- paginateCursor: <X extends ExtractCollectionNames<TClients, TDb>>(collection: X, baseFilter: FilterInput<CollectionDoc<TClients[TDb]["collections"][X]>>, config: CursorPaginationConfig<CollectionDoc<TClients[TDb]["collections"][X]>>) => Promise<CursorPage<CollectionDoc<TClients[TDb]["collections"][X]>>>;
2193
+ paginateCursor: <X extends ExtractCollectionNames<TClients, TDb>>(collection: X, baseFilter: FilterInput<CollectionDoc<TClients[TDb]["collections"][X]>>, config: CursorPaginationConfig) => Promise<CursorPage<CollectionDoc<TClients[TDb]["collections"][X]>>>;
2194
2194
  paginateFlexible: <X extends ExtractCollectionNames<TClients, TDb>>(collection: X, baseFilter: FilterInput<CollectionDoc<TClients[TDb]["collections"][X]>>, config?: PaginationConfig) => Promise<PaginationResult<CollectionDoc<TClients[TDb]["collections"][X]>>>;
2195
2195
  };
2196
2196
 
@@ -2467,7 +2467,7 @@ type RepositoryFor<TClients extends DbClientsDefinition, TDb extends ExtractDbNa
2467
2467
  /** `$facet` pagination with totals (one round trip). */
2468
2468
  page(filter: FilterInput<Doc>, config?: PaginationConfig): Promise<PaginationResult<Doc>>;
2469
2469
  /** Keyset/cursor pagination (O(log n), no totals). */
2470
- pageCursor(filter: FilterInput<Doc>, config: CursorPaginationConfig<Doc>): Promise<CursorPage<Doc>>;
2470
+ pageCursor(filter: FilterInput<Doc>, config: CursorPaginationConfig): Promise<CursorPage<Doc>>;
2471
2471
  /** Type-safe chained aggregation builder. */
2472
2472
  pipeline(options?: QueryOptions): PipelineBuilder<TClients, TDb, Doc>;
2473
2473
  /** Callback aggregation over a typed stage builder. */