leoric 2.8.5 → 2.8.7

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/History.md CHANGED
@@ -1,3 +1,27 @@
1
+ 2.8.7 / 2022-10-11
2
+ ==================
3
+
4
+ ## What's Changed
5
+ * fix: enable strictNullChecks by @cyjake in https://github.com/cyjake/leoric/pull/357
6
+ * fix: declaration types of realm.query() and static update values by @cyjake in https://github.com/cyjake/leoric/pull/358
7
+
8
+
9
+ **Full Changelog**: https://github.com/cyjake/leoric/compare/v2.8.6...v2.8.7
10
+
11
+ 2.8.6 / 2022-10-11
12
+ ==================
13
+
14
+ ## What's Changed
15
+ * fix: new Realm({ sequelize: true }).Bone == Realm.SequelizeBone by @cyjake in https://github.com/cyjake/leoric/pull/349
16
+ * fix: edge cases in attribute.equals() by @cyjake in https://github.com/cyjake/leoric/pull/350
17
+ * fix: bone.attribute(name, value?) type infer with this[name] by @cyjake in https://github.com/cyjake/leoric/pull/351
18
+ * fix: ts type definitions by @JimmyDaddy in https://github.com/cyjake/leoric/pull/352
19
+ * fix: this.attribute(name) should fallback to Literal by @cyjake in https://github.com/cyjake/leoric/pull/353
20
+ * fix: type definitions for columns constraint by @JimmyDaddy in https://github.com/cyjake/leoric/pull/355
21
+
22
+
23
+ **Full Changelog**: https://github.com/cyjake/leoric/compare/v2.8.5...v2.8.6
24
+
1
25
  2.8.5 / 2022-09-21
2
26
  ==================
3
27
 
package/index.d.ts CHANGED
@@ -74,7 +74,7 @@ export default class Realm {
74
74
 
75
75
  escape(value: Literal): string;
76
76
 
77
- query<T extends typeof Bone>(sql: string, values?: Array<Literal>, options?: RawQueryOptions & { model?: T }): Promise<{ rows: T extends typeof Bone ? InstanceType<T>[] : Object[], fields?: Object[], affectedRows?: number }>;
77
+ query<T>(sql: string, values?: Array<Literal>, options?: RawQueryOptions & { model?: T }): Promise<{ rows: T extends typeof Bone ? InstanceType<T>[] : Record<string, Literal>[], fields?: Record<string, ColumnMeta>[], affectedRows?: number }>;
78
78
 
79
79
  transaction<T extends (options: { connection: Connection }) => Generator>(callback: T): Promise<GeneratorReturnType<ReturnType<T>>>;
80
80
  transaction<T extends (options: { connection: Connection }) => Promise<any>>(callback: T): Promise<ReturnType<T>>;
package/index.js CHANGED
@@ -12,7 +12,7 @@ const { heresql } = require('./src/utils/string');
12
12
  const Hint = require('./src/hint');
13
13
  const Realm = require('./src/realm');
14
14
  const Decorators = require('./src/decorators');
15
- const Raw = require('./src/raw');
15
+ const Raw = require('./src/raw').default;
16
16
  const { MysqlDriver, PostgresDriver, SqliteDriver, AbstractDriver } = require('./src/drivers');
17
17
  const { isBone } = require('./src/utils');
18
18
 
@@ -52,7 +52,6 @@ Object.assign(Realm, {
52
52
  connect,
53
53
  disconnect,
54
54
  Bone,
55
- SequelizeBone: sequelize(Bone),
56
55
  Collection,
57
56
  DataTypes,
58
57
  Logger,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leoric",
3
- "version": "2.8.5",
3
+ "version": "2.8.7",
4
4
  "description": "JavaScript Object-relational mapping alchemy",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -2,7 +2,7 @@ import {
2
2
  Attributes, Literal, OperatorCondition,
3
3
  BoneOptions, ResultSet, Raw,
4
4
  SetOptions, BeforeHooksType, AfterHooksType,
5
- QueryOptions, OrderOptions, QueryResult
5
+ QueryOptions, OrderOptions, QueryResult, Values as CommonValues, BoneColumns, InstanceColumns,
6
6
  } from '../types/common';
7
7
  import { AbstractBone } from '../types/abstract_bone';
8
8
  import { Spell } from '../spell';
@@ -21,16 +21,21 @@ interface BaseSequelizeConditions<T extends typeof SequelizeBone> extends QueryO
21
21
  where?: WhereConditions<T>;
22
22
  order?: OrderOptions<T>;
23
23
  limit?: number;
24
- attributes?: string | Raw | Array<[keyof Extract<InstanceType<T>, Literal>] | string | Raw> | [keyof Extract<InstanceType<T>, Literal>];
24
+ attributes?: BoneColumns<T> | Array<BoneColumns<T> | string | Raw> | string | Raw;
25
25
  offset?: number;
26
26
  }
27
27
 
28
28
  type SequelizeUpdateOptions<T extends typeof SequelizeBone> = BaseSequelizeConditions<T> & {
29
- fields?: string[];
29
+ fields?: BoneColumns<T> | Array<BoneColumns<T> | string | Raw> | string;
30
+ }
31
+
32
+ interface SequelizeInstanceUpdateOptions<T extends SequelizeBone> extends QueryOptions {
33
+ attributes?: [keyof Extract<CommonValues<T>, Literal>] | string | Raw | Array<[keyof Extract<CommonValues<T>, Literal>] | string | Raw>;
34
+ fields?: Array<[keyof Extract<CommonValues<T>, Literal>] | string | Raw> | [keyof Extract<CommonValues<T>, Literal>];
30
35
  }
31
36
 
32
37
  interface SequelizeConditions<T extends typeof SequelizeBone> extends BaseSequelizeConditions<T> {
33
- group?: string | string[] | Raw;
38
+ group?: BoneColumns<T> | BoneColumns<T>[] | Raw | string;
34
39
  having?: WhereConditions<T> | string | { [key:string]: Literal | Literal[] } | Raw;
35
40
  include?: string | Raw;
36
41
  }
@@ -77,7 +82,7 @@ export class SequelizeBone extends AbstractBone {
77
82
 
78
83
  static getTableName(): boolean;
79
84
 
80
- static removeAttribute(name: string): void;
85
+ static removeAttribute<T extends typeof SequelizeBone>(this: T, name?: BoneColumns<T>): void;
81
86
 
82
87
  /**
83
88
  *
@@ -117,7 +122,8 @@ export class SequelizeBone extends AbstractBone {
117
122
  */
118
123
  static setScope<T extends typeof SequelizeBone>(this: T, name: (string | ((...args: any[]) => SequelizeConditions<T>) | SequelizeConditions<T> | Array<SequelizeConditions<T>>), ...args: any[]): void;
119
124
 
120
- static aggregate<T extends typeof SequelizeBone>(this: T, name: string, func: aggregators, options?: SequelizeConditions<T>): Spell<T, number>;
125
+ static aggregate<T extends typeof SequelizeBone>(this: T, name: BoneColumns<T>, func: aggregators, options?: SequelizeConditions<T>): Spell<T, number>;
126
+ static aggregate<T extends typeof SequelizeBone>(this: T, name: Raw | '*', func: aggregators, options?: SequelizeConditions<T>): Spell<T, number>;
121
127
 
122
128
  static build<T extends typeof SequelizeBone>(this: T, values: Values<T>, options?: BoneOptions): InstanceType<T>;
123
129
 
@@ -128,24 +134,30 @@ export class SequelizeBone extends AbstractBone {
128
134
  */
129
135
  static bulkBuild<T extends typeof SequelizeBone>(this:T, valueSets: Array<Values<T>>, options?: BoneOptions): Array<InstanceType<T>>;
130
136
 
131
- static count<T extends typeof SequelizeBone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
137
+ static count<T extends typeof SequelizeBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
138
+ static count<T extends typeof SequelizeBone>(this: T, name?: Raw | '*'): Spell<T, ResultSet<T> | number>;
132
139
  static count<T extends typeof SequelizeBone>(this: T, conditions?: SequelizeConditions<T>): Spell<T, ResultSet<T> | number>;
133
140
 
134
141
  static decrement<T extends typeof SequelizeBone>(
135
142
  this: T,
136
- fields: string | Array<string> | { [Property in keyof Extract<InstanceType<T>, Literal>]?: number },
143
+ fields: { [Property in keyof Extract<InstanceType<T>, Literal>]?: number } | string | Array<BoneColumns<T> | string> ,
137
144
  options?: SequelizeConditions<T>
138
145
  ): Spell<T, QueryResult>;
139
146
 
140
147
  static increment<T extends typeof SequelizeBone>(
141
148
  this: T,
142
- fields: string | Array<string> | { [Property in keyof Extract<InstanceType<T>, Literal>]?: number },
149
+ fields: { [Property in keyof Extract<InstanceType<T>, Literal>]?: number } | string | Array<BoneColumns<T> | string> ,
143
150
  options?: SequelizeConditions<T>
144
151
  ): Spell<T, QueryResult>;
145
152
 
146
- static max<T extends typeof SequelizeBone>(this: T, filed: string, options?: SequelizeConditions<T>): Promise<Literal>;
147
- static min<T extends typeof SequelizeBone>(this: T, filed: string, options?: SequelizeConditions<T>): Promise<Literal>;
148
- static sum<T extends typeof SequelizeBone>(this: T, filed: string, options?: SequelizeConditions<T>): Promise<Literal>;
153
+ static max<T extends typeof SequelizeBone>(this: T, field: BoneColumns<T>, options?: SequelizeConditions<T>): Promise<Literal>;
154
+ static max<T extends typeof SequelizeBone>(this: T, field: Raw, options?: SequelizeConditions<T>): Promise<Literal>;
155
+
156
+ static min<T extends typeof SequelizeBone>(this: T, field: BoneColumns<T>, options?: SequelizeConditions<T>): Promise<Literal>;
157
+ static min<T extends typeof SequelizeBone>(this: T, field: Raw, options?: SequelizeConditions<T>): Promise<Literal>;
158
+
159
+ static sum<T extends typeof SequelizeBone>(this: T, field: BoneColumns<T>, options?: SequelizeConditions<T>): Promise<Literal>;
160
+ static sum<T extends typeof SequelizeBone>(this: T, field: Raw, options?: SequelizeConditions<T>): Promise<Literal>;
149
161
 
150
162
  static destroy<T extends typeof SequelizeBone>(this: T, options?: DestroyOptions<T>): Promise<Array<number> | number>;
151
163
  static bulkDestroy<T extends typeof SequelizeBone>(this: T, options?: DestroyOptions<T>): Spell<T, number>;
@@ -179,17 +191,32 @@ export class SequelizeBone extends AbstractBone {
179
191
  get dataValues(): { [key: string]: Literal };
180
192
 
181
193
  where(): { [key: string]: number | bigint | string };
182
- set(key: string, value: Literal | Literal[]): void;
183
- get(key?: string): Literal | { [key: string]: Literal };
194
+ set<T, Key extends keyof CommonValues<T>>(this: T, key: Key, value: T[Key]): void;
195
+ set<T, Key extends keyof T>(this: T, key: Key, value: T[Key]): void;
196
+
197
+ get<T, Key extends keyof CommonValues<T>>(this: T, key?: Key): T[Key];
198
+ get<T, Key extends keyof T>(this: T, key?: Key): T[Key];
199
+
200
+ setDataValue<T, Key extends keyof CommonValues<T>>(this: T, key: Key, value: T[Key]): void;
184
201
  setDataValue<T, Key extends keyof T>(this: T, key: Key, value: T[Key]): void;
202
+
185
203
  getDataValue<T>(this: T): T;
204
+ getDataValue<T, Key extends keyof CommonValues<T>>(this: T, key: Key): T[Key];
186
205
  getDataValue<T, Key extends keyof T>(this: T, key: Key): T[Key];
187
- previous(key?: string): Literal | Literal[] | { [key: string]: Literal | Literal[] };
206
+
207
+ previous<T, Key extends keyof CommonValues<T>>(this: T, key?: Key): Literal | Literal[] | { [Property in keyof Extract<this, Literal>]?: Literal | Literal[] };
208
+ previous<T, Key extends keyof T>(this: T, key?: Key): Literal | Literal[] | { [Property in keyof Extract<this, Literal>]?: Literal | Literal[] };
209
+
188
210
  isSoftDeleted(): boolean;
189
211
 
190
- increment(field: string | string[] | { [Property in keyof Extract<this, Literal>]?: number }, options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
191
- decrement(field: string | string[] | { [Property in keyof Extract<this, Literal>]?: number }, options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
212
+ increment(field: InstanceColumns<this> | Array<InstanceColumns<this>> | { [Property in keyof Extract<this, Literal>]?: number }, options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
213
+ increment(field: string | Raw | Array<string | Raw>, options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
214
+ decrement(field: InstanceColumns<this> | Array<InstanceColumns<this>> | { [Property in keyof Extract<this, Literal>]?: number }, options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
215
+ decrement(field: string | Raw | Array<string | Raw> , options?: QueryOptions): Spell<typeof SequelizeBone, QueryResult>;
192
216
  destroy(options?: SequelizeDestroyOptions): Promise<this| number>;
217
+ update<T = this>(this: T, changes?: { [Property in keyof Extract<this, Literal>]?: Literal }, opts?: SequelizeInstanceUpdateOptions<this>): Promise<number>;
218
+ update<T = this>(this: T, changes?: { [key: string]: Literal }, opts?: SequelizeInstanceUpdateOptions<this>): Promise<number>;
219
+
193
220
  }
194
221
 
195
222
  export const sequelize: (Bone: AbstractBone) => typeof SequelizeBone;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { setupSingleHook } = require('../setup_hooks');
4
4
  const { compose, isPlainObject } = require('../utils');
5
- const Raw = require('../raw');
5
+ const Raw = require('../raw').default;
6
6
 
7
7
  function translateOptions(spell, options) {
8
8
  const { attributes, where, group, order, offset, limit, include, having } = options;
package/src/bone.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Spell } from './spell';
2
2
  import { AbstractBone } from './types/abstract_bone';
3
- import { Collection, Literal, QueryOptions, ResultSet, WhereConditions } from './types/common';
3
+ import { BoneColumns, Collection, Literal, QueryOptions, Raw, ResultSet, Values, WhereConditions } from './types/common';
4
4
 
5
5
  export default class Bone extends AbstractBone {
6
6
 
@@ -26,7 +26,8 @@ export default class Bone extends AbstractBone {
26
26
  static findOne<T extends typeof Bone>(this: T, primaryKey: number | number[] | bigint): Spell<T, InstanceType<T> | null>;
27
27
  static findOne<T extends typeof Bone>(this: T, ): Spell<T, InstanceType<T> | null>;
28
28
 
29
- static sum<T extends typeof Bone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
29
+ static sum<T extends typeof Bone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
30
+ static sum<T extends typeof Bone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
30
31
 
31
32
  /**
32
33
  * restore rows
@@ -36,12 +37,12 @@ export default class Bone extends AbstractBone {
36
37
  * @param conditions query conditions
37
38
  * @param opts query options
38
39
  */
39
- static restore<T extends typeof Bone>(this: T, conditions: Object, opts?: QueryOptions): Spell<T, number>;
40
+ static restore<T extends typeof Bone>(this: T, conditions: WhereConditions<T>, opts?: QueryOptions): Spell<T, number>;
40
41
 
41
42
  /**
42
43
  * UPDATE rows.
43
44
  */
44
- static update<T extends typeof Bone>(this: T, whereConditions: WhereConditions<T>, values?: Object, opts?: QueryOptions): Spell<T, number>;
45
+ static update<T extends typeof Bone>(this: T, whereConditions: WhereConditions<T>, values?: Values<InstanceType<T>> & Partial<Record<BoneColumns<T>, Literal>>, opts?: QueryOptions): Spell<T, number>;
45
46
 
46
47
  /**
47
48
  * Discard all the applied scopes.
package/src/bone.js CHANGED
@@ -14,7 +14,7 @@ require('reflect-metadata');
14
14
  const { default: DataTypes } = require('./data_types');
15
15
  const Collection = require('./collection');
16
16
  const Spell = require('./spell');
17
- const Raw = require('./raw');
17
+ const Raw = require('./raw').default;
18
18
  const { capitalize, camelCase, snakeCase } = require('./utils/string');
19
19
  const { hookNames, setupSingleHook } = require('./setup_hooks');
20
20
  const {
@@ -1016,9 +1016,6 @@ class Bone {
1016
1016
  if (columnInfo && attribute.type instanceof DataTypes.DATE && attribute.type.precision == null) {
1017
1017
  attribute.type.precision = columnInfo.datetimePrecision;
1018
1018
  }
1019
- // if (columnInfo && columnInfo.defaultValue != null && attribute.defaultValue === undefined) {
1020
- // attribute.defaultValue = columnInfo.defaultValue;
1021
- // }
1022
1019
  }
1023
1020
 
1024
1021
  const primaryKey = Object.keys(attributes).find(key => attributes[key].primaryKey);
@@ -1032,6 +1029,7 @@ class Bone {
1032
1029
  }
1033
1030
  }
1034
1031
  for (const name in attributes) this.loadAttribute(name);
1032
+ const diff = compare(attributes, columnMap);
1035
1033
 
1036
1034
  Object.defineProperties(this, looseReadonly({
1037
1035
  timestamps,
@@ -1041,11 +1039,11 @@ class Bone {
1041
1039
  attributeMap,
1042
1040
  associations,
1043
1041
  tableAlias,
1044
- synchronized: Object.keys(compare(attributes, columnMap)).length === 0,
1042
+ synchronized: Object.keys(diff).length === 0,
1045
1043
  }));
1046
1044
 
1047
1045
  if (!this.synchronized) {
1048
- debug('[load] %s not fully synchronized with %s', this.name, this.table);
1046
+ debug('[load] %s `%s` out of sync %j', this.name, this.table, Object.keys(diff));
1049
1047
  }
1050
1048
 
1051
1049
  for (const hookName of hookNames) {
package/src/data_types.js CHANGED
@@ -1,9 +1,12 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.invokable = exports.DataType = exports.LENGTH_VARIANTS = void 0;
4
- const util = require('util');
7
+ const raw_1 = __importDefault(require("./raw"));
8
+ const util_1 = __importDefault(require("util"));
5
9
  const invokableFunc = require('./utils/invokable');
6
- const Raw = require('./raw');
7
10
  var LENGTH_VARIANTS;
8
11
  (function (LENGTH_VARIANTS) {
9
12
  LENGTH_VARIANTS["tiny"] = "tiny";
@@ -58,11 +61,17 @@ class STRING extends DataType {
58
61
  return chunks.join(' ');
59
62
  }
60
63
  uncast(value) {
61
- if (value == null || value instanceof Raw)
64
+ if (value == null || value instanceof raw_1.default)
62
65
  return value;
63
66
  return '' + value;
64
67
  }
65
68
  }
69
+ class CHAR extends STRING {
70
+ constructor(dataLength = 255) {
71
+ super(dataLength);
72
+ this.dataType = 'char';
73
+ }
74
+ }
66
75
  class BINARY extends DataType {
67
76
  constructor(dataLength = 255) {
68
77
  super();
@@ -135,13 +144,13 @@ class INTEGER extends DataType {
135
144
  }
136
145
  uncast(value, strict = true) {
137
146
  const originValue = value;
138
- if (value == null || value instanceof Raw)
147
+ if (value == null || value instanceof raw_1.default)
139
148
  return value;
140
149
  if (typeof value === 'string')
141
150
  value = parseInt(value, 10);
142
151
  if (Number.isNaN(value)) {
143
152
  if (strict)
144
- throw new Error(util.format('invalid integer: %s', originValue));
153
+ throw new Error(util_1.default.format('invalid integer: %s', originValue));
145
154
  return originValue;
146
155
  }
147
156
  return value;
@@ -278,11 +287,14 @@ class DATE extends DataType {
278
287
  }
279
288
  uncast(value, _strict) {
280
289
  const originValue = value;
281
- if (value == null || value instanceof Raw)
290
+ // type narrowing doesn't handle `return value` correctly
291
+ if (value == null)
292
+ return value;
293
+ if (value instanceof raw_1.default)
282
294
  return value;
283
- if (typeof value.toDate === 'function') {
295
+ // Date | Moment
296
+ if (typeof value === 'object' && 'toDate' in value)
284
297
  value = value.toDate();
285
- }
286
298
  // @deprecated
287
299
  // vaguely standard date formats such as 2021-10-15 15:50:02,548
288
300
  if (typeof value === 'string' && rDateFormat.test(value)) {
@@ -295,7 +307,7 @@ class DATE extends DataType {
295
307
  if (!(value instanceof Date))
296
308
  value = new Date(value);
297
309
  if (isNaN(value))
298
- throw new Error(util.format('invalid date: %s', originValue));
310
+ throw new Error(util_1.default.format('invalid date: %s', originValue));
299
311
  return this._round(value);
300
312
  }
301
313
  }
@@ -390,7 +402,7 @@ class MYJSON extends DataType {
390
402
  }
391
403
  }
392
404
  uncast(value) {
393
- if (value == null || value instanceof Raw)
405
+ if (value == null || value instanceof raw_1.default)
394
406
  return value;
395
407
  return global.JSON.stringify(value);
396
408
  }
@@ -425,6 +437,7 @@ class VIRTUAL extends DataType {
425
437
  }
426
438
  }
427
439
  const AllDataTypes = {
440
+ CHAR,
428
441
  STRING,
429
442
  TINYINT,
430
443
  SMALLINT,
@@ -445,7 +458,7 @@ const AllDataTypes = {
445
458
  };
446
459
  class DataTypes {
447
460
  static findType(columnType) {
448
- const { STRING, TEXT, DATE, DATEONLY, TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT, DECIMAL, BOOLEAN, BINARY, VARBINARY, BLOB, } = this;
461
+ const { CHAR, STRING, TEXT, DATE, DATEONLY, TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT, DECIMAL, BOOLEAN, BINARY, VARBINARY, BLOB, } = this;
449
462
  const res = columnType === null || columnType === void 0 ? void 0 : columnType.match(/(\w+)(?:\((\d+)(?:,(\d+))?\))?/);
450
463
  if (!res) {
451
464
  throw new Error(`Unknown columnType ${columnType}`);
@@ -457,8 +470,9 @@ class DataTypes {
457
470
  params[i] = parseInt(matches[i], 10);
458
471
  }
459
472
  switch (dataType) {
460
- case 'varchar':
461
473
  case 'char':
474
+ return new CHAR(...params);
475
+ case 'varchar':
462
476
  return new STRING(...params);
463
477
  // longtext is only for MySQL
464
478
  case 'longtext':
@@ -528,6 +542,7 @@ class DataTypes {
528
542
  return params instanceof DataType;
529
543
  }
530
544
  }
545
+ DataTypes.CHAR = CHAR;
531
546
  DataTypes.STRING = STRING;
532
547
  DataTypes.TINYINT = TINYINT;
533
548
  DataTypes.SMALLINT = SMALLINT;
@@ -1 +1 @@
1
- {"version":3,"file":"data_types.js","sourceRoot":"","sources":["data_types.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,MAAM,IAAI,GAAG,OAAO,CAAC,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MAAa,CAAC;AAC1C,mBAAS,GAAyB,SAAgB,CAAC;AACnD,iBAAO,GAAuB,OAAc,CAAC;AAC7C,kBAAQ,GAAwB,QAAe,CAAC;AAChD,iBAAO,GAAuB,OAAc,CAAC;AA+FzC,QAAA,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;AAE7C,kBAAe,SAAS,CAAC"}
package/src/data_types.ts CHANGED
@@ -1,8 +1,6 @@
1
- 'use strict';
2
-
3
- const util = require('util');
1
+ import Raw from './raw';
2
+ import util from 'util';
4
3
  const invokableFunc = require('./utils/invokable');
5
- const Raw = require('./raw');
6
4
 
7
5
  export enum LENGTH_VARIANTS {
8
6
  tiny = 'tiny',
@@ -67,12 +65,19 @@ class STRING extends DataType {
67
65
  return chunks.join(' ');
68
66
  }
69
67
 
70
- uncast(value: string | typeof Raw | null): string {
68
+ uncast(value: string | Raw | null): string | Raw | null {
71
69
  if (value == null || value instanceof Raw) return value;
72
70
  return '' + value;
73
71
  }
74
72
  }
75
73
 
74
+ class CHAR extends STRING {
75
+ constructor(dataLength: number = 255) {
76
+ super(dataLength);
77
+ this.dataType = 'char';
78
+ }
79
+ }
80
+
76
81
  class BINARY extends DataType {
77
82
  constructor(dataLength = 255) {
78
83
  super();
@@ -299,13 +304,14 @@ class DATE extends DataType {
299
304
  return this._round(value);
300
305
  }
301
306
 
302
- uncast(value: null | typeof Raw | string | Date, _strict?: boolean): string | Date {
307
+ uncast(value: null | Raw | string | Date | { toDate: () => Date }, _strict?: boolean): string | Date | Raw | null | undefined {
303
308
  const originValue = value;
304
309
 
305
- if (value == null || value instanceof Raw) return value;
306
- if (typeof value.toDate === 'function') {
307
- value = value.toDate();
308
- }
310
+ // type narrowing doesn't handle `return value` correctly
311
+ if (value == null) return value as null | undefined;
312
+ if (value instanceof Raw) return value;
313
+ // Date | Moment
314
+ if (typeof value === 'object' && 'toDate' in value) value = value.toDate();
309
315
 
310
316
  // @deprecated
311
317
  // vaguely standard date formats such as 2021-10-15 15:50:02,548
@@ -317,8 +323,8 @@ class DATE extends DataType {
317
323
 
318
324
  // 1634611135776
319
325
  // '2021-10-15T08:38:43.877Z'
320
- if (!(value instanceof Date)) value = new Date(value);
321
- if (isNaN(value)) throw new Error(util.format('invalid date: %s', originValue));
326
+ if (!(value instanceof Date)) value = new Date((value as string));
327
+ if (isNaN((value as any))) throw new Error(util.format('invalid date: %s', originValue));
322
328
 
323
329
  return this._round(value);
324
330
  }
@@ -466,6 +472,7 @@ class VIRTUAL extends DataType {
466
472
  }
467
473
 
468
474
  const AllDataTypes = {
475
+ CHAR,
469
476
  STRING,
470
477
  TINYINT,
471
478
  SMALLINT,
@@ -488,6 +495,7 @@ const AllDataTypes = {
488
495
  export type DATA_TYPE<T> = AbstractDataType<T> & T;
489
496
 
490
497
  class DataTypes {
498
+ static CHAR: DATA_TYPE<CHAR> = CHAR as any;
491
499
  static STRING: DATA_TYPE<STRING> = STRING as any;
492
500
  static TINYINT: DATA_TYPE<TINYINT> = TINYINT as any;
493
501
  static SMALLINT: DATA_TYPE<SMALLINT> = SMALLINT as any;
@@ -508,7 +516,7 @@ class DataTypes {
508
516
 
509
517
  static findType(columnType: string): DataTypes {
510
518
  const {
511
- STRING, TEXT, DATE, DATEONLY,
519
+ CHAR, STRING, TEXT, DATE, DATEONLY,
512
520
  TINYINT, SMALLINT, MEDIUMINT, INTEGER,
513
521
  BIGINT, DECIMAL, BOOLEAN,
514
522
  BINARY, VARBINARY, BLOB,
@@ -525,8 +533,9 @@ class DataTypes {
525
533
  }
526
534
 
527
535
  switch (dataType) {
528
- case 'varchar':
529
536
  case 'char':
537
+ return new CHAR(...params);
538
+ case 'varchar':
530
539
  return new STRING(...params);
531
540
  // longtext is only for MySQL
532
541
  case 'longtext':
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const debug = require('debug')('leoric');
4
-
5
3
  const { snakeCase } = require('../../utils/string');
4
+ const { LENGTH_VARIANTS } = require('../../data_types');
6
5
 
7
6
  /**
8
7
  * Find the corresponding JavaScript type of the type in database.
@@ -79,6 +78,7 @@ function createType(DataTypes, params) {
79
78
  case 'CHAR':
80
79
  case 'VARCHAR':
81
80
  case 'STRING':
81
+ case 'TEXT':
82
82
  return new DataType(type.dataLength);
83
83
  default:
84
84
  return new DataType();
@@ -133,15 +133,18 @@ class Attribute {
133
133
  if (!columnInfo) return false;
134
134
  const props = [ 'allowNull', 'dataType', 'defaultValue', 'primaryKey' ];
135
135
  for (const prop of props) {
136
- // SQLite has default value as string even if data type is integer
137
- if (this[prop] != columnInfo[prop]) {
138
- debug('[attribute] [%s] %s not equal (defined: %s, actual: %s)',
139
- this.columnName,
140
- prop,
141
- this[prop],
142
- columnInfo[prop]);
143
- return false;
136
+ let source = this[prop];
137
+ const target = columnInfo[prop];
138
+ if (prop === 'dataType') {
139
+ if (source === 'integer' && target === 'int') continue;
140
+ if (source !== target && Object.values(LENGTH_VARIANTS).includes(this.type.dataLength)) {
141
+ source = `${this.type.dataLength}${source}`;
142
+ }
143
+ } else if (prop === 'defaultValue') {
144
+ if (source === null && target === 'CURRENT_TIMESTAMP') continue;
144
145
  }
146
+ // SQLite has default value as string even if data type is integer
147
+ if (source != target) return false;
145
148
  }
146
149
  return true;
147
150
  }
@@ -4,7 +4,7 @@ const SqlString = require('sqlstring');
4
4
 
5
5
  const { copyExpr, findExpr, walkExpr } = require('../../expr');
6
6
  const { formatExpr, formatConditions, collectLiteral, isAggregatorExpr } = require('../../expr_formatter');
7
- const Raw = require('../../raw');
7
+ const Raw = require('../../raw').default;
8
8
 
9
9
  /**
10
10
  * Create a subquery to make sure OFFSET and LIMIT on left table takes effect.
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { default: DataTypes } = require('../../data_types');
4
4
  const util = require('util');
5
- const Raw = require('../../raw');
5
+ const Raw = require('../../raw').default;
6
6
 
7
7
 
8
8
  class Postgres_DATE extends DataTypes.DATE {
package/src/expr.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const Raw = require('./raw').default;
4
+
3
5
  /**
4
6
  * This module contains a simple SQL expression parser which parses `select_expr` and `expr` in `WHERE`/`HAVING`/`ON` conditions. Most of {@link Spell}'s functionalities are made possible because of this parser. Currently, it cannot parse a full SQL.
5
7
  * @module
@@ -133,6 +135,7 @@ function parseValue(value) {
133
135
  * @returns {Object[]}
134
136
  */
135
137
  function parseExprList(str, ...values) {
138
+ if (str instanceof Raw) return [ str ];
136
139
  let i = 0;
137
140
  let chr = str[i];
138
141
  let valueIndex = 0;
@@ -3,7 +3,7 @@
3
3
  const util = require('util');
4
4
  const { isPlainObject } = require('./utils');
5
5
  const { parseExpr } = require('./expr');
6
- const Raw = require('./raw');
6
+ const Raw = require('./raw').default;
7
7
  // deferred to break cyclic dependencies
8
8
  let Spell;
9
9
 
package/src/raw.js CHANGED
@@ -1,9 +1,21 @@
1
- 'use strict';
2
-
3
- module.exports = class Raw {
4
- constructor(value) {
5
- this.value = value;
6
- // consumed in expr_formatter.js
7
- this.type = 'raw';
8
- }
9
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Raw {
4
+ constructor(value) {
5
+ // consumed in expr_formatter.js
6
+ this.type = 'raw';
7
+ if (typeof value !== 'string') {
8
+ throw new Error('invalid type of raw value');
9
+ }
10
+ this.value = value;
11
+ }
12
+ toString() {
13
+ return this.value;
14
+ }
15
+ static build(value) {
16
+ return new Raw(value);
17
+ }
18
+ }
19
+ exports.default = Raw;
20
+ ;
21
+ //# sourceMappingURL=raw.js.map
package/src/raw.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.js","sourceRoot":"","sources":["raw.ts"],"names":[],"mappings":";;AAAA,MAAqB,GAAG;IAMtB,YAAY,KAAa;QAHzB,gCAAgC;QAChC,SAAI,GAAW,KAAK,CAAC;QAGnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAa;QACxB,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF;AApBD,sBAoBC;AAAA,CAAC"}
package/src/raw.ts ADDED
@@ -0,0 +1,21 @@
1
+ export default class Raw {
2
+ value: string;
3
+
4
+ // consumed in expr_formatter.js
5
+ type: string = 'raw';
6
+
7
+ constructor(value: string) {
8
+ if (typeof value !== 'string') {
9
+ throw new Error('invalid type of raw value');
10
+ }
11
+ this.value = value;
12
+ }
13
+
14
+ toString() {
15
+ return this.value;
16
+ }
17
+
18
+ static build(value: string) {
19
+ return new Raw(value);
20
+ }
21
+ };
package/src/realm.js CHANGED
@@ -8,9 +8,11 @@ const { findDriver, AbstractDriver } = require('./drivers');
8
8
  const { camelCase } = require('./utils/string');
9
9
  const { isBone } = require('./utils');
10
10
  const sequelize = require('./adapters/sequelize');
11
- const Raw = require('./raw');
11
+ const Raw = require('./raw').default;
12
12
  const { LEGACY_TIMESTAMP_MAP } = require('./constants');
13
13
 
14
+ const SequelizeBone = sequelize(Bone);
15
+
14
16
  /**
15
17
  *
16
18
  * @typedef {Object} QueryResult
@@ -91,10 +93,13 @@ async function loadModels(Spine, models, opts) {
91
93
  }
92
94
 
93
95
  function createSpine(opts) {
94
- if (opts.Bone && opts.Bone.prototype instanceof Bone) return opts.Bone;
95
- if (opts.sequelize) return sequelize(Bone);
96
- if (opts.subclass !== true) return Bone;
97
- return class Spine extends Bone {};
96
+ let Model = Bone;
97
+ if (opts.Bone && opts.Bone.prototype instanceof Bone) {
98
+ Model = opts.Bone;
99
+ } else if (opts.sequelize) {
100
+ Model = SequelizeBone;
101
+ }
102
+ return opts.subclass === true ? class Spine extends Model {} : Model;
98
103
  }
99
104
 
100
105
  const rReplacementKey = /\s:(\w+)\b/g;
@@ -267,6 +272,8 @@ class Realm {
267
272
  escape(value) {
268
273
  return this.driver.escape(value);
269
274
  }
275
+
276
+ static SequelizeBone = SequelizeBone;
270
277
  }
271
278
 
272
279
  module.exports = Realm;
package/src/spell.d.ts CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  Literal, command, Raw, Connection,
3
3
  ResultSet, QueryResult,
4
4
  QueryOptions, SetOptions, WithOptions,
5
- Collection, WhereConditions, OrderOptions,
5
+ Collection, WhereConditions, OrderOptions, BoneColumns,
6
6
  } from './types/common';
7
7
  import { AbstractBone } from './types/abstract_bone';
8
8
  import { Hint, IndexHint, CommonHintsArgs, HintInterface } from './hint';
@@ -134,15 +134,28 @@ export class Spell<T extends typeof AbstractBone, U = InstanceType<T> | Collecti
134
134
  $limit(rowCount: number): Spell<T, U>;
135
135
  limit(rowCount: number): Spell<T, U>;
136
136
 
137
- count(name?: string): Spell<T, Extract<U, ResultSet<T> | number>>;
138
- average(name?: string): Spell<T, Extract<U, ResultSet<T> | number>>;
139
- minimum(name?: string): Spell<T, Extract<U, ResultSet<T> | number>>;
140
- maximum(name?: string): Spell<T, Extract<U, ResultSet<T> | number>>;
141
- sum(name?: string): Spell<T, Extract<U, ResultSet<T> | number>>;
137
+ // aggregator(name: string) for Model.first/all/last.aggregator(name) because of ts(2526)
138
+ count(name?: BoneColumns<T>): Spell<T, Extract<U, ResultSet<T> | number>>;
139
+ count(name?: Raw | string): Spell<T, Extract<U, ResultSet<T> | number>>;
140
+
141
+ average(name?: BoneColumns<T>): Spell<T, Extract<U, ResultSet<T> | number>>;
142
+ average(name?: Raw | string): Spell<T, Extract<U, ResultSet<T> | number>>;
143
+
144
+ minimum(name?: BoneColumns<T>): Spell<T, Extract<U, ResultSet<T> | number>>;
145
+ minimum(name?: Raw | string): Spell<T, Extract<U, ResultSet<T> | number>>;
146
+
147
+ maximum(name?: BoneColumns<T>): Spell<T, Extract<U, ResultSet<T> | number>>;
148
+ maximum(name?: Raw | string): Spell<T, Extract<U, ResultSet<T> | number>>;
149
+
150
+ sum(name?: BoneColumns<T>): Spell<T, Extract<U, ResultSet<T> | number>>;
151
+ sum(name?: Raw | string): Spell<T, Extract<U, ResultSet<T> | number>>;
142
152
 
143
153
  batch(size?: number): AsyncIterable<T>;
144
154
 
155
+ increment(name: BoneColumns<T>, by?: number, options?: QueryOptions): Spell<T, QueryResult>;
145
156
  increment(name: string, by?: number, options?: QueryOptions): Spell<T, QueryResult>;
157
+
158
+ decrement(name: BoneColumns<T>, by?: number, options?: QueryOptions): Spell<T, QueryResult>;
146
159
  decrement(name: string, by?: number, options?: QueryOptions): Spell<T, QueryResult>;
147
160
 
148
161
  toSqlString(): string;
package/src/spell.js CHANGED
@@ -10,7 +10,7 @@ const { parseExprList, parseExpr, walkExpr } = require('./expr');
10
10
  const { isPlainObject } = require('./utils');
11
11
  const { IndexHint, INDEX_HINT_TYPE, Hint } = require('./hint');
12
12
  const { parseObject } = require('./query_object');
13
- const Raw = require('./raw');
13
+ const Raw = require('./raw').default;
14
14
  const { AGGREGATOR_MAP } = require('./constants');
15
15
 
16
16
  /**
@@ -961,7 +961,11 @@ for (const aggregator in AGGREGATOR_MAP) {
961
961
  configurable: true,
962
962
  writable: true,
963
963
  value: function Spell_aggregator(name = '*') {
964
- if (name != '*' && parseExpr(name).type != 'id') {
964
+ if (name instanceof Raw) {
965
+ this.$select(Raw.build(`${func.toUpperCase()}(${name}) AS ${aggregator}`));
966
+ return this
967
+ }
968
+ if (name !== '*' && parseExpr(name).type !== 'id') {
965
969
  throw new Error(`unexpected operand ${name} for ${func.toUpperCase()}()`);
966
970
  }
967
971
  this.$select(`${func}(${name}) as ${aggregator}`);
@@ -3,10 +3,11 @@ import {
3
3
  Pool, Literal, WhereConditions,
4
4
  Collection, ResultSet, OrderOptions,
5
5
  QueryOptions, AttributeMeta, AssociateOptions, Values, Connection, BulkCreateOptions,
6
- GeneratorReturnType,
6
+ GeneratorReturnType, BoneColumns, InstanceColumns, Raw,
7
7
  } from './common';
8
8
  import { AbstractDriver } from '../drivers';
9
9
  import { Spell } from '../spell';
10
+ import { Key } from "readline";
10
11
 
11
12
  interface SyncOptions {
12
13
  force?: boolean;
@@ -17,7 +18,10 @@ interface TransactionOptions {
17
18
  connection: Connection;
18
19
  }
19
20
 
21
+ type V<T, Key extends keyof T> = Record<Key, T[Key]>;
20
22
  export class AbstractBone {
23
+ static name: string;
24
+
21
25
  static DataTypes: typeof DataTypes;
22
26
 
23
27
  /**
@@ -28,7 +32,7 @@ export class AbstractBone {
28
32
  /**
29
33
  * The driver that powers the model
30
34
  */
31
- static driver: AbstractDriver;
35
+ static driver: AbstractDriver | null;
32
36
 
33
37
  /**
34
38
  * The connected models structured as `{ [model.name]: model }`, e.g. `Bone.model.Post => Post`
@@ -60,6 +64,11 @@ export class AbstractBone {
60
64
  */
61
65
  static attributes: { [key: string]: AbstractDataType<DataType> | AttributeMeta };
62
66
 
67
+ /**
68
+ * The actual attribute definitions of the model.
69
+ */
70
+ static columnAttributes: { [key: string]: AbstractDataType<DataType> | AttributeMeta };
71
+
63
72
  /**
64
73
  * The schema info of current model.
65
74
  */
@@ -89,11 +98,18 @@ export class AbstractBone {
89
98
  * @example
90
99
  * Bone.renameAttribute('foo', 'bar')
91
100
  */
92
- static renameAttribute(originalName: string, newName: string): void;
101
+ static renameAttribute<T extends typeof AbstractBone>(this: T, originalName: BoneColumns<T>, newName: string): void;
102
+ // after renamed
103
+ static renameAttribute<T extends typeof AbstractBone>(this: T, originalName: string, newName: string): void;
93
104
 
94
- static alias(name: string): string;
95
- static alias(data: Record<string, Literal>): Record<string, Literal>;
96
- static unalias(name: string): string;
105
+ static alias<T extends typeof AbstractBone>(this: T, name: BoneColumns<T>): string;
106
+ static alias<T extends typeof AbstractBone>(this: T, data: Record<BoneColumns<T>, Literal>): Record<string, Literal>;
107
+ static unalias<T extends typeof AbstractBone>(this: T, name: BoneColumns<T>): string;
108
+
109
+ // after alias/unalias
110
+ static alias<T extends typeof AbstractBone>(this: T, name: string): string;
111
+ static alias<T extends typeof AbstractBone>(this: T, data: Record<string, Literal>): Record<string, Literal>;
112
+ static unalias<T extends typeof AbstractBone>(this: T, name: string): string;
97
113
 
98
114
  static hasOne(name: string, opts?: AssociateOptions): void;
99
115
  static hasMany(name: string, opts?: AssociateOptions): void;
@@ -104,7 +120,7 @@ export class AbstractBone {
104
120
  * @example
105
121
  * Bone.create({ foo: 1, bar: 'baz' })
106
122
  */
107
- static create<T extends typeof AbstractBone>(this: T, values: Values<InstanceType<T>> & Record<string, any>, options?: QueryOptions): Promise<InstanceType<T>>;
123
+ static create<T extends typeof AbstractBone>(this: T, values: Values<InstanceType<T>> & Partial<Record<BoneColumns<T>, Literal>>, options?: QueryOptions): Promise<InstanceType<T>>;
108
124
 
109
125
  /**
110
126
  * INSERT or UPDATE rows
@@ -113,12 +129,12 @@ export class AbstractBone {
113
129
  * @param values values
114
130
  * @param opt query options
115
131
  */
116
- static upsert<T extends typeof AbstractBone>(this: T, values: Object, options?: QueryOptions): Spell<T, number>;
132
+ static upsert<T extends typeof AbstractBone>(this: T, values: Partial<Record<BoneColumns<T>, Literal>>, options?: QueryOptions): Spell<T, number>;
117
133
 
118
134
  /**
119
135
  * Batch INSERT
120
136
  */
121
- static bulkCreate<T extends typeof AbstractBone>(this: T, records: Array<Record<string, Literal>>, options?: BulkCreateOptions): Promise<Array<InstanceType<T>>>;
137
+ static bulkCreate<T extends typeof AbstractBone>(this: T, records: Array<Partial<Record<BoneColumns<T>, Literal>>>, options?: BulkCreateOptions): Promise<Array<InstanceType<T>>>;
122
138
 
123
139
  /**
124
140
  * SELECT all rows. In production, when the table is at large, it is not recommended to access records in this way. To iterate over all records, {@link Bone.batch} shall be considered as the better alternative. For tables with soft delete enabled, which means they've got `deletedAt` attribute, use {@link Bone.unscoped} to discard the default scope.
@@ -159,6 +175,7 @@ export class AbstractBone {
159
175
  * Bone.select('MONTH(date), foo + 1')
160
176
  * Bone.select(name => name !== foo)
161
177
  */
178
+ static select<T extends typeof AbstractBone>(this: T, ...names: Array<BoneColumns<T>> | string[]): Spell<T>;
162
179
  static select<T extends typeof AbstractBone>(this: T, ...names: string[]): Spell<T>;
163
180
  static select<T extends typeof AbstractBone>(this: T, filter: (name: string) => boolean): Spell<T>;
164
181
 
@@ -167,8 +184,8 @@ export class AbstractBone {
167
184
  * @example
168
185
  * Bone.join(Muscle, 'bones.id == muscles.boneId')
169
186
  */
170
- static join<T extends typeof AbstractBone>(this: T, Model: AbstractBone, onConditions: string, ...values: Literal[]): Spell<T, Collection<InstanceType<T>>>;
171
187
  static join<T extends typeof AbstractBone>(this: T, Model: AbstractBone, onConditions: WhereConditions<T>): Spell<T, Collection<InstanceType<T>>>;
188
+ static join<T extends typeof AbstractBone>(this: T, Model: AbstractBone, onConditions: string, ...values: Literal[]): Spell<T, Collection<InstanceType<T>>>;
172
189
 
173
190
  /**
174
191
  * Set WHERE conditions
@@ -176,8 +193,8 @@ export class AbstractBone {
176
193
  * Bone.where('foo = ?', 1)
177
194
  * Bone.where({ foo: { $eq: 1 } })
178
195
  */
179
- static where<T extends typeof AbstractBone>(this: T, whereConditions: string, ...values: Literal[]): Spell<T, Collection<InstanceType<T>>>;
180
196
  static where<T extends typeof AbstractBone>(this: T, whereConditions: WhereConditions<T>): Spell<T, Collection<InstanceType<T>>>;
197
+ static where<T extends typeof AbstractBone>(this: T, whereConditions: string, ...values: Literal[]): Spell<T, Collection<InstanceType<T>>>;
181
198
 
182
199
  /**
183
200
  * Set GROUP fields
@@ -185,7 +202,8 @@ export class AbstractBone {
185
202
  * Bone.group('foo')
186
203
  * Bone.group('MONTH(createdAt)')
187
204
  */
188
- static group<T extends typeof AbstractBone>(this: T, ...names: string[]): Spell<T, ResultSet<T>>;
205
+ static group<T extends typeof AbstractBone>(this: T, ...names: Array<BoneColumns<T>>): Spell<T, ResultSet<T>>;
206
+ static group<T extends typeof AbstractBone>(this: T, ...names: Array<string>): Spell<T, ResultSet<T>>;
189
207
 
190
208
  /**
191
209
  * Set ORDER fields
@@ -194,14 +212,17 @@ export class AbstractBone {
194
212
  * Bone.order('foo', 'desc')
195
213
  * Bone.order({ foo: 'desc' })
196
214
  */
197
- static order<T extends typeof AbstractBone>(this: T, name: string, order?: 'desc' | 'asc'): Spell<T>;
215
+ static order<T extends typeof AbstractBone>(this: T, name: BoneColumns<T>, order?: 'desc' | 'asc'): Spell<T>;
198
216
  static order<T extends typeof AbstractBone>(this: T, opts: OrderOptions<T>): Spell<T>;
199
217
 
200
- static count<T extends typeof AbstractBone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
201
- static average<T extends typeof AbstractBone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
202
- static minimum<T extends typeof AbstractBone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
203
- static maximum<T extends typeof AbstractBone>(this: T, name?: string): Spell<T, ResultSet<T> | number>;
204
-
218
+ static count<T extends typeof AbstractBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
219
+ static count<T extends typeof AbstractBone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
220
+ static average<T extends typeof AbstractBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
221
+ static average<T extends typeof AbstractBone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
222
+ static minimum<T extends typeof AbstractBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
223
+ static minimum<T extends typeof AbstractBone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
224
+ static maximum<T extends typeof AbstractBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
225
+ static maximum<T extends typeof AbstractBone>(this: T, name?: Raw): Spell<T, ResultSet<T> | number>;
205
226
  /**
206
227
  * Remove rows. If soft delete is applied, an UPDATE query is performed instead of DELETing records directly. Set `forceDelete` to true to force a `DELETE` query.
207
228
  */
@@ -241,15 +262,19 @@ export class AbstractBone {
241
262
  * bone.attribute('foo'); // => 1
242
263
  * bone.attribute('foo', 2); // => bone
243
264
  */
244
- attribute(name: string, value: Literal): void;
245
- attribute(name: string): Literal;
265
+ attribute<T, Key extends keyof Values<T>>(this: T, name: Key, value: Literal): void;
266
+ attribute<T, Key extends keyof T>(this: T, name: Key, value: Literal): void;
267
+
268
+ attribute<T, Key extends keyof Values<T>, U extends T[Key]>(this: T, name: Key): U extends Literal ? U : Literal;
269
+ attribute<T, Key extends keyof T, U extends T[Key]>(this: T, name: Key): U extends Literal ? U : Literal;
246
270
 
247
271
  /**
248
272
  * Get the original attribute value.
249
273
  * @example
250
274
  * bone.attributeWas('foo') // => 1
251
275
  */
252
- attributeWas(name: string): Literal;
276
+ attributeWas<T, Key extends keyof Values<T>, U extends T[Key]>(this: T, key: Key): U extends Literal ? U : Literal;
277
+ attributeWas<T, Key extends keyof T, U extends T[Key]>(this: T, key: Key): U extends Literal ? U : Literal;
253
278
 
254
279
  /**
255
280
  * See if attribute has been changed or not.
@@ -257,28 +282,42 @@ export class AbstractBone {
257
282
  * @example
258
283
  * bone.attributeChanged('foo')
259
284
  */
260
- attributeChanged(name: string): boolean;
285
+ attributeChanged<T, Key extends keyof Values<T>>(this: T, name: Key): boolean;
286
+ // for getter/setter
287
+ attributeChanged<T, Key extends keyof T>(this: T, name: Key): boolean;
261
288
 
262
289
  /**
263
290
  * Get changed attributes or check if given attribute is changed or not
264
291
  */
265
- changed(name: string): boolean;
266
- changed(): Array<string> | false;
292
+ changed<T, Key extends keyof Values<T>>(this: T, name: Key): boolean;
293
+ // for getter/setter
294
+ changed<T, Key extends keyof T>(this: T, name: Key): boolean;
295
+
296
+ changed<T, Key extends keyof Values<T>>(this: T): Array<Key> | false;
297
+ // for getter/setter
298
+ changed<T, Key extends keyof T>(this: T): Array<Key> | false;
267
299
 
268
300
  /**
269
301
  * Get attribute changes
270
302
  */
271
- changes(name: string): Record<string, [ Literal, Literal ]>;
272
- changes(): Record<string, [ Literal, Literal ]>;
303
+ changes<T, Key extends keyof Values<T>>(this: T, name: Key): Record<InstanceColumns<this>, [ Literal, Literal ]>;
304
+ changes<T, Key extends keyof T>(this: T, name: Key): Record<InstanceColumns<this>, [ Literal, Literal ]>;
305
+ changes(): Record<InstanceColumns<this>, [ Literal, Literal ]>;
273
306
 
274
307
  /**
275
308
  * See if attribute was changed previously or not.
276
309
  */
277
- previousChanged(name: string): boolean;
278
- previousChanged(): Array<string>;
310
+ previousChanged<T, Key extends keyof Values<T>>(this: T, name: Key): boolean;
311
+ previousChanged<T, Key extends keyof T>(this: T, name: Key): boolean;
312
+
313
+ previousChanged<T, Key extends keyof Values<T>>(this: T): Array<Key>;
314
+ previousChanged<T, Key extends keyof T>(this: T): Array<Key>;
315
+
316
+ previousChanges<T, Key extends keyof Values<T>>(this: T, name: Key): boolean;
317
+ previousChanges<T, Key extends keyof T>(this: T, name: Key): boolean;
279
318
 
280
- previousChanges(name: string): boolean;
281
- previousChanges(): Array<string>;
319
+ previousChanges<T, Key extends keyof Values<T>>(this: T ): Array<Key>;
320
+ previousChanges<T, Key extends keyof T>(this: T ): Array<Key>;
282
321
 
283
322
  /**
284
323
  * Persist changes of current record to database. If current record has never been saved before, an INSERT query is performed. If the primary key was set and is not changed since, an UPDATE query is performed. If the primary key is changed, an INSERT ... UPDATE query is performed instead.
@@ -316,7 +355,7 @@ export class AbstractBone {
316
355
  * @param changes data changes
317
356
  * @param opts query options
318
357
  */
319
- update(changes?: { [key: string]: Literal } | { [Property in keyof Extract<this, Literal>]: Literal }, opts?: QueryOptions): Promise<number>;
358
+ update(changes?: { [key: string]: Literal } | { [Property in keyof Extract<this, Literal>]?: Literal }, opts?: QueryOptions): Promise<number>;
320
359
 
321
360
  /**
322
361
  * create instance
@@ -61,7 +61,7 @@ export interface QueryOptions {
61
61
  hint?: CommonHintsArgs;
62
62
  transaction?: Connection | {
63
63
  connection: Connection
64
- };
64
+ } | null;
65
65
  }
66
66
 
67
67
  export type BulkCreateOptions = QueryOptions & {
@@ -146,19 +146,21 @@ export class Raw {
146
146
  type: 'raw';
147
147
  }
148
148
 
149
- export type SetOptions<T extends typeof AbstractBone> = {
150
- [key: string]: Literal
151
- } | {
149
+ export type SetOptions<T extends typeof AbstractBone> = {
152
150
  [Property in keyof Extract<InstanceType<T>, Literal>]: Literal
151
+ } | {
152
+ [key: string]: Literal
153
153
  };
154
154
 
155
155
  export type WithOptions = {
156
156
  [qualifier: string]: { select: string | string[], throughRelation?: string }
157
157
  }
158
158
 
159
- type OrderOptions<T extends typeof AbstractBone> = {
160
- [Property in keyof Extract<InstanceType<T>, Literal>]: 'desc' | 'asc'
161
- } | { [name: string]: 'desc' | 'asc' } | Array<string | string[] | Raw> | string | Raw;
159
+ type OrderOptions<T extends typeof AbstractBone> = {
160
+ [key in keyof Extract<InstanceType<T>, Literal>]?: 'desc' | 'asc'
161
+ } | [ BoneColumns<T>, 'desc' | 'asc' ]
162
+ | Array<BoneColumns<T> | [ BoneColumns<T>, 'desc' | 'asc' ] | Raw | string>
163
+ | string | Raw;
162
164
 
163
165
  export class Collection<T extends AbstractBone> extends Array<T> {
164
166
  save(): Promise<void>;
@@ -175,7 +177,13 @@ export type WhereConditions<T extends typeof AbstractBone> = {
175
177
  // https://stackoverflow.com/a/68077021/179691
176
178
  export type PickTypeKeys<Obj, Type, T extends keyof Obj = keyof Obj> = ({ [P in keyof Obj]: Obj[P] extends Type ? P : never })[T];
177
179
 
178
- export type Values<T> = Partial<Omit<T, PickTypeKeys<T, Function>>>;
180
+ export type NullablePartial<T> = { [P in keyof T]?: T[P] | null };
181
+
182
+ export type Values<T> = NullablePartial<Omit<T, PickTypeKeys<T, Function> | 'isNewRecord' | 'Model' | 'dataValues'>>;
183
+
184
+ export type BoneColumns<T extends typeof AbstractBone, Key extends keyof InstanceType<T> = keyof Values<InstanceType<T>>> = Key;
185
+
186
+ export type InstanceColumns<T = typeof AbstractBone, Key extends keyof T = keyof Values<T>> = Key;
179
187
 
180
188
  export type BeforeHooksType = 'beforeCreate' | 'beforeBulkCreate' | 'beforeUpdate' | 'beforeSave' | 'beforeUpsert' | 'beforeRemove';
181
189
  export type AfterHooksType = 'afterCreate' | 'afterBulkCreate' | 'afterUpdate' | 'afterSave' | 'afterUpsert' | 'afterRemove';