@mgremy/core 0.19.0 → 0.20.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/fesm2022/mgremy-core-guards.mjs +103 -0
- package/fesm2022/mgremy-core-guards.mjs.map +1 -0
- package/fesm2022/mgremy-core-interceptors.mjs +34 -0
- package/fesm2022/mgremy-core-interceptors.mjs.map +1 -0
- package/fesm2022/mgremy-core-models.mjs +43 -0
- package/fesm2022/mgremy-core-models.mjs.map +1 -0
- package/fesm2022/mgremy-core-pipes.mjs +88 -0
- package/fesm2022/mgremy-core-pipes.mjs.map +1 -0
- package/fesm2022/mgremy-core-resolvers.mjs +30 -0
- package/fesm2022/mgremy-core-resolvers.mjs.map +1 -0
- package/fesm2022/mgremy-core-types.mjs +4 -0
- package/fesm2022/mgremy-core-types.mjs.map +1 -0
- package/fesm2022/mgremy-core-utils.mjs +32 -0
- package/fesm2022/mgremy-core-utils.mjs.map +1 -0
- package/fesm2022/mgremy-core.mjs +342 -7
- package/fesm2022/mgremy-core.mjs.map +1 -1
- package/guards/README.md +3 -0
- package/interceptors/README.md +4 -0
- package/models/README.md +3 -0
- package/package.json +36 -2
- package/pipes/README.md +3 -0
- package/resolvers/README.md +3 -0
- package/types/README.md +3 -0
- package/types/mgremy-core-guards.d.ts +49 -0
- package/types/mgremy-core-interceptors.d.ts +8 -0
- package/types/mgremy-core-models.d.ts +75 -0
- package/types/mgremy-core-pipes.d.ts +33 -0
- package/types/mgremy-core-resolvers.d.ts +11 -0
- package/types/mgremy-core-types.d.ts +14 -0
- package/types/mgremy-core-utils.d.ts +13 -0
- package/types/mgremy-core.d.ts +190 -14
- package/utils/README.md +3 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AUTH_SERVICE } from '@mgremy/core';
|
|
2
|
+
import { hasProperty } from '@mgremy/core/utils';
|
|
3
|
+
import { inject } from '@angular/core';
|
|
4
|
+
import { Router } from '@angular/router';
|
|
5
|
+
|
|
6
|
+
const authGuard = () => {
|
|
7
|
+
const authService = inject(AUTH_SERVICE);
|
|
8
|
+
if (authService.isAuthenticated()) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
authService.login();
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Check if user is not connected
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The returnPath has a default value of `['/']`
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
{
|
|
22
|
+
path: 'feat',
|
|
23
|
+
loadChildren: () => import('./feat/feat.routes'),
|
|
24
|
+
canActivate: [notAuthGuard],
|
|
25
|
+
data: {
|
|
26
|
+
notAuthGuard: {
|
|
27
|
+
returnPath: ['/', 'some', 'path'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
*/
|
|
32
|
+
const notAuthGuard = (route) => {
|
|
33
|
+
const router = inject(Router);
|
|
34
|
+
const authService = inject(AUTH_SERVICE);
|
|
35
|
+
const guardData = route.data?.['notAuthGuard'];
|
|
36
|
+
let returnPath = ['/'];
|
|
37
|
+
if (hasProperty(guardData, 'returnPath')) {
|
|
38
|
+
if (Array.isArray(guardData.returnPath))
|
|
39
|
+
returnPath = guardData.returnPath;
|
|
40
|
+
else if (typeof guardData.returnPath === 'string')
|
|
41
|
+
returnPath = guardData.returnPath.split('/');
|
|
42
|
+
}
|
|
43
|
+
if (authService.isAuthenticated()) {
|
|
44
|
+
return router.createUrlTree(returnPath);
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Check if connected user has role
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This guards waits for `hasRoleGuard.roles` as data from angular route (as shown in the example)
|
|
54
|
+
* The behavior can be changed between `any` and `all`
|
|
55
|
+
*
|
|
56
|
+
* `any` checks if the user has at least one role provided
|
|
57
|
+
*
|
|
58
|
+
* `all` checks if the user has every role provided
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
{
|
|
62
|
+
path: 'feat',
|
|
63
|
+
canActivate: [hasRoleGuard],
|
|
64
|
+
data: {
|
|
65
|
+
hasRoleGuard: {
|
|
66
|
+
mode: 'any',
|
|
67
|
+
roles: [roles.Admin],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
*/
|
|
72
|
+
const hasRoleGuard = (route) => {
|
|
73
|
+
const authService = inject(AUTH_SERVICE);
|
|
74
|
+
const guardData = route.data['hasRoleGuard'];
|
|
75
|
+
if (guardData?.roles === undefined || !Array.isArray(guardData.roles)) {
|
|
76
|
+
throw new Error('Role must be passed as an array');
|
|
77
|
+
}
|
|
78
|
+
const roles = guardData.roles;
|
|
79
|
+
const mode = guardData.mode ?? 'any';
|
|
80
|
+
if (authService.isAuthenticated()) {
|
|
81
|
+
const accessToken = authService.getDecodedAccessToken();
|
|
82
|
+
if (accessToken !== undefined) {
|
|
83
|
+
const accessTokenRoles = accessToken.roles;
|
|
84
|
+
if (accessTokenRoles != undefined) {
|
|
85
|
+
const matchedRoles = accessTokenRoles.filter((x) => roles.includes(x));
|
|
86
|
+
switch (mode) {
|
|
87
|
+
case 'all':
|
|
88
|
+
return matchedRoles.length === roles.length;
|
|
89
|
+
case 'any':
|
|
90
|
+
return matchedRoles.length > 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generated bundle index. Do not edit.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export { authGuard, hasRoleGuard, notAuthGuard };
|
|
103
|
+
//# sourceMappingURL=mgremy-core-guards.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-guards.mjs","sources":["../../../../packages/core/guards/src/lib/auth.ts","../../../../packages/core/guards/src/lib/has-role.ts","../../../../packages/core/guards/src/mgremy-core-guards.ts"],"sourcesContent":["import { AUTH_SERVICE } from '@mgremy/core';\nimport { hasProperty } from '@mgremy/core/utils';\n\nimport { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivateFn, Router } from '@angular/router';\n\nexport const authGuard: CanActivateFn = () => {\n const authService = inject(AUTH_SERVICE);\n\n if (authService.isAuthenticated()) {\n return true;\n }\n\n authService.login();\n return false;\n};\n\n/**\n * Check if user is not connected\n *\n * @remarks\n * The returnPath has a default value of `['/']`\n *\n * @example\n {\n path: 'feat',\n loadChildren: () => import('./feat/feat.routes'),\n canActivate: [notAuthGuard],\n data: {\n notAuthGuard: {\n returnPath: ['/', 'some', 'path'],\n },\n },\n }\n */\nexport const notAuthGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => {\n const router = inject(Router);\n const authService = inject(AUTH_SERVICE);\n const guardData: unknown = route.data?.['notAuthGuard'];\n\n let returnPath: string[] = ['/'];\n\n if (hasProperty(guardData, 'returnPath')) {\n if (Array.isArray(guardData.returnPath)) returnPath = guardData.returnPath;\n else if (typeof guardData.returnPath === 'string') returnPath = guardData.returnPath.split('/');\n }\n\n if (authService.isAuthenticated()) {\n return router.createUrlTree(returnPath);\n }\n\n return true;\n};\n","import { AUTH_SERVICE } from '@mgremy/core';\n\nimport { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivateFn } from '@angular/router';\n\n/**\n * Check if connected user has role\n *\n * @remarks\n * This guards waits for `hasRoleGuard.roles` as data from angular route (as shown in the example)\n * The behavior can be changed between `any` and `all`\n *\n * `any` checks if the user has at least one role provided\n *\n * `all` checks if the user has every role provided\n *\n * @example\n {\n path: 'feat',\n canActivate: [hasRoleGuard],\n data: {\n hasRoleGuard: {\n mode: 'any',\n roles: [roles.Admin],\n },\n },\n },\n */\nexport const hasRoleGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => {\n const authService = inject(AUTH_SERVICE);\n const guardData = route.data['hasRoleGuard'];\n\n if (guardData?.roles === undefined || !Array.isArray(guardData.roles)) {\n throw new Error('Role must be passed as an array');\n }\n\n const roles: string[] = guardData.roles;\n const mode: 'all' | 'any' = guardData.mode ?? 'any';\n\n if (authService.isAuthenticated()) {\n const accessToken = authService.getDecodedAccessToken();\n\n if (accessToken !== undefined) {\n const accessTokenRoles = accessToken.roles;\n\n if (accessTokenRoles != undefined) {\n const matchedRoles = accessTokenRoles.filter((x) => roles.includes(x));\n\n switch (mode) {\n case 'all':\n return matchedRoles.length === roles.length;\n case 'any':\n return matchedRoles.length > 0;\n }\n }\n }\n }\n\n return false;\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAMO,MAAM,SAAS,GAAkB,MAAK;AAC3C,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC;AAExC,IAAA,IAAI,WAAW,CAAC,eAAe,EAAE,EAAE;AACjC,QAAA,OAAO,IAAI;IACb;IAEA,WAAW,CAAC,KAAK,EAAE;AACnB,IAAA,OAAO,KAAK;AACd;AAEA;;;;;;;;;;;;;;;;;AAiBG;AACI,MAAM,YAAY,GAAkB,CAAC,KAA6B,KAAI;AAC3E,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC;IACxC,MAAM,SAAS,GAAY,KAAK,CAAC,IAAI,GAAG,cAAc,CAAC;AAEvD,IAAA,IAAI,UAAU,GAAa,CAAC,GAAG,CAAC;AAEhC,IAAA,IAAI,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE;AACxC,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;AAAE,YAAA,UAAU,GAAG,SAAS,CAAC,UAAU;AACrE,aAAA,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,QAAQ;YAAE,UAAU,GAAG,SAAS,CAA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,IAAA,OAAO,KAAK;AACd;;AC3DA;;AAEG;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AUTH_SERVICE, CONFIG_SERVICE, TRANSLATION_SERVICE } from '@mgremy/core';
|
|
2
|
+
import { inject } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
function authInterceptor(req, next) {
|
|
5
|
+
const authService = inject(AUTH_SERVICE);
|
|
6
|
+
const configService = inject(CONFIG_SERVICE);
|
|
7
|
+
if (authService.isAuthenticated() && req.url.startsWith(configService.apiUrl)) {
|
|
8
|
+
const clone = req.clone({
|
|
9
|
+
withCredentials: true,
|
|
10
|
+
headers: req.headers.append('Authorization', `Bearer ${authService.getAccessToken()}`),
|
|
11
|
+
});
|
|
12
|
+
return next(clone);
|
|
13
|
+
}
|
|
14
|
+
return next(req);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function langInterceptor(req, next) {
|
|
18
|
+
const translationService = inject(TRANSLATION_SERVICE);
|
|
19
|
+
const configService = inject(CONFIG_SERVICE);
|
|
20
|
+
if (req.url.startsWith(configService.apiUrl)) {
|
|
21
|
+
const clone = req.clone({
|
|
22
|
+
headers: req.headers.append('Accept-Language', translationService.currentLanguage()),
|
|
23
|
+
});
|
|
24
|
+
return next(clone);
|
|
25
|
+
}
|
|
26
|
+
return next(req);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generated bundle index. Do not edit.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export { authInterceptor, langInterceptor };
|
|
34
|
+
//# sourceMappingURL=mgremy-core-interceptors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-interceptors.mjs","sources":["../../../../packages/core/interceptors/src/lib/auth.ts","../../../../packages/core/interceptors/src/lib/lang.ts","../../../../packages/core/interceptors/src/mgremy-core-interceptors.ts"],"sourcesContent":["import { AUTH_SERVICE, CONFIG_SERVICE } from '@mgremy/core';\n\nimport { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport function authInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const authService = inject(AUTH_SERVICE);\n const configService = inject(CONFIG_SERVICE);\n\n if (authService.isAuthenticated() && req.url.startsWith(configService.apiUrl)) {\n const clone = req.clone({\n withCredentials: true,\n headers: req.headers.append('Authorization', `Bearer ${authService.getAccessToken()}`),\n });\n\n return next(clone);\n }\n\n return next(req);\n}\n","import { CONFIG_SERVICE, TRANSLATION_SERVICE } from '@mgremy/core';\n\nimport { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport function langInterceptor(\n req: HttpRequest<unknown>,\n next: HttpHandlerFn\n): Observable<HttpEvent<unknown>> {\n const translationService = inject(TRANSLATION_SERVICE);\n const configService = inject(CONFIG_SERVICE);\n\n if (req.url.startsWith(configService.apiUrl)) {\n const clone = req.clone({\n headers: req.headers.append('Accept-Language', translationService.currentLanguage()),\n });\n\n return next(clone);\n }\n\n return next(req);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAMM,SAAU,eAAe,CAC7B,GAAyB,EACzB,IAAmB,EAAA;AAEnB,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC;AACxC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;AAE5C,IAAA,IAAI,WAAW,CAAC,eAAe,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;AAC7E,QAAA,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;AACtB,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC;AACvF,SAAA,CAAC;AAEF,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB;AAEA,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC;AAClB;;ACjBM,SAAU,eAAe,CAC7B,GAAyB,EACzB,IAAmB,EAAA;AAEnB,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACtD,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;IAE5C,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;AAC5C,QAAA,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;AACtB,YAAA,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,eAAe,EAAE,CAAC;AACrF,SAAA,CAAC;AAEF,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB;AAEA,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC;AAClB;;ACtBA;;AAEG;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import z__default from 'zod';
|
|
3
|
+
|
|
4
|
+
const ZErrorResponse = z.object({
|
|
5
|
+
errors: z.record(z.string(), z.array(z.string())),
|
|
6
|
+
message: z.string(),
|
|
7
|
+
statusCode: z.number(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
var FilterRequestOperator;
|
|
11
|
+
(function (FilterRequestOperator) {
|
|
12
|
+
FilterRequestOperator[FilterRequestOperator["Equal"] = 0] = "Equal";
|
|
13
|
+
FilterRequestOperator[FilterRequestOperator["NotEqual"] = 1] = "NotEqual";
|
|
14
|
+
FilterRequestOperator[FilterRequestOperator["LessThan"] = 2] = "LessThan";
|
|
15
|
+
FilterRequestOperator[FilterRequestOperator["LessThanOrEqual"] = 3] = "LessThanOrEqual";
|
|
16
|
+
FilterRequestOperator[FilterRequestOperator["GreaterThan"] = 4] = "GreaterThan";
|
|
17
|
+
FilterRequestOperator[FilterRequestOperator["GreaterThanOrEqual"] = 5] = "GreaterThanOrEqual";
|
|
18
|
+
FilterRequestOperator[FilterRequestOperator["Contains"] = 6] = "Contains";
|
|
19
|
+
FilterRequestOperator[FilterRequestOperator["NotContains"] = 7] = "NotContains";
|
|
20
|
+
FilterRequestOperator[FilterRequestOperator["StartWith"] = 8] = "StartWith";
|
|
21
|
+
FilterRequestOperator[FilterRequestOperator["EndWith"] = 9] = "EndWith";
|
|
22
|
+
})(FilterRequestOperator || (FilterRequestOperator = {}));
|
|
23
|
+
var FilterRequestLogic;
|
|
24
|
+
(function (FilterRequestLogic) {
|
|
25
|
+
FilterRequestLogic[FilterRequestLogic["And"] = 0] = "And";
|
|
26
|
+
FilterRequestLogic[FilterRequestLogic["Or"] = 1] = "Or";
|
|
27
|
+
})(FilterRequestLogic || (FilterRequestLogic = {}));
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
const ZPaginationResponse = (itemSchema) => z__default.object({
|
|
30
|
+
pageNumber: z__default.number(),
|
|
31
|
+
pageSize: z__default.number(),
|
|
32
|
+
hasNextPage: z__default.boolean(),
|
|
33
|
+
hasPreviousPage: z__default.boolean(),
|
|
34
|
+
totalPages: z__default.number(),
|
|
35
|
+
data: z__default.array(itemSchema),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generated bundle index. Do not edit.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
export { FilterRequestLogic, FilterRequestOperator, ZErrorResponse, ZPaginationResponse };
|
|
43
|
+
//# sourceMappingURL=mgremy-core-models.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-models.mjs","sources":["../../../../packages/core/models/src/lib/error.ts","../../../../packages/core/models/src/lib/pagination.ts","../../../../packages/core/models/src/mgremy-core-models.ts"],"sourcesContent":["import * as z from 'zod';\n\nexport type ErrorResponse = {\n errors: Record<string, string[]>;\n message: string;\n statusCode: number;\n};\n\nexport const ZErrorResponse: z.ZodType<ErrorResponse> = z.object({\n errors: z.record(z.string(), z.array(z.string())),\n message: z.string(),\n statusCode: z.number(),\n});\n","import z from 'zod';\n\nexport enum FilterRequestOperator {\n Equal = 0,\n NotEqual = 1,\n LessThan = 2,\n LessThanOrEqual = 3,\n GreaterThan = 4,\n GreaterThanOrEqual = 5,\n Contains = 6,\n NotContains = 7,\n StartWith = 8,\n EndWith = 9,\n}\n\nexport enum FilterRequestLogic {\n And = 0,\n Or = 1,\n}\n\nexport type FilterRequest<T> = {\n propertyName: keyof T;\n filterOperator: FilterRequestOperator;\n value: string;\n filterLogic: FilterRequestLogic;\n filters?: FilterRequest<T>[] | undefined;\n};\n\nexport type SortRequest<T> = {\n propertyName: keyof T;\n isDescending: boolean;\n};\n\nexport type PaginationRequest<T> = {\n pageNumber: number;\n pageSize: number;\n sortRequests?: SortRequest<T>[] | undefined;\n filterRequest?: FilterRequest<T>[] | undefined;\n};\n\nexport type PaginationResponse<T> = {\n pageNumber: number;\n pageSize: number;\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n totalPages: number;\n data: T[];\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const ZPaginationResponse = <T extends z.ZodType<any, any>>(itemSchema: T) =>\n z.object({\n pageNumber: z.number(),\n pageSize: z.number(),\n hasNextPage: z.boolean(),\n hasPreviousPage: z.boolean(),\n totalPages: z.number(),\n data: z.array(itemSchema),\n });\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["z"],"mappings":";;;AAQO,MAAM,cAAc,GAA6B,CAAC,CAAC,MAAM,CAAC;AAC/D,IAAA,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAA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CAAA,GAAA,IAAM;AACR,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAAA,EAAA,CAAA,CAAA;AAkC9B;AACO,MAAM,mBAAmB,GAAG,CAAgC,UAAa,KAC9EA,UAAC,CAAC,MAAM,CAAC;AACP,IAAA,UAAU,EAAEA,UAAC,CAAC,MAAM,EAAE;AACtB,IAAA,QAAQ,EAAEA,UAAC,CAAC,MAAM,EAAE;AACpB,IAAA,WAAW,EAAEA,UAAC,CAAC,OAAO,EAAE;AACxB,IAAA,eAAe,EAAEA,UAAC,CAAC,OAAO,EAAE;AAC5B,IAAA,UAAU,EAAEA,UAAC,CAAC,MAAM,EAAE;AACtB,IAAA,IAAI,EAAEA,UAAC,CAAC,KAAK,CAAC,UAAU,CAAC;AAC1B,CAAA;;AC1DH;;AAEG;;;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Pipe, inject } from '@angular/core';
|
|
3
|
+
import { TRANSLATION_SERVICE } from '@mgremy/core';
|
|
4
|
+
import { DatePipe } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
class ArrayFilterPipe {
|
|
7
|
+
transform(value, callback, mode) {
|
|
8
|
+
if (mode === 'multiple')
|
|
9
|
+
return value.filter(callback);
|
|
10
|
+
if (mode === 'single')
|
|
11
|
+
return value.find(callback);
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ArrayFilterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
15
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.1", ngImport: i0, type: ArrayFilterPipe, isStandalone: true, name: "arrayFilter" });
|
|
16
|
+
}
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ArrayFilterPipe, decorators: [{
|
|
18
|
+
type: Pipe,
|
|
19
|
+
args: [{
|
|
20
|
+
name: 'arrayFilter',
|
|
21
|
+
standalone: true,
|
|
22
|
+
pure: true,
|
|
23
|
+
}]
|
|
24
|
+
}] });
|
|
25
|
+
|
|
26
|
+
class LocalizedDatePipe {
|
|
27
|
+
_translationService = inject(TRANSLATION_SERVICE);
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
transform(value, format, timezone) {
|
|
30
|
+
const datePipe = new DatePipe(this._translationService.currentLanguage());
|
|
31
|
+
return datePipe.transform(value, format, timezone);
|
|
32
|
+
}
|
|
33
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: LocalizedDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
34
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.1", ngImport: i0, type: LocalizedDatePipe, isStandalone: true, name: "localizedDate", pure: false });
|
|
35
|
+
}
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: LocalizedDatePipe, decorators: [{
|
|
37
|
+
type: Pipe,
|
|
38
|
+
args: [{
|
|
39
|
+
name: 'localizedDate',
|
|
40
|
+
pure: false,
|
|
41
|
+
}]
|
|
42
|
+
}] });
|
|
43
|
+
|
|
44
|
+
class EnumKeyValuePairPipe {
|
|
45
|
+
transform(value) {
|
|
46
|
+
return Object.entries(value)
|
|
47
|
+
.filter(([, v]) => typeof v === 'number')
|
|
48
|
+
.map(([k, v]) => ({ key: k, value: v }));
|
|
49
|
+
}
|
|
50
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: EnumKeyValuePairPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
51
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.1", ngImport: i0, type: EnumKeyValuePairPipe, isStandalone: true, name: "enumKeyValuePair" });
|
|
52
|
+
}
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: EnumKeyValuePairPipe, decorators: [{
|
|
54
|
+
type: Pipe,
|
|
55
|
+
args: [{
|
|
56
|
+
name: 'enumKeyValuePair',
|
|
57
|
+
standalone: true,
|
|
58
|
+
pure: true,
|
|
59
|
+
}]
|
|
60
|
+
}] });
|
|
61
|
+
|
|
62
|
+
class FirstLetterUpperPipe {
|
|
63
|
+
transform(value) {
|
|
64
|
+
if (value.length === 0)
|
|
65
|
+
return '';
|
|
66
|
+
if (value.length === 1)
|
|
67
|
+
return value.toUpperCase();
|
|
68
|
+
const firstLetter = value.at(0);
|
|
69
|
+
const remaning = value.substring(1, value.length);
|
|
70
|
+
return `${firstLetter?.toUpperCase()}${remaning}`;
|
|
71
|
+
}
|
|
72
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FirstLetterUpperPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
73
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.1", ngImport: i0, type: FirstLetterUpperPipe, isStandalone: true, name: "firstLetterUpper", pure: false });
|
|
74
|
+
}
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: FirstLetterUpperPipe, decorators: [{
|
|
76
|
+
type: Pipe,
|
|
77
|
+
args: [{
|
|
78
|
+
name: 'firstLetterUpper',
|
|
79
|
+
pure: false,
|
|
80
|
+
}]
|
|
81
|
+
}] });
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generated bundle index. Do not edit.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
export { ArrayFilterPipe, EnumKeyValuePairPipe, FirstLetterUpperPipe, LocalizedDatePipe };
|
|
88
|
+
//# sourceMappingURL=mgremy-core-pipes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-pipes.mjs","sources":["../../../../packages/core/pipes/src/lib/array-filter.ts","../../../../packages/core/pipes/src/lib/date.ts","../../../../packages/core/pipes/src/lib/enum-key-value-pair.ts","../../../../packages/core/pipes/src/lib/first-letter-upper.ts","../../../../packages/core/pipes/src/mgremy-core-pipes.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'arrayFilter',\n standalone: true,\n pure: true,\n})\nexport class ArrayFilterPipe<T> implements PipeTransform {\n transform(value: T[], callback: (x: T) => boolean, mode: 'multiple'): T[];\n transform(value: T[], callback: (x: T) => boolean, mode: 'single'): T | undefined;\n transform(\n value: T[],\n callback: (x: T) => boolean,\n mode: 'multiple' | 'single'\n ): T | T[] | undefined {\n if (mode === 'multiple') return value.filter(callback);\n\n if (mode === 'single') return value.find(callback);\n\n return undefined;\n }\n}\n","import { TRANSLATION_SERVICE } from '@mgremy/core';\n\nimport { DatePipe } from '@angular/common';\nimport { inject, Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'localizedDate',\n pure: false,\n})\nexport class LocalizedDatePipe implements PipeTransform {\n private readonly _translationService = inject(TRANSLATION_SERVICE);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transform(value: any, format?: string, timezone?: string): string | null {\n const datePipe = new DatePipe(this._translationService.currentLanguage());\n\n return datePipe.transform(value, format, timezone);\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'enumKeyValuePair',\n standalone: true,\n pure: true,\n})\nexport class EnumKeyValuePairPipe implements PipeTransform {\n transform(value: object): { key: string; value: number }[] {\n return Object.entries(value)\n .filter(([, v]) => typeof v === 'number')\n .map(([k, v]) => ({ key: k, value: v }));\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'firstLetterUpper',\n pure: false,\n})\nexport class FirstLetterUpperPipe implements PipeTransform {\n transform(value: string): string {\n if (value.length === 0) return '';\n if (value.length === 1) return value.toUpperCase();\n\n const firstLetter = value.at(0);\n const remaning = value.substring(1, value.length);\n\n return `${firstLetter?.toUpperCase()}${remaning}`;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAOa,eAAe,CAAA;AAG1B,IAAA,SAAS,CACP,KAAU,EACV,QAA2B,EAC3B,IAA2B,EAAA;QAE3B,IAAI,IAAI,KAAK,UAAU;AAAE,YAAA,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAEtD,IAAI,IAAI,KAAK,QAAQ;AAAE,YAAA,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AAElD,QAAA,OAAO,SAAS;IAClB;uGAbW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAAf,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,aAAA,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAL3B,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,aAAa;AACnB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE,IAAI;AACX,iBAAA;;;MCGY,iBAAiB,CAAA;AACX,IAAA,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC;;AAGlE,IAAA,SAAS,CAAC,KAAU,EAAE,MAAe,EAAE,QAAiB,EAAA;AACtD,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;QAEzE,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC;IACpD;uGARW,iBAAi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,OAAO,KAAK,CAAC,WAAW,EAAE;QAElD,MAAM,WAAW,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC;QAEjD,OAAO,CAAA,EAAG,WAAW,EAAE,WAAW,EAAE,CAAA,EAAG,QAAQ,EAAE;IACnD;uGATW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAApB,oBAAoB,EAAA,YAAA,EAAA,IAAA,EAAA,IAAA,EAAA,kBAAA,EAAA,IAAA,EAAA,KAAA,EAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAJhC,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACJ,oBAAA,IAAI,EAAE,kBAAkB;AACxB,oBAAA,IAAI,EAAE,KAAK;AACZ,iBAAA;;;ACLD;;AAEG;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a route resolver that extracts a query parameter value with type safety.
|
|
3
|
+
* @param key - The query parameter key to extract
|
|
4
|
+
* @param defaultValue - The default value to use if the parameter is not present
|
|
5
|
+
* @returns A resolver function for use in Angular route configuration
|
|
6
|
+
*/
|
|
7
|
+
const paramResolver = (key, defaultValue) => ({
|
|
8
|
+
[key]: (route) => {
|
|
9
|
+
const paramValue = route.queryParams[key];
|
|
10
|
+
if (paramValue === undefined || paramValue === null || paramValue === '') {
|
|
11
|
+
return defaultValue;
|
|
12
|
+
}
|
|
13
|
+
// Type conversion based on defaultValue type
|
|
14
|
+
if (typeof defaultValue === 'number') {
|
|
15
|
+
const numValue = Number(paramValue);
|
|
16
|
+
return isNaN(numValue) ? defaultValue : numValue;
|
|
17
|
+
}
|
|
18
|
+
if (typeof defaultValue === 'boolean') {
|
|
19
|
+
return (paramValue === 'true');
|
|
20
|
+
}
|
|
21
|
+
return paramValue;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Generated bundle index. Do not edit.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export { paramResolver };
|
|
30
|
+
//# sourceMappingURL=mgremy-core-resolvers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-resolvers.mjs","sources":["../../../../packages/core/resolvers/src/lib/param.ts","../../../../packages/core/resolvers/src/mgremy-core-resolvers.ts"],"sourcesContent":["import { ActivatedRouteSnapshot, ResolveData } from '@angular/router';\n\n/**\n * Creates a route resolver that extracts a query parameter value with type safety.\n * @param key - The query parameter key to extract\n * @param defaultValue - The default value to use if the parameter is not present\n * @returns A resolver function for use in Angular route configuration\n */\nexport const paramResolver = <T extends string | number | boolean>(\n key: string,\n defaultValue: T\n): ResolveData => ({\n [key]: (route: ActivatedRouteSnapshot) => {\n const paramValue = route.queryParams[key];\n if (paramValue === undefined || paramValue === null || paramValue === '') {\n return defaultValue;\n }\n // Type conversion based on defaultValue type\n if (typeof defaultValue === 'number') {\n const numValue = Number(paramValue);\n return isNaN(numValue) ? defaultValue : (numValue as T);\n }\n if (typeof defaultValue === 'boolean') {\n return (paramValue === 'true') as T;\n }\n return paramValue as T;\n },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAEA;;;;;AAKG;AACI,MAAM,aAAa,GAAG,CAC3B,GAAW,EACX,YAAe,MACE;AACjB,IAAA,CAAC,GAAG,GAAG,CAAC,KAA6B,KAAI;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;AACzC,QAAA,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,EAAE,EAAE;AACxE,YAAA,OAAO,YAAY;QACrB;;AAEA,QAAA,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;AACpC,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;AACnC,YAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,YAAY,GAAI,QAAc;QACzD;AACA,QAAA,IAAI,OAAO,YAAY,KAAK,SAAS,EAAE;AACrC,YAAA,QAAQ,UAAU,KAAK,MAAM;QAC/B;AACA,QAAA,OAAO,UAAe;IACxB,CAAC;AACF,CAAA;;AC3BD;;AAEG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-types.mjs","sources":["../../../../packages/core/types/src/mgremy-core-types.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;AAEG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { pipe, map } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
function hasProperty(value, key) {
|
|
4
|
+
return typeof value === 'object' && value !== null && value !== undefined && key in value;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function toURLSearchParams(...handlers) {
|
|
8
|
+
const urlSearchParams = new URLSearchParams();
|
|
9
|
+
handlers.forEach((handler) => handler(urlSearchParams));
|
|
10
|
+
return urlSearchParams;
|
|
11
|
+
}
|
|
12
|
+
function withPagination(request) {
|
|
13
|
+
return (params) => {
|
|
14
|
+
params.set('pageNumber', request.pageNumber.toString());
|
|
15
|
+
params.set('pageSize', request.pageSize.toString());
|
|
16
|
+
if (request.sortRequests?.length)
|
|
17
|
+
params.set('sortRequest', JSON.stringify(request.sortRequests));
|
|
18
|
+
if (request.filterRequest?.length)
|
|
19
|
+
params.set('filterRequest', JSON.stringify(request.filterRequest));
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function zParse(zObj) {
|
|
24
|
+
return pipe(map((data) => zObj.parse(data)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generated bundle index. Do not edit.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export { hasProperty, toURLSearchParams, withPagination, zParse };
|
|
32
|
+
//# sourceMappingURL=mgremy-core-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgremy-core-utils.mjs","sources":["../../../../packages/core/utils/src/lib/has-property.ts","../../../../packages/core/utils/src/lib/to-url-search-params.ts","../../../../packages/core/utils/src/lib/zod.ts","../../../../packages/core/utils/src/mgremy-core-utils.ts"],"sourcesContent":["export function hasProperty<K extends PropertyKey>(\n value: unknown,\n key: K\n): value is Record<K, unknown> {\n return typeof value === 'object' && value !== null && value !== undefined && key in value;\n}\n","import { PaginationRequest } from '@mgremy/core/models';\n\ntype ToURLSearchParamsHandler = (params: URLSearchParams) => void;\n\nexport function toURLSearchParams(...handlers: ToURLSearchParamsHandler[]): URLSearchParams {\n const urlSearchParams = new URLSearchParams();\n\n handlers.forEach((handler) => handler(urlSearchParams));\n\n return urlSearchParams;\n}\n\nexport function withPagination<T>(request: PaginationRequest<T>): ToURLSearchParamsHandler {\n return (params) => {\n params.set('pageNumber', request.pageNumber.toString());\n params.set('pageSize', request.pageSize.toString());\n\n if (request.sortRequests?.length)\n params.set('sortRequest', JSON.stringify(request.sortRequests));\n if (request.filterRequest?.length)\n params.set('filterRequest', JSON.stringify(request.filterRequest));\n };\n}\n","import { map, pipe } from 'rxjs';\nimport * as z from 'zod';\n\nexport function zParse<T extends z.ZodType>(zObj: T) {\n return pipe(map((data: unknown): z.infer<T> => zObj.parse(data)));\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAM,SAAU,WAAW,CACzB,KAAc,EACd,GAAM,EAAA;AAEN,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK;AAC3F;;ACDM,SAAU,i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