pangea-server 3.3.87 → 3.3.89

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,21 +1,20 @@
1
1
  import * as seq from 'sequelize-typescript';
2
2
  import { BaseModel } from './models';
3
3
  import { Db as _Db } from './db.class';
4
- import type { OptionalFields, OptionalIfNullish } from 'pangea-helpers';
5
4
  import type { InferAttributes, InferCreationAttributes, CreationOptional, AbstractDataTypeConstructor, AbstractDataType, Transaction, WhereOptions } from 'sequelize';
6
5
  import type { ModelCtor } from 'sequelize-typescript';
7
6
  declare global {
8
7
  type ModelId = number;
9
8
  type ModelName = string;
10
9
  type BaseModelCtor<BM extends BaseModel = BaseModel> = typeof BaseModel & ModelCtor<BM>;
11
- type ColOptional<T> = CreationOptional<T>;
10
+ type ColDefault<T> = CreationOptional<T>;
12
11
  type ColHidden<T> = T & {
13
12
  __brand: 'hidden';
14
13
  };
15
14
  type ColVirtual<T> = CreationOptional<T>;
16
15
  type ModelInstance<BM extends BaseModel> = InferAttributes<BM>;
17
16
  type Where<BM extends BaseModel> = WhereOptions<BM> & Record<symbol, any>;
18
- type InsertParams<BM extends BaseModel> = OptionalIfNullish<OptionalIfOptional<StripRelations<OptionalFields<IncludeHidden<InferCreationAttributes<BM>>, keyof InferCreationAttributes<BM> & 'id'>>>>;
17
+ type InsertParams<BM extends BaseModel> = OptionalIfNullish<IncludeHidden<StripRelations<InferCreationAttributes<BM>>>>;
19
18
  type UpdateParams<BM extends BaseModel> = Partial<InsertParams<BM>>;
20
19
  type UpdateParamsWithId<BM extends BaseModel> = UpdateParams<BM> & {
21
20
  id: ModelId;
@@ -51,20 +50,19 @@ export type ColVirtualOptions = {
51
50
  set?: ColVirtualSet;
52
51
  };
53
52
  export type GetModelFn = () => BaseModelCtor;
54
- type OptionalIfOptional<T> = {
55
- [K in keyof T as undefined extends T[K] ? K : never]?: Exclude<T[K], undefined>;
53
+ export type OptionalIfNullish<T> = {
54
+ [K in keyof T as null extends T[K] ? never : undefined extends T[K] ? never : K]: T[K];
56
55
  } & {
57
- [K in keyof T as undefined extends T[K] ? never : K]: T[K];
56
+ [K in keyof T as null extends T[K] ? K : undefined extends T[K] ? K : never]?: Exclude<T[K], undefined>;
58
57
  };
59
58
  type IncludeHidden<T> = {
60
59
  [K in keyof T]-?: Exclude<T[K], undefined> extends ColHidden<infer U> ? U : T[K];
61
60
  };
62
- type IsRelation<T> = NonNullable<T> extends {
63
- id: ModelId;
64
- } ? true : NonNullable<T> extends Array<infer U> ? NonNullable<U> extends {
65
- id: ModelId;
66
- } ? true : false : false;
67
61
  type StripRelations<T> = {
68
- [K in keyof T as IsRelation<T[K]> extends true ? never : K]: T[K];
62
+ [K in keyof T as NonNullable<T[K]> extends {
63
+ id: ModelId;
64
+ } | Array<{
65
+ id: ModelId;
66
+ }> ? never : K]: T[K];
69
67
  };
70
68
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Model, Column } from 'sequelize-typescript';
2
- import type { NonAttribute } from 'sequelize';
2
+ import type { NonAttribute, CreationOptional } from 'sequelize';
3
3
  import type { Index, DefaultValue, GetModelFn } from '../database.types';
4
4
  type Column = {
5
5
  allowNull: boolean;
@@ -15,12 +15,12 @@ type Relation = {
15
15
  };
16
16
  type Relations = Record<string, Relation>;
17
17
  export declare abstract class BaseModel extends Model {
18
- version: NonAttribute<number>;
19
18
  private static __HiddenAttributes?;
20
19
  private static __Columns?;
21
20
  private static __ColumnIndexes?;
22
21
  private static __Relations?;
23
- id: ModelId;
22
+ id: CreationOptional<ModelId>;
23
+ version: NonAttribute<number>;
24
24
  static get HiddenAttributes(): string[];
25
25
  static get Columns(): Columns;
26
26
  static get ColumnIndexes(): Index[];
@@ -72,5 +72,5 @@ __decorate([
72
72
  sequelize_typescript_1.PrimaryKey,
73
73
  sequelize_typescript_1.AutoIncrement,
74
74
  sequelize_typescript_1.Column,
75
- __metadata("design:type", Number)
75
+ __metadata("design:type", Object)
76
76
  ], BaseModel.prototype, "id", void 0);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.87",
4
+ "version": "3.3.89",
5
5
  "files": [
6
6
  "dist"
7
7
  ],