mongo-typed 1.0.4 → 1.0.6

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.
@@ -4,7 +4,7 @@ export type DotNotation<T extends object, TAllowPlaceholder extends boolean = fa
4
4
  [K in keyof T & string]: T[K] extends (...args: any[]) => any ? never : (`${TPrefix}${K}` | DotNotation<NonNullable<T[K]> extends object ? NonNullable<T[K]> : never, TAllowPlaceholder, `${TPrefix}${K}.`, [...TDepth, 1]>);
5
5
  }[keyof T & string];
6
6
  /** Resolves a dot-notated path to the corresponding type, including array indexing */
7
- export type DotPathValue<T, TPath extends string, TAllowPlaceholder extends boolean = false, TCheckInArray extends boolean = false, TIsInArray extends boolean = false, TDepth extends number[] = []> = TDepth['length'] extends 9 ? never : TPath extends `${infer Key}.${infer Rest}` ? T extends readonly (infer U)[] ? Key extends `${number}` ? DotPathValue<U, Rest, TAllowPlaceholder, TCheckInArray, TIsInArray, [...TDepth, 1]> : TAllowPlaceholder extends true ? Key extends `$[${string}]` | `$[]` | `$` ? DotPathValue<U, Rest, TAllowPlaceholder, TCheckInArray, true, [...TDepth, 1]> : never : never : Key extends keyof T ? DotPathValue<NonNullable<T[Key]>, Rest, TAllowPlaceholder, TCheckInArray, TIsInArray, [...TDepth, 1]> : never : T extends readonly (infer U)[] ? TPath extends `${number}` ? And<TIsInArray, TCheckInArray, U[], U> : TAllowPlaceholder extends true ? TPath extends `$[${string}]` | `$[]` | `$` ? TCheckInArray extends true ? U[] : U : TPath extends keyof U ? TCheckInArray extends true ? U[TPath][] : U[TPath] : never : TPath extends keyof U ? TCheckInArray extends true ? U[TPath][] : U[TPath] : never : TPath extends keyof T ? And<TIsInArray, TCheckInArray, T[TPath][], T[TPath]> : never;
7
+ export type DotPathValue<T, TPath extends string, TAllowPlaceholder extends boolean = false, TCheckInArray extends boolean = false, TIsInArray extends boolean = false, TDepth extends number[] = []> = TDepth['length'] extends 9 ? never : TPath extends `${infer Key}.${infer Rest}` ? T extends readonly (infer U)[] ? Key extends `${number}` ? DotPathValue<U, Rest, TAllowPlaceholder, TCheckInArray, TIsInArray, [...TDepth, 1]> : TAllowPlaceholder extends true ? Key extends `$[${string}]` | `$[]` | `$` ? DotPathValue<U, Rest, TAllowPlaceholder, TCheckInArray, true, [...TDepth, 1]> : never : never : Key extends string ? T extends unknown ? Key extends keyof T ? DotPathValue<NonNullable<T[Key]>, Rest, TAllowPlaceholder, TCheckInArray, TIsInArray, [...TDepth, 1]> : T extends object ? T[keyof T] extends infer V ? V extends object ? DotPathValue<V, Rest, TAllowPlaceholder, TCheckInArray, TIsInArray, [...TDepth, 1]> : never : never : never : never : never : T extends readonly (infer U)[] ? U extends unknown ? TPath extends `${number}` ? And<TIsInArray, TCheckInArray, U[], U> : TAllowPlaceholder extends true ? TPath extends `$[${string}]` | `$[]` | `$` ? TCheckInArray extends true ? U[] : U : TPath extends keyof U ? TCheckInArray extends true ? U[TPath][] : U[TPath] : never : TPath extends keyof U ? TCheckInArray extends true ? U[TPath][] : U[TPath] : never : never : T extends unknown ? TPath extends keyof T ? And<TIsInArray, TCheckInArray, T[TPath][], T[TPath]> : never : never;
8
8
  export type OnlyFieldsOfTypeDotNotation<T extends object, TFieldType, TAllowPlaceholder extends boolean = false, TCheckInArray extends boolean = false, TAssignableType = never> = {
9
9
  [P in DotNotation<T, TAllowPlaceholder> as NonNullable<DotPathValue<T, P, TAllowPlaceholder, TCheckInArray>> extends TFieldType ? P : never]?: [
10
10
  TAssignableType
package/dist/filter.d.ts CHANGED
@@ -2,9 +2,10 @@ import { BsonType, BsonTypeNumeric, IntegerType } from './bson-types.js';
2
2
  import { DotNotation, DotPathValue } from './dot-notation.js';
3
3
  import { Expr } from './expr.js';
4
4
  import { GeoJson, GeoJsonMultiPolygon, GeoJsonPoint, GeoJsonPolygon } from './geo-json.js';
5
+ import { DeepPartialButId, Identifiable } from './identifiable.js';
5
6
  import { JsonSchema } from './json-schema/index.js';
6
7
  import { And, DeepPartial } from './types.js';
7
- export declare type AlternativeTypes<T, TPartial extends boolean = false> = T extends string ? RegExp | T : And<T extends object ? true : false, TPartial, DeepPartial<T>, T>;
8
+ export declare type AlternativeTypes<T, TPartial extends boolean = false> = T extends string ? RegExp | T : And<T extends object ? true : false, TPartial, T extends Identifiable ? DeepPartialButId<T> : DeepPartial<T>, T>;
8
9
  export declare type BitwiseFilter = number /** BinData bit mask */ | ReadonlyArray<number>;
9
10
  export declare type Condition<T, TPartial extends boolean = false> = AlternativeTypes<T, TPartial> | FilterOperators<T>;
10
11
  export declare interface Document {
@@ -34,7 +35,6 @@ export declare interface FilterOperators<TValue> {
34
35
  $gt?: NonNullable<TValue> extends ReadonlyArray<infer U> ? U : TValue;
35
36
  $gte?: NonNullable<TValue> extends ReadonlyArray<infer U> ? U : TValue;
36
37
  $in?: NonNullable<TValue> extends ReadonlyArray<infer U> ? ReadonlyArray<TValue> | ReadonlyArray<U> : ReadonlyArray<TValue>;
37
- $jsonSchema?: JsonSchema;
38
38
  $lt?: NonNullable<TValue> extends ReadonlyArray<infer U> ? U : TValue;
39
39
  $lte?: NonNullable<TValue> extends ReadonlyArray<infer U> ? U : TValue;
40
40
  $maxDistance?: TValue extends [number, number] | GeoJsonPoint ? number : never;
@@ -59,6 +59,7 @@ export declare interface NearFilter {
59
59
  export declare interface ObjFilterOperators<TSchema extends object> {
60
60
  $and?: ObjFilter<TSchema>[];
61
61
  $comment?: Document | string;
62
+ $jsonSchema?: JsonSchema;
62
63
  $nor?: ObjFilter<TSchema>[];
63
64
  $or?: ObjFilter<TSchema>[];
64
65
  $text?: {
@@ -1,3 +1,5 @@
1
+ import { DeepPartial } from './types.js';
2
+ export type DeepPartialButId<T extends Identifiable> = DeepPartial<Omit<T, '_id'>> & Pick<T, '_id'>;
1
3
  export type Identifiable = {
2
4
  _id: string;
3
5
  };
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "mongo-typed",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Provides type-safe MongoDB-style query and update utilities in TypeScript. It is designed to assist with building fully-typed data repository layers or services that interact with MongoDB-like syntax, without relying on external libraries or runtime packages.",
5
5
  "author": "SecureDataSystems",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/secure-data-systems/mongo-typed.git"
10
+ },
7
11
  "type": "module",
8
12
  "main": "dist/index.js",
9
13
  "types": "dist/index.d.ts",
@@ -21,12 +25,12 @@
21
25
  }
22
26
  },
23
27
  "devDependencies": {
24
- "@secure-data-systems/eslint-config": "^1.0.2",
25
- "@secure-data-systems/tsconfig": "^1.0.0",
26
- "@types/node": "^24.0.3",
28
+ "@secure-data-systems/eslint-config": "^1.0.33",
29
+ "@secure-data-systems/tsconfig": "^1.0.3",
30
+ "@types/node": "^24.10.1",
27
31
  "glob": "^11.0.3",
28
- "tsx": "^4.20.3",
29
- "typescript": "^5.8.3"
32
+ "tsx": "^4.21.0",
33
+ "typescript": "^5.9.3"
30
34
  },
31
35
  "scripts": {
32
36
  "build": "node scripts/build.mjs && tsc --project tsconfig.build.json",