itlab-internal-services 2.16.20 → 2.16.22

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,5 +1,5 @@
1
1
  import { LabComment } from 'itlab-functions';
2
2
  import { Document } from 'mongoose';
3
- export declare function CommentableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): new (...args: any[]) => InstanceType<TBase> & {
3
+ export declare function CommentableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): TBase & (new (...args: any[]) => {
4
4
  comments?: LabComment[];
5
- };
5
+ });
@@ -1,5 +1,5 @@
1
1
  import { LabHtmlContent, LabJsonContent, LabTextContent } from 'itlab-functions';
2
2
  import { Document } from 'mongoose';
3
- export declare function ContentDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): new (...args: any[]) => InstanceType<TBase> & {
3
+ export declare function ContentDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): TBase & (new (...args: any[]) => {
4
4
  content?: LabJsonContent | LabHtmlContent | LabTextContent;
5
- };
5
+ });
@@ -2,4 +2,4 @@ import { Document } from 'mongoose';
2
2
  import { IsLikeable } from '../../types';
3
3
  export declare function LikeableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase, options?: {
4
4
  requiredPermissions?: string[];
5
- }): new (...args: any[]) => InstanceType<TBase> & IsLikeable;
5
+ }): TBase & (new (...args: any[]) => IsLikeable);
@@ -1,5 +1,5 @@
1
1
  import { Document } from 'mongoose';
2
- export declare function TimestampsDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): new (...args: any[]) => InstanceType<TBase> & {
2
+ export declare function TimestampsDocument<TBase extends new (...args: any[]) => Document>(Base: TBase): TBase & (new (...args: any[]) => {
3
3
  createdAt: Date;
4
4
  updatedAt: Date;
5
- };
5
+ });
@@ -2,4 +2,4 @@ import { Document } from 'mongoose';
2
2
  import { IsViewable } from '../../types';
3
3
  export declare function ViewableDocument<TBase extends new (...args: any[]) => Document>(Base: TBase, options?: {
4
4
  requiredPermissions?: string[];
5
- }): new (...args: any[]) => InstanceType<TBase> & IsViewable;
5
+ }): TBase & (new (...args: any[]) => IsViewable);
@@ -106,9 +106,10 @@ class BaseHttpService {
106
106
  if (ids && Array.isArray(ids)) {
107
107
  if (ids.length === 0)
108
108
  return [];
109
- if (ids.length > 50) {
109
+ const uniqueIds = new Set(ids);
110
+ if (uniqueIds.size > 50) {
110
111
  // Parallelize requests for each chunk; flatten the results into one array.
111
- const batchPromises = (0, itlab_functions_1.createChunks)(ids, 50).map((chunk) => {
112
+ const batchPromises = (0, itlab_functions_1.createChunks)(Array.from(uniqueIds), 50).map((chunk) => {
112
113
  const chunkConfig = Object.assign({}, config);
113
114
  chunkConfig.params.ids = chunk;
114
115
  return this.fetchResourceCollectionBatch(endpoint, chunkConfig);
@@ -1,18 +1,26 @@
1
- import { MailRecipient } from '../models';
1
+ import { MailAttachment, MailRecipient } from '../models';
2
2
  /**
3
3
  * Payload for sending a cancellation notification for an event.
4
4
  */
5
5
  export type EventUserCancellationMailDtoV1 = {
6
6
  recipient: MailRecipient;
7
7
  /**
8
- * Mode of participation (e.g., in person, online).
8
+ * Optional attachments
9
9
  */
10
- participation?: string;
10
+ attachments?: MailAttachment[];
11
+ /**
12
+ * Mode of participation (e.g., vor Ort, Online).
13
+ */
14
+ participation: string;
11
15
  /**
12
16
  * Title of the event that has been cancelled.
13
17
  * @example "Meetup"
14
18
  */
15
19
  title: string;
20
+ /**
21
+ * Series of the event.
22
+ */
23
+ series: string;
16
24
  /**
17
25
  * Human-readable date and time string of the event.
18
26
  * @example "17. April 2000 17:04–20:00 Uhr"
@@ -9,17 +9,29 @@ export type EventUserRegistrationMailDtoV1 = {
9
9
  */
10
10
  attachments?: MailAttachment[];
11
11
  /**
12
- * Mode of participation (e.g., in person, online).
12
+ * Mode of participation (e.g., vor Ort, Online).
13
13
  */
14
- participation?: string;
14
+ participation: string;
15
15
  /**
16
16
  * Title of the event.
17
17
  */
18
18
  title: string;
19
+ /**
20
+ * Summary of the event.
21
+ */
22
+ summary: string;
23
+ /**
24
+ * Series of the event.
25
+ */
26
+ series: string;
19
27
  /**
20
28
  * Date and time string describing the event.
21
29
  */
22
30
  dateString: string;
31
+ /**
32
+ * URL to join the event online
33
+ */
34
+ meetingUrl?: string;
23
35
  /**
24
36
  * URL linking to the event on the public hub.
25
37
  */
@@ -5,6 +5,7 @@ exports.ApiMongoIdsQuery = ApiMongoIdsQuery;
5
5
  const common_1 = require("@nestjs/common");
6
6
  const swagger_1 = require("@nestjs/swagger");
7
7
  const class_validator_1 = require("class-validator");
8
+ const transform_1 = require("../../transform");
8
9
  /**
9
10
  * ParseMongoIdsPipe
10
11
  *
@@ -23,13 +24,10 @@ class ParseMongoIdsPipe {
23
24
  * @returns {string[]} - Array of valid MongoDB IDs; returns empty array if input is invalid.
24
25
  */
25
26
  transform(value) {
26
- if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
27
- value = Object.values(value);
28
- }
29
- if (!Array.isArray(value))
27
+ const array = (0, transform_1.arrayTransform)(value, { unique: true });
28
+ if (!array)
30
29
  return undefined;
31
- const mongoIds = value.filter((v) => (0, class_validator_1.isMongoId)(v)).map((v) => String(v));
32
- return Array.from(new Set(mongoIds));
30
+ return array.filter((v) => (0, class_validator_1.isMongoId)(v)).map((v) => String(v));
33
31
  }
34
32
  }
35
33
  /**
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Options for ArrayTransform decorator.
3
+ */
4
+ type ArrayTransformOptions = {
5
+ unique?: boolean;
6
+ };
7
+ /**
8
+ * function to normalize and sanitize an array of any.
9
+ * Applies deduplication as configured.
10
+ *
11
+ * @param {any} value - Value to transform
12
+ * @param {ArrayTransformOptions} opts - Transformation configuration.
13
+ * @returns {any[]} - Transforms a property into a cleaned array.
14
+ */
15
+ export declare function arrayTransform(value: any, opts?: ArrayTransformOptions): any[] | undefined;
16
+ /**
17
+ * Property decorator to normalize and sanitize an array of any.
18
+ * Applies deduplication as configured.
19
+ *
20
+ * @param {ArrayTransformOptions} opts - Transformation configuration.
21
+ * @returns {PropertyDecorator} - Transforms a property into a cleaned array.
22
+ */
23
+ export declare function ArrayTransform(opts?: ArrayTransformOptions): PropertyDecorator;
24
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.arrayTransform = arrayTransform;
4
+ exports.ArrayTransform = ArrayTransform;
5
+ const class_transformer_1 = require("class-transformer");
6
+ /**
7
+ * function to normalize and sanitize an array of any.
8
+ * Applies deduplication as configured.
9
+ *
10
+ * @param {any} value - Value to transform
11
+ * @param {ArrayTransformOptions} opts - Transformation configuration.
12
+ * @returns {any[]} - Transforms a property into a cleaned array.
13
+ */
14
+ function arrayTransform(value, opts = {}) {
15
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
16
+ value = Object.values(value);
17
+ }
18
+ if (!Array.isArray(value))
19
+ return undefined;
20
+ if (!opts.unique)
21
+ return value;
22
+ return Array.from(new Set(value));
23
+ }
24
+ /**
25
+ * Property decorator to normalize and sanitize an array of any.
26
+ * Applies deduplication as configured.
27
+ *
28
+ * @param {ArrayTransformOptions} opts - Transformation configuration.
29
+ * @returns {PropertyDecorator} - Transforms a property into a cleaned array.
30
+ */
31
+ function ArrayTransform(opts = {}) {
32
+ return (0, class_transformer_1.Transform)(({ value }) => {
33
+ return arrayTransform(value, opts);
34
+ });
35
+ }
@@ -1,3 +1,4 @@
1
+ export * from './array.transform';
1
2
  export * from './boolean.transform';
2
3
  export * from './image-url.transform';
3
4
  export * from './mongo-id.transform';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./array.transform"), exports);
17
18
  __exportStar(require("./boolean.transform"), exports);
18
19
  __exportStar(require("./image-url.transform"), exports);
19
20
  __exportStar(require("./mongo-id.transform"), exports);
@@ -3,17 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MongoIdsTransform = MongoIdsTransform;
4
4
  const class_transformer_1 = require("class-transformer");
5
5
  const class_validator_1 = require("class-validator");
6
+ const array_transform_1 = require("./array.transform");
6
7
  /**
7
8
  * @returns {PropertyDecorator} - Transforms a property to a boolean.
8
9
  */
9
10
  function MongoIdsTransform() {
10
11
  return (0, class_transformer_1.Transform)(({ value }) => {
11
- if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
12
- value = Object.values(value);
13
- }
14
- if (!Array.isArray(value))
12
+ const array = (0, array_transform_1.arrayTransform)(value, { unique: true });
13
+ if (!array)
15
14
  return undefined;
16
- const mongoIds = value.filter((v) => (0, class_validator_1.isMongoId)(v)).map((v) => String(v));
17
- return Array.from(new Set(mongoIds));
15
+ return array.filter((v) => (0, class_validator_1.isMongoId)(v)).map((v) => String(v));
18
16
  });
19
17
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringArrayTransform = StringArrayTransform;
4
4
  const class_transformer_1 = require("class-transformer");
5
+ const array_transform_1 = require("./array.transform");
5
6
  /**
6
7
  * Property decorator to normalize and sanitize an array of strings.
7
8
  * Applies trimming, lowercasing, and deduplication as configured.
@@ -11,12 +12,10 @@ const class_transformer_1 = require("class-transformer");
11
12
  */
12
13
  function StringArrayTransform(opts = {}) {
13
14
  return (0, class_transformer_1.Transform)(({ value }) => {
14
- if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
15
- value = Object.values(value);
16
- }
17
- if (!Array.isArray(value))
15
+ const array = (0, array_transform_1.arrayTransform)(value, opts);
16
+ if (!array)
18
17
  return undefined;
19
- const transformedValue = value.map((value) => {
18
+ return array.map((value) => {
20
19
  let str = String(value);
21
20
  if (opts.trim)
22
21
  str = str.trim();
@@ -24,8 +23,5 @@ function StringArrayTransform(opts = {}) {
24
23
  str = str.toLowerCase();
25
24
  return str;
26
25
  });
27
- if (!opts.unique)
28
- return transformedValue;
29
- return Array.from(new Set(transformedValue));
30
26
  });
31
27
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Timo Scheuermann",
5
5
  "email": "timo.scheuermann@sv-informatik.de"
6
6
  },
7
- "version": "2.16.20",
7
+ "version": "2.16.22",
8
8
  "type": "commonjs",
9
9
  "files": [
10
10
  "dist"