dl-commons 0.0.2-testing.5 → 0.0.2-testing.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dl-commons",
3
3
  "type": "commonjs",
4
- "version": "0.0.2-testing.5",
4
+ "version": "0.0.2-testing.7",
5
5
  "description": "distance learning commons",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -96,6 +96,9 @@ import {
96
96
  S3File,
97
97
  S3FileSchema,
98
98
  S3FileDocument,
99
+ FileEmbedded,
100
+ FileEmbeddedDocument,
101
+ FileEmbeddedSchema,
99
102
  } from './models/schemas/embedded/s3.schema';
100
103
 
101
104
  export {
@@ -185,6 +188,9 @@ export {
185
188
  IFileRecord,
186
189
  IFileMeta,
187
190
  IFileLog,
191
+ FileEmbedded,
192
+ FileEmbeddedSchema,
193
+ FileEmbeddedDocument,
188
194
 
189
195
  /**
190
196
  * Schemas & Documents
@@ -43,3 +43,13 @@ export interface IFileLog {
43
43
  value: S3FileState;
44
44
  initiator: ILogInitiator;
45
45
  }
46
+
47
+ export interface IFileEmbedded {
48
+ id: string;
49
+ name: string;
50
+ size: number;
51
+ mimeType: string;
52
+ s3: IS3;
53
+ state: S3FileState;
54
+ createdAt: Date;
55
+ }
@@ -1,14 +1,14 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
2
  import { HydratedDocument, mongo, SchemaTypes } from 'mongoose';
3
- import { IFileLog, IFileMeta, IFileRecord, IFileState, ILogInitiator, IS3, IS3File } from '../../interfaces/s3.interface';
3
+ import { IFileEmbedded, IFileLog, IFileMeta, IFileRecord, IFileState, ILogInitiator, IS3, IS3File } from '../../interfaces/s3.interface';
4
4
  import { FileLogInitType, S3FileState } from '../../enums/s3.enum';
5
5
 
6
6
  @Schema({ _id: false })
7
7
  export class S3 implements IS3 {
8
- @Prop({ type: String, required: false })
8
+ @Prop({ type: String, required: true })
9
9
  key: string;
10
10
 
11
- @Prop({ type: String, required: false })
11
+ @Prop({ type: String, required: true })
12
12
  bucket: string;
13
13
 
14
14
  @Prop({ type: String, required: false })
@@ -24,12 +24,12 @@ export class LogInitiator implements ILogInitiator {
24
24
  name: string;
25
25
  }
26
26
 
27
- @Schema({ _id: false })
27
+ @Schema()
28
28
  export class FileLog implements IFileLog {
29
- @Prop({ type: Date, required: false })
29
+ @Prop({ type: Date, required: true })
30
30
  createdAt: Date;
31
31
 
32
- @Prop({ type: String, enum: S3FileState, required: false })
32
+ @Prop({ type: String, enum: S3FileState, required: true })
33
33
  value: S3FileState;
34
34
 
35
35
  @Prop({ type: LogInitiator, required: false })
@@ -53,16 +53,16 @@ export class FileMeta implements IFileMeta {
53
53
 
54
54
  @Schema({ _id: false })
55
55
  export class FileState implements IFileState {
56
- @Prop({ type: String, enum: S3FileState, required: false })
56
+ @Prop({ type: String, enum: S3FileState, required: true })
57
57
  value: S3FileState;
58
58
 
59
- @Prop({ type: [FileLog], required: false })
59
+ @Prop({ type: [FileLog], required: true, default: [] })
60
60
  log: FileLog[];
61
61
  }
62
62
 
63
63
  @Schema({ _id: false })
64
64
  export class FileRecord implements IFileRecord {
65
- @Prop({ type: Date, required: false })
65
+ @Prop({ type: Date, required: true })
66
66
  createdAt: Date;
67
67
 
68
68
  @Prop({ type: Date, required: false })
@@ -74,22 +74,46 @@ export class S3File implements IS3File {
74
74
  @Prop({ type: SchemaTypes.ObjectId, required: true })
75
75
  id: mongo.ObjectId;
76
76
 
77
- @Prop({ type: FileMeta, required: false })
77
+ @Prop({ type: FileMeta, required: true, default: null })
78
78
  fileMeta: FileMeta;
79
79
 
80
- @Prop({ type: FileState, required: false })
80
+ @Prop({ type: FileState, required: true, default: null })
81
81
  state: FileState;
82
82
 
83
- @Prop({ type: S3, required: false })
83
+ @Prop({ type: S3, required: true, default: null })
84
84
  s3: S3;
85
85
 
86
- @Prop({ type: FileRecord, required: false })
86
+ @Prop({ type: FileRecord, required: true })
87
87
  record: FileRecord;
88
88
 
89
- @Prop({ required: false, type: String })
89
+ @Prop({ type: String, required: true })
90
90
  owner: string;
91
91
  }
92
92
 
93
+ @Schema({ _id: false })
94
+ export class FileEmbedded implements IFileEmbedded {
95
+ @Prop({ type: String, required: true })
96
+ id: string;
97
+
98
+ @Prop({ type: String, required: false })
99
+ name: string;
100
+
101
+ @Prop({ type: Number, required: true })
102
+ size: number;
103
+
104
+ @Prop({ type: String, required: true })
105
+ mimeType: string;
106
+
107
+ @Prop({ type: S3, required: true, default: null })
108
+ s3: S3;
109
+
110
+ @Prop({ type: String, enum: S3FileState, required: true })
111
+ state: S3FileState;
112
+
113
+ @Prop({ type: Date, required: true })
114
+ createdAt: Date;
115
+ }
116
+
93
117
  export const S3Schema = SchemaFactory.createForClass(S3);
94
118
  export const LogInitiatorSchema = SchemaFactory.createForClass(LogInitiator);
95
119
  export const FileLogSchema = SchemaFactory.createForClass(FileLog);
@@ -97,6 +121,7 @@ export const FileMetaSchema = SchemaFactory.createForClass(FileMeta);
97
121
  export const FileStateSchema = SchemaFactory.createForClass(FileState);
98
122
  export const FileRecordSchema = SchemaFactory.createForClass(FileRecord);
99
123
  export const S3FileSchema = SchemaFactory.createForClass(S3File);
124
+ export const FileEmbeddedSchema = SchemaFactory.createForClass(FileEmbedded);
100
125
 
101
126
  export type S3Document = HydratedDocument<S3>;
102
127
  export type LogInitiatorDocument = HydratedDocument<LogInitiator>;
@@ -105,3 +130,4 @@ export type FileMetaDocument = HydratedDocument<FileMeta>;
105
130
  export type FileStateDocument = HydratedDocument<FileState>;
106
131
  export type FileRecordDocument = HydratedDocument<FileRecord>;
107
132
  export type S3FileDocument = HydratedDocument<S3File>;
133
+ export type FileEmbeddedDocument = HydratedDocument<FileEmbedded>;