@ez4/database 0.13.0 → 0.14.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.
@@ -42,11 +42,11 @@ export declare namespace Database {
42
42
  */
43
43
  handler: (change: StreamChange<T>, context: Service.Context<Service<any>>) => void | Promise<void>;
44
44
  /**
45
- * Variables associated to the route.
45
+ * Variables associated to the handler.
46
46
  */
47
47
  variables?: LinkedVariables;
48
48
  /**
49
- * Max route execution time (in seconds) for the handler.
49
+ * Max execution time (in seconds) for the handler.
50
50
  */
51
51
  timeout?: number;
52
52
  /**
@@ -2,7 +2,7 @@ import type { RelationMetadata } from './relations.js';
2
2
  import type { Database } from './database.js';
3
3
  import type { Order } from './order.js';
4
4
  import type { DecomposeIndexName, DecomposePrimaryIndexNames, DecomposeUniqueIndexNames } from './indexes.js';
5
- import type { AnyObject, PartialProperties, PartialObject, FlatObject, OptionalObject, StrictObject, IsNullable, IsObjectEmpty, IsObject } from '@ez4/utils';
5
+ import type { AnyObject, PartialProperties, PartialObject, FlatObject, OptionalObject, StrictObject, IsNullable, IsObjectEmpty, IsObject, IsArray } from '@ez4/utils';
6
6
  /**
7
7
  * Query builder types.
8
8
  */
@@ -82,13 +82,13 @@ export declare namespace Query {
82
82
  [P in DecomposeIndexName<keyof I>]?: Order;
83
83
  };
84
84
  export type WhereInput<T extends Database.Schema, I extends Database.Indexes<T>, R extends RelationMetadata> = WhereInputFilters<T, I, R> & WhereNot<WhereInputFilters<T, I, R>> & WhereAnd<WhereInputFilters<T, I, R>> & WhereOr<WhereInputFilters<T, I, R>>;
85
- export type WhereOperators = keyof (WhereNegate<any> & WhereEqual<any> & WhereGreaterThan<any> & WhereGreaterThanOrEqual<any> & WhereLessThan<any> & WhereLessThanOrEqual<any> & WhereIn<any> & WhereBetween<any> & WhereIsMissing & WhereIsNull & WhereStartsWith & WhereContains);
85
+ export type WhereOperators = keyof (WhereNegate<any> & WhereEqual<any> & WhereGreaterThan<any> & WhereGreaterThanOrEqual<any> & WhereLessThan<any> & WhereLessThanOrEqual<any> & WhereIn<any> & WhereBetween<any> & WhereIsMissing & WhereIsNull & WhereStartsWith & WhereContains<any>);
86
86
  type IndexFields<R extends RelationMetadata> = string extends R['indexes'] ? never : R['indexes'];
87
87
  type SelectFields<T extends Database.Schema, R extends RelationMetadata> = IsObjectEmpty<R['selects']> extends true ? T : T & R['selects'];
88
88
  type IncludeFilters<T extends AnyObject, S extends AnyObject> = {
89
89
  [P in keyof T]?: P extends keyof S ? IsObject<T[P]> extends true ? null | WhereRelationField<NonNullable<T[P]>> : never : never;
90
90
  };
91
- type WhereOperations<T> = WhereNegate<T> | WhereEqual<T> | WhereGreaterThan<T> | WhereGreaterThanOrEqual<T> | WhereLessThan<T> | WhereLessThanOrEqual<T> | WhereIn<T> | WhereBetween<T> | WhereIsMissing | WhereIsNull | WhereStartsWith | WhereContains;
91
+ type WhereOperations<T> = WhereNegate<T> | WhereEqual<T> | WhereGreaterThan<T> | WhereGreaterThanOrEqual<T> | WhereLessThan<T> | WhereLessThanOrEqual<T> | WhereIn<T> | WhereBetween<T> | WhereIsMissing | WhereIsNull | WhereStartsWith | WhereContains<T>;
92
92
  type WhereField<T> = IsObject<T> extends false ? T | WhereOperations<T> : IsNullable<T> extends true ? null | WhereObjectField<NonNullable<T>> : WhereObjectField<NonNullable<T>>;
93
93
  type WhereObjectField<T extends AnyObject> = {
94
94
  [P in keyof T]?: WhereField<T[P]>;
@@ -133,7 +133,7 @@ export declare namespace Query {
133
133
  lte: T;
134
134
  };
135
135
  type WhereIn<T> = {
136
- isIn: T[];
136
+ isIn: IsArray<T> extends true ? T : IsObject<T> extends true ? T : T[];
137
137
  };
138
138
  type WhereBetween<T> = {
139
139
  isBetween: [T, T];
@@ -147,8 +147,8 @@ export declare namespace Query {
147
147
  type WhereStartsWith = {
148
148
  startsWith: string;
149
149
  };
150
- type WhereContains = {
151
- contains: string;
150
+ type WhereContains<T> = {
151
+ contains: IsObject<T> extends true ? Partial<T> : T;
152
152
  };
153
153
  export {};
154
154
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ez4/database",
3
3
  "description": "EZ4: Components to build database services",
4
- "version": "0.13.0",
4
+ "version": "0.14.0",
5
5
  "author": "Silas B.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -42,10 +42,10 @@
42
42
  "live:publish": "npm run test && npm publish --access public"
43
43
  },
44
44
  "dependencies": {
45
- "@ez4/common": "^0.13.0",
46
- "@ez4/project": "^0.13.0",
47
- "@ez4/reflection": "^0.13.0",
48
- "@ez4/schema": "^0.13.0",
49
- "@ez4/utils": "^0.13.0"
45
+ "@ez4/common": "^0.14.0",
46
+ "@ez4/project": "^0.14.0",
47
+ "@ez4/reflection": "^0.14.0",
48
+ "@ez4/schema": "^0.14.0",
49
+ "@ez4/utils": "^0.14.0"
50
50
  }
51
51
  }