itlab-internal-services 2.16.21 → 2.16.23
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/classes/entity-map.class.d.ts +1 -1
- package/dist/classes/entity-map.class.js +2 -1
- package/dist/hub-resource.enum.d.ts +1 -1
- package/dist/hub-resource.enum.js +2 -2
- package/dist/modules/services/base-http.service.js +3 -2
- package/dist/modules/services/providers/hackschool/hackschool.service.d.ts +1 -23
- package/dist/modules/services/providers/hackschool/hackschool.service.js +0 -28
- package/dist/modules/services/providers/hackschool/index.d.ts +1 -0
- package/dist/modules/services/providers/hackschool/index.js +1 -0
- package/dist/modules/services/providers/mail/dtos/event-user-cancellation-mail.dto.v1.d.ts +11 -3
- package/dist/modules/services/providers/mail/dtos/event-user-registration-mail.dto.v1.d.ts +14 -2
- package/dist/modules/services/providers/tech-radar/fetch-tech-scout-options.dto.v1.type.d.ts +22 -0
- package/dist/modules/services/providers/tech-radar/index.d.ts +2 -1
- package/dist/modules/services/providers/tech-radar/index.js +2 -1
- package/dist/modules/services/providers/tech-radar/tech-radar.service.d.ts +24 -2
- package/dist/modules/services/providers/tech-radar/tech-radar.service.js +28 -0
- package/dist/pipes/queries/mongo-ids.pipe.js +4 -6
- package/dist/transform/array.transform.d.ts +24 -0
- package/dist/transform/array.transform.js +35 -0
- package/dist/transform/index.d.ts +1 -0
- package/dist/transform/index.js +1 -0
- package/dist/transform/mongo-ids.transform.js +4 -6
- package/dist/transform/string-array.transform.js +4 -8
- package/package.json +2 -2
- package/dist/modules/services/providers/hackschool/fetch-thread-options.dto.v1.type.d.ts +0 -18
- /package/dist/modules/services/providers/tech-radar/{fetch-edition-options.dto.v1.type copy.d.ts → fetch-edition-options.dto.v1.type.d.ts} +0 -0
- /package/dist/modules/services/providers/{hackschool/fetch-thread-options.dto.v1.type.js → tech-radar/fetch-edition-options.dto.v1.type.js} +0 -0
- /package/dist/modules/services/providers/tech-radar/{fetch-edition-options.dto.v1.type copy.js → fetch-tech-scout-options.dto.v1.type.js} +0 -0
|
@@ -9,7 +9,7 @@ export declare class EntityMap<T extends {
|
|
|
9
9
|
* @param map Map of id -> user/account object
|
|
10
10
|
* @returns user/account object
|
|
11
11
|
*/
|
|
12
|
-
get(id: string): T;
|
|
12
|
+
get(id: string): T | undefined;
|
|
13
13
|
/**
|
|
14
14
|
* Maps an array of IDs to user/account objects using a user/account Map.
|
|
15
15
|
* Filters out any IDs that don’t have a corresponding entity.
|
|
@@ -24,7 +24,8 @@ class EntityMap {
|
|
|
24
24
|
getMultiple(ids) {
|
|
25
25
|
if (!ids || ids.length === 0)
|
|
26
26
|
return [];
|
|
27
|
-
|
|
27
|
+
const entities = ids.map((id) => this.map.get(id));
|
|
28
|
+
return entities.filter(Boolean);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
exports.EntityMap = EntityMap;
|
|
@@ -21,11 +21,11 @@ export declare enum HubResource {
|
|
|
21
21
|
NEWSROOM_NEWS = "newsroom-news",
|
|
22
22
|
EVENTS_EVENT = "events-event",
|
|
23
23
|
HACKSCHOOL_COURSE = "hackschool-course",
|
|
24
|
-
HACKSCHOOL_THREAD = "hackschool-thread",
|
|
25
24
|
HACKSCHOOL_DOC = "hackschool-doc",
|
|
26
25
|
DEMO_HIVE_DEMO = "demo-hive-demo",
|
|
27
26
|
TECH_RADAR_BLIP = "tech-radar-blip",
|
|
28
27
|
TECH_RADAR_EDITION = "tech-radar-edition",
|
|
28
|
+
TECH_RADAR_TECH_SCOUT = "tech-radar-tech-scout",
|
|
29
29
|
PODCASTS_EPISODE = "podcasts-podcast",
|
|
30
30
|
BOOKS_BOOK = "books-book",
|
|
31
31
|
TEAM_MEMBER = "team-member",
|
|
@@ -25,11 +25,11 @@ var HubResource;
|
|
|
25
25
|
HubResource["NEWSROOM_NEWS"] = "newsroom-news";
|
|
26
26
|
HubResource["EVENTS_EVENT"] = "events-event";
|
|
27
27
|
HubResource["HACKSCHOOL_COURSE"] = "hackschool-course";
|
|
28
|
-
HubResource["HACKSCHOOL_THREAD"] = "hackschool-thread";
|
|
29
28
|
HubResource["HACKSCHOOL_DOC"] = "hackschool-doc";
|
|
30
29
|
HubResource["DEMO_HIVE_DEMO"] = "demo-hive-demo";
|
|
31
30
|
HubResource["TECH_RADAR_BLIP"] = "tech-radar-blip";
|
|
32
31
|
HubResource["TECH_RADAR_EDITION"] = "tech-radar-edition";
|
|
32
|
+
HubResource["TECH_RADAR_TECH_SCOUT"] = "tech-radar-tech-scout";
|
|
33
33
|
HubResource["PODCASTS_EPISODE"] = "podcasts-podcast";
|
|
34
34
|
HubResource["BOOKS_BOOK"] = "books-book";
|
|
35
35
|
HubResource["TEAM_MEMBER"] = "team-member";
|
|
@@ -54,11 +54,11 @@ exports.HUB_RESOURCES = [
|
|
|
54
54
|
HubResource.NEWSROOM_NEWS,
|
|
55
55
|
HubResource.EVENTS_EVENT,
|
|
56
56
|
HubResource.HACKSCHOOL_COURSE,
|
|
57
|
-
HubResource.HACKSCHOOL_THREAD,
|
|
58
57
|
HubResource.HACKSCHOOL_DOC,
|
|
59
58
|
HubResource.DEMO_HIVE_DEMO,
|
|
60
59
|
HubResource.TECH_RADAR_BLIP,
|
|
61
60
|
HubResource.TECH_RADAR_EDITION,
|
|
61
|
+
HubResource.TECH_RADAR_TECH_SCOUT,
|
|
62
62
|
HubResource.PODCASTS_EPISODE,
|
|
63
63
|
HubResource.BOOKS_BOOK,
|
|
64
64
|
HubResource.TEAM_MEMBER,
|
|
@@ -106,9 +106,10 @@ class BaseHttpService {
|
|
|
106
106
|
if (ids && Array.isArray(ids)) {
|
|
107
107
|
if (ids.length === 0)
|
|
108
108
|
return [];
|
|
109
|
-
|
|
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)(
|
|
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,10 +1,9 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { LabHackschoolCourse, LabHackschoolDoc
|
|
2
|
+
import { LabHackschoolCourse, LabHackschoolDoc } from 'itlab-functions';
|
|
3
3
|
import { AuthenticationModuleOptions } from '../../../authentication';
|
|
4
4
|
import { BaseHttpService } from '../../base-http.service';
|
|
5
5
|
import { FetchCourseOptionsDtoV1 } from './fetch-course-options.dto.v1.type';
|
|
6
6
|
import { FetchDocOptionsDtoV1 } from './fetch-doc-options.dto.v1.type';
|
|
7
|
-
import { FetchThreadOptionsDtoV1 } from './fetch-thread-options.dto.v1.type';
|
|
8
7
|
/**
|
|
9
8
|
* HackschoolService
|
|
10
9
|
*
|
|
@@ -48,27 +47,6 @@ export declare class HackschoolService extends BaseHttpService {
|
|
|
48
47
|
* @returns {Promise<LabHackschoolCourse[]>} Resolves to a list of courses, or an empty array if none found.
|
|
49
48
|
*/
|
|
50
49
|
fetchCourseCollectionV1(options?: FetchCourseOptionsDtoV1): Promise<LabHackschoolCourse[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves a single thread entry by its MongoDB identifier.
|
|
53
|
-
*
|
|
54
|
-
* This method gracefully handles downstream failures by logging
|
|
55
|
-
* and returning `undefined` instead of throwing.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} threadId - Unique MongoDB identifier of the thread.
|
|
58
|
-
* @param {FetchThreadOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
59
|
-
* @returns {Promise<LabHackschoolThread | undefined>} Resolves to an Thread or `undefined` on failure.
|
|
60
|
-
*/
|
|
61
|
-
fetchThreadV1(threadId: string, options?: FetchThreadOptionsDtoV1): Promise<LabHackschoolThread | undefined>;
|
|
62
|
-
/**
|
|
63
|
-
* Retrieves a collection of thread entries.
|
|
64
|
-
*
|
|
65
|
-
* Useful for batch lookups or paginated listings.
|
|
66
|
-
* Returns an empty array if the downstream service call fails.
|
|
67
|
-
*
|
|
68
|
-
* @param {FetchThreadOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
69
|
-
* @returns {Promise<LabHackschoolThread[]>} Resolves to a list of threads, or an empty array if none found.
|
|
70
|
-
*/
|
|
71
|
-
fetchThreadCollectionV1(options?: FetchThreadOptionsDtoV1): Promise<LabHackschoolThread[]>;
|
|
72
50
|
/**
|
|
73
51
|
* Retrieves a single doc entry by its MongoDB identifier.
|
|
74
52
|
*
|
|
@@ -71,34 +71,6 @@ let HackschoolService = class HackschoolService extends base_http_service_1.Base
|
|
|
71
71
|
return this.fetchResourceCollection(`v1/internal/courses`, { params: options });
|
|
72
72
|
}
|
|
73
73
|
// ─────────────────────────────────────────────────────────────
|
|
74
|
-
// Thread Resource Methods
|
|
75
|
-
// ─────────────────────────────────────────────────────────────
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves a single thread entry by its MongoDB identifier.
|
|
78
|
-
*
|
|
79
|
-
* This method gracefully handles downstream failures by logging
|
|
80
|
-
* and returning `undefined` instead of throwing.
|
|
81
|
-
*
|
|
82
|
-
* @param {string} threadId - Unique MongoDB identifier of the thread.
|
|
83
|
-
* @param {FetchThreadOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
84
|
-
* @returns {Promise<LabHackschoolThread | undefined>} Resolves to an Thread or `undefined` on failure.
|
|
85
|
-
*/
|
|
86
|
-
async fetchThreadV1(threadId, options) {
|
|
87
|
-
return this.fetchResource(`v1/internal/thread/${threadId}`, { params: options });
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves a collection of thread entries.
|
|
91
|
-
*
|
|
92
|
-
* Useful for batch lookups or paginated listings.
|
|
93
|
-
* Returns an empty array if the downstream service call fails.
|
|
94
|
-
*
|
|
95
|
-
* @param {FetchThreadOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
96
|
-
* @returns {Promise<LabHackschoolThread[]>} Resolves to a list of threads, or an empty array if none found.
|
|
97
|
-
*/
|
|
98
|
-
async fetchThreadCollectionV1(options) {
|
|
99
|
-
return this.fetchResourceCollection(`v1/internal/threads`, { params: options });
|
|
100
|
-
}
|
|
101
|
-
// ─────────────────────────────────────────────────────────────
|
|
102
74
|
// Doc Resource Methods
|
|
103
75
|
// ─────────────────────────────────────────────────────────────
|
|
104
76
|
/**
|
|
@@ -14,5 +14,6 @@ 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("./fetch-course-options.dto.v1.type"), exports);
|
|
17
18
|
__exportStar(require("./fetch-doc-options.dto.v1.type"), exports);
|
|
18
19
|
__exportStar(require("./hackschool.service"), exports);
|
|
@@ -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
|
-
*
|
|
8
|
+
* Optional attachments
|
|
9
9
|
*/
|
|
10
|
-
|
|
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.,
|
|
12
|
+
* Mode of participation (e.g., vor Ort, Online).
|
|
13
13
|
*/
|
|
14
|
-
participation
|
|
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
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseFetchOptions, DraftedFetchOptions, TimestampsFetchOptions } from '../../../../classes';
|
|
2
|
+
/**
|
|
3
|
+
* FetchTechScoutOptionsDtoV1
|
|
4
|
+
*
|
|
5
|
+
* Data Transfer Object for querying tech scout collections.
|
|
6
|
+
* Inherits timestamp filtering fields and extends them with
|
|
7
|
+
* tech-scout-specific query parameters.
|
|
8
|
+
*/
|
|
9
|
+
export type FetchTechScoutOptionsDtoV1 = BaseFetchOptions & TimestampsFetchOptions & DraftedFetchOptions & {
|
|
10
|
+
includeAccount?: boolean;
|
|
11
|
+
includeEditionIds?: boolean;
|
|
12
|
+
includeEditions?: boolean;
|
|
13
|
+
includeBlipIds?: boolean;
|
|
14
|
+
includeBlips?: boolean;
|
|
15
|
+
isActive?: boolean;
|
|
16
|
+
accountId?: string;
|
|
17
|
+
accountIds?: string[];
|
|
18
|
+
department?: string;
|
|
19
|
+
departments?: string[];
|
|
20
|
+
role?: string;
|
|
21
|
+
roles?: string[];
|
|
22
|
+
};
|
|
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./fetch-blip-options.dto.v1.type"), exports);
|
|
18
|
-
__exportStar(require("./fetch-edition-options.dto.v1.type
|
|
18
|
+
__exportStar(require("./fetch-edition-options.dto.v1.type"), exports);
|
|
19
|
+
__exportStar(require("./fetch-tech-scout-options.dto.v1.type"), exports);
|
|
19
20
|
__exportStar(require("./tech-radar.service"), exports);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { LabTechRadarBlip, LabTechRadarEdition } from 'itlab-functions';
|
|
2
|
+
import { LabTechRadarBlip, LabTechRadarEdition, LabTechRadarTechScout } from 'itlab-functions';
|
|
3
3
|
import { AuthenticationModuleOptions } from '../../../authentication';
|
|
4
4
|
import { BaseHttpService } from '../../base-http.service';
|
|
5
5
|
import { FetchBlipOptionsDtoV1 } from './fetch-blip-options.dto.v1.type';
|
|
6
|
-
import { FetchEditionOptionsDtoV1 } from './fetch-edition-options.dto.v1.type
|
|
6
|
+
import { FetchEditionOptionsDtoV1 } from './fetch-edition-options.dto.v1.type';
|
|
7
|
+
import { FetchTechScoutOptionsDtoV1 } from './fetch-tech-scout-options.dto.v1.type';
|
|
7
8
|
/**
|
|
8
9
|
* TechRadarService
|
|
9
10
|
*
|
|
@@ -68,4 +69,25 @@ export declare class TechRadarService extends BaseHttpService {
|
|
|
68
69
|
* @returns {Promise<LabTechRadarEdition[]>} Resolves to a list of editions, or an empty array if none found.
|
|
69
70
|
*/
|
|
70
71
|
fetchEditionCollectionV1(options?: FetchEditionOptionsDtoV1): Promise<LabTechRadarEdition[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves a single tech scout entry by its MongoDB identifier.
|
|
74
|
+
*
|
|
75
|
+
* This method gracefully handles downstream failures by logging
|
|
76
|
+
* and returning `undefined` instead of throwing.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} techScoutId - Unique MongoDB identifier of the tech scout.
|
|
79
|
+
* @param {FetchTechScoutOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
80
|
+
* @returns {Promise<LabTechRadarTechScout | undefined>} Resolves to an Tech Scout or `undefined` on failure.
|
|
81
|
+
*/
|
|
82
|
+
fetchTechScoutV1(techScoutId: string, options?: FetchTechScoutOptionsDtoV1): Promise<LabTechRadarTechScout | undefined>;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves a collection of tech scout entries.
|
|
85
|
+
*
|
|
86
|
+
* Useful for batch lookups or paginated listings.
|
|
87
|
+
* Returns an empty array if the downstream service call fails.
|
|
88
|
+
*
|
|
89
|
+
* @param {FetchTechScoutOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
90
|
+
* @returns {Promise<LabTechRadarTechScout[]>} Resolves to a list of tech scouts, or an empty array if none found.
|
|
91
|
+
*/
|
|
92
|
+
fetchTechScoutCollectionV1(options?: FetchTechScoutOptionsDtoV1): Promise<LabTechRadarTechScout[]>;
|
|
71
93
|
}
|
|
@@ -98,6 +98,34 @@ let TechRadarService = class TechRadarService extends base_http_service_1.BaseHt
|
|
|
98
98
|
async fetchEditionCollectionV1(options) {
|
|
99
99
|
return this.fetchResourceCollection(`v1/internal/editions`, { params: options });
|
|
100
100
|
}
|
|
101
|
+
// ─────────────────────────────────────────────────────────────
|
|
102
|
+
// Tech Scout Resource Methods
|
|
103
|
+
// ─────────────────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves a single tech scout entry by its MongoDB identifier.
|
|
106
|
+
*
|
|
107
|
+
* This method gracefully handles downstream failures by logging
|
|
108
|
+
* and returning `undefined` instead of throwing.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} techScoutId - Unique MongoDB identifier of the tech scout.
|
|
111
|
+
* @param {FetchTechScoutOptionsDtoV1} [options] - Optional query parameters for filtering or projection.
|
|
112
|
+
* @returns {Promise<LabTechRadarTechScout | undefined>} Resolves to an Tech Scout or `undefined` on failure.
|
|
113
|
+
*/
|
|
114
|
+
async fetchTechScoutV1(techScoutId, options) {
|
|
115
|
+
return this.fetchResource(`v1/internal/tech-scout/${techScoutId}`, { params: options });
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves a collection of tech scout entries.
|
|
119
|
+
*
|
|
120
|
+
* Useful for batch lookups or paginated listings.
|
|
121
|
+
* Returns an empty array if the downstream service call fails.
|
|
122
|
+
*
|
|
123
|
+
* @param {FetchTechScoutOptionsDtoV1} [options] - Optional filter options for narrowing results.
|
|
124
|
+
* @returns {Promise<LabTechRadarTechScout[]>} Resolves to a list of tech scouts, or an empty array if none found.
|
|
125
|
+
*/
|
|
126
|
+
async fetchTechScoutCollectionV1(options) {
|
|
127
|
+
return this.fetchResourceCollection(`v1/internal/tech-scouts`, { params: options });
|
|
128
|
+
}
|
|
101
129
|
};
|
|
102
130
|
exports.TechRadarService = TechRadarService;
|
|
103
131
|
exports.TechRadarService = TechRadarService = __decorate([
|
|
@@ -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
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (!Array.isArray(value))
|
|
27
|
+
const array = (0, transform_1.arrayTransform)(value, { unique: true });
|
|
28
|
+
if (!array)
|
|
30
29
|
return undefined;
|
|
31
|
-
|
|
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
|
+
}
|
package/dist/transform/index.js
CHANGED
|
@@ -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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
if (!Array.isArray(value))
|
|
15
|
+
const array = (0, array_transform_1.arrayTransform)(value, opts);
|
|
16
|
+
if (!array)
|
|
18
17
|
return undefined;
|
|
19
|
-
|
|
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.
|
|
7
|
+
"version": "2.16.23",
|
|
8
8
|
"type": "commonjs",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"cache-manager": "^7.2.4",
|
|
36
36
|
"class-transformer": "^0.5.1",
|
|
37
37
|
"class-validator": "^0.14.2",
|
|
38
|
-
"itlab-functions": "^1.0.
|
|
38
|
+
"itlab-functions": "^1.0.13",
|
|
39
39
|
"mongoose": "^8.19.2",
|
|
40
40
|
"rxjs": "^7.8.2"
|
|
41
41
|
},
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseFetchOptions, CommentsFetchOptions, ContentFetchOptions, ViewedByFetchOptions } from '../../../../classes';
|
|
2
|
-
/**
|
|
3
|
-
* FetchThreadOptionsDtoV1
|
|
4
|
-
*
|
|
5
|
-
* Data Transfer Object for querying thread collections.
|
|
6
|
-
* Inherits timestamp filtering fields and extends them with
|
|
7
|
-
* thread-specific query parameters.
|
|
8
|
-
*/
|
|
9
|
-
export type FetchThreadOptionsDtoV1 = BaseFetchOptions & ContentFetchOptions & ViewedByFetchOptions & CommentsFetchOptions & {
|
|
10
|
-
includeAuthor?: boolean;
|
|
11
|
-
isClosed?: boolean;
|
|
12
|
-
tag?: string;
|
|
13
|
-
tags?: string[];
|
|
14
|
-
authorId?: string;
|
|
15
|
-
authorIds?: string[];
|
|
16
|
-
timestampMin?: number;
|
|
17
|
-
timestampMax?: number;
|
|
18
|
-
};
|
|
File without changes
|
|
File without changes
|