@edifice.io/communities-tests 1.0.0-develop-pedago.9.1753990538887 → 1.1.3

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.
@@ -0,0 +1,46 @@
1
+ //Response type: wrap either an error code or a response entity from HTTP calls
2
+ export type HttpResponse<T> = Either<HttpError, T>;
3
+
4
+ //Http Error type, for use in the k6 function checkReturnCode
5
+ export type HttpError = {
6
+ status: number;
7
+ };
8
+
9
+ //Helper functions to create success or failure http responses
10
+ export function failure<T>(status: number): HttpResponse<T> {
11
+ return left({ status });
12
+ }
13
+ export function success<T>(result: T): HttpResponse<T> {
14
+ return right(result);
15
+ }
16
+
17
+ //Either type with Left and Right classes
18
+ type Either<L, R> = Left<L> | Right<R>;
19
+
20
+ class Left<L> {
21
+ constructor(public readonly value: L) {}
22
+ isLeft(): this is Left<L> {
23
+ return true;
24
+ }
25
+ isRight(): this is Right<unknown> {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ class Right<R> {
31
+ constructor(public readonly value: R) {}
32
+ isLeft(): this is Left<unknown> {
33
+ return false;
34
+ }
35
+ isRight(): this is Right<R> {
36
+ return true;
37
+ }
38
+ }
39
+
40
+ //Helper functions to create instances of Left and Right
41
+ function left<L, R>(l: L): Either<L, R> {
42
+ return new Left(l);
43
+ }
44
+ function right<L, R>(r: R): Either<L, R> {
45
+ return new Right(r);
46
+ }
@@ -191,54 +191,54 @@ export function listMyInvitations(
191
191
  seeLater?: boolean;
192
192
  communityId?: number;
193
193
  fields?: string[];
194
- } = {}
194
+ } = {},
195
195
  ): PaginatedInvitations | null {
196
196
  try {
197
197
  let url = `${rootUrl}/communities/api/invitations`;
198
198
  const queryParams = new URLSearchParams();
199
-
199
+
200
200
  // Add pagination parameters
201
201
  if (options.page) {
202
202
  queryParams.append("page", options.page.toString());
203
203
  }
204
-
204
+
205
205
  if (options.size) {
206
206
  queryParams.append("size", options.size.toString());
207
207
  }
208
-
208
+
209
209
  // Add filters
210
210
  if (options.status) {
211
211
  queryParams.append("status", options.status);
212
212
  }
213
-
213
+
214
214
  if (options.seeLater !== undefined) {
215
215
  queryParams.append("seelater", options.seeLater.toString());
216
216
  }
217
-
217
+
218
218
  if (options.communityId) {
219
219
  queryParams.append("communityid", options.communityId.toString());
220
220
  }
221
-
221
+
222
222
  // Add fields to include
223
223
  if (options.fields && options.fields.length > 0) {
224
- options.fields.forEach(field => {
224
+ options.fields.forEach((field) => {
225
225
  queryParams.append("fields", field);
226
226
  });
227
227
  }
228
-
228
+
229
229
  // Add query string to URL if there are parameters
230
230
  const queryString = queryParams.toString();
231
231
  if (queryString) {
232
232
  url += `?${queryString}`;
233
233
  }
234
-
234
+
235
235
  const response = http.get(url, { headers: getHeaders() });
236
-
236
+
237
237
  if (response.status === 200) {
238
238
  return JSON.parse(<string>response.body);
239
239
  } else {
240
240
  console.error(
241
- `Failed to list invitations: ${response.status} ${response.body}`
241
+ `Failed to list invitations: ${response.status} ${response.body}`,
242
242
  );
243
243
  return null;
244
244
  }
@@ -426,23 +426,21 @@ export function updateRequestStatus(
426
426
  */
427
427
  export function updateInvitationSeeLater(
428
428
  invitationId: number | string,
429
- seeLater: boolean
429
+ seeLater: boolean,
430
430
  ): Invitation | null {
431
431
  try {
432
432
  const url = `${rootUrl}/communities/api/invitations/${invitationId}/see-later`;
433
433
  const payload = { seeLater };
434
-
435
- const response = http.put(
436
- url,
437
- JSON.stringify(payload),
438
- { headers: { ...getHeaders(), "Content-Type": "application/json" } }
439
- );
440
-
434
+
435
+ const response = http.put(url, JSON.stringify(payload), {
436
+ headers: { ...getHeaders(), "Content-Type": "application/json" },
437
+ });
438
+
441
439
  if (response.status === 200 || response.status === 201) {
442
440
  return JSON.parse(<string>response.body);
443
441
  } else {
444
442
  console.error(
445
- `Failed to update see-later flag: ${response.status} ${response.body}`
443
+ `Failed to update see-later flag: ${response.status} ${response.body}`,
446
444
  );
447
445
  return null;
448
446
  }
@@ -35,6 +35,7 @@ export type CreateResourceParams = {
35
35
  resourceUrl?: string;
36
36
  openInNewTab?: boolean;
37
37
  resourceEntId?: string;
38
+ folderId?: number;
38
39
  };
39
40
 
40
41
  export type UpdateResourceParams = {
@@ -65,7 +66,7 @@ export type Resource = {
65
66
  displayName: string;
66
67
  };
67
68
  communityId: number;
68
- folderIds: number[];
69
+ folderId?: number;
69
70
  };
70
71
 
71
72
  export type PageMetadata = {
@@ -261,8 +262,9 @@ export function listResourcesWithSearch(
261
262
  addedAfter?: string;
262
263
  sortBy?: string;
263
264
  sortDirection?: SortDirection;
264
- } = {}
265
- ) : ResourcesResponse | null {
265
+ folderId?: number;
266
+ } = {},
267
+ ): ResourcesResponse | null {
266
268
  const {
267
269
  page = 1,
268
270
  size = 10,
@@ -271,22 +273,27 @@ export function listResourcesWithSearch(
271
273
  addedAfter,
272
274
  sortBy,
273
275
  sortDirection,
276
+ folderId,
274
277
  } = options;
275
278
 
276
279
  let url = `${rootUrl}/communities/api/communities/${communityId}/resources?page=${page}&size=${size}`;
277
-
280
+
278
281
  if (search) url += `&search=${encodeURIComponent(search)}`;
279
282
  if (type) url += `&type=${encodeURIComponent(type)}`;
283
+ if (folderId) url += `&folderId=${encodeURIComponent(folderId)}`;
280
284
  if (addedAfter) url += `&addedafter=${encodeURIComponent(addedAfter)}`;
281
285
  if (sortBy) url += `&sortby=${encodeURIComponent(sortBy)}`;
282
- if (sortDirection) url += `&sortdirection=${encodeURIComponent(sortDirection)}`;
286
+ if (sortDirection)
287
+ url += `&sortdirection=${encodeURIComponent(sortDirection)}`;
283
288
 
284
289
  const response = http.get(url, { headers: getHeaders() });
285
290
 
286
291
  if (response.status === 200) {
287
292
  return JSON.parse(response.body as string);
288
293
  }
289
-
290
- console.error(`Failed to list resources: ${response.status} - ${response.body}`);
294
+
295
+ console.error(
296
+ `Failed to list resources: ${response.status} - ${response.body}`,
297
+ );
291
298
  return null;
292
299
  }
@@ -1,5 +1,9 @@
1
1
  import http from "k6/http";
2
- import { getHeaders, getRoleByName, Role } from "../../../node_modules/edifice-k6-commons/dist/index.js";
2
+ import {
3
+ getHeaders,
4
+ getRoleByName,
5
+ Role,
6
+ } from "../../../node_modules/edifice-k6-commons/dist/index.js";
3
7
  import { check } from "k6";
4
8
 
5
9
  const rootUrl = __ENV.ROOT_URL || "";
@@ -15,8 +19,12 @@ export function createAndSetAllRoles(): Role {
15
19
  { headers: getHeaders() },
16
20
  );
17
21
  check(res, { "get workflow actions": (r) => r.status == 200 });
18
- const applications = JSON.parse(<string>res.body) as Array<{actions: string[]}>;
19
- const actions = applications.flatMap(application => application.actions.map((entries) => entries[0]));
22
+ const applications = JSON.parse(<string>res.body) as Array<{
23
+ actions: string[];
24
+ }>;
25
+ const actions = applications.flatMap((application) =>
26
+ application.actions.map((entries) => entries[0]),
27
+ );
20
28
  const headers = getHeaders();
21
29
  headers["content-type"] = "application/json";
22
30
  const payload = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/communities-tests",
3
- "version": "1.0.0-develop-pedago.9.1753990538887",
3
+ "version": "1.1.3",
4
4
  "description": "Common functions for testing module community with K6.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,22 +27,14 @@
27
27
  "husky": "^9.0.11",
28
28
  "prettier": "^3.2.5",
29
29
  "semantic-release": "^23.0.2",
30
- "typescript": "^5.2.2",
31
30
  "vite": "^5.1.4",
32
31
  "vite-plugin-dts": "^4.3.0"
33
32
  },
34
- "lint-staged": {
35
- "*.{js,ts,jsx,tsx,json,css,md}": "pnpm format"
36
- },
37
33
  "scripts": {
38
34
  "dev": "vite",
39
35
  "build": "tsc && vite build",
40
36
  "build:types": "tsc --build",
41
37
  "preview": "vite preview",
42
- "clean": "rm -Rf dist",
43
- "format": "pnpm run format:write && pnpm run format:check",
44
- "format:check": "npx prettier --check \"src/**/*.ts\"",
45
- "format:write": "npx prettier --write \"src/**/*.ts\"",
46
- "pre-commit": "pnpm run format"
38
+ "clean": "rm -Rf dist"
47
39
  }
48
40
  }
@@ -0,0 +1,73 @@
1
+ // Types automatically generated from DTOs using TypeScript Compiler API
2
+ // Category: announcement
3
+ // Generated on: 2025-12-02T09:34:02.434Z
4
+
5
+ import {
6
+ PageMetadataDto,
7
+ PaginationQueryDto,
8
+ SortDirection,
9
+ UserDto,
10
+ } from "./base";
11
+
12
+ export enum MediaType {
13
+ AUDIO = "audio",
14
+ VIDEO = "video",
15
+ IMAGE = "image",
16
+ ATTACHMENT = "attachment",
17
+ EMBEDDER = "embedder",
18
+ HYPERLINK = "hyperlink",
19
+ STUDIO = "studio",
20
+ }
21
+
22
+ export enum AnnouncementSortField {
23
+ PUBLICATION_DATE = "publicationDate",
24
+ MODIFICATION_DATE = "modificationDate",
25
+ }
26
+
27
+ export interface MediaDto {
28
+ id: string;
29
+ name: string;
30
+ type: MediaType;
31
+ mimeType: string;
32
+ url: string;
33
+ }
34
+
35
+ export interface AnnouncementDto {
36
+ id: number;
37
+ content: string;
38
+ publicationDate: Date;
39
+ modificationDate?: Date;
40
+ author: UserDto;
41
+ modifier?: UserDto;
42
+ media: MediaDto[];
43
+ communityId: number;
44
+ }
45
+
46
+ export interface CreateAnnouncementDto {
47
+ content: string;
48
+ media: MediaDto[];
49
+ }
50
+
51
+ export interface UpdateAnnouncementDto {
52
+ content: string;
53
+ media: MediaDto[];
54
+ }
55
+
56
+ export interface CountAnnouncementDto {
57
+ count: number;
58
+ }
59
+
60
+ export interface SearchAnnouncementDto extends PaginationQueryDto {
61
+ publishedAfter?: Date;
62
+ sortBy?: AnnouncementSortField;
63
+ sortDirection?: SortDirection;
64
+ }
65
+
66
+ export interface SearchAnnouncementResponseDto {
67
+ items: AnnouncementDto[];
68
+ meta: PageMetadataDto;
69
+ }
70
+
71
+ export interface CountAnnouncementsDto {
72
+ count: number;
73
+ }
@@ -0,0 +1,32 @@
1
+ // Types automatically generated from DTOs using TypeScript Compiler API
2
+ // Category: base
3
+ // Generated on: 2025-12-02T09:34:02.436Z
4
+
5
+ export enum SortDirection {
6
+ ASC = "ASC",
7
+ DESC = "DESC",
8
+ }
9
+
10
+ export interface PaginationQueryDto {
11
+ page?: number;
12
+ size?: number;
13
+ }
14
+
15
+ export interface PageMetadataDto {
16
+ totalItems: number;
17
+ itemCount: number;
18
+ itemsPerPage: number;
19
+ totalPages: number;
20
+ currentPage: number;
21
+ }
22
+
23
+ export interface FieldSelectionDto {
24
+ fields?: string;
25
+ }
26
+
27
+ export interface UserDto {
28
+ id: number;
29
+ displayName: string;
30
+ entId: string;
31
+ profile: string;
32
+ }
@@ -0,0 +1,97 @@
1
+ // Types automatically generated from DTOs using TypeScript Compiler API
2
+ // Category: community
3
+ // Generated on: 2025-12-02T09:34:02.436Z
4
+
5
+ import { InvitedUserDto } from "./invitation";
6
+ import {
7
+ PageMetadataDto,
8
+ PaginationQueryDto,
9
+ SortDirection,
10
+ UserDto,
11
+ } from "./base";
12
+
13
+ export enum CommunityType {
14
+ CLASS = "CLASS",
15
+ FREE = "FREE",
16
+ }
17
+
18
+ export enum CommunitySortField {
19
+ TITLE = "TITLE",
20
+ }
21
+
22
+ export interface InitialInvitationDto {
23
+ users: InvitedUserDto[];
24
+ }
25
+
26
+ export interface CreateCommunityDto {
27
+ image?: string;
28
+ title: string;
29
+ type: CommunityType;
30
+ schoolYearStart?: number;
31
+ schoolYearEnd?: number;
32
+ welcomeNote?: string;
33
+ discussionEnabled: boolean;
34
+ secretCode?: string;
35
+ invitations?: InitialInvitationDto;
36
+ colour?: string;
37
+ }
38
+
39
+ export interface UpdateCommunityDto {
40
+ image?: string;
41
+ title: string;
42
+ type: CommunityType;
43
+ schoolYearStart?: number;
44
+ schoolYearEnd?: number;
45
+ welcomeNote?: string;
46
+ discussionEnabled: boolean;
47
+ secretCode?: string;
48
+ colour?: string;
49
+ }
50
+
51
+ export interface SearchCommunityRequestDto extends PaginationQueryDto {
52
+ title?: string;
53
+ type?: CommunityType;
54
+ createdAfter?: Date;
55
+ schoolYear?: number;
56
+ sortBy?: CommunitySortField;
57
+ sortDirection?: SortDirection;
58
+ fields?: string[];
59
+ }
60
+
61
+ export interface SearchCommunityResponseDto {
62
+ items: CommunityResponseDto[];
63
+ meta: PageMetadataDto;
64
+ }
65
+
66
+ export interface CommunityStatsDto {
67
+ totalMembers: number;
68
+ acceptedMembers: number;
69
+ totalAdmins: number;
70
+ acceptedAdmins: number;
71
+ }
72
+
73
+ export interface CommunityResponseDto {
74
+ id: number;
75
+ image?: string;
76
+ title: string;
77
+ creationDate: Date;
78
+ updateDate?: Date;
79
+ type: CommunityType;
80
+ schoolYearStart?: number;
81
+ schoolYearEnd?: number;
82
+ welcomeNote?: string;
83
+ discussionEnabled: boolean;
84
+ archivedDate?: Date;
85
+ creator: UserDto;
86
+ modifier?: UserDto;
87
+ archiver?: UserDto;
88
+ stats?: CommunityStatsDto;
89
+ colour?: string;
90
+ }
91
+
92
+ export interface CommunitySecretCodeDto {
93
+ id: number;
94
+ secretCode: string;
95
+ }
96
+
97
+ export type CommunityFields = "basic" | "stats";
@@ -0,0 +1,47 @@
1
+ // Types automatically generated from DTOs using TypeScript Compiler API
2
+ // Category: discussion
3
+ // Generated on: 2025-12-02T09:34:02.436Z
4
+
5
+ import { PageMetadataDto } from "./base";
6
+
7
+ export interface CountDiscussionDto {
8
+ count: number;
9
+ }
10
+
11
+ export interface CountDiscussionMessageDto {
12
+ count: number;
13
+ }
14
+
15
+ export interface CountDiscussionsDto {
16
+ count: number;
17
+ }
18
+
19
+ export interface DiscussionDto {
20
+ id: number;
21
+ title: string;
22
+ creationDate: Date;
23
+ updateDate: Date;
24
+ creatorId: number;
25
+ communityId: number;
26
+ archivedDate?: Date;
27
+ archivedById?: number;
28
+ }
29
+
30
+ export interface SearchDiscussionDto {
31
+ page?: number;
32
+ size?: number;
33
+ sortBy?: string;
34
+ sortDirection?: string;
35
+ search?: string;
36
+ }
37
+
38
+ export interface SearchDiscussionResponseDto {
39
+ items: DiscussionDto[];
40
+ meta: PageMetadataDto;
41
+ }
42
+
43
+ export interface CreateDiscussionDto {
44
+ title: string;
45
+ content: string;
46
+ communityId: number;
47
+ }
@@ -0,0 +1,49 @@
1
+ // Types automatically generated from DTOs using TypeScript Compiler API
2
+ // Category: folder
3
+ // Generated on: 2025-12-02T09:34:02.436Z
4
+
5
+ import { PageMetadataDto, PaginationQueryDto, UserDto } from "./base";
6
+ import { ResourceDto } from "./resource";
7
+
8
+ export interface FolderStatsDto {
9
+ childCount: number;
10
+ }
11
+
12
+ export interface FolderDto {
13
+ id: number;
14
+ name: string;
15
+ creationDate: Date;
16
+ modificationDate?: Date;
17
+ isRoot: boolean;
18
+ creator: UserDto;
19
+ modifier?: UserDto;
20
+ parentId?: number;
21
+ communityId: number;
22
+ stats?: FolderStatsDto;
23
+ }
24
+
25
+ export interface FolderDetailsDto extends FolderDto {
26
+ subFolders?: FolderDto[];
27
+ resources?: ResourceDto[];
28
+ }
29
+
30
+ export interface CreateFolderDto {
31
+ name: string;
32
+ parentId?: number;
33
+ }
34
+
35
+ export interface UpdateFolderDto {
36
+ name: string;
37
+ parentId?: number;
38
+ }
39
+
40
+ export interface SearchFolderDto extends PaginationQueryDto {
41
+ name?: string;
42
+ parentId?: number;
43
+ rootOnly?: boolean;
44
+ }
45
+
46
+ export interface SearchFolderResponseDto {
47
+ items: FolderDto[];
48
+ meta: PageMetadataDto;
49
+ }
@@ -0,0 +1,12 @@
1
+ // Index of automatically generated K6 types
2
+ // Generated on: 2025-12-02T09:34:02.437Z
3
+
4
+ export * from "./announcement.ts";
5
+ export * from "./base.ts";
6
+ export * from "./community.ts";
7
+ export * from "./discussion.ts";
8
+ export * from "./folder.ts";
9
+ export * from "./invitation.ts";
10
+ export * from "./membership.ts";
11
+ export * from "./resource.ts";
12
+ export * from "./wiki.ts";