@domain.js/main 0.1.11 → 0.1.15

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/.eslintrc.js CHANGED
@@ -1,67 +1,32 @@
1
1
  module.exports = {
2
- parser: "@typescript-eslint/parser",
3
- plugins: ["@typescript-eslint"],
4
- extends: ["airbnb", "eslint:recommended", "plugin:@typescript-eslint/recommended"],
5
- ignorePatterns: [".eslintrc.js"],
6
- root: true,
2
+ parser: "@typescript-eslint/parser", // 解析ts 代码编译器,将ts 语法树转化为 eslint 期望的
3
+ extends: ["alloy", "alloy/typescript"],
4
+ plugins: ["simple-import-sort", "unused-imports"],
7
5
  env: {
8
- es6: true,
6
+ // Your environments (which contains several predefined global variables)
7
+ //
9
8
  node: true,
10
- jest: true,
9
+ commonjs: true,
10
+ es6: true,
11
11
  },
12
- settings: {
13
- react: {
14
- version: "999.999.999",
15
- },
12
+ globals: {
13
+ // Your global variables (setting to false means it's not allowed to be reassigned)
14
+ //
15
+ // myGlobal: false
16
16
  },
17
17
  rules: {
18
- "nonblock-statement-body-position": "off",
19
- "operator-linebreak": ["error", "after"],
20
- "prefer-destructuring": ["error", { object: true, array: true }],
21
- indent: ["error", 2],
22
- "no-use-before-define": ["error", { functions: true, classes: true, variables: true }],
23
- "no-param-reassign": 0,
24
- "no-continue": 0,
25
- "no-console": 0,
26
- "no-debugger": 1,
27
- "no-var": 1,
28
- semi: ["error", "always"],
29
- "no-trailing-spaces": "error",
30
- "eol-last": 1,
31
- "no-underscore-dangle": 0,
32
- "no-empty": "error",
33
- "no-loop-func": "error",
34
- "no-bitwise": "off", // "error",
35
- quotes: ["error", "double"],
36
- "comma-dangle": ["error", "only-multiline"],
37
- "arrow-parens": ["error", "always"],
38
- "object-curly-newline": 0,
39
- "function-paren-newline": 0,
40
- "implicit-arrow-linebreak": 0,
41
- curly: 0,
42
- "no-mixed-operators": "error",
43
- "no-restricted-syntax": 0,
44
- "no-lone-blocks": "error",
45
- "lines-between-class-members": "off",
46
- yoda: "error",
47
- "no-plusplus": 0,
48
- "import/export": 0,
49
- "no-cond-assign": "error",
50
- "no-shadow": 0,
51
- camelcase: 0,
52
- "prefer-destructuring": 0,
53
- "import/prefer-default-export": "off",
54
- "newline-per-chained-call": 0,
55
- "@typescript-eslint/interface-name-prefix": "off",
56
- "@typescript-eslint/explicit-function-return-type": "off",
57
- "@typescript-eslint/explicit-module-boundary-types": "off",
58
- "@typescript-eslint/no-explicit-any": "off",
59
- "@typescript-eslint/no-namespace": 0,
60
- "@typescript-eslint/ban-types": 0,
61
- "import/export": 0,
62
- "import/no-unresolved": 0,
63
- "import/extensions": 0,
64
- "@typescript-eslint/no-var-requires": 0,
65
- "@typescript-eslint/no-this-alias": 0,
18
+ // Customize your rules
19
+ "spaced-comment": "off", // 注释前有空白检查
20
+ "simple-import-sort/imports": "error", // 优化import 顺序
21
+ "simple-import-sort/exports": "error", // 优化 export 顺序
22
+ "no-multiple-empty-lines": ["warn", { max: 2 }], // 强制最大连续空行数为 2
23
+ complexity: ["error", 20], // https://cn.eslint.org/docs/rules/complexity
24
+ "no-template-curly-in-string": "error", //禁止在常规字符串中出现模板字面量占位符语法
25
+ "unused-imports/no-unused-imports": "warn",
26
+ "@typescript-eslint/explicit-member-accessibility": "off", // 不强制设置类成员的可访问性
27
+ "@typescript-eslint/member-ordering": "off", // 不严格限制类成员顺序
28
+ "max-params": ["error", 6], // 函数最多6个参数
29
+ "@typescript-eslint/no-require-imports": "off", // 部分第三方库不支持 esModuleInterop 编译选项
30
+ "@typescript-eslint/prefer-optional-chain": "off", // 过多使用可选操作符降低代码可读性 foo?.a?.b?.c
66
31
  },
67
32
  };
package/.husky/pre-commit CHANGED
@@ -5,4 +5,5 @@ fi
5
5
  . "$(dirname "$0")/_/husky.sh"
6
6
 
7
7
  ts-node src/cli/index.ts loadDeps ./src/deps ts && npm run lint-staged && npm run build
8
+ npm run build
8
9
  npm tst
package/dist/cfg/index.js CHANGED
@@ -1,9 +1,31 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
2
24
  Object.defineProperty(exports, "__esModule", { value: true });
3
25
  exports.Main = void 0;
4
- const _ = require("lodash");
5
- const ajv_1 = require("ajv");
6
- const ajv_formats_1 = require("ajv-formats");
26
+ const _ = __importStar(require("lodash"));
27
+ const ajv_1 = __importDefault(require("ajv"));
28
+ const ajv_formats_1 = __importDefault(require("ajv-formats"));
7
29
  function Main(object, schema) {
8
30
  if (typeof schema !== "object")
9
31
  throw Error("object type isnt an object");
package/dist/cli/index.js CHANGED
@@ -1,10 +1,29 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6
+ }) : (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ o[k2] = m[k];
9
+ }));
10
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
11
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
12
+ }) : function(o, v) {
13
+ o["default"] = v;
14
+ });
15
+ var __importStar = (this && this.__importStar) || function (mod) {
16
+ if (mod && mod.__esModule) return mod;
17
+ var result = {};
18
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
19
+ __setModuleDefault(result, mod);
20
+ return result;
21
+ };
3
22
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs = require("fs");
5
- const path = require("path");
6
- const readline = require("readline");
7
23
  const child_process_1 = require("child_process");
24
+ const fs = __importStar(require("fs"));
25
+ const path = __importStar(require("path"));
26
+ const readline = __importStar(require("readline"));
8
27
  const rl = readline.createInterface({
9
28
  input: process.stdin,
10
29
  output: process.stdout,
@@ -16,7 +35,7 @@ rl.setPrompt("> ");
16
35
  const _require = require;
17
36
  const showMessage = (msg, exit) => {
18
37
  rl.write(`${msg}\n`);
19
- if (exit != null)
38
+ if (exit)
20
39
  process.exit(exit);
21
40
  rl.setPrompt("> ");
22
41
  };
@@ -34,8 +53,8 @@ const makeDefineFile = async (modules, targetFile, isTS) => {
34
53
  const dirname = path.dirname(targetFile);
35
54
  const content = ["// domain-cli 自动生成"];
36
55
  const _exports = [];
37
- for (let i = 0; i < modules.length; i += 1) {
38
- const name = path.relative(dirname, modules[i]);
56
+ for (const x of modules) {
57
+ const name = path.relative(dirname, x);
39
58
  const variable = filePath2Var(name);
40
59
  if (isTS) {
41
60
  content.push(`import * as ${variable} from "./${name}"`);
@@ -1,18 +1,18 @@
1
- import * as _ from "lodash";
2
- import * as uuid from "uuid";
3
1
  import * as ajv from "ajv";
4
2
  import * as ajvFormats from "ajv-formats";
5
3
  import * as async from "async";
6
4
  import * as axios from "axios";
7
5
  import * as cronParser from "cron-parser";
8
- import humanInterval = require("human-interval");
9
- import * as IORedis from "ioredis";
10
- import * as LRU from "lru-cache";
6
+ import humanInterval from "human-interval";
7
+ import IORedis from "ioredis";
8
+ import _ from "lodash";
9
+ import LRU from "lru-cache";
10
+ import moment from "moment";
11
11
  import * as mysql from "mysql2";
12
12
  import * as Sequelize from "sequelize";
13
- import * as moment from "moment";
14
- import * as utils from "./utils";
13
+ import * as uuid from "uuid";
15
14
  import { errors } from "./basic-errors";
15
+ import * as utils from "./utils";
16
16
  /** npm packages injection */
17
17
  export interface Defaults {
18
18
  /**
package/dist/defaults.js CHANGED
@@ -1,35 +1,57 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
2
24
  Object.defineProperty(exports, "__esModule", { value: true });
3
25
  exports.defaults = void 0;
4
- const _ = require("lodash");
5
- const uuid = require("uuid");
6
- const ajv = require("ajv");
7
- const ajvFormats = require("ajv-formats");
8
- const async = require("async");
9
- const axios = require("axios");
10
- const cronParser = require("cron-parser");
11
- const humanInterval = require("human-interval");
12
- const IORedis = require("ioredis");
13
- const LRU = require("lru-cache");
14
- const mysql = require("mysql2");
15
- const Sequelize = require("sequelize");
16
- const moment = require("moment");
17
- const utils = require("./utils");
26
+ const ajv = __importStar(require("ajv"));
27
+ const ajvFormats = __importStar(require("ajv-formats"));
28
+ const async = __importStar(require("async"));
29
+ const axios = __importStar(require("axios"));
30
+ const cronParser = __importStar(require("cron-parser"));
31
+ const human_interval_1 = __importDefault(require("human-interval"));
32
+ const ioredis_1 = __importDefault(require("ioredis"));
33
+ const lodash_1 = __importDefault(require("lodash"));
34
+ const lru_cache_1 = __importDefault(require("lru-cache"));
35
+ const moment_1 = __importDefault(require("moment"));
36
+ const mysql = __importStar(require("mysql2"));
37
+ const Sequelize = __importStar(require("sequelize"));
38
+ const uuid = __importStar(require("uuid"));
18
39
  const basic_errors_1 = require("./basic-errors");
40
+ const utils = __importStar(require("./utils"));
19
41
  exports.defaults = {
20
- _,
42
+ _: lodash_1.default,
21
43
  uuid,
22
44
  ajv,
23
45
  ajvFormats,
24
46
  async,
25
47
  axios,
26
48
  cronParser,
27
- humanInterval,
28
- IORedis,
29
- LRU,
49
+ humanInterval: human_interval_1.default,
50
+ IORedis: ioredis_1.default,
51
+ LRU: lru_cache_1.default,
30
52
  mysql,
31
53
  Sequelize,
32
- moment,
54
+ moment: moment_1.default,
33
55
  utils,
34
56
  U: utils,
35
57
  errors: basic_errors_1.errors,
@@ -1,8 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
22
  exports.Main = void 0;
4
- const cryptojs = require("crypto-js/core");
5
- const AES = require("crypto-js/aes");
23
+ const cryptojs = __importStar(require("crypto-js/core"));
24
+ const AES = __importStar(require("crypto-js/aes"));
6
25
  function Main() {
7
26
  // aes-256-cbc encrypt
8
27
  const encrypt = (message, key) => AES.encrypt(message, key).toString();
@@ -1,5 +1,5 @@
1
- import * as LRU from "lru-cache";
2
- import * as Redis from "ioredis";
1
+ import LRU from "lru-cache";
2
+ import Redis from "ioredis";
3
3
  import { SetRequired } from "type-fest";
4
4
  export interface CnfDef {
5
5
  cache?: {
@@ -1,36 +1,55 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  // domain-cli 自动生成
3
- const aes = require("./aes");
4
- const cache = require("./cache");
5
- const checker = require("./checker");
6
- const counter = require("./counter");
7
- const cron = require("./cron");
8
- const graceful = require("./graceful");
9
- const hash = require("./hash");
10
- const logger = require("./logger");
11
- const myCia = require("./myCia");
12
- const parallel = require("./parallel");
13
- const redis = require("./redis");
14
- const request = require("./request");
15
- const rest = require("./rest");
16
- const schema = require("./schema");
17
- const sequelize = require("./sequelize");
18
- const signer = require("./signer");
22
+ const aes = __importStar(require("./aes"));
23
+ const cache = __importStar(require("./cache"));
24
+ const checker = __importStar(require("./checker"));
25
+ const counter = __importStar(require("./counter"));
26
+ const cron = __importStar(require("./cron"));
27
+ const graceful = __importStar(require("./graceful"));
28
+ const hash = __importStar(require("./hash"));
29
+ const logger = __importStar(require("./logger"));
30
+ const myCia = __importStar(require("./myCia"));
31
+ const parallel = __importStar(require("./parallel"));
32
+ const redis = __importStar(require("./redis"));
33
+ const request = __importStar(require("./request"));
34
+ const rest = __importStar(require("./rest"));
35
+ const schema = __importStar(require("./schema"));
36
+ const sequelize = __importStar(require("./sequelize"));
37
+ const signer = __importStar(require("./signer"));
19
38
  module.exports = {
20
- aes,
21
- cache,
22
- checker,
23
- counter,
24
- cron,
25
- graceful,
26
- hash,
27
- logger,
28
- myCia,
29
- parallel,
30
- redis,
31
- request,
32
- rest,
33
- schema,
34
- sequelize,
35
- signer,
39
+ aes: aes,
40
+ cache: cache,
41
+ checker: checker,
42
+ counter: counter,
43
+ cron: cron,
44
+ graceful: graceful,
45
+ hash: hash,
46
+ logger: logger,
47
+ myCia: myCia,
48
+ parallel: parallel,
49
+ redis: redis,
50
+ request: request,
51
+ rest: rest,
52
+ schema: schema,
53
+ sequelize: sequelize,
54
+ signer: signer,
36
55
  };
@@ -1,11 +1,15 @@
1
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.Deps = exports.Main = void 0;
4
- const process = require("process");
7
+ const process_1 = __importDefault(require("process"));
5
8
  function Graceful(info) {
6
9
  let exiting = false; // 是否正在退出
7
10
  const callbacks = [];
8
- const counter = ((count = 0) => {
11
+ const counter = ((init = 0) => {
12
+ let count = init;
9
13
  const decr = () => {
10
14
  count -= 1;
11
15
  };
@@ -53,11 +57,11 @@ function Graceful(info) {
53
57
  return;
54
58
  info("process exit check success, process exited");
55
59
  clearInterval(timer);
56
- process.exit(0);
60
+ process_1.default.exit(0);
57
61
  }, 1000);
58
62
  };
59
- process.on("SIGTERM", exitHandle);
60
- process.on("SIGINT", exitHandle);
63
+ process_1.default.on("SIGTERM", exitHandle);
64
+ process_1.default.on("SIGINT", exitHandle);
61
65
  /**
62
66
  * addListen function be called when process exit
63
67
  * @param listenner
@@ -1,8 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
22
  exports.Deps = exports.Main = void 0;
4
- const fs = require("fs");
5
- const path = require("path");
23
+ const fs = __importStar(require("fs"));
24
+ const path = __importStar(require("path"));
6
25
  const date = (offset = 0) => new Date(Date.now() + (offset | 0)).toISOString();
7
26
  function Main(cnf, deps) {
8
27
  const { logger: { errorLogPath, infoLogPath, ignoreErrors, clientId }, } = cnf;
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const util = require("util");
22
+ const util = __importStar(require("util"));
4
23
  exports.default = () => {
5
24
  const defines = [
6
25
  ["duplicatRegistMessage", "The message has been registed: %s"],
@@ -1,7 +1,10 @@
1
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.Deps = exports.Main = void 0;
4
- const errors_1 = require("./errors");
7
+ const errors_1 = __importDefault(require("./errors"));
5
8
  function Main(cnf, deps) {
6
9
  const { _, async, uuid: { v4: uuid }, logger, redis, graceful, U: { tryCatchLog }, } = deps;
7
10
  const { cia } = cnf;
@@ -1,7 +1,26 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
22
  exports.Deps = exports.Main = void 0;
4
- const utils = require("../../utils");
23
+ const utils = __importStar(require("../../utils"));
5
24
  /**
6
25
  * Parallel control module
7
26
  * @param cnf Module initialization configuration parameters
@@ -1,4 +1,4 @@
1
- import * as Redis from "ioredis";
1
+ import Redis from "ioredis";
2
2
  interface Cnf {
3
3
  redis: Redis.RedisOptions;
4
4
  }
@@ -1,50 +1,5 @@
1
- import * as Sequelize from "sequelize";
1
+ import { ModelBase } from "../sequelize";
2
2
  export interface Params {
3
3
  [propName: string]: any;
4
4
  }
5
- export declare type TModel = typeof Sequelize.Model & {
6
- filterAttrs?: string[];
7
- writableCols?: string[];
8
- editableCols?: string[];
9
- allowIncludeCols?: string[];
10
- onlyAdminCols?: string[];
11
- pagination?: {
12
- maxResults: number;
13
- maxStartIndex: number;
14
- maxResultsLimit: number;
15
- };
16
- sort?: {
17
- default: string;
18
- allow: string[];
19
- defaultDirection?: "DESC" | "ASC";
20
- };
21
- includes?: {
22
- [k: string]: {
23
- as: string;
24
- required: boolean;
25
- model: TModel;
26
- };
27
- };
28
- searchCols?: {
29
- [k: string]: {
30
- op: "=" | "LIKE";
31
- match: string[];
32
- };
33
- };
34
- stats?: {
35
- dimensions?: Record<string, string>;
36
- metrics: Record<string, string>;
37
- pagination?: {
38
- maxResults: number;
39
- maxStartIndex: number;
40
- maxResultsLimit: number;
41
- };
42
- };
43
- unique?: string[];
44
- };
45
- export declare type ModelExtraAtts = Omit<TModel, keyof typeof Sequelize.Model>;
46
- export interface Include {
47
- as: string;
48
- required: boolean;
49
- model: TModel;
50
- }
5
+ export declare type TModel = typeof ModelBase;
@@ -1,6 +1,6 @@
1
- import * as _ from "lodash";
1
+ import _ from "lodash";
2
2
  import * as Sequelize from "sequelize";
3
- import { TModel, Params } from "./defines";
3
+ import { ModelBase, ModelStatic } from "../sequelize";
4
4
  import { Stats } from "./stats";
5
5
  import { Utils } from "./utils";
6
6
  export { Before } from "./Before";
@@ -24,14 +24,14 @@ export interface CreatorAndClientIp {
24
24
  * @returns modify, add, remove, list, stats five methods
25
25
  */
26
26
  export declare function Main(cnf: Cnf, deps: Deps, utils: ReturnType<typeof Utils>): {
27
- modify: (Model: TModel, model: Sequelize.Model<any, any>, params: Params, isAdmin?: boolean, _cols?: string[] | undefined) => Promise<Sequelize.Model<any, any>>;
28
- add: (Model: TModel, params: Params, isAdmin: boolean | undefined, _cols: string[] | undefined, { creatorId, clientIp }: CreatorAndClientIp) => Promise<any>;
27
+ modify: <T extends ModelBase<any, any>>(Model: ModelStatic<T>, model: T, params: Record<string, any>, isAdmin?: boolean, _cols?: string[] | undefined) => Promise<T>;
28
+ add: <T_1 extends ModelBase<any, any>>(Model: ModelStatic<T_1>, params: Record<string, any>, isAdmin: boolean | undefined, _cols: string[] | undefined, { creatorId, clientIp }: CreatorAndClientIp) => Promise<T_1>;
29
29
  remove: (model: Sequelize.Model, deletorId: UserId) => Promise<void | Sequelize.Model<any, any>>;
30
- list: (Model: TModel, params: Params, allowAttrs?: string[] | undefined, toJSON?: boolean | undefined) => Promise<{
30
+ list: <T_2 extends ModelBase<any, any>>(Model: ModelStatic<T_2>, params: Record<string, any>, allowAttrs?: string[] | undefined, toJSON?: boolean | undefined) => Promise<{
31
31
  count: number;
32
- rows: any[];
32
+ rows: T_2[];
33
33
  }>;
34
- stats: (Model: TModel, params: Params, where?: any, conf?: {
34
+ stats: <T_3 extends ModelBase<any, any>>(Model: ModelStatic<T_3>, params: Record<string, any>, where?: any, conf?: {
35
35
  dimensions?: Record<string, string> | undefined;
36
36
  metrics: Record<string, string>;
37
37
  pagination?: {
@@ -41,7 +41,7 @@ export declare function Main(cnf: Cnf, deps: Deps, utils: ReturnType<typeof Util
41
41
  } | undefined;
42
42
  } | undefined) => Promise<{
43
43
  count: number;
44
- rows: any;
44
+ rows: Record<string, string | number>[];
45
45
  }>;
46
46
  };
47
47
  export declare const Deps: string[];