fib-orm 2.0.0 → 2.1.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.
Files changed (179) hide show
  1. package/lib/cli/commands/ddlFrom.d.ts +1 -1
  2. package/lib/cli/commands/ddlFrom.js +1 -0
  3. package/lib/cli/commands/dumpModel.d.ts +1 -1
  4. package/lib/cli/commands/dumpModel.js +1 -0
  5. package/lib/cli/commands/escape.d.ts +1 -1
  6. package/lib/cli/commands/escape.js +1 -0
  7. package/lib/cli/commands/spinner.d.ts +1 -1
  8. package/lib/cli/commands/spinner.js +1 -0
  9. package/lib/cli/commands/upgrade.d.ts +1 -1
  10. package/lib/cli/commands/upgrade.js +1 -0
  11. package/lib/cli/helpers/ddl.d.ts +1 -1
  12. package/lib/cli/helpers/ddl.js +3 -3
  13. package/lib/cli/helpers/package.d.ts +0 -1
  14. package/lib/cli/helpers/package.js +4 -4
  15. package/lib/cli/index.js +1 -0
  16. package/lib/db-driver/Typo.d.ts +0 -1
  17. package/lib/db-driver/Typo.js +1 -0
  18. package/lib/db-driver/built-ins/base.class.d.ts +0 -5
  19. package/lib/db-driver/built-ins/base.class.js +1 -0
  20. package/lib/db-driver/built-ins/driver-dm.d.ts +0 -1
  21. package/lib/db-driver/built-ins/driver-dm.js +1 -0
  22. package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -1
  23. package/lib/db-driver/built-ins/driver-mongodb.js +1 -0
  24. package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -1
  25. package/lib/db-driver/built-ins/driver-mysql.js +1 -0
  26. package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -1
  27. package/lib/db-driver/built-ins/driver-postgresql.js +1 -0
  28. package/lib/db-driver/built-ins/driver-redis.d.ts +0 -1
  29. package/lib/db-driver/built-ins/driver-redis.js +1 -0
  30. package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -1
  31. package/lib/db-driver/built-ins/driver-sqlite.js +1 -0
  32. package/lib/db-driver/index.js +1 -0
  33. package/lib/db-driver/utils.js +13 -13
  34. package/lib/knex/knex.js +1 -0
  35. package/lib/knex/sandbox.js +1 -0
  36. package/lib/orm/Adapters.js +3 -3
  37. package/lib/orm/AggregateFunctions.js +1 -0
  38. package/lib/orm/Associations/Extend.js +4 -4
  39. package/lib/orm/Associations/Many.d.ts +0 -1
  40. package/lib/orm/Associations/Many.js +6 -6
  41. package/lib/orm/Associations/One.js +4 -4
  42. package/lib/orm/Associations/_utils.d.ts +0 -1
  43. package/lib/orm/Associations/_utils.js +8 -7
  44. package/lib/orm/ChainFind.js +1 -0
  45. package/lib/orm/ChainInstance.js +1 -0
  46. package/lib/orm/Debug.js +4 -4
  47. package/lib/orm/Drivers/DB/base.d.ts +0 -1
  48. package/lib/orm/Drivers/DB/base.js +1 -0
  49. package/lib/orm/Drivers/DB/dm.d.ts +0 -2
  50. package/lib/orm/Drivers/DB/dm.js +1 -0
  51. package/lib/orm/Drivers/DB/mysql.d.ts +0 -2
  52. package/lib/orm/Drivers/DB/mysql.js +1 -0
  53. package/lib/orm/Drivers/DB/postgres.d.ts +0 -2
  54. package/lib/orm/Drivers/DB/postgres.js +1 -0
  55. package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -2
  56. package/lib/orm/Drivers/DB/sqlite3.js +1 -0
  57. package/lib/orm/Drivers/DML/_ddl-sql.js +1 -0
  58. package/lib/orm/Drivers/DML/_dml-helpers.js +6 -6
  59. package/lib/orm/Drivers/DML/_shared.js +5 -4
  60. package/lib/orm/Drivers/DML/_utils.js +7 -7
  61. package/lib/orm/Drivers/DML/constants.js +1 -0
  62. package/lib/orm/Drivers/DML/dm.js +1 -0
  63. package/lib/orm/Drivers/DML/index.js +1 -0
  64. package/lib/orm/Drivers/DML/mysql.js +1 -0
  65. package/lib/orm/Drivers/DML/postgres.d.ts +0 -1
  66. package/lib/orm/Drivers/DML/postgres.js +1 -0
  67. package/lib/orm/Drivers/DML/sqlite.js +1 -0
  68. package/lib/orm/Error.js +2 -1
  69. package/lib/orm/Helpers.js +22 -21
  70. package/lib/orm/Hook.js +1 -0
  71. package/lib/orm/Instance.js +1 -0
  72. package/lib/orm/LazyLoad.js +2 -2
  73. package/lib/orm/Model.d.ts +1 -2
  74. package/lib/orm/Model.js +7 -4
  75. package/lib/orm/ORM.js +1 -0
  76. package/lib/orm/Patch/fib-cache.d.ts +0 -1
  77. package/lib/orm/Patch/plugin.js +2 -1
  78. package/lib/orm/Property.js +2 -2
  79. package/lib/orm/Settings.js +3 -2
  80. package/lib/orm/Singleton.js +1 -0
  81. package/lib/orm/Typo/Adapter.js +1 -0
  82. package/lib/orm/Typo/DMLDriver.d.ts +0 -1
  83. package/lib/orm/Typo/DMLDriver.js +1 -0
  84. package/lib/orm/Typo/Db.d.ts +0 -3
  85. package/lib/orm/Typo/Db.js +1 -0
  86. package/lib/orm/Typo/Error.d.ts +0 -2
  87. package/lib/orm/Typo/Error.js +1 -0
  88. package/lib/orm/Typo/ORM.d.ts +0 -2
  89. package/lib/orm/Typo/ORM.js +1 -0
  90. package/lib/orm/Typo/Validators.d.ts +0 -1
  91. package/lib/orm/Typo/Validators.js +1 -0
  92. package/lib/orm/Typo/_common.d.ts +0 -1
  93. package/lib/orm/Typo/_common.js +1 -0
  94. package/lib/orm/Typo/assoc.js +1 -0
  95. package/lib/orm/Typo/hook.js +1 -0
  96. package/lib/orm/Typo/instance.d.ts +0 -1
  97. package/lib/orm/Typo/instance.js +1 -0
  98. package/lib/orm/Typo/model.d.ts +0 -2
  99. package/lib/orm/Typo/model.js +2 -1
  100. package/lib/orm/Typo/patch.js +1 -0
  101. package/lib/orm/Typo/property.js +1 -0
  102. package/lib/orm/Typo/query.js +1 -0
  103. package/lib/orm/Typo/settings.js +2 -1
  104. package/lib/orm/Typo/synchronous.js +1 -0
  105. package/lib/orm/Utilities.d.ts +1 -2
  106. package/lib/orm/Utilities.js +60 -60
  107. package/lib/orm/Validators.d.ts +0 -1
  108. package/lib/orm/Validators.js +4 -3
  109. package/lib/orm/Where/common.js +2 -2
  110. package/lib/orm/Where/filterDate.js +2 -2
  111. package/lib/orm/index.d.ts +0 -1
  112. package/lib/orm/index.js +7 -6
  113. package/lib/orm-core/callback.js +1 -0
  114. package/lib/orm-core/dialect.js +1 -0
  115. package/lib/orm-core/error.js +3 -3
  116. package/lib/orm-core/index.js +1 -0
  117. package/lib/orm-core/sync.js +1 -0
  118. package/lib/orm-core/utils.js +1 -0
  119. package/lib/orm-property/Property.js +1 -0
  120. package/lib/orm-property/Utils.js +2 -2
  121. package/lib/orm-property/customTypes.js +2 -2
  122. package/lib/orm-property/index.js +3 -2
  123. package/lib/orm-property/transformer.js +2 -2
  124. package/lib/orm-property/transformers/dm.js +1 -0
  125. package/lib/orm-property/transformers/index.js +1 -0
  126. package/lib/orm-property/transformers/mysql.d.ts +0 -1
  127. package/lib/orm-property/transformers/mysql.js +1 -0
  128. package/lib/orm-property/transformers/postgresql.js +1 -0
  129. package/lib/orm-property/transformers/sqlite.js +1 -0
  130. package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -1
  131. package/lib/sql-ddl-sync/Dialects/dm.js +1 -0
  132. package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -1
  133. package/lib/sql-ddl-sync/Dialects/index.js +1 -0
  134. package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -1
  135. package/lib/sql-ddl-sync/Dialects/mysql.js +1 -0
  136. package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -1
  137. package/lib/sql-ddl-sync/Dialects/postgresql.js +1 -0
  138. package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -1
  139. package/lib/sql-ddl-sync/Dialects/sqlite.js +1 -0
  140. package/lib/sql-ddl-sync/SQL.js +11 -11
  141. package/lib/sql-ddl-sync/Typo/Collection.js +1 -0
  142. package/lib/sql-ddl-sync/Typo/DbIndex.js +1 -0
  143. package/lib/sql-ddl-sync/Typo/Dialect.js +1 -0
  144. package/lib/sql-ddl-sync/Typo/Driver.js +1 -0
  145. package/lib/sql-ddl-sync/Typo/Query.js +1 -0
  146. package/lib/sql-ddl-sync/Typo/SQL.js +1 -0
  147. package/lib/sql-ddl-sync/Typo/_common.js +1 -0
  148. package/lib/sql-ddl-sync/Utils.d.ts +0 -1
  149. package/lib/sql-ddl-sync/Utils.js +14 -14
  150. package/lib/sql-ddl-sync/index.js +3 -2
  151. package/lib/sql-query/Comparators.js +1 -0
  152. package/lib/sql-query/Create.js +1 -0
  153. package/lib/sql-query/Dialects/dm.js +1 -0
  154. package/lib/sql-query/Dialects/index.js +1 -0
  155. package/lib/sql-query/Dialects/mssql.js +1 -0
  156. package/lib/sql-query/Dialects/mysql.js +1 -0
  157. package/lib/sql-query/Dialects/postgresql.js +1 -0
  158. package/lib/sql-query/Dialects/sqlite.js +1 -0
  159. package/lib/sql-query/Helpers.d.ts +0 -1
  160. package/lib/sql-query/Helpers.js +21 -20
  161. package/lib/sql-query/Insert.js +1 -0
  162. package/lib/sql-query/Query.d.ts +0 -1
  163. package/lib/sql-query/Query.js +1 -0
  164. package/lib/sql-query/Remove.js +1 -0
  165. package/lib/sql-query/Select.js +1 -0
  166. package/lib/sql-query/Set.js +2 -2
  167. package/lib/sql-query/Typo/Aggregation.js +1 -0
  168. package/lib/sql-query/Typo/Comparators.js +1 -0
  169. package/lib/sql-query/Typo/Dialect.js +1 -0
  170. package/lib/sql-query/Typo/Field.js +1 -0
  171. package/lib/sql-query/Typo/Helper.js +1 -0
  172. package/lib/sql-query/Typo/Query-ChainBuilder.js +1 -0
  173. package/lib/sql-query/Typo/Query.js +2 -1
  174. package/lib/sql-query/Typo/Sql.js +1 -0
  175. package/lib/sql-query/Typo/SubQuery.js +1 -0
  176. package/lib/sql-query/Typo/index.js +1 -0
  177. package/lib/sql-query/Update.js +1 -0
  178. package/lib/sql-query/Where.js +2 -2
  179. package/package.json +9 -10
@@ -1,2 +1,2 @@
1
- declare const _default: (cli: import("@fxjs/cli/typings/Cli")) => import("@fibcli/make-cli").CliCommand;
1
+ declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const fs = require("fs");
3
4
  const path = require("path");
@@ -1,2 +1,2 @@
1
- declare const _default: (cli: import("@fxjs/cli/typings/Cli")) => import("@fibcli/make-cli").CliCommand;
1
+ declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const fs = require("fs");
3
4
  const path = require("path");
@@ -1,2 +1,2 @@
1
- declare const cmd: (cli: import("@fxjs/cli/typings/Cli")) => import("@fibcli/make-cli").CliCommand;
1
+ declare const cmd: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
2
2
  export default cmd;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  // import fs = require('fs');
3
4
  // import path = require('path');
@@ -1,2 +1,2 @@
1
- declare const _default: (cli: import("@fxjs/cli/typings/Cli")) => import("@fibcli/make-cli").CliCommand;
1
+ declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const logUpdate = require("@fibcli/log-update");
3
4
  const cliSpinners = require("@fibcli/cli-spinners");
@@ -1,2 +1,2 @@
1
- declare const _default: (cli: import("@fxjs/cli/typings/Cli")) => import("@fibcli/make-cli").CliCommand;
1
+ declare const _default: (cli: import("@fibcli/make-cli").FCli) => import("@fibcli/make-cli").CliCommand;
2
2
  export default _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const child_process = require("child_process");
3
4
  const chalk = require("@fibjs/chalk");
@@ -12,6 +12,6 @@ export declare function getTableDDLs(sync: Sync, { tableNames, afterGetTableDDL
12
12
  }) => void;
13
13
  }): {
14
14
  collection: string;
15
- rawColumns: unknown[];
15
+ rawColumns: IRawColumns;
16
16
  properties: IModelProperties;
17
17
  }[];
@@ -1,5 +1,7 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.getTableDDLs = exports.getAllTableNames = void 0;
3
+ exports.getAllTableNames = getAllTableNames;
4
+ exports.getTableDDLs = getTableDDLs;
3
5
  const coroutine = require("coroutine");
4
6
  function getAllTableNames(driver) {
5
7
  let tableNames = [];
@@ -38,7 +40,6 @@ function getAllTableNames(driver) {
38
40
  }
39
41
  return tableNames;
40
42
  }
41
- exports.getAllTableNames = getAllTableNames;
42
43
  function getTableDDLs(sync, { tableNames, afterGetTableDDL } = {}) {
43
44
  tableNames = (tableNames === null || tableNames === void 0 ? void 0 : tableNames.length) ? tableNames : getAllTableNames(sync.dbdriver);
44
45
  const tableDDLs = coroutine.parallel(tableNames, (tableName) => {
@@ -52,4 +53,3 @@ function getTableDDLs(sync, { tableNames, afterGetTableDDL } = {}) {
52
53
  });
53
54
  return tableDDLs;
54
55
  }
55
- exports.getTableDDLs = getTableDDLs;
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  export declare function parsePkgInfo(filepath?: string): Record<string, string | boolean | number | object> & {
3
2
  name: string;
4
3
  version: string;
@@ -1,5 +1,8 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.checkUpgrade = exports.getPackgageNpmInfo = exports.parsePkgInfo = void 0;
3
+ exports.parsePkgInfo = parsePkgInfo;
4
+ exports.getPackgageNpmInfo = getPackgageNpmInfo;
5
+ exports.checkUpgrade = checkUpgrade;
3
6
  const fs = require("fs");
4
7
  const path = require("path");
5
8
  const http = require("http");
@@ -10,13 +13,11 @@ const PKGJSON_FILE = path.resolve(__dirname, '../../package.json');
10
13
  function parsePkgInfo(filepath = PKGJSON_FILE) {
11
14
  return JSON.parse(fs.readFile(filepath).toString());
12
15
  }
13
- exports.parsePkgInfo = parsePkgInfo;
14
16
  const PKGJSON = parsePkgInfo();
15
17
  function getPackgageNpmInfo({ registry = 'https://registry.npmjs.org', pkgName = PKGJSON.name } = {}) {
16
18
  const pkgInfo = parsePkgInfo();
17
19
  return http.get(`${registry}/${pkgName}`, {});
18
20
  }
19
- exports.getPackgageNpmInfo = getPackgageNpmInfo;
20
21
  function checkUpgrade({ pkgCurrentVersion }) {
21
22
  var _a, _b, _c;
22
23
  const response = getPackgageNpmInfo();
@@ -53,4 +54,3 @@ function checkUpgrade({ pkgCurrentVersion }) {
53
54
  }
54
55
  };
55
56
  }
56
- exports.checkUpgrade = checkUpgrade;
package/lib/cli/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env fibjs
2
+ "use strict";
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const pkg = require('../package.json');
4
5
  const getCli = require("@fxjs/cli");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxOrmCoreCallbackNS } from "../orm-core/index";
3
2
  export declare namespace FxDbDriverNS {
4
3
  type DriverType = 'mysql' | 'sqlite' | 'psql' | 'dm' | 'redis' | 'unknown';
@@ -1 +1,2 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
- /// <reference types="@fibjs/types" />
3
- /// <reference types="@fibjs/types" />
4
- /// <reference types="@fibjs/types" />
5
- /// <reference types="@fibjs/types" />
6
1
  import { FxDbDriverNS } from '../Typo';
7
2
  import { FxOrmCoreCallbackNS } from '../../orm-core/index';
8
3
  declare function getDriver(name: 'mysql'): typeof import('./driver-mysql').default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.SQLDriver = exports.Driver = void 0;
3
4
  const url = require("url");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { FxOrmCoreCallbackNS } from '../../orm-core/index';
4
3
  import { SQLDriver } from "./base.class";
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const base_class_1 = require("./base.class");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { Driver } from "./base.class";
4
3
  /**
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const base_class_1 = require("./base.class");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { FxOrmCoreCallbackNS } from '../../orm-core/index';
4
3
  import { SQLDriver } from "./base.class";
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const base_class_1 = require("./base.class");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { FxOrmCoreCallbackNS } from '../../orm-core/index';
4
3
  import { SQLDriver } from "./base.class";
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const base_class_1 = require("./base.class");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { Driver } from "./base.class";
4
3
  export default class RedisDriver extends Driver<Class_Redis> implements FxDbDriverNS.CommandDriver {
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const coroutine = require("coroutine");
@@ -1,4 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
1
  import { FxDbDriverNS } from '../Typo';
3
2
  import { FxOrmCoreCallbackNS } from '../../orm-core/index';
4
3
  import { SQLDriver } from "./base.class";
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const db = require("db");
3
4
  const base_class_1 = require("./base.class");
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.Driver = void 0;
3
4
  var base_class_1 = require("./built-ins/base.class");
@@ -1,6 +1,16 @@
1
+ "use strict";
1
2
  /// <reference types="@fibjs/types" />
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterPSQLSearchPath = exports.detectWindowsCodePoints = exports.logDebugSQL = exports.arraify = exports.parseConnectionString = exports.ensureSuffix = exports.castQueryStringToBoolean = exports.forceInteger = exports.filterDriverType = exports.driverUUid = void 0;
4
+ exports.driverUUid = driverUUid;
5
+ exports.filterDriverType = filterDriverType;
6
+ exports.forceInteger = forceInteger;
7
+ exports.castQueryStringToBoolean = castQueryStringToBoolean;
8
+ exports.ensureSuffix = ensureSuffix;
9
+ exports.parseConnectionString = parseConnectionString;
10
+ exports.arraify = arraify;
11
+ exports.logDebugSQL = logDebugSQL;
12
+ exports.detectWindowsCodePoints = detectWindowsCodePoints;
13
+ exports.filterPSQLSearchPath = filterPSQLSearchPath;
4
14
  const url = require("url");
5
15
  const util = require("util");
6
16
  const tty = require("tty");
@@ -12,7 +22,6 @@ const ParseQSDotKey = require("parse-querystring-dotkey");
12
22
  function driverUUid() {
13
23
  return uuid.node().hex();
14
24
  }
15
- exports.driverUUid = driverUUid;
16
25
  function filterDriverType(protocol) {
17
26
  switch (protocol) {
18
27
  case 'sqlite:':
@@ -34,7 +43,6 @@ function filterDriverType(protocol) {
34
43
  return 'unknown';
35
44
  }
36
45
  }
37
- exports.filterDriverType = filterDriverType;
38
46
  function forceInteger(input, fallback) {
39
47
  try {
40
48
  input = parseInt(input);
@@ -46,7 +54,6 @@ function forceInteger(input, fallback) {
46
54
  input = fallback;
47
55
  return input;
48
56
  }
49
- exports.forceInteger = forceInteger;
50
57
  function castQueryStringToBoolean(input) {
51
58
  switch (input) {
52
59
  case "1":
@@ -63,7 +70,6 @@ function castQueryStringToBoolean(input) {
63
70
  return !!input;
64
71
  }
65
72
  }
66
- exports.castQueryStringToBoolean = castQueryStringToBoolean;
67
73
  function unPrefix(str = '', prefix = '/') {
68
74
  if (!str || typeof str !== 'string')
69
75
  return '';
@@ -79,7 +85,6 @@ function ensureSuffix(str = '', suffix = '//') {
79
85
  str += suffix;
80
86
  return str;
81
87
  }
82
- exports.ensureSuffix = ensureSuffix;
83
88
  function parseConnectionString(input) {
84
89
  input = input || {};
85
90
  let urlObj = input instanceof net.Url ? input : null;
@@ -135,16 +140,14 @@ function parseConnectionString(input) {
135
140
  input.port = forceInteger(input.port, null);
136
141
  return input;
137
142
  }
138
- exports.parseConnectionString = parseConnectionString;
139
143
  function arraify(item) {
140
144
  return Array.isArray(item) ? item : [item];
141
145
  }
142
- exports.arraify = arraify;
143
146
  function logDebugSQL(dbtype, sql, is_sync = true) {
144
147
  let fmt;
145
148
  if (tty.isatty(process.stdout.fd)) {
146
- fmt = "\033[32;1m(orm/%s) \033[34m%s\033[0m\n";
147
- sql = sql.replace(/`(.+?)`/g, function (m) { return "\033[31m" + m + "\033[34m"; });
149
+ fmt = "\x1b[32;1m(orm/%s) \x1b[34m%s\x1b[0m\n";
150
+ sql = sql.replace(/`(.+?)`/g, function (m) { return "\x1b[31m" + m + "\x1b[34m"; });
148
151
  }
149
152
  else {
150
153
  fmt = "[SQL/%s] %s\n";
@@ -157,7 +160,6 @@ function logDebugSQL(dbtype, sql, is_sync = true) {
157
160
  process.stdout.write(text);
158
161
  }
159
162
  }
160
- exports.logDebugSQL = logDebugSQL;
161
163
  ;
162
164
  function detectWindowsCodePoints() {
163
165
  let codepoints = '';
@@ -178,10 +180,8 @@ function detectWindowsCodePoints() {
178
180
  codepoints
179
181
  };
180
182
  }
181
- exports.detectWindowsCodePoints = detectWindowsCodePoints;
182
183
  function filterPSQLSearchPath(input_sp) {
183
184
  input_sp = Array.isArray(input_sp) ? input_sp.join(', ') : `${input_sp}`;
184
185
  const filtered_sp = input_sp === null || input_sp === void 0 ? void 0 : input_sp.replace(/[^a-zA-Z0-9_"$,]/g, '');
185
186
  return filtered_sp || '';
186
187
  }
187
- exports.filterPSQLSearchPath = filterPSQLSearchPath;
package/lib/knex/knex.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  const sandbox_1 = require("./sandbox");
2
3
  const Sandbox = new sandbox_1.default();
3
4
  module.exports = Sandbox.require('knex', __dirname);
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  const vm = require("vm");
3
4
  const path = require("path");
@@ -1,5 +1,7 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.getAdapter = exports.addAdapter = void 0;
3
+ exports.addAdapter = addAdapter;
4
+ exports.getAdapter = getAdapter;
3
5
  const DMLs = require("./Drivers/DML");
4
6
  const adapters = {};
5
7
  function addAdapter(name, constructor) {
@@ -13,7 +15,6 @@ function addAdapter(name, constructor) {
13
15
  configurable: false
14
16
  });
15
17
  }
16
- exports.addAdapter = addAdapter;
17
18
  addAdapter('mysql', DMLs.mysql.Driver);
18
19
  addAdapter('sqlite', DMLs.sqlite.Driver);
19
20
  addAdapter('postgres', DMLs.postgres.Driver);
@@ -41,4 +42,3 @@ function getAdapter(name) {
41
42
  }
42
43
  return adapters[name];
43
44
  }
44
- exports.getAdapter = getAdapter;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  const Error_1 = require("./Error");
2
3
  const Utilities = require("./Utilities");
3
4
  const AggregateFunctions = function (opts) {
@@ -1,5 +1,8 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.autoFetch = exports.extend = exports.prepare = void 0;
3
+ exports.prepare = prepare;
4
+ exports.extend = extend;
5
+ exports.autoFetch = autoFetch;
3
6
  const util = require("util");
4
7
  const Hook = require("../Hook");
5
8
  const _cloneDeep = require("lodash.clonedeep");
@@ -117,14 +120,12 @@ function prepare(Model, assocs, opts) {
117
120
  return association.model;
118
121
  };
119
122
  }
120
- exports.prepare = prepare;
121
123
  ;
122
124
  function extend(Model, Instance, Driver, associations, cfg) {
123
125
  for (let i = 0; i < associations.length; i++) {
124
126
  extendInstance(Model, Instance, Driver, associations[i], cfg);
125
127
  }
126
128
  }
127
- exports.extend = extend;
128
129
  ;
129
130
  function autoFetch(Instance, associations, opts, parallel = false) {
130
131
  if (associations.length === 0) {
@@ -132,7 +133,6 @@ function autoFetch(Instance, associations, opts, parallel = false) {
132
133
  }
133
134
  Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
134
135
  }
135
- exports.autoFetch = autoFetch;
136
136
  ;
137
137
  function extendInstance(Model, Instance, Driver, association, cfg) {
138
138
  Utilities.addHiddenPropertyToInstance(Instance, association.hasSyncAccessor, function () {
@@ -1,4 +1,3 @@
1
- /// <reference lib="es5" />
2
1
  import type { FxOrmInstance } from '../Typo/instance';
3
2
  import type { FxOrmAssociation } from '../Typo/assoc';
4
3
  import type { FxOrmModel } from '../Typo/model';
@@ -1,6 +1,9 @@
1
+ "use strict";
1
2
  /// <reference lib="es5" />
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoFetch = exports.extend = exports.prepare = void 0;
4
+ exports.prepare = prepare;
5
+ exports.extend = extend;
6
+ exports.autoFetch = autoFetch;
4
7
  const util = require("util");
5
8
  const _flatten = require("lodash.flatten");
6
9
  const Hook = require("../Hook");
@@ -181,21 +184,18 @@ function prepare(Model, assocs, opts) {
181
184
  return this;
182
185
  };
183
186
  }
184
- exports.prepare = prepare;
185
187
  ;
186
188
  function extend(Model, Instance, Driver, associations, cfg) {
187
189
  for (let i = 0; i < associations.length; i++) {
188
190
  extendInstance(Model, Instance, Driver, associations[i], cfg);
189
191
  }
190
192
  }
191
- exports.extend = extend;
192
193
  ;
193
194
  function autoFetch(Instance, associations, opts, parallel = false) {
194
195
  if (associations.length === 0)
195
196
  return;
196
197
  Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
197
198
  }
198
- exports.autoFetch = autoFetch;
199
199
  ;
200
200
  function adjustForMapsTo(properties, field) {
201
201
  if (!field)
@@ -234,7 +234,7 @@ function extendInstance(Model, Instance, Driver, association, cfg) {
234
234
  options.autoFetchLimit = 0;
235
235
  options.__merge = {
236
236
  from: { table: association.mergeTable, field: Object.keys(association.mergeAssocId) },
237
- to: { table: association.model.table, field: association.model.id.slice(0) },
237
+ to: { table: association.model.table, field: association.model.id.slice(0) }, // clone model id
238
238
  where: [association.mergeTable, join_conditions],
239
239
  table: association.model.table,
240
240
  select: []
@@ -318,7 +318,7 @@ function extendInstance(Model, Instance, Driver, association, cfg) {
318
318
  extraWhere = Object.assign(Object.assign({}, options.join_where), extraWhere);
319
319
  options.__merge = {
320
320
  from: { table: association.mergeTable, field: Object.keys(association.mergeAssocId) },
321
- to: { table: association.model.table, field: association.model.id.slice(0) },
321
+ to: { table: association.model.table, field: association.model.id.slice(0) }, // clone model id
322
322
  where: [association.mergeTable, extraWhere],
323
323
  table: association.model.table,
324
324
  select: []
@@ -1,5 +1,8 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.autoFetch = exports.extend = exports.prepare = void 0;
3
+ exports.prepare = prepare;
4
+ exports.extend = extend;
5
+ exports.autoFetch = autoFetch;
3
6
  const util = require("util");
4
7
  const Hook = require("../Hook");
5
8
  const Utilities = require("../Utilities");
@@ -112,7 +115,6 @@ function prepare(Model, assocs, opts) {
112
115
  return this;
113
116
  };
114
117
  }
115
- exports.prepare = prepare;
116
118
  ;
117
119
  function extend(Model, Instance, Driver,
118
120
  // extend target
@@ -121,14 +123,12 @@ associations, cfg) {
121
123
  extendInstance(Model, Instance, Driver, associations[i], cfg);
122
124
  }
123
125
  }
124
- exports.extend = extend;
125
126
  ;
126
127
  function autoFetch(Instance, associations, opts, parallel) {
127
128
  if (associations.length === 0)
128
129
  return;
129
130
  Utilities.parallelQueryIfPossible(parallel, associations, (item) => autoFetchInstance(Instance, item, opts));
130
131
  }
131
- exports.autoFetch = autoFetch;
132
132
  ;
133
133
  function extendInstance(Model, Instance, Driver,
134
134
  // extend target
@@ -1,4 +1,3 @@
1
- /// <reference lib="es6" />
2
1
  import type { FxOrmAssociation } from "../Typo/assoc";
3
2
  import type { FxOrmModel } from "../Typo/model";
4
3
  import type { FxOrmProperty } from "../Typo/property";
@@ -1,14 +1,19 @@
1
+ "use strict";
1
2
  /// <reference lib="es6" />
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addAssociationInfoToModel = exports.cutOffAssociatedModelFindOptions = exports.getMapsToFromPropertyHash = exports.getMapsToFromProperty = exports.ACCESSOR_KEYS = exports.defineAssociationAccessorMethodName = exports.defineDefaultExtendsToTableName = void 0;
4
+ exports.ACCESSOR_KEYS = void 0;
5
+ exports.defineDefaultExtendsToTableName = defineDefaultExtendsToTableName;
6
+ exports.defineAssociationAccessorMethodName = defineAssociationAccessorMethodName;
7
+ exports.getMapsToFromProperty = getMapsToFromProperty;
8
+ exports.getMapsToFromPropertyHash = getMapsToFromPropertyHash;
9
+ exports.cutOffAssociatedModelFindOptions = cutOffAssociatedModelFindOptions;
10
+ exports.addAssociationInfoToModel = addAssociationInfoToModel;
4
11
  function defineDefaultExtendsToTableName(modelTableName, assocName) {
5
12
  return `${modelTableName}_${assocName}`;
6
13
  }
7
- exports.defineDefaultExtendsToTableName = defineDefaultExtendsToTableName;
8
14
  function defineAssociationAccessorMethodName(prefixer, assocName) {
9
15
  return `${prefixer}${assocName}`;
10
16
  }
11
- exports.defineAssociationAccessorMethodName = defineAssociationAccessorMethodName;
12
17
  exports.ACCESSOR_KEYS = {
13
18
  /* common :start */
14
19
  "get": "get",
@@ -23,14 +28,12 @@ exports.ACCESSOR_KEYS = {
23
28
  function getMapsToFromProperty(property, k) {
24
29
  return property.mapsTo || k;
25
30
  }
26
- exports.getMapsToFromProperty = getMapsToFromProperty;
27
31
  function getMapsToFromPropertyHash(hash) {
28
32
  return Object.keys(hash).map(k => {
29
33
  const item = hash[k];
30
34
  return item.mapsTo || k;
31
35
  });
32
36
  }
33
- exports.getMapsToFromPropertyHash = getMapsToFromPropertyHash;
34
37
  function cutOffAssociatedModelFindOptions(findby_options, association_name) {
35
38
  let opts = null;
36
39
  const k = `find_options:${association_name}`;
@@ -41,7 +44,6 @@ function cutOffAssociatedModelFindOptions(findby_options, association_name) {
41
44
  return;
42
45
  return opts;
43
46
  }
44
- exports.cutOffAssociatedModelFindOptions = cutOffAssociatedModelFindOptions;
45
47
  function addAssociationInfoToModel(Model, association_name, opts) {
46
48
  Model.associations[association_name] = {
47
49
  type: opts.type,
@@ -49,4 +51,3 @@ function addAssociationInfoToModel(Model, association_name, opts) {
49
51
  };
50
52
  return Model.associations[association_name];
51
53
  }
52
- exports.addAssociationInfoToModel = addAssociationInfoToModel;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  const util = require("util");
2
3
  const Utilities = require("./Utilities");
3
4
  const ChainInstance = require("./ChainInstance");
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  module.exports = function ChainInstance(chain, chain_cb) {
2
3
  let instances = null;
3
4
  let loading = false;
package/lib/orm/Debug.js CHANGED
@@ -1,17 +1,17 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.sql = void 0;
3
+ exports.sql = sql;
3
4
  const util = require("util");
4
5
  const tty = require("tty");
5
6
  function sql(driver, sql) {
6
7
  var fmt;
7
8
  if (tty.isatty(process.stdout.fd)) {
8
- fmt = "\033[32;1m(orm/%s) \033[34m%s\033[0m\n";
9
- sql = sql.replace(/`(.+?)`/g, function (m) { return "\033[31m" + m + "\033[34m"; });
9
+ fmt = "\x1b[32;1m(orm/%s) \x1b[34m%s\x1b[0m\n";
10
+ sql = sql.replace(/`(.+?)`/g, function (m) { return "\x1b[31m" + m + "\x1b[34m"; });
10
11
  }
11
12
  else {
12
13
  fmt = "[SQL/%s] %s\n";
13
14
  }
14
15
  process.stdout.write(util.format(fmt, driver, sql));
15
16
  }
16
- exports.sql = sql;
17
17
  ;
@@ -1,3 +1,2 @@
1
- /// <reference types="@fibjs/types" />
2
1
  declare const _default: () => Class_EventEmitter;
3
2
  export = _default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  const events = require("events");
2
3
  const EventEmitter = events.EventEmitter;
3
4
  module.exports = () => new EventEmitter();
@@ -1,5 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
- /// <reference types="@fibjs/types" />
3
1
  import type { FxOrmCommon } from '../../Typo/_common';
4
2
  import type { FxOrmDb } from '../../Typo/Db';
5
3
  declare const Driver: typeof import("../../../db-driver/built-ins/driver-dm").default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.Database = void 0;
3
4
  const index_1 = require("../../../db-driver/index");
@@ -1,5 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
- /// <reference types="@fibjs/types" />
3
1
  import type { FxOrmCommon } from '../../Typo/_common';
4
2
  import type { FxOrmDb } from '../../Typo/Db';
5
3
  declare const Driver: typeof import("../../../db-driver/built-ins/driver-mysql").default;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.Database = void 0;
3
4
  const index_1 = require("../../../db-driver/index");
@@ -1,5 +1,3 @@
1
- /// <reference types="@fibjs/types" />
2
- /// <reference types="@fibjs/types" />
3
1
  import type { FxOrmCommon } from '../../Typo/_common';
4
2
  import type { FxOrmDb } from '../../Typo/Db';
5
3
  declare const Driver: typeof import("../../../db-driver/built-ins/driver-postgresql").default;