tering-serieuze-types 2.5.0 → 2.6.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.
package/dist/index.js CHANGED
@@ -20,8 +20,7 @@ var __decorateClass = (decorators, target, key, kind) => {
20
20
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
21
  if (decorator = decorators[i])
22
22
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
- if (kind && result)
24
- __defProp(target, key, result);
23
+ if (kind && result) __defProp(target, key, result);
25
24
  return result;
26
25
  };
27
26
 
@@ -62,6 +61,8 @@ module.exports = __toCommonJS(src_exports);
62
61
 
63
62
  // src/application.ts
64
63
  var import_swagger = require("@nestjs/swagger");
64
+ var import_class_validator = require("class-validator");
65
+ var import_class_transformer = require("class-transformer");
65
66
  var Application = class {
66
67
  name;
67
68
  icon;
@@ -77,40 +78,52 @@ var Application = class {
77
78
  custom;
78
79
  };
79
80
  __decorateClass([
80
- (0, import_swagger.ApiProperty)({ type: String })
81
+ (0, import_swagger.ApiProperty)({ type: String }),
82
+ (0, import_class_validator.IsNotEmpty)()
81
83
  ], Application.prototype, "name", 2);
82
84
  __decorateClass([
83
- (0, import_swagger.ApiProperty)({ type: String })
85
+ (0, import_swagger.ApiProperty)({ type: String }),
86
+ (0, import_class_validator.IsNotEmpty)()
84
87
  ], Application.prototype, "icon", 2);
85
88
  __decorateClass([
86
- (0, import_swagger.ApiProperty)({ type: Boolean })
89
+ (0, import_swagger.ApiProperty)({ type: Boolean }),
90
+ (0, import_class_validator.IsBoolean)()
87
91
  ], Application.prototype, "isOpened", 2);
88
92
  __decorateClass([
89
- (0, import_swagger.ApiProperty)({ type: Boolean })
93
+ (0, import_swagger.ApiProperty)({ type: Boolean }),
94
+ (0, import_class_validator.IsBoolean)()
90
95
  ], Application.prototype, "isMinimized", 2);
91
96
  __decorateClass([
92
- (0, import_swagger.ApiProperty)({ type: Boolean })
97
+ (0, import_swagger.ApiProperty)({ type: Boolean }),
98
+ (0, import_class_validator.IsBoolean)()
93
99
  ], Application.prototype, "isMaximized", 2);
94
100
  __decorateClass([
95
- (0, import_swagger.ApiProperty)({ type: Boolean })
101
+ (0, import_swagger.ApiProperty)({ type: Boolean }),
102
+ (0, import_class_validator.IsBoolean)()
96
103
  ], Application.prototype, "isAdminOnly", 2);
97
104
  __decorateClass([
98
- (0, import_swagger.ApiProperty)({ type: Boolean })
105
+ (0, import_swagger.ApiProperty)({ type: Boolean }),
106
+ (0, import_class_validator.IsBoolean)()
99
107
  ], Application.prototype, "isDevOnly", 2);
100
108
  __decorateClass([
101
- (0, import_swagger.ApiProperty)({ type: Number })
109
+ (0, import_swagger.ApiProperty)({ type: Number }),
110
+ (0, import_class_validator.IsNumber)()
102
111
  ], Application.prototype, "width", 2);
103
112
  __decorateClass([
104
- (0, import_swagger.ApiProperty)({ type: Number })
113
+ (0, import_swagger.ApiProperty)({ type: Number }),
114
+ (0, import_class_validator.IsNumber)()
105
115
  ], Application.prototype, "height", 2);
106
116
  __decorateClass([
107
- (0, import_swagger.ApiProperty)({ type: Number })
117
+ (0, import_swagger.ApiProperty)({ type: Number }),
118
+ (0, import_class_validator.IsNumber)()
108
119
  ], Application.prototype, "x", 2);
109
120
  __decorateClass([
110
- (0, import_swagger.ApiProperty)({ type: Number })
121
+ (0, import_swagger.ApiProperty)({ type: Number }),
122
+ (0, import_class_validator.IsNumber)()
111
123
  ], Application.prototype, "y", 2);
112
124
  __decorateClass([
113
- (0, import_swagger.ApiProperty)({ type: Object })
125
+ (0, import_swagger.ApiProperty)({ type: Object }),
126
+ (0, import_class_validator.IsOptional)()
114
127
  ], Application.prototype, "custom", 2);
115
128
  var WindowStateApplication = class extends (0, import_swagger.OmitType)(Application, ["icon", "isAdminOnly"]) {
116
129
  };
@@ -119,10 +132,14 @@ var WindowState = class {
119
132
  activeApplication;
120
133
  };
121
134
  __decorateClass([
122
- (0, import_swagger.ApiProperty)({ type: [WindowStateApplication] })
135
+ (0, import_swagger.ApiProperty)({ type: [WindowStateApplication] }),
136
+ (0, import_class_validator.ValidateNested)({ each: true }),
137
+ (0, import_class_transformer.Type)(() => WindowStateApplication)
123
138
  ], WindowState.prototype, "applications", 2);
124
139
  __decorateClass([
125
- (0, import_swagger.ApiProperty)({ type: String })
140
+ (0, import_swagger.ApiProperty)({ type: String }),
141
+ (0, import_class_validator.IsString)(),
142
+ (0, import_class_validator.IsNotEmpty)()
126
143
  ], WindowState.prototype, "activeApplication", 2);
127
144
 
128
145
  // src/authenticator.ts
@@ -144,7 +161,8 @@ var import_swagger5 = require("@nestjs/swagger");
144
161
 
145
162
  // src/user.ts
146
163
  var import_swagger4 = require("@nestjs/swagger");
147
- var import_class_validator = require("class-validator");
164
+ var import_class_transformer2 = require("class-transformer");
165
+ var import_class_validator2 = require("class-validator");
148
166
 
149
167
  // src/session.ts
150
168
  var import_swagger3 = require("@nestjs/swagger");
@@ -245,13 +263,14 @@ var User = class {
245
263
  apiTokens;
246
264
  };
247
265
  __decorateClass([
266
+ (0, import_class_validator2.IsNumberString)(),
248
267
  (0, import_swagger4.ApiProperty)({ type: Number })
249
268
  ], User.prototype, "id", 2);
250
269
  __decorateClass([
251
270
  (0, import_swagger4.ApiProperty)({ type: Number, nullable: true, default: null })
252
271
  ], User.prototype, "_id", 2);
253
272
  __decorateClass([
254
- (0, import_class_validator.IsEmail)(),
273
+ (0, import_class_validator2.IsEmail)(),
255
274
  (0, import_swagger4.ApiProperty)({ type: String })
256
275
  ], User.prototype, "email", 2);
257
276
  __decorateClass([
@@ -271,7 +290,9 @@ __decorateClass([
271
290
  (0, import_swagger4.ApiProperty)()
272
291
  ], User.prototype, "isRegistering", 2);
273
292
  __decorateClass([
274
- (0, import_swagger4.ApiProperty)({ type: WindowState })
293
+ (0, import_swagger4.ApiProperty)({ type: WindowState }),
294
+ (0, import_class_validator2.ValidateNested)(),
295
+ (0, import_class_transformer2.Type)(() => WindowState)
275
296
  ], User.prototype, "windowState", 2);
276
297
  __decorateClass([
277
298
  (0, import_swagger4.ApiProperty)({ type: () => [Button] })
@@ -301,7 +322,7 @@ var AddUserDto = class {
301
322
  email;
302
323
  };
303
324
  __decorateClass([
304
- (0, import_class_validator.IsEmail)(),
325
+ (0, import_class_validator2.IsEmail)(),
305
326
  (0, import_swagger4.ApiProperty)({ type: String, example: "info@example.com" })
306
327
  ], AddUserDto.prototype, "email", 2);
307
328
  var RemoveUserDto = class extends (0, import_swagger4.PickType)(User, ["id"]) {
@@ -379,7 +400,7 @@ __decorateClass([
379
400
  ], Button.prototype, "ButtonHold", 2);
380
401
 
381
402
  // src/emulator.ts
382
- var import_class_validator2 = require("class-validator");
403
+ var import_class_validator3 = require("class-validator");
383
404
  var import_swagger6 = require("@nestjs/swagger");
384
405
  var City = /* @__PURE__ */ ((City2) => {
385
406
  City2["Waalwijk"] = "Waalwijk";
@@ -391,11 +412,13 @@ var EmulateFireDepartmentDto = class {
391
412
  };
392
413
  __decorateClass([
393
414
  (0, import_swagger6.ApiProperty)({ enum: City }),
394
- (0, import_class_validator2.IsEnum)(City)
415
+ (0, import_class_validator3.IsEnum)(City)
395
416
  ], EmulateFireDepartmentDto.prototype, "city", 2);
396
417
 
397
418
  // src/jingle.ts
398
419
  var import_swagger7 = require("@nestjs/swagger");
420
+ var import_class_validator4 = require("class-validator");
421
+ var import_class_transformer3 = require("class-transformer");
399
422
  var Jingle = class {
400
423
  folder;
401
424
  file;
@@ -404,10 +427,14 @@ var Jingle = class {
404
427
  mtime;
405
428
  };
406
429
  __decorateClass([
407
- (0, import_swagger7.ApiProperty)({ type: String, example: "internet-gekkies" })
430
+ (0, import_swagger7.ApiProperty)({ type: String, example: "internet-gekkies" }),
431
+ (0, import_class_validator4.IsString)(),
432
+ (0, import_class_validator4.IsNotEmpty)()
408
433
  ], Jingle.prototype, "folder", 2);
409
434
  __decorateClass([
410
- (0, import_swagger7.ApiProperty)({ type: String, example: "mand.mp3" })
435
+ (0, import_swagger7.ApiProperty)({ type: String, example: "mand.mp3" }),
436
+ (0, import_class_validator4.IsString)(),
437
+ (0, import_class_validator4.IsNotEmpty)()
411
438
  ], Jingle.prototype, "file", 2);
412
439
  __decorateClass([
413
440
  (0, import_swagger7.ApiProperty)({ type: [String], examples: ["internet", "gekkies", "mand"] })
@@ -423,10 +450,14 @@ var JingleFolder = class {
423
450
  jingles;
424
451
  };
425
452
  __decorateClass([
426
- (0, import_swagger7.ApiProperty)({ type: String, example: "internet-gekkies" })
453
+ (0, import_swagger7.ApiProperty)({ type: String, example: "internet-gekkies" }),
454
+ (0, import_class_validator4.IsString)(),
455
+ (0, import_class_validator4.IsNotEmpty)()
427
456
  ], JingleFolder.prototype, "folder", 2);
428
457
  __decorateClass([
429
- (0, import_swagger7.ApiProperty)({ type: [Jingle] })
458
+ (0, import_swagger7.ApiProperty)({ type: [Jingle] }),
459
+ (0, import_class_validator4.ValidateNested)({ each: true }),
460
+ (0, import_class_transformer3.Type)(() => Jingle)
430
461
  ], JingleFolder.prototype, "jingles", 2);
431
462
  var PlayJingleDto = class extends (0, import_swagger7.PickType)(Jingle, ["folder", "file"]) {
432
463
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tering-serieuze-types",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Tering serieuze types",
5
5
  "author": "Frank",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "devDependencies": {
20
20
  "@typescript-eslint/eslint-plugin": "^7.7.0",
21
21
  "@typescript-eslint/parser": "^7.7.0",
22
- "esbuild": "^0.16.10",
22
+ "esbuild": "^0.23.1",
23
23
  "eslint": "^8.57.0",
24
24
  "eslint-config-airbnb-base": "^15.0.0",
25
25
  "eslint-config-prettier": "^9.1.0",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@nestjs/swagger": "^7.1.16",
31
31
  "@simplewebauthn/typescript-types": "^7.4.0",
32
- "class-validator": "^0.13.2"
32
+ "class-transformer": "^0.5.1",
33
+ "class-validator": "^0.14.1"
33
34
  }
34
35
  }
@@ -1,40 +1,54 @@
1
1
  import { ApiProperty, OmitType } from '@nestjs/swagger';
2
+ import { IsBoolean, IsNotEmpty, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';
3
+ import { Type } from 'class-transformer';
2
4
 
3
5
  export class Application {
4
6
  @ApiProperty({ type: String })
7
+ @IsNotEmpty()
5
8
  name: string;
6
9
 
7
10
  @ApiProperty({ type: String })
11
+ @IsNotEmpty()
8
12
  icon: string;
9
13
 
10
14
  @ApiProperty({ type: Boolean })
15
+ @IsBoolean()
11
16
  isOpened: boolean;
12
17
 
13
18
  @ApiProperty({ type: Boolean })
19
+ @IsBoolean()
14
20
  isMinimized: boolean;
15
21
 
16
22
  @ApiProperty({ type: Boolean })
23
+ @IsBoolean()
17
24
  isMaximized: boolean;
18
25
 
19
26
  @ApiProperty({ type: Boolean })
27
+ @IsBoolean()
20
28
  isAdminOnly: boolean;
21
29
 
22
30
  @ApiProperty({ type: Boolean })
31
+ @IsBoolean()
23
32
  isDevOnly: boolean;
24
33
 
25
34
  @ApiProperty({ type: Number })
35
+ @IsNumber()
26
36
  width: number;
27
37
 
28
38
  @ApiProperty({ type: Number })
39
+ @IsNumber()
29
40
  height: number;
30
41
 
31
42
  @ApiProperty({ type: Number })
43
+ @IsNumber()
32
44
  x: number;
33
45
 
34
46
  @ApiProperty({ type: Number })
47
+ @IsNumber()
35
48
  y: number;
36
49
 
37
50
  @ApiProperty({ type: Object })
51
+ @IsOptional()
38
52
  custom: any;
39
53
  }
40
54
 
@@ -42,8 +56,12 @@ export class WindowStateApplication extends OmitType(Application, ['icon', 'isAd
42
56
 
43
57
  export class WindowState {
44
58
  @ApiProperty({ type: [WindowStateApplication] })
59
+ @ValidateNested({ each: true })
60
+ @Type(() => WindowStateApplication)
45
61
  applications: WindowStateApplication[];
46
62
 
47
63
  @ApiProperty({ type: String })
64
+ @IsString()
65
+ @IsNotEmpty()
48
66
  activeApplication: string;
49
67
  }
package/src/jingle.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  import { ApiProperty, PickType } from '@nestjs/swagger';
2
+ import { IsNotEmpty, IsString, ValidateNested } from 'class-validator';
3
+ import { Type } from 'class-transformer';
2
4
 
3
5
  export class Jingle {
4
6
  @ApiProperty({ type: String, example: 'internet-gekkies' })
7
+ @IsString()
8
+ @IsNotEmpty()
5
9
  folder: string;
6
10
 
7
11
  @ApiProperty({ type: String, example: 'mand.mp3' })
12
+ @IsString()
13
+ @IsNotEmpty()
8
14
  file: string;
9
15
 
10
16
  @ApiProperty({ type: [String], examples: ['internet', 'gekkies', 'mand'] })
@@ -19,9 +25,13 @@ export class Jingle {
19
25
 
20
26
  export class JingleFolder {
21
27
  @ApiProperty({ type: String, example: 'internet-gekkies' })
28
+ @IsString()
29
+ @IsNotEmpty()
22
30
  folder: string;
23
31
 
24
32
  @ApiProperty({ type: [Jingle] })
33
+ @ValidateNested({ each: true })
34
+ @Type(() => Jingle)
25
35
  jingles: Jingle[];
26
36
  }
27
37
 
package/src/user.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { ApiProperty, PickType } from '@nestjs/swagger';
2
- import { IsEmail } from 'class-validator';
2
+ import { Type } from 'class-transformer';
3
+ import { IsEmail, IsNumberString, ValidateNested } from 'class-validator';
3
4
  import { Button } from './button';
4
5
  import { WindowState } from './application';
5
6
  import { type DbAuthenticator } from './authenticator';
6
7
  import { ApiToken, Session } from './session';
7
8
 
8
9
  export class User {
10
+ @IsNumberString()
9
11
  @ApiProperty({ type: Number })
10
12
  id: number;
11
13
 
@@ -34,6 +36,8 @@ export class User {
34
36
  isRegistering: Date | null;
35
37
 
36
38
  @ApiProperty({ type: WindowState })
39
+ @ValidateNested()
40
+ @Type(() => WindowState)
37
41
  windowState: WindowState;
38
42
 
39
43
  @ApiProperty({ type: () => [Button] })
package/tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "emitDecoratorMetadata": true,
3
4
  "experimentalDecorators": true,
4
5
  "target": "esnext",
5
6
  "moduleResolution": "NodeNext"