leoric 2.11.2 → 2.11.3

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/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import DataTypes, { DataType, AbstractDataType, LENGTH_VARIANTS } from './src/data_types';
2
- import {
2
+ import {
3
3
  Hint, IndexHint, HintInterface,
4
4
  INDEX_HINT_SCOPE_TYPE, INDEX_HINT_SCOPE, INDEX_HINT_TYPE
5
5
  } from './src/hint';
6
6
  import {
7
7
  Literal, Validator,
8
- Connection, QueryOptions,
8
+ Connection, QueryOptions, WhereConditions,
9
9
  Raw, ColumnMeta, AttributeMeta,
10
10
  BeforeHooksType, AfterHooksType, Collection,
11
11
  GeneratorReturnType, Values, BoneCreateValues, BoneInstanceValues,
@@ -14,9 +14,9 @@ import { SpellMeta, Spell, SpellBookFormatResult } from './src/spell';
14
14
  import Bone from './src/bone';
15
15
  import { ConnectOptions, AbstractDriver } from './src/drivers';
16
16
 
17
- export {
17
+ export {
18
18
  LENGTH_VARIANTS as LENGTH_VARIANTS,
19
- DataTypes, Literal, Validator, Connection,
19
+ DataTypes, Literal, Validator, Connection, WhereConditions,
20
20
  Hint, IndexHint, HintInterface, INDEX_HINT_SCOPE_TYPE, INDEX_HINT_SCOPE, INDEX_HINT_TYPE,
21
21
  Bone, Raw, Collection,
22
22
  SpellMeta, Spell, ColumnMeta, AttributeMeta, SpellBookFormatResult, Values, BoneCreateValues, BoneInstanceValues,
@@ -32,7 +32,7 @@ interface InitOptions {
32
32
  hooks?: {
33
33
  [key in BeforeHooksType ]: (options: QueryOptions) => Promise<void>
34
34
  } | {
35
- [key in AfterHooksType ]: (instance: Bone, result: Object) => Promise<void>
35
+ [key in AfterHooksType ]: (instance: Bone, result: object) => Promise<void>
36
36
  };
37
37
  }
38
38
 
@@ -62,13 +62,13 @@ export default class Realm {
62
62
  * disconnect manually
63
63
  * @param callback
64
64
  */
65
- disconnect(callback?: Function): Promise<boolean | void>;
65
+ disconnect(callback?: () => Promise<void>): Promise<boolean | void>;
66
66
 
67
67
  define(
68
68
  name: string,
69
69
  attributes: Record<string, AbstractDataType<DataType> | AttributeMeta>,
70
70
  options?: InitOptions,
71
- descriptors?: Record<string, Function>,
71
+ descriptors?: Record<string, PropertyDescriptor>,
72
72
  ): typeof Bone;
73
73
 
74
74
  raw(sql: string): Raw;
@@ -94,11 +94,11 @@ export default class Realm {
94
94
  * })
95
95
  */
96
96
  export function connect(opts: ConnectOptions): Promise<Realm>;
97
- export function disconnect(realm: Realm, callback?: Function): Promise<boolean | void>;
97
+ export function disconnect(realm: Realm, callback?: () => Promise<void>): Promise<boolean | void>;
98
98
 
99
99
  /**
100
100
  * Check if cls is subclass of Bone
101
- * @param cls
101
+ * @param cls
102
102
  */
103
103
  export function isBone(cls: any): boolean;
104
104
 
@@ -110,6 +110,6 @@ export function isBone(cls: any): boolean;
110
110
  * FROM users
111
111
  * WHERE age >= 35
112
112
  * `)
113
- * @param text
113
+ * @param text
114
114
  */
115
115
  export function heresql(text): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leoric",
3
- "version": "2.11.2",
3
+ "version": "2.11.3",
4
4
  "description": "JavaScript Object-relational mapping alchemy",
5
5
  "main": "index.js",
6
6
  "browser": "dist/browser.js",
@@ -1,5 +1,5 @@
1
1
  import {
2
- Attributes, Literal, OperatorCondition,
2
+ Attributes, Literal, WhereConditions,
3
3
  BoneOptions, ResultSet, Raw,
4
4
  SetOptions, BeforeHooksType, AfterHooksType,
5
5
  QueryOptions, OrderOptions, QueryResult, Values as CommonValues, BoneColumns, InstanceColumns, BoneCreateValues,
@@ -7,12 +7,6 @@ import {
7
7
  import { AbstractBone } from '../types/abstract_bone';
8
8
  import { Spell } from '../spell';
9
9
 
10
- type WhereConditions<T extends typeof SequelizeBone> = {
11
- [Property in BoneColumns<T>]?: Literal | Literal[] | OperatorCondition;
12
- } | {
13
- [key in '$and' | '$or']?: WhereConditions<T>[];
14
- }
15
-
16
10
  interface SequelizeDestroyOptions extends QueryOptions {
17
11
  force?: boolean;
18
12
  }
@@ -62,8 +56,8 @@ type aggregators = 'count' | 'COUNT' | 'average' | 'AVERAGE' | 'minimum' | 'MINI
62
56
 
63
57
  export class Collection<T extends SequelizeBone> extends Array<T> {
64
58
  save(): Promise<void>;
65
- toJSON(): Object[];
66
- toObject(): Object[];
59
+ toJSON(): object[];
60
+ toObject(): object[];
67
61
  }
68
62
 
69
63
  export class SequelizeBone extends AbstractBone {
@@ -85,10 +79,10 @@ export class SequelizeBone extends AbstractBone {
85
79
  * @param {string | Function} fnNameOrFun function name or function
86
80
  * @param {Function} func hook function
87
81
  */
88
- static addHook(
82
+ static addHook<T extends SequelizeBone>(
89
83
  name: BeforeHooksType | AfterHooksType | 'beforeDestroy' | 'afterDestroy' | 'beforeBulkDestroy' | 'afterBulkDestroy' | 'beforeBulkUpdate' | 'afterBulkUpdate',
90
- fnNameOrFun: string | Function,
91
- func?: Function,
84
+ fnNameOrFun: string | ((target: T, ...args: [Record<keyof Extract<CommonValues<T>, Literal>, Literal>, ...any[]]) => void),
85
+ func?: (target: T, ...args: [Record<keyof Extract<CommonValues<T>, Literal>, Literal>, ...any[]]) => void,
92
86
  ): void;
93
87
 
94
88
  /**
package/src/spell.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {
1
+ import {
2
2
  Literal, command, Raw, Connection,
3
3
  ResultSet, QueryResult,
4
4
  QueryOptions, SetOptions, WithOptions,
@@ -54,6 +54,8 @@ interface ExprTernaryOperator {
54
54
  type ExprOperator = ExprBinaryOperator | ExprTernaryOperator;
55
55
  type SpellColumn = ExprIdentifier | Raw;
56
56
 
57
+ type ScopeFunction = (spell: SpellMeta) => void;
58
+
57
59
  interface SpellOptions {
58
60
  command?: command;
59
61
  columns: SpellColumn[];
@@ -64,7 +66,7 @@ interface SpellOptions {
64
66
  havingCondtions: ExprOperator[];
65
67
  joins: Join;
66
68
  skip: number;
67
- scopes: Function[];
69
+ scopes: ScopeFunction[];
68
70
  subqueryIndex: number;
69
71
  rowCount?: number;
70
72
  connection?: Connection;
@@ -96,7 +98,7 @@ export class Spell<T extends typeof AbstractBone, U = InstanceType<T> | Collecti
96
98
  connection: Connection;
97
99
 
98
100
  command: string;
99
- scopes: Function[];
101
+ scopes: Array<(spell: this) => void>;
100
102
 
101
103
  select(...names: Array<string | Raw> | Array<(name: string) => boolean>): Spell<T, U>;
102
104
  insert(opts: SetOptions<T>): Spell<T, QueryResult>;
@@ -136,7 +138,7 @@ export class Spell<T extends typeof AbstractBone, U = InstanceType<T> | Collecti
136
138
 
137
139
  $offset(skip: number): Spell<T, U>;
138
140
  offset(skip: number): Spell<T, U>;
139
-
141
+
140
142
  $limit(rowCount: number): Spell<T, U>;
141
143
  limit(rowCount: number): Spell<T, U>;
142
144