90dc-core 1.6.8 → 1.7.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.
@@ -2,6 +2,7 @@ import { Model } from "sequelize-typescript";
2
2
  import { ConsumableProgramGoals, ConsumableProgramTypes, ConsumableProgramWeightGoals } from "../../enums/ProgramEnums";
3
3
  import { TranslatedConsumableProgram } from "./TranslatedConsumableProgram";
4
4
  import { PersistedUser } from "../PersistedUser";
5
+ import { Program } from "../program/Program";
5
6
  export declare class NonConsumableProgram extends Model {
6
7
  uuid: string;
7
8
  title: string;
@@ -17,4 +18,5 @@ export declare class NonConsumableProgram extends Model {
17
18
  productIdIos: string | null;
18
19
  translatedPrograms: TranslatedConsumableProgram[];
19
20
  users: PersistedUser[];
21
+ programs: Program[];
20
22
  }
@@ -8,6 +8,7 @@ import { BelongsToMany, Column, DataType, Default, HasMany, Model, Table } from
8
8
  import { TranslatedConsumableProgram } from "./TranslatedConsumableProgram";
9
9
  import { UserPrograms } from "./UserNonConsumableProgram";
10
10
  import { PersistedUser } from "../PersistedUser";
11
+ import { Program } from "../program/Program";
11
12
  export let NonConsumableProgram = class NonConsumableProgram extends Model {
12
13
  };
13
14
  __decorate([
@@ -94,6 +95,9 @@ __decorate([
94
95
  through: ()=>UserPrograms
95
96
  })
96
97
  ], NonConsumableProgram.prototype, "users", void 0);
98
+ __decorate([
99
+ HasMany(()=>Program)
100
+ ], NonConsumableProgram.prototype, "programs", void 0);
97
101
  NonConsumableProgram = __decorate([
98
102
  Table
99
103
  ], NonConsumableProgram);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/dbmodels/nonconsprogram/NonConsumableProgram.ts"],"sourcesContent":["import {\n BelongsToMany,\n Column,\n DataType,\n Default,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport {\n ConsumableProgramGoals,\n ConsumableProgramTypes,\n ConsumableProgramWeightGoals,\n} from \"../../enums/ProgramEnums\";\nimport { TranslatedConsumableProgram } from \"./TranslatedConsumableProgram\";\nimport { UserPrograms } from \"./UserNonConsumableProgram\";\nimport { PersistedUser } from \"../PersistedUser\";\n\n@Table\nexport class NonConsumableProgram extends Model {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare uuid: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare title: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare description: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare coverImageUri: string;\n\n @Column({ type: DataType.INTEGER, allowNull: false })\n declare order: number;\n\n @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0 })\n declare popularityOrder: number;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare weightGoal: ConsumableProgramWeightGoals;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare goal: ConsumableProgramGoals;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare type: ConsumableProgramTypes;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false })\n declare isFree: boolean;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare productIdAndroid: string | null;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare productIdIos: string | null;\n\n @HasMany(() => TranslatedConsumableProgram)\n declare translatedPrograms: TranslatedConsumableProgram[];\n\n @BelongsToMany(() => PersistedUser, { through: () => UserPrograms })\n declare users: PersistedUser[];\n}\n"],"names":["BelongsToMany","Column","DataType","Default","HasMany","Model","Table","TranslatedConsumableProgram","UserPrograms","PersistedUser","NonConsumableProgram","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","INTEGER","BOOLEAN","through"],"mappings":";;;;;;AAAA,SACEA,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAM9B,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,aAAa,QAAQ,mBAAmB;AAGjD,WAAaC,uBAAN,mCAAmCL;AAgD1C,EAAC;;IA/CEF,QAAQD,SAASS,MAAM;IACvBV,OAAO;QACNW,MAAMV,SAASW,IAAI;QACnBC,cAAcZ,SAASW,IAAI;QAC3BE,WAAW,KAAK;QAChBC,YAAY,IAAI;IAClB;GAPWN;;IAUVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GAVrCL;;IAaVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GAbrCL;;IAgBVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GAhBrCL;;IAmBVT,OAAO;QAAEW,MAAMV,SAASgB,OAAO;QAAEH,WAAW,KAAK;IAAC;GAnBxCL;;IAsBVT,OAAO;QAAEW,MAAMV,SAASgB,OAAO;QAAEH,WAAW,KAAK;QAAED,cAAc;IAAE;GAtBzDJ;;IAyBVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GAzBrCL;;IA4BVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GA5BrCL;;IA+BVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,KAAK;IAAC;GA/BrCL;;IAkCVT,OAAO;QAAEW,MAAMV,SAASiB,OAAO;QAAEJ,WAAW,KAAK;IAAC;GAlCxCL;;IAqCVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,IAAI;IAAC;GArCpCL;;IAwCVT,OAAO;QAAEW,MAAMV,SAASe,IAAI;QAAEF,WAAW,IAAI;IAAC;GAxCpCL;;IA2CVN,QAAQ,IAAMG;GA3CJG;;IA8CVV,cAAc,IAAMS,eAAe;QAAEW,SAAS,IAAMZ;IAAa;GA9CvDE;AAAAA;IADZJ;GACYI"}
1
+ {"version":3,"sources":["../../../../src/lib/dbmodels/nonconsprogram/NonConsumableProgram.ts"],"sourcesContent":["import {\n BelongsToMany,\n Column,\n DataType,\n Default,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport {\n ConsumableProgramGoals,\n ConsumableProgramTypes,\n ConsumableProgramWeightGoals,\n} from \"../../enums/ProgramEnums\";\nimport { TranslatedConsumableProgram } from \"./TranslatedConsumableProgram\";\nimport { UserPrograms } from \"./UserNonConsumableProgram\";\nimport { PersistedUser } from \"../PersistedUser\";\nimport {Program} from \"../program/Program\";\n\n@Table\nexport class NonConsumableProgram extends Model {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare uuid: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare title: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare description: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare coverImageUri: string;\n\n @Column({ type: DataType.INTEGER, allowNull: false })\n declare order: number;\n\n @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0 })\n declare popularityOrder: number;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare weightGoal: ConsumableProgramWeightGoals;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare goal: ConsumableProgramGoals;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare type: ConsumableProgramTypes;\n\n @Column({ type: DataType.BOOLEAN, allowNull: false })\n declare isFree: boolean;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare productIdAndroid: string | null;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare productIdIos: string | null;\n\n @HasMany(() => TranslatedConsumableProgram)\n declare translatedPrograms: TranslatedConsumableProgram[];\n\n @BelongsToMany(() => PersistedUser, { through: () => UserPrograms })\n declare users: PersistedUser[];\n\n @HasMany(() => Program)\n declare programs: Program[];\n}\n"],"names":["BelongsToMany","Column","DataType","Default","HasMany","Model","Table","TranslatedConsumableProgram","UserPrograms","PersistedUser","Program","NonConsumableProgram","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","INTEGER","BOOLEAN","through"],"mappings":";;;;;;AAAA,SACEA,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAM9B,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,OAAO,QAAO,qBAAqB;AAG5C,WAAaC,uBAAN,mCAAmCN;AAmD1C,EAAC;;IAlDEF,QAAQD,SAASU,MAAM;IACvBX,OAAO;QACNY,MAAMX,SAASY,IAAI;QACnBC,cAAcb,SAASY,IAAI;QAC3BE,WAAW,KAAK;QAChBC,YAAY,IAAI;IAClB;GAPWN;;IAUVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAVrCL;;IAaVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAbrCL;;IAgBVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAhBrCL;;IAmBVV,OAAO;QAAEY,MAAMX,SAASiB,OAAO;QAAEH,WAAW,KAAK;IAAC;GAnBxCL;;IAsBVV,OAAO;QAAEY,MAAMX,SAASiB,OAAO;QAAEH,WAAW,KAAK;QAAED,cAAc;IAAE;GAtBzDJ;;IAyBVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAzBrCL;;IA4BVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GA5BrCL;;IA+BVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,KAAK;IAAC;GA/BrCL;;IAkCVV,OAAO;QAAEY,MAAMX,SAASkB,OAAO;QAAEJ,WAAW,KAAK;IAAC;GAlCxCL;;IAqCVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,IAAI;IAAC;GArCpCL;;IAwCVV,OAAO;QAAEY,MAAMX,SAASgB,IAAI;QAAEF,WAAW,IAAI;IAAC;GAxCpCL;;IA2CVP,QAAQ,IAAMG;GA3CJI;;IA8CVX,cAAc,IAAMS,eAAe;QAAEY,SAAS,IAAMb;IAAa;GA9CvDG;;IAiDVP,QAAQ,IAAMM;GAjDJC;AAAAA;IADZL;GACYK"}
@@ -2,4 +2,5 @@ import { Model } from "sequelize-typescript";
2
2
  export declare class UserPrograms extends Model<UserPrograms> {
3
3
  userUuid: string;
4
4
  programUuid: string;
5
+ purchasePlatform: string;
5
6
  }
@@ -4,12 +4,13 @@ var __decorate = this && this.__decorate || function(decorators, target, key, de
4
4
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Table, Column, Model, ForeignKey, DataType } from "sequelize-typescript";
7
+ import { Table, Column, Model, ForeignKey, DataType, PrimaryKey } from "sequelize-typescript";
8
8
  import { PersistedUser } from "../PersistedUser";
9
9
  import { NonConsumableProgram } from "./NonConsumableProgram";
10
10
  export let UserPrograms = class UserPrograms extends Model {
11
11
  };
12
12
  __decorate([
13
+ PrimaryKey,
13
14
  ForeignKey(()=>PersistedUser),
14
15
  Column({
15
16
  type: DataType.UUID,
@@ -17,15 +18,23 @@ __decorate([
17
18
  })
18
19
  ], UserPrograms.prototype, "userUuid", void 0);
19
20
  __decorate([
21
+ PrimaryKey,
20
22
  ForeignKey(()=>NonConsumableProgram),
21
23
  Column({
22
24
  type: DataType.UUID,
23
25
  allowNull: false
24
26
  })
25
27
  ], UserPrograms.prototype, "programUuid", void 0);
28
+ __decorate([
29
+ Column({
30
+ type: DataType.UUID,
31
+ allowNull: false
32
+ })
33
+ ], UserPrograms.prototype, "purchasePlatform", void 0);
26
34
  UserPrograms = __decorate([
27
35
  Table({
28
- tableName: "UserPrograms"
36
+ tableName: "UserPrograms",
37
+ timestamps: true
29
38
  })
30
39
  ], UserPrograms);
31
40
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/dbmodels/nonconsprogram/UserNonConsumableProgram.ts"],"sourcesContent":["import {Table, Column, Model, ForeignKey, DataType} from \"sequelize-typescript\";\nimport { PersistedUser } from \"../PersistedUser\";\nimport { NonConsumableProgram } from \"./NonConsumableProgram\";\n\n@Table({ tableName: \"UserPrograms\" })\nexport class UserPrograms extends Model<UserPrograms> {\n @ForeignKey(() => PersistedUser)\n @Column({ type: DataType.UUID, allowNull: false })\n declare userUuid: string;\n\n @ForeignKey(() => NonConsumableProgram)\n @Column({ type: DataType.UUID, allowNull: false })\n declare programUuid: string;\n}\n\n"],"names":["Table","Column","Model","ForeignKey","DataType","PersistedUser","NonConsumableProgram","UserPrograms","type","UUID","allowNull","tableName"],"mappings":";;;;;;AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,QAAO,uBAAuB;AAChF,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,oBAAoB,QAAQ,yBAAyB;AAG9D,WAAaC,eAAN,2BAA2BL;AAQlC,EAAC;;IAPIC,WAAW,IAAME;IACjBJ,OAAO;QAAEO,MAAMJ,SAASK,IAAI;QAAEC,WAAW,KAAK;IAAC;GAFvCH;;IAKRJ,WAAW,IAAMG;IACjBL,OAAO;QAAEO,MAAMJ,SAASK,IAAI;QAAEC,WAAW,KAAK;IAAC;GANvCH;AAAAA;IADZP,MAAM;QAAEW,WAAW;IAAe;GACtBJ"}
1
+ {"version":3,"sources":["../../../../src/lib/dbmodels/nonconsprogram/UserNonConsumableProgram.ts"],"sourcesContent":["import {Table, Column, Model, ForeignKey, DataType, PrimaryKey} from \"sequelize-typescript\";\nimport { PersistedUser } from \"../PersistedUser\";\nimport { NonConsumableProgram } from \"./NonConsumableProgram\";\n\n@Table({ tableName: \"UserPrograms\", timestamps: true })\nexport class UserPrograms extends Model<UserPrograms> {\n @PrimaryKey\n @ForeignKey(() => PersistedUser)\n @Column({ type: DataType.UUID, allowNull: false })\n declare userUuid: string;\n\n @PrimaryKey\n @ForeignKey(() => NonConsumableProgram)\n @Column({ type: DataType.UUID, allowNull: false })\n declare programUuid: string;\n\n @Column({ type: DataType.UUID, allowNull: false })\n declare purchasePlatform: string;\n}\n\n"],"names":["Table","Column","Model","ForeignKey","DataType","PrimaryKey","PersistedUser","NonConsumableProgram","UserPrograms","type","UUID","allowNull","tableName","timestamps"],"mappings":";;;;;;AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,UAAU,QAAO,uBAAuB;AAC5F,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,oBAAoB,QAAQ,yBAAyB;AAG9D,WAAaC,eAAN,2BAA2BN;AAalC,EAAC;;IAZIG;IACAF,WAAW,IAAMG;IACjBL,OAAO;QAAEQ,MAAML,SAASM,IAAI;QAAEC,WAAW,KAAK;IAAC;GAHvCH;;IAMRH;IACAF,WAAW,IAAMI;IACjBN,OAAO;QAAEQ,MAAML,SAASM,IAAI;QAAEC,WAAW,KAAK;IAAC;GARvCH;;IAWRP,OAAO;QAAEQ,MAAML,SAASM,IAAI;QAAEC,WAAW,KAAK;IAAC;GAXvCH;AAAAA;IADZR,MAAM;QAAEY,WAAW;QAAgBC,YAAY,IAAI;IAAC;GACxCL"}
@@ -8,7 +8,7 @@ export declare class Program extends Model<Program> {
8
8
  startDate: string;
9
9
  programType: string;
10
10
  createdAt: Date;
11
- nonConsumableProgram: NonConsumableProgram;
12
11
  workout: Workout[];
12
+ nonConsumableProgram: NonConsumableProgram;
13
13
  static deleteRelatedWorkouts(instance: Program): Promise<void>;
14
14
  }
@@ -34,10 +34,7 @@ __decorate([
34
34
  ], Program.prototype, "userUuid", void 0);
35
35
  __decorate([
36
36
  ForeignKey(()=>NonConsumableProgram),
37
- Column({
38
- type: DataType.UUID,
39
- allowNull: false
40
- })
37
+ Column
41
38
  ], Program.prototype, "nonConsumableProgramUuid", void 0);
42
39
  __decorate([
43
40
  Column({
@@ -57,15 +54,15 @@ __decorate([
57
54
  allowNull: true
58
55
  })
59
56
  ], Program.prototype, "createdAt", void 0);
60
- __decorate([
61
- BelongsTo(()=>NonConsumableProgram)
62
- ], Program.prototype, "nonConsumableProgram", void 0);
63
57
  __decorate([
64
58
  HasMany(()=>Workout, {
65
59
  foreignKey: "programId",
66
60
  onDelete: "CASCADE"
67
61
  })
68
62
  ], Program.prototype, "workout", void 0);
63
+ __decorate([
64
+ BelongsTo(()=>NonConsumableProgram)
65
+ ], Program.prototype, "nonConsumableProgram", void 0);
69
66
  __decorate([
70
67
  BeforeDestroy
71
68
  ], Program, "deleteRelatedWorkouts", null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/dbmodels/program/Program.ts"],"sourcesContent":["import { Workout } from \"./Workout\";\nimport {\n BeforeDestroy, BelongsTo,\n Column,\n DataType,\n Default, ForeignKey,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport {NonConsumableProgram} from \"../nonconsprogram/NonConsumableProgram\";\n\n@Table\nexport class Program extends Model<Program> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare programId: string;\n\n @Column({ type: DataType.UUID, allowNull: false })\n declare userUuid: string;\n\n @ForeignKey(() => NonConsumableProgram)\n @Column({ type: DataType.UUID, allowNull: false })\n declare nonConsumableProgramUuid: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare startDate: string;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare programType: string;\n\n @Column({ type: DataType.DATE, allowNull: true })\n declare createdAt: Date;\n\n @BelongsTo(() => NonConsumableProgram)\n declare nonConsumableProgram: NonConsumableProgram;\n\n @HasMany(() => Workout, { foreignKey: \"programId\", onDelete: \"CASCADE\" })\n declare workout: Workout[];\n\n @BeforeDestroy\n static async deleteRelatedWorkouts(instance: Program) {\n const workouts = await instance.$get(\"workout\", { scope: \"workout\" });\n\n for (const workout of workouts) {\n await workout.destroy();\n }\n }\n}\n"],"names":["Workout","BeforeDestroy","BelongsTo","Column","DataType","Default","ForeignKey","HasMany","Model","Table","NonConsumableProgram","Program","deleteRelatedWorkouts","instance","workouts","$get","scope","workout","destroy","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","DATE","foreignKey","onDelete"],"mappings":";;;;;;AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SACEC,aAAa,EAAEC,SAAS,EACxBC,MAAM,EACNC,QAAQ,EACRC,OAAO,EAAEC,UAAU,EACnBC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAC9B,SAAQC,oBAAoB,QAAO,yCAAyC;AAG5E,WAAaC,UAAN,sBAAsBH;IAgC3B,aACaI,sBAAsBC,QAAiB,EAAE;QACpD,MAAMC,WAAW,MAAMD,SAASE,IAAI,CAAC,WAAW;YAAEC,OAAO;QAAU;QAEnE,KAAK,MAAMC,WAAWH,SAAU;YAC9B,MAAMG,QAAQC,OAAO;QACvB;IACF;AACF,EAAC;;IAvCEb,QAAQD,SAASe,MAAM;IACvBhB,OAAO;QACNiB,MAAMhB,SAASiB,IAAI;QACnBC,cAAclB,SAASiB,IAAI;QAC3BE,WAAW,KAAK;QAChBC,YAAY,IAAI;IAClB;GAPWb;;IAUVR,OAAO;QAAEiB,MAAMhB,SAASiB,IAAI;QAAEE,WAAW,KAAK;IAAC;GAVrCZ;;IAaVL,WAAW,IAAMI;IACjBP,OAAO;QAAEiB,MAAMhB,SAASiB,IAAI;QAAEE,WAAW,KAAK;IAAC;GAdrCZ;;IAiBVR,OAAO;QAAEiB,MAAMhB,SAASqB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAjBrCZ;;IAoBVR,OAAO;QAAEiB,MAAMhB,SAASqB,IAAI;QAAEF,WAAW,IAAI;IAAC;GApBpCZ;;IAuBVR,OAAO;QAAEiB,MAAMhB,SAASsB,IAAI;QAAEH,WAAW,IAAI;IAAC;GAvBpCZ;;IA0BVT,UAAU,IAAMQ;GA1BNC;;IA6BVJ,QAAQ,IAAMP,SAAS;QAAE2B,YAAY;QAAaC,UAAU;IAAU;GA7B5DjB;;IAgCVV;GAhCUU;AAAAA;IADZF;GACYE"}
1
+ {"version":3,"sources":["../../../../src/lib/dbmodels/program/Program.ts"],"sourcesContent":["import { Workout } from \"./Workout\";\nimport {\n BeforeDestroy, BelongsTo,\n Column,\n DataType,\n Default, ForeignKey,\n HasMany,\n Model,\n Table,\n} from \"sequelize-typescript\";\nimport {NonConsumableProgram} from \"../nonconsprogram/NonConsumableProgram\";\n\n@Table\nexport class Program extends Model<Program> {\n @Default(DataType.UUIDV4)\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUID,\n allowNull: false,\n primaryKey: true,\n })\n declare programId: string;\n\n @Column({ type: DataType.UUID, allowNull: false })\n declare userUuid: string;\n\n @ForeignKey(() => NonConsumableProgram)\n @Column\n declare nonConsumableProgramUuid: string;\n\n @Column({ type: DataType.TEXT, allowNull: false })\n declare startDate: string;\n\n @Column({ type: DataType.TEXT, allowNull: true })\n declare programType: string;\n\n @Column({ type: DataType.DATE, allowNull: true })\n declare createdAt: Date;\n\n @HasMany(() => Workout, { foreignKey: \"programId\", onDelete: \"CASCADE\" })\n declare workout: Workout[];\n\n @BelongsTo(() => NonConsumableProgram)\n declare nonConsumableProgram: NonConsumableProgram;\n\n @BeforeDestroy\n static async deleteRelatedWorkouts(instance: Program) {\n const workouts = await instance.$get(\"workout\", { scope: \"workout\" });\n\n for (const workout of workouts) {\n await workout.destroy();\n }\n }\n}\n"],"names":["Workout","BeforeDestroy","BelongsTo","Column","DataType","Default","ForeignKey","HasMany","Model","Table","NonConsumableProgram","Program","deleteRelatedWorkouts","instance","workouts","$get","scope","workout","destroy","UUIDV4","type","UUID","defaultValue","allowNull","primaryKey","TEXT","DATE","foreignKey","onDelete"],"mappings":";;;;;;AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SACEC,aAAa,EAAEC,SAAS,EACxBC,MAAM,EACNC,QAAQ,EACRC,OAAO,EAAEC,UAAU,EACnBC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAC9B,SAAQC,oBAAoB,QAAO,yCAAyC;AAG5E,WAAaC,UAAN,sBAAsBH;IAgC3B,aACaI,sBAAsBC,QAAiB,EAAE;QACpD,MAAMC,WAAW,MAAMD,SAASE,IAAI,CAAC,WAAW;YAAEC,OAAO;QAAU;QAEnE,KAAK,MAAMC,WAAWH,SAAU;YAC9B,MAAMG,QAAQC,OAAO;QACvB;IACF;AACF,EAAC;;IAvCEb,QAAQD,SAASe,MAAM;IACvBhB,OAAO;QACNiB,MAAMhB,SAASiB,IAAI;QACnBC,cAAclB,SAASiB,IAAI;QAC3BE,WAAW,KAAK;QAChBC,YAAY,IAAI;IAClB;GAPWb;;IAUVR,OAAO;QAAEiB,MAAMhB,SAASiB,IAAI;QAAEE,WAAW,KAAK;IAAC;GAVrCZ;;IAaVL,WAAW,IAAMI;IACjBP;GAdUQ;;IAiBVR,OAAO;QAAEiB,MAAMhB,SAASqB,IAAI;QAAEF,WAAW,KAAK;IAAC;GAjBrCZ;;IAoBVR,OAAO;QAAEiB,MAAMhB,SAASqB,IAAI;QAAEF,WAAW,IAAI;IAAC;GApBpCZ;;IAuBVR,OAAO;QAAEiB,MAAMhB,SAASsB,IAAI;QAAEH,WAAW,IAAI;IAAC;GAvBpCZ;;IA0BVJ,QAAQ,IAAMP,SAAS;QAAE2B,YAAY;QAAaC,UAAU;IAAU;GA1B5DjB;;IA6BVT,UAAU,IAAMQ;GA7BNC;;IAgCVV;GAhCUU;AAAAA;IADZF;GACYE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "90dc-core",
3
- "version": "1.6.8",
3
+ "version": "1.7.0",
4
4
  "description": "A package that contains utils and interfaces used to create 90dc",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -15,6 +15,7 @@ import {
15
15
  import { TranslatedConsumableProgram } from "./TranslatedConsumableProgram";
16
16
  import { UserPrograms } from "./UserNonConsumableProgram";
17
17
  import { PersistedUser } from "../PersistedUser";
18
+ import {Program} from "../program/Program";
18
19
 
19
20
  @Table
20
21
  export class NonConsumableProgram extends Model {
@@ -65,4 +66,7 @@ export class NonConsumableProgram extends Model {
65
66
 
66
67
  @BelongsToMany(() => PersistedUser, { through: () => UserPrograms })
67
68
  declare users: PersistedUser[];
69
+
70
+ @HasMany(() => Program)
71
+ declare programs: Program[];
68
72
  }
@@ -1,15 +1,20 @@
1
- import {Table, Column, Model, ForeignKey, DataType} from "sequelize-typescript";
1
+ import {Table, Column, Model, ForeignKey, DataType, PrimaryKey} from "sequelize-typescript";
2
2
  import { PersistedUser } from "../PersistedUser";
3
3
  import { NonConsumableProgram } from "./NonConsumableProgram";
4
4
 
5
- @Table({ tableName: "UserPrograms" })
5
+ @Table({ tableName: "UserPrograms", timestamps: true })
6
6
  export class UserPrograms extends Model<UserPrograms> {
7
+ @PrimaryKey
7
8
  @ForeignKey(() => PersistedUser)
8
9
  @Column({ type: DataType.UUID, allowNull: false })
9
10
  declare userUuid: string;
10
11
 
12
+ @PrimaryKey
11
13
  @ForeignKey(() => NonConsumableProgram)
12
14
  @Column({ type: DataType.UUID, allowNull: false })
13
15
  declare programUuid: string;
16
+
17
+ @Column({ type: DataType.UUID, allowNull: false })
18
+ declare purchasePlatform: string;
14
19
  }
15
20
 
@@ -25,7 +25,7 @@ export class Program extends Model<Program> {
25
25
  declare userUuid: string;
26
26
 
27
27
  @ForeignKey(() => NonConsumableProgram)
28
- @Column({ type: DataType.UUID, allowNull: false })
28
+ @Column
29
29
  declare nonConsumableProgramUuid: string;
30
30
 
31
31
  @Column({ type: DataType.TEXT, allowNull: false })
@@ -37,12 +37,12 @@ export class Program extends Model<Program> {
37
37
  @Column({ type: DataType.DATE, allowNull: true })
38
38
  declare createdAt: Date;
39
39
 
40
- @BelongsTo(() => NonConsumableProgram)
41
- declare nonConsumableProgram: NonConsumableProgram;
42
-
43
40
  @HasMany(() => Workout, { foreignKey: "programId", onDelete: "CASCADE" })
44
41
  declare workout: Workout[];
45
42
 
43
+ @BelongsTo(() => NonConsumableProgram)
44
+ declare nonConsumableProgram: NonConsumableProgram;
45
+
46
46
  @BeforeDestroy
47
47
  static async deleteRelatedWorkouts(instance: Program) {
48
48
  const workouts = await instance.$get("workout", { scope: "workout" });