oip-common 0.3.3 → 0.5.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/README.md +68 -68
- package/assets/demo/code.scss +17 -17
- package/assets/demo/demo.scss +2 -2
- package/assets/demo/flags/flags.scss +984 -984
- package/assets/i18n/app-modules.en.json +8 -1
- package/assets/i18n/app-modules.ru.json +8 -1
- package/assets/i18n/applications.en.json +46 -0
- package/assets/i18n/applications.ru.json +46 -0
- package/assets/i18n/config.en.json +18 -17
- package/assets/i18n/config.ru.json +18 -17
- package/assets/i18n/db-migration.en.json +19 -19
- package/assets/i18n/db-migration.ru.json +19 -19
- package/assets/i18n/en.json +4 -2
- package/assets/i18n/extensions.en.json +1 -0
- package/assets/i18n/extensions.ru.json +1 -0
- package/assets/i18n/notfound.en.json +8 -8
- package/assets/i18n/notfound.ru.json +8 -8
- package/assets/i18n/ru.json +4 -2
- package/assets/layout/_core.scss +30 -30
- package/assets/layout/_footer.scss +8 -8
- package/assets/layout/_main.scss +12 -12
- package/assets/layout/_mixins.scss +15 -15
- package/assets/layout/_preloading.scss +49 -49
- package/assets/layout/_responsive.scss +108 -108
- package/assets/layout/_topbar.scss +168 -168
- package/assets/layout/_typography.scss +68 -68
- package/assets/layout/_utils.scss +25 -25
- package/assets/layout/layout.scss +13 -13
- package/assets/layout/variables/_common.scss +20 -20
- package/assets/layout/variables/_dark.scss +5 -5
- package/assets/layout/variables/_light.scss +5 -5
- package/assets/tailwind.css +3 -3
- package/fesm2022/oip-common.mjs +2445 -1047
- package/fesm2022/oip-common.mjs.map +1 -1
- package/index.d.ts +355 -172
- package/package.json +2 -2
- package/scripts/generate-api.mjs +4 -4
- package/templates/http-client.ejs +14 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oip-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A template for cross-platform web applications based on sakai-ng and primeNG",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"template"
|
|
9
9
|
],
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@
|
|
11
|
+
"@angular-architects/module-federation": "^20.0.0"
|
|
12
12
|
},
|
|
13
13
|
"author": "Igor Tyulyakov aka g101k",
|
|
14
14
|
"license": "MIT",
|
package/scripts/generate-api.mjs
CHANGED
|
@@ -67,7 +67,7 @@ let config = {
|
|
|
67
67
|
fixInvalidTypeNamePrefix: "Type",
|
|
68
68
|
fixInvalidEnumKeyPrefix: "Value",
|
|
69
69
|
codeGenConstructs: (constructs) => ({
|
|
70
|
-
...constructs
|
|
70
|
+
...constructs
|
|
71
71
|
}),
|
|
72
72
|
primitiveTypeConstructs: (constructs) => ({
|
|
73
73
|
...constructs,
|
|
@@ -84,13 +84,13 @@ let config = {
|
|
|
84
84
|
onCreateRouteName: (routeNameInfo, rawRouteInfo) => {
|
|
85
85
|
const route = rawRouteInfo.route || rawRouteInfo.path || "<unknown route>";
|
|
86
86
|
const method = rawRouteInfo.method || rawRouteInfo.requestMethod || "<unknown method>";
|
|
87
|
-
const tags = Array.isArray(rawRouteInfo.tags) ? rawRouteInfo.tags.join(", ") :
|
|
87
|
+
const tags = Array.isArray(rawRouteInfo.tags) ? rawRouteInfo.tags.join(", ") : rawRouteInfo.tags || "<none>";
|
|
88
88
|
const moduleName = rawRouteInfo.moduleName;
|
|
89
89
|
|
|
90
90
|
if (!moduleName) {
|
|
91
91
|
throw new Error(
|
|
92
92
|
`Invalid API route name for ${method.toUpperCase()} ${route}. Missing moduleName. Tags: ${tags}. ` +
|
|
93
|
-
"Add a controller tag/module name or provide explicit operationId."
|
|
93
|
+
"Add a controller tag/module name or provide explicit operationId."
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -98,7 +98,7 @@ let config = {
|
|
|
98
98
|
throw new Error(
|
|
99
99
|
`Invalid API route name for ${method.toUpperCase()} ${route}. Generated usage "${routeNameInfo.usage}" ` +
|
|
100
100
|
`equals moduleName "${moduleName}". Add an action segment in controller route, ` +
|
|
101
|
-
`e.g. [HttpGet("get-${moduleName}")], or provide explicit operationId
|
|
101
|
+
`e.g. [HttpGet("get-${moduleName}")], or provide explicit operationId.`
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -238,7 +238,10 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
<% if (!config.disableThrowOnError) { %>
|
|
241
|
-
if (!response.ok)
|
|
241
|
+
if (!response.ok) {
|
|
242
|
+
this.authorizeOnUnauthorized(response, path);
|
|
243
|
+
throw data;
|
|
244
|
+
}
|
|
242
245
|
<% } %>
|
|
243
246
|
<% if (config.unwrapResponseData) { %>
|
|
244
247
|
return data.data;
|
|
@@ -248,6 +251,16 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
248
251
|
});
|
|
249
252
|
};
|
|
250
253
|
|
|
254
|
+
private authorizeOnUnauthorized(response: Response, path: string): void {
|
|
255
|
+
if (response.status !== 401 || path.includes("/api/security/create-auth-session")) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.securityService.authorize(
|
|
260
|
+
`${window.location.pathname}${window.location.search}${window.location.hash}`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
251
264
|
private async getCsrfRequestParams(method: string | undefined, path: string): Promise<RequestParams> {
|
|
252
265
|
if (!method || !["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase())) {
|
|
253
266
|
return {};
|