@open-norantec/herbal 1.0.2-alpha.1 → 1.0.2-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,10 @@
1
- import { BelongsToOptions, ModelAttributeColumnOptions } from 'sequelize';
2
- import { Model, TableOptions, ModelClassGetter } from 'sequelize-typescript';
1
+ import { BelongsToOptions, IndexesOptions, ModelAttributeColumnOptions } from 'sequelize';
2
+ import { Model, TableOptions as SequelizeTableOptions, ModelClassGetter } from 'sequelize-typescript';
3
3
  import { Constructor } from 'type-fest';
4
4
  export * from 'sequelize-typescript';
5
- export declare function Table<M extends Model = Model>(options: TableOptions<M>): (target: Constructor<M>) => void;
5
+ export interface TableOptions<M extends Model = Model> extends Omit<SequelizeTableOptions<M>, 'indexes'> {
6
+ indexes?: Array<IndexesOptions | string>;
7
+ }
8
+ export declare function Table<M extends Model = Model>({ indexes, ...options }: TableOptions<M>): (target: Constructor<M>) => void;
6
9
  export declare function BelongsTo(associatedClassGetter: ModelClassGetter<{}, {}>, options?: BelongsToOptions): Function;
7
10
  export declare function DateColumn(options: Partial<ModelAttributeColumnOptions>): Function;
@@ -24,16 +24,37 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
24
24
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
25
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
26
  };
27
+ var __rest = (this && this.__rest) || function (s, e) {
28
+ var t = {};
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
+ t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
+ t[p[i]] = s[p[i]];
35
+ }
36
+ return t;
37
+ };
27
38
  Object.defineProperty(exports, "__esModule", { value: true });
28
39
  exports.DateColumn = exports.BelongsTo = exports.Table = void 0;
29
40
  var sequelize_typescript_1 = require("sequelize-typescript");
30
41
  __exportStar(require("sequelize-typescript"), exports);
31
- function Table(options) {
42
+ function Table(_a) {
43
+ var indexes = _a.indexes, options = __rest(_a, ["indexes"]);
32
44
  return function (target) {
33
45
  var newOptions = !options ? {} : options;
34
- if (!Array.isArray(newOptions === null || newOptions === void 0 ? void 0 : newOptions.indexes))
35
- newOptions.indexes = [];
36
- newOptions.indexes = Array.from(newOptions.indexes).concat({
46
+ newOptions.indexes = [];
47
+ newOptions.indexes = Array.from(Array.isArray(indexes) ? indexes : []).map(function (item, index) {
48
+ if (typeof item === 'string') {
49
+ return [
50
+ {
51
+ name: "sidx__".concat(index),
52
+ fields: [item],
53
+ },
54
+ ];
55
+ }
56
+ return item;
57
+ }).concat({
37
58
  name: 'pagination',
38
59
  fields: ['id', 'created_at'],
39
60
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/herbal",
3
- "version": "1.0.2-alpha.1",
3
+ "version": "1.0.2-alpha.3",
4
4
  "description": "Herbal is a builder and toolchain for Nest.js applications",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {