pangea-server 1.0.76 → 1.0.78

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.
@@ -270,6 +270,8 @@ function getInclude(model, config = {}, relDepth = new Map()) {
270
270
  const maxDepth = rel.joinDepth;
271
271
  if (currentDepth >= maxDepth)
272
272
  continue;
273
+ if (rel.exclude)
274
+ continue;
273
275
  const relWhere = cleanWhere[relName];
274
276
  delete cleanWhere[relName];
275
277
  const newRelDepth = new Map(relDepth);
@@ -1,4 +1,4 @@
1
1
  import type { ColGeneralOptions, ColVirtualGet, ColVirtualOptions, GetModelFn } from '../../../database/database.types';
2
2
  export declare function ColBool(options?: ColGeneralOptions): (target: any, propertyName: string) => void;
3
- export declare function ColForeignKey(getModelFn: GetModelFn, options?: ColGeneralOptions): (target: any, propertyName: string) => void;
3
+ export declare function ColForeignKey(getModelFn: GetModelFn, options?: Omit<ColGeneralOptions, 'index'>): (target: any, propertyName: string) => void;
4
4
  export declare function ColVirtual(options?: ColVirtualOptions | ColVirtualGet): Function;
@@ -32,7 +32,7 @@ function ColBool(options) {
32
32
  exports.ColBool = ColBool;
33
33
  function ColForeignKey(getModelFn, options) {
34
34
  return function (target, propertyName) {
35
- (0, column_1.Column)('INTEGER', { ...options, onUpdate: 'RESTRICT', onDelete: 'RESTRICT' })(target, propertyName);
35
+ (0, column_1.Column)('INTEGER', { ...options, index: true, onUpdate: 'RESTRICT', onDelete: 'RESTRICT' })(target, propertyName);
36
36
  seq.ForeignKey(getModelFn)(target, propertyName);
37
37
  };
38
38
  }
@@ -1,9 +1,10 @@
1
1
  import type { GetModelFn } from '../database.types';
2
2
  type RelationOptions = {
3
+ foreignKey?: string;
4
+ exclude?: boolean;
3
5
  required?: boolean;
4
6
  paranoid?: boolean;
5
7
  joinDepth?: number;
6
- foreignKey?: string;
7
8
  };
8
9
  export declare const BelongsTo: (getModelFn: GetModelFn, options?: RelationOptions) => (target: any, propertyName: string) => void;
9
10
  export declare const HasOne: (getModelFn: GetModelFn, options?: RelationOptions) => (target: any, propertyName: string) => void;
@@ -35,8 +35,8 @@ function getRelation(relationFn) {
35
35
  const { foreignKey, ...relOptions } = options;
36
36
  relationFn(getModelFn, { as: propertyName, ...(foreignKey && { foreignKey }) })(target, propertyName);
37
37
  const model = target.constructor;
38
- const { required = relationFn === seq.BelongsTo ? !model.Columns[`${propertyName}Id`].allowNull : false, paranoid = relationFn !== seq.BelongsTo, joinDepth = 1, ...restOptions } = relOptions;
39
- model.AddRelation(propertyName, { getModelFn, required, paranoid, joinDepth, ...restOptions });
38
+ const { exclude = false, required = relationFn === seq.BelongsTo ? !model.Columns[`${propertyName}Id`].allowNull : false, paranoid = relationFn !== seq.BelongsTo, joinDepth = 1, ...restOptions } = relOptions;
39
+ model.AddRelation(propertyName, { getModelFn, exclude, required, paranoid, joinDepth, ...restOptions });
40
40
  };
41
41
  };
42
42
  }
@@ -7,6 +7,7 @@ type Column = {
7
7
  type Columns = Record<string, Column>;
8
8
  type Relation = {
9
9
  getModelFn: GetModelFn;
10
+ exclude: boolean;
10
11
  required: boolean;
11
12
  paranoid: boolean;
12
13
  joinDepth: number;
@@ -10,23 +10,23 @@ export declare namespace Val {
10
10
  type Regex<T extends string> = string & tags.Pattern<T>;
11
11
  type Num = number;
12
12
  type Int = Val.Num & tags.Type<'int32'>;
13
- type Greater<T extends number = 0> = Val.Num & tags.Minimum<T>;
13
+ type GreaterEqual<T extends number = 0> = Val.Num & tags.Minimum<T>;
14
14
  type GreaterThan<T extends number = 0> = Val.Num & tags.ExclusiveMinimum<T>;
15
- type Less<T extends number = 0> = Val.Num & tags.Maximum<T>;
15
+ type LessEqual<T extends number = 0> = Val.Num & tags.Maximum<T>;
16
16
  type LessThan<T extends number = 0> = Val.Num & tags.ExclusiveMaximum<T>;
17
17
  type Bool = boolean;
18
18
  type Datetime = globalThis.Date;
19
19
  type Date = string & tags.Format<'date'>;
20
20
  type Time = string & tags.Format<'time'>;
21
- type Id = Val.Int & Val.Greater<1>;
21
+ type Id = Val.Int & Val.GreaterEqual<1>;
22
22
  type IdOptional = Val.Id | 0;
23
23
  type Ids = Val.Id[];
24
24
  interface IdParams {
25
25
  id: Val.Id;
26
26
  }
27
27
  interface GetManyQueryBase {
28
- page?: (Val.Int & Val.Greater<0>) | null;
29
- pageSize?: (Val.Int & Val.Greater<0>) | null;
28
+ page?: (Val.Int & Val.GreaterEqual<0>) | null;
29
+ pageSize?: (Val.Int & Val.GreaterEqual<0>) | null;
30
30
  search?: Val.Str | '' | null;
31
31
  }
32
32
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "1.0.76",
4
+ "version": "1.0.78",
5
5
  "files": [
6
6
  "dist"
7
7
  ],