dl-commons 0.0.2-testing.14 → 0.0.2-testing.16
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/dist/index.d.ts +8 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/models/enums/attachement-type.enum.d.ts +4 -0
- package/dist/models/enums/attachement-type.enum.js +9 -0
- package/dist/models/enums/attachement-type.enum.js.map +1 -0
- package/dist/models/interfaces/attachement.interface.d.ts +8 -0
- package/dist/models/interfaces/attachement.interface.js +3 -0
- package/dist/models/interfaces/attachement.interface.js.map +1 -0
- package/dist/models/interfaces/crop-area.interface.d.ts +6 -0
- package/dist/models/interfaces/crop-area.interface.js +3 -0
- package/dist/models/interfaces/crop-area.interface.js.map +1 -0
- package/dist/models/interfaces/group.interface.d.ts +17 -0
- package/dist/models/interfaces/group.interface.js +3 -0
- package/dist/models/interfaces/group.interface.js.map +1 -0
- package/dist/models/interfaces/picture.interface.d.ts +7 -0
- package/dist/models/interfaces/picture.interface.js +3 -0
- package/dist/models/interfaces/picture.interface.js.map +1 -0
- package/dist/models/schemas/base.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/attachement.schema.d.ts +20 -0
- package/dist/models/schemas/embedded/attachement.schema.js +36 -0
- package/dist/models/schemas/embedded/attachement.schema.js.map +1 -0
- package/dist/models/schemas/embedded/contact.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/crop-area.schema.d.ts +18 -0
- package/dist/models/schemas/embedded/crop-area.schema.js +37 -0
- package/dist/models/schemas/embedded/crop-area.schema.js.map +1 -0
- package/dist/models/schemas/embedded/dictionary-embedded.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/group-session.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/i18n.embedded.d.ts +2 -2
- package/dist/models/schemas/embedded/person.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/picture.schema.d.ts +19 -0
- package/dist/models/schemas/embedded/picture.schema.js +35 -0
- package/dist/models/schemas/embedded/picture.schema.js.map +1 -0
- package/dist/models/schemas/embedded/record.embedded.d.ts +2 -2
- package/dist/models/schemas/embedded/residence.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/s3.schema.d.ts +16 -16
- package/dist/models/schemas/embedded/session-user.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/student-embedded.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/teacher.schema.d.ts +2 -2
- package/dist/models/schemas/embedded/time.schema.d.ts +2 -2
- package/dist/models/schemas/identifable.schema.d.ts +2 -2
- package/dist/models/schemas/parent.schema.d.ts +2 -2
- package/dist/models/schemas/session.schema.d.ts +2 -2
- package/dist/transformers/common.transformer.d.ts +1 -1
- package/dist/transformers/common.transformer.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/helper.utils.d.ts +2 -2
- package/dist/utils/helper.utils.js +14 -13
- package/dist/utils/helper.utils.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +21 -2
- package/src/models/enums/attachement-type.enum.ts +4 -0
- package/src/models/interfaces/attachement.interface.ts +9 -0
- package/src/models/interfaces/crop-area.interface.ts +6 -0
- package/src/models/interfaces/picture.interface.ts +8 -0
- package/src/models/schemas/embedded/attachement.schema.ts +22 -0
- package/src/models/schemas/embedded/crop-area.schema.ts +21 -0
- package/src/models/schemas/embedded/picture.schema.ts +22 -0
- package/src/transformers/common.transformer.ts +4 -4
- package/src/utils/helper.utils.ts +19 -15
|
@@ -3,5 +3,5 @@ declare const toStringArray: (value: string | string[]) => string[];
|
|
|
3
3
|
declare const toMongoId: (value: string) => import("bson").ObjectId;
|
|
4
4
|
declare const toMongoIdArray: (values: string | string[]) => Types.ObjectId[];
|
|
5
5
|
declare const toBoolean: (value: string) => value is "true";
|
|
6
|
-
declare const
|
|
7
|
-
export { toStringArray, toMongoId, toMongoIdArray, toBoolean,
|
|
6
|
+
declare const toInt32: (value: string) => number;
|
|
7
|
+
export { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt32 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toInt32 = exports.toBoolean = exports.toMongoIdArray = exports.toMongoId = exports.toStringArray = void 0;
|
|
4
4
|
const class_validator_1 = require("class-validator");
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
6
|
const rest_wrapper_class_1 = require("../models/dtos/wrappers/rest-wrapper.class");
|
|
@@ -29,19 +29,20 @@ const toBoolean = (value) => {
|
|
|
29
29
|
return value === 'true';
|
|
30
30
|
};
|
|
31
31
|
exports.toBoolean = toBoolean;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new rest_wrapper_class_1.RESTError('conversion_error', 'Value is out of the 64-bit signed integer range.');
|
|
39
|
-
}
|
|
40
|
-
return int64Value;
|
|
32
|
+
const toInt32 = (value) => {
|
|
33
|
+
const int64Min = -9223372036854775808;
|
|
34
|
+
const int64Max = 9223372036854775807;
|
|
35
|
+
const intValue = Number(value);
|
|
36
|
+
if (isNaN(intValue)) {
|
|
37
|
+
throw new rest_wrapper_class_1.RESTError('conversion_error', 'Invalid input: Not a number.');
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
throw new rest_wrapper_class_1.RESTError('
|
|
39
|
+
if (!Number.isSafeInteger(intValue)) {
|
|
40
|
+
throw new rest_wrapper_class_1.RESTError('conversion_error', 'Invalid input: Value exceeds safe integer limits.');
|
|
44
41
|
}
|
|
42
|
+
if (intValue < int64Min || intValue > int64Max) {
|
|
43
|
+
throw new rest_wrapper_class_1.RESTError('conversion_error', 'Value is out of the 64-bit signed integer range.');
|
|
44
|
+
}
|
|
45
|
+
return intValue;
|
|
45
46
|
};
|
|
46
|
-
exports.
|
|
47
|
+
exports.toInt32 = toInt32;
|
|
47
48
|
//# sourceMappingURL=helper.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.utils.js","sourceRoot":"","sources":["../../src/utils/helper.utils.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,uCAAiC;AACjC,mFAAuE;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"helper.utils.js","sourceRoot":"","sources":["../../src/utils/helper.utils.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,uCAAiC;AACjC,mFAAuE;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC,CAAC;AA4CO,sCAAa;AA1CtB,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE;IAChC,MAAM,KAAK,GAAG,IAAA,2BAAS,EAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,IAAI,8BAAS,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,gBAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC,CAAC;AAoCsB,8BAAS;AAlCjC,MAAM,cAAc,GAAG,CAAC,MAAyB,EAAE,EAAE;IACjD,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AA2BiC,wCAAc;AAzBjD,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE;IAChC,OAAO,KAAK,KAAK,MAAM,CAAC;AAC5B,CAAC,CAAC;AAuBiD,8BAAS;AArB5D,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9B,MAAM,QAAQ,GAAG,CAAC,mBAAmB,CAAC;IACtC,MAAM,QAAQ,GAAG,mBAAmB,CAAC;IAErC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,8BAAS,CAAC,kBAAkB,EAAE,8BAA8B,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,8BAAS,CAAC,kBAAkB,EAAE,mDAAmD,CAAC,CAAC;IACjG,CAAC;IAED,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,QAAQ,EAAE,CAAC;QAC7C,MAAM,IAAI,8BAAS,CAAC,kBAAkB,EAAE,kDAAkD,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAE4D,0BAAO"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -101,6 +101,13 @@ import {
|
|
|
101
101
|
FileEmbeddedSchema,
|
|
102
102
|
} from './models/schemas/embedded/s3.schema';
|
|
103
103
|
import { IUserMeta } from './models/interfaces/user-meta.interface';
|
|
104
|
+
import { ICropArea } from './models/interfaces/crop-area.interface';
|
|
105
|
+
import { CropArea, CropAreaDocument, CropAreaSchema } from './models/schemas/embedded/crop-area.schema';
|
|
106
|
+
import { AttachementType } from './models/enums/attachement-type.enum';
|
|
107
|
+
import { IAttachement } from './models/interfaces/attachement.interface';
|
|
108
|
+
import { Attachement, AttachementDocument, AttachementSchema } from './models/schemas/embedded/attachement.schema';
|
|
109
|
+
import { Picture, PictureSchema, PictureDocument } from './models/schemas/embedded/picture.schema';
|
|
110
|
+
import { IPicture } from './models/interfaces/picture.interface';
|
|
104
111
|
|
|
105
112
|
export {
|
|
106
113
|
/**
|
|
@@ -153,6 +160,7 @@ export {
|
|
|
153
160
|
GroupState,
|
|
154
161
|
S3FileState,
|
|
155
162
|
FileLogInitType,
|
|
163
|
+
AttachementType,
|
|
156
164
|
|
|
157
165
|
/**
|
|
158
166
|
* DTOs
|
|
@@ -190,7 +198,10 @@ export {
|
|
|
190
198
|
IFileMeta,
|
|
191
199
|
IFileLog,
|
|
192
200
|
IUserMeta,
|
|
193
|
-
|
|
201
|
+
ICropArea,
|
|
202
|
+
IAttachement,
|
|
203
|
+
IPicture,
|
|
204
|
+
|
|
194
205
|
/**
|
|
195
206
|
* Schemas & Documents
|
|
196
207
|
*/
|
|
@@ -260,7 +271,15 @@ export {
|
|
|
260
271
|
FileEmbedded,
|
|
261
272
|
FileEmbeddedSchema,
|
|
262
273
|
FileEmbeddedDocument,
|
|
263
|
-
|
|
274
|
+
CropArea,
|
|
275
|
+
CropAreaSchema,
|
|
276
|
+
CropAreaDocument,
|
|
277
|
+
Attachement,
|
|
278
|
+
AttachementSchema,
|
|
279
|
+
AttachementDocument,
|
|
280
|
+
Picture,
|
|
281
|
+
PictureSchema,
|
|
282
|
+
PictureDocument,
|
|
264
283
|
|
|
265
284
|
/**
|
|
266
285
|
* Filters
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AttachementType } from '../enums/attachement-type.enum';
|
|
2
|
+
import { IIdentifable } from './identifable.interface';
|
|
3
|
+
import { IFileEmbedded } from './s3.interface';
|
|
4
|
+
|
|
5
|
+
export interface IAttachement extends IIdentifable {
|
|
6
|
+
type: AttachementType;
|
|
7
|
+
file?: IFileEmbedded | null | undefined;
|
|
8
|
+
link?: string | null | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { IAttachement } from '../../interfaces/attachement.interface';
|
|
4
|
+
import { Identifable } from '../identifable.schema';
|
|
5
|
+
import { AttachementType } from '../../enums/attachement-type.enum';
|
|
6
|
+
import { IFileEmbedded } from '../../interfaces/s3.interface';
|
|
7
|
+
import { FileEmbeddedSchema } from './s3.schema';
|
|
8
|
+
|
|
9
|
+
@Schema({ _id: false })
|
|
10
|
+
export class Attachement extends Identifable implements IAttachement {
|
|
11
|
+
@Prop({ required: true, enum: AttachementType, type: String })
|
|
12
|
+
type: AttachementType;
|
|
13
|
+
|
|
14
|
+
@Prop({ type: FileEmbeddedSchema, required: false, default: null })
|
|
15
|
+
file: IFileEmbedded;
|
|
16
|
+
|
|
17
|
+
@Prop({ type: String, required: false, default: null })
|
|
18
|
+
link: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AttachementSchema = SchemaFactory.createForClass(Attachement);
|
|
22
|
+
export type AttachementDocument = HydratedDocument<Attachement>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { ICropArea } from '../../interfaces/crop-area.interface';
|
|
4
|
+
|
|
5
|
+
@Schema({ _id: false })
|
|
6
|
+
export class CropArea implements ICropArea {
|
|
7
|
+
@Prop({ type: Number, required: true })
|
|
8
|
+
x1: number;
|
|
9
|
+
|
|
10
|
+
@Prop({ type: Number, required: true })
|
|
11
|
+
x2: number;
|
|
12
|
+
|
|
13
|
+
@Prop({ type: Number, required: true })
|
|
14
|
+
y1: number;
|
|
15
|
+
|
|
16
|
+
@Prop({ type: Number, required: true })
|
|
17
|
+
y2: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const CropAreaSchema = SchemaFactory.createForClass(CropArea);
|
|
21
|
+
export type CropAreaDocument = HydratedDocument<CropArea>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument } from 'mongoose';
|
|
3
|
+
import { IFileEmbedded } from '../../interfaces/s3.interface';
|
|
4
|
+
import { FileEmbeddedSchema } from './s3.schema';
|
|
5
|
+
import { IPicture } from '../../interfaces/picture.interface';
|
|
6
|
+
import { ICropArea } from '../../interfaces/crop-area.interface';
|
|
7
|
+
import { CropAreaSchema } from './crop-area.schema';
|
|
8
|
+
|
|
9
|
+
@Schema({ _id: false })
|
|
10
|
+
export class Picture implements IPicture {
|
|
11
|
+
@Prop({ type: FileEmbeddedSchema, required: true, default: null })
|
|
12
|
+
original: IFileEmbedded;
|
|
13
|
+
|
|
14
|
+
@Prop({ type: FileEmbeddedSchema, required: false, default: null })
|
|
15
|
+
cropped: IFileEmbedded;
|
|
16
|
+
|
|
17
|
+
@Prop({ type: CropAreaSchema, required: false, default: null })
|
|
18
|
+
cropArea: ICropArea;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const PictureSchema = SchemaFactory.createForClass(Picture);
|
|
22
|
+
export type PictureDocument = HydratedDocument<Picture>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformFnParams } from 'class-transformer';
|
|
2
|
-
import { toStringArray, toMongoId, toMongoIdArray, toBoolean,
|
|
2
|
+
import { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt32 } from '../utils/helper.utils';
|
|
3
3
|
|
|
4
4
|
const stringArray = (params: TransformFnParams) => {
|
|
5
5
|
return toStringArray(params.value);
|
|
@@ -17,8 +17,8 @@ const boolean = (params: TransformFnParams) => {
|
|
|
17
17
|
return toBoolean(params.value);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
return
|
|
20
|
+
const int32 = (params: TransformFnParams) => {
|
|
21
|
+
return toInt32(params.value);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const transformers = {
|
|
@@ -26,7 +26,7 @@ const transformers = {
|
|
|
26
26
|
mongoId,
|
|
27
27
|
mongoIdArray,
|
|
28
28
|
boolean,
|
|
29
|
-
|
|
29
|
+
int32,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export { transformers };
|
|
@@ -27,21 +27,25 @@ const toBoolean = (value: string) => {
|
|
|
27
27
|
return value === 'true';
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw new RESTError('conversion_error_invalid_input', `Invalid input for conversion to Int64: ${error.message}`);
|
|
30
|
+
const toInt32 = (value: string) => {
|
|
31
|
+
const int64Min = -9223372036854775808; // Minimum 64-bit signed integer
|
|
32
|
+
const int64Max = 9223372036854775807; // Maximum 64-bit signed integer
|
|
33
|
+
|
|
34
|
+
const intValue = Number(value); // Convert the string to a Number
|
|
35
|
+
|
|
36
|
+
if (isNaN(intValue)) {
|
|
37
|
+
throw new RESTError('conversion_error', 'Invalid input: Not a number.');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!Number.isSafeInteger(intValue)) {
|
|
41
|
+
throw new RESTError('conversion_error', 'Invalid input: Value exceeds safe integer limits.');
|
|
44
42
|
}
|
|
43
|
+
|
|
44
|
+
if (intValue < int64Min || intValue > int64Max) {
|
|
45
|
+
throw new RESTError('conversion_error', 'Value is out of the 64-bit signed integer range.');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return intValue;
|
|
45
49
|
};
|
|
46
50
|
|
|
47
|
-
export { toStringArray, toMongoId, toMongoIdArray, toBoolean,
|
|
51
|
+
export { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt32 };
|