@acorex/platform-generator 18.0.10 → 18.0.13
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/package.json +1 -1
- package/src/generators/app-module/files/project.json.template +0 -116
- package/src/generators/app-module/files/src/app/app.module.ts.template +5 -2
- package/src/generators/app-module/files/src/app/basic-interceptor.interceptor.ts.template +62 -0
- package/src/generators/app-module/files/src/app/modules/auth/auth-root.module.ts.template +1 -1
- package/src/generators/app-module/files/src/app/modules/layout/entity.loader.ts.template +5 -4
- package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template +26 -29
- package/src/generators/app-module/files/src/app/modules/layout/menu.loader.ts.template +1 -1
- package/src/generators/app-module/files/src/app/modules/root/mock.data.ts.template +14 -0
- package/src/generators/app-module/files/src/app/modules/root/sample/sample.entity.ts.template +456 -159
- package/src/generators/app-module/files/src/assets/i18n/en/common.json +41 -0
- package/src/generators/app-module/files/src/assets/i18n/fa/auth.json +50 -0
- package/src/generators/app-module/files/src/assets/i18n/fa/common.json +220 -0
- package/src/generators/app-module/files/src/app/header-interceptor.interceptor.ts.template +0 -33
- package/src/generators/app-module/files/src/environments/environment.local.ts.template +0 -19
- package/src/generators/app-module/files/src/environments/environment.prod.ts.template +0 -19
- package/src/generators/app-module/files/src/environments/environment.test.local.ts.template +0 -19
- package/src/generators/app-module/files/src/environments/environment.test.ts.template +0 -19
package/package.json
CHANGED
|
@@ -58,35 +58,6 @@
|
|
|
58
58
|
"commonChunk": true,
|
|
59
59
|
"extractLicenses": true
|
|
60
60
|
},
|
|
61
|
-
"build-test": {
|
|
62
|
-
"fileReplacements": [
|
|
63
|
-
{
|
|
64
|
-
"replace": "apps/<%= name %>/src/environments/environment.ts",
|
|
65
|
-
"with": "apps/<%= name %>/src/environments/environment.test.ts"
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
"budgets": [
|
|
69
|
-
{
|
|
70
|
-
"type": "initial",
|
|
71
|
-
"maximumWarning": "500kb",
|
|
72
|
-
"maximumError": "5mb"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"type": "anyComponentStyle",
|
|
76
|
-
"maximumWarning": "200kb",
|
|
77
|
-
"maximumError": "400kb"
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
"outputHashing": "all",
|
|
81
|
-
"sourceMap": false,
|
|
82
|
-
"optimization": true,
|
|
83
|
-
"namedChunks": false,
|
|
84
|
-
"vendorChunk": true,
|
|
85
|
-
"buildOptimizer": true,
|
|
86
|
-
"aot": true,
|
|
87
|
-
"commonChunk": true,
|
|
88
|
-
"extractLicenses": true
|
|
89
|
-
},
|
|
90
61
|
"build-dev": {
|
|
91
62
|
"fileReplacements": [
|
|
92
63
|
{
|
|
@@ -142,32 +113,6 @@
|
|
|
142
113
|
"sourceMap": true,
|
|
143
114
|
"namedChunks": true
|
|
144
115
|
},
|
|
145
|
-
"serve-test": {
|
|
146
|
-
"fileReplacements": [
|
|
147
|
-
{
|
|
148
|
-
"replace": "apps/<%= name %>/src/environments/environment.ts",
|
|
149
|
-
"with": "apps/<%= name %>/src/environments/environment.test.ts"
|
|
150
|
-
}
|
|
151
|
-
],
|
|
152
|
-
"budgets": [
|
|
153
|
-
{
|
|
154
|
-
"type": "initial",
|
|
155
|
-
"maximumWarning": "500kb",
|
|
156
|
-
"maximumError": "8mb"
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"type": "anyComponentStyle",
|
|
160
|
-
"maximumWarning": "200kb",
|
|
161
|
-
"maximumError": "400kb"
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
"buildOptimizer": false,
|
|
165
|
-
"optimization": false,
|
|
166
|
-
"vendorChunk": true,
|
|
167
|
-
"extractLicenses": false,
|
|
168
|
-
"sourceMap": true,
|
|
169
|
-
"namedChunks": true
|
|
170
|
-
},
|
|
171
116
|
"serve-dev": {
|
|
172
117
|
"fileReplacements": [
|
|
173
118
|
{
|
|
@@ -194,58 +139,6 @@
|
|
|
194
139
|
"sourceMap": true,
|
|
195
140
|
"namedChunks": true
|
|
196
141
|
},
|
|
197
|
-
"serve-local": {
|
|
198
|
-
"fileReplacements": [
|
|
199
|
-
{
|
|
200
|
-
"replace": "apps/<%= name %>/src/environments/environment.ts",
|
|
201
|
-
"with": "apps/<%= name %>/src/environments/environment.local.ts"
|
|
202
|
-
}
|
|
203
|
-
],
|
|
204
|
-
"budgets": [
|
|
205
|
-
{
|
|
206
|
-
"type": "initial",
|
|
207
|
-
"maximumWarning": "500kb",
|
|
208
|
-
"maximumError": "8mb"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
"type": "anyComponentStyle",
|
|
212
|
-
"maximumWarning": "200kb",
|
|
213
|
-
"maximumError": "400kb"
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
"buildOptimizer": false,
|
|
217
|
-
"optimization": false,
|
|
218
|
-
"vendorChunk": true,
|
|
219
|
-
"extractLicenses": false,
|
|
220
|
-
"sourceMap": true,
|
|
221
|
-
"namedChunks": true
|
|
222
|
-
},
|
|
223
|
-
"serve-test-local": {
|
|
224
|
-
"fileReplacements": [
|
|
225
|
-
{
|
|
226
|
-
"replace": "apps/<%= name %>/src/environments/environment.ts",
|
|
227
|
-
"with": "apps/<%= name %>/src/environments/environment.test.local.ts"
|
|
228
|
-
}
|
|
229
|
-
],
|
|
230
|
-
"budgets": [
|
|
231
|
-
{
|
|
232
|
-
"type": "initial",
|
|
233
|
-
"maximumWarning": "500kb",
|
|
234
|
-
"maximumError": "8mb"
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"type": "anyComponentStyle",
|
|
238
|
-
"maximumWarning": "200kb",
|
|
239
|
-
"maximumError": "400kb"
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
"buildOptimizer": false,
|
|
243
|
-
"optimization": false,
|
|
244
|
-
"vendorChunk": true,
|
|
245
|
-
"extractLicenses": false,
|
|
246
|
-
"sourceMap": true,
|
|
247
|
-
"namedChunks": true
|
|
248
|
-
}
|
|
249
142
|
},
|
|
250
143
|
"defaultConfiguration": "serve:prod"
|
|
251
144
|
},
|
|
@@ -255,18 +148,9 @@
|
|
|
255
148
|
"serve-prod": {
|
|
256
149
|
"browserTarget": "<%= name %>:build:serve-prod"
|
|
257
150
|
},
|
|
258
|
-
"serve-test": {
|
|
259
|
-
"browserTarget": "<%= name %>:build:serve-test"
|
|
260
|
-
},
|
|
261
151
|
"serve-dev": {
|
|
262
152
|
"browserTarget": "<%= name %>:build:serve-dev"
|
|
263
153
|
},
|
|
264
|
-
"serve-local": {
|
|
265
|
-
"browserTarget": "<%= name %>:build:serve-local"
|
|
266
|
-
},
|
|
267
|
-
"serve-test-local": {
|
|
268
|
-
"browserTarget": "<%= name %>:build:serve-test-local"
|
|
269
|
-
}
|
|
270
154
|
},
|
|
271
155
|
"defaultConfiguration": "development"
|
|
272
156
|
},
|
|
@@ -10,13 +10,15 @@ import { StoreModule } from '@ngrx/store';
|
|
|
10
10
|
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
|
|
11
11
|
import { AppComponent } from './app.component';
|
|
12
12
|
import { appRoutes } from './app.routes';
|
|
13
|
-
import {
|
|
13
|
+
import { BasicInterceptor } from './basic-interceptor.interceptor';
|
|
14
14
|
|
|
15
15
|
import { AXFormatModule } from '@acorex/core/format';
|
|
16
16
|
import { AXValidationModule } from '@acorex/core/validation';
|
|
17
17
|
import {
|
|
18
|
+
AXPDexieStorageService,
|
|
18
19
|
AXPImageUrlLogoConfig,
|
|
19
20
|
AXPTextLogoConfig,
|
|
21
|
+
AXPStorageService,
|
|
20
22
|
AXP_PLATFORM_CONFIG_TOKEN,
|
|
21
23
|
configPlatform,
|
|
22
24
|
} from '@acorex/platform/common';
|
|
@@ -73,7 +75,7 @@ export function initApp() {
|
|
|
73
75
|
provideHttpClient(),
|
|
74
76
|
provideRouter(appRoutes, withEnabledBlockingInitialNavigation()),
|
|
75
77
|
{ provide: APP_INITIALIZER, useFactory: initApp, multi: true, deps: [] },
|
|
76
|
-
{ provide: HTTP_INTERCEPTORS, useClass:
|
|
78
|
+
{ provide: HTTP_INTERCEPTORS, useClass: BasicInterceptor, multi: true },
|
|
77
79
|
{
|
|
78
80
|
provide: AXP_ROOT_CONFIG_TOKEN, useValue: {
|
|
79
81
|
baseUrl: environment.baseUrl
|
|
@@ -92,6 +94,7 @@ export function initApp() {
|
|
|
92
94
|
'Copyright © 2024',
|
|
93
95
|
}),
|
|
94
96
|
},
|
|
97
|
+
{ provide: AXPStorageService, useClass: AXPDexieStorageService },
|
|
95
98
|
],
|
|
96
99
|
declarations: [AppComponent],
|
|
97
100
|
bootstrap: [AppComponent],
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
import { AXPSessionService } from '@acorex/platform/auth';
|
|
3
|
+
import { HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest, HttpEvent } from '@angular/common/http';
|
|
4
|
+
import { inject, Injectable } from '@angular/core';
|
|
5
|
+
import { Router } from '@angular/router';
|
|
6
|
+
import { Observable, throwError, from } from 'rxjs';
|
|
7
|
+
import { catchError, switchMap } from 'rxjs/operators';
|
|
8
|
+
|
|
9
|
+
@Injectable({ providedIn: 'root' })
|
|
10
|
+
export class BasicInterceptor implements HttpInterceptor {
|
|
11
|
+
private isRefreshing = false;
|
|
12
|
+
|
|
13
|
+
session = inject(AXPSessionService);
|
|
14
|
+
token = this.session.getToken();
|
|
15
|
+
router = inject(Router);
|
|
16
|
+
|
|
17
|
+
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<any> {
|
|
18
|
+
let modifiedReq = request.clone();
|
|
19
|
+
if (!(request.body instanceof FormData) && !request.headers.has('Content-Type')) {
|
|
20
|
+
modifiedReq = modifiedReq.clone({ setHeaders: { 'Content-Type': 'application/json' } });
|
|
21
|
+
}
|
|
22
|
+
if (this.token) {
|
|
23
|
+
modifiedReq = modifiedReq.clone({ setHeaders: { Authorization: `Bearer ${this.token}` } });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return next.handle(modifiedReq).pipe(
|
|
27
|
+
catchError((error: HttpErrorResponse) => {
|
|
28
|
+
if (error.status === 401 && !this.isRefreshing && this.token) {
|
|
29
|
+
return this.handle401Error(modifiedReq, next);
|
|
30
|
+
} else {
|
|
31
|
+
return throwError(() => error);
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private handle401Error(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
38
|
+
this.isRefreshing = true;
|
|
39
|
+
|
|
40
|
+
return from(this.session.refreshToken()).pipe(
|
|
41
|
+
switchMap((c) => {
|
|
42
|
+
this.isRefreshing = false;
|
|
43
|
+
|
|
44
|
+
const _req = request.clone({
|
|
45
|
+
setHeaders: {
|
|
46
|
+
Authorization: `Bearer ${c}`,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Retry the request with the new token
|
|
51
|
+
return next.handle(_req);
|
|
52
|
+
}),
|
|
53
|
+
catchError(() => {
|
|
54
|
+
this.isRefreshing = false;
|
|
55
|
+
this.session.signout();
|
|
56
|
+
this.router.navigate(['auth']); // Redirect to login on failure
|
|
57
|
+
return throwError(() => new Error('Token refresh failed'));
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
@@ -21,7 +21,7 @@ import { <%= upperCase(name) %>Strategy } from './auth.strategy';
|
|
|
21
21
|
provide: AXM_AUTH_CONFIG_TOKEN,
|
|
22
22
|
useValue: configAuthModule({
|
|
23
23
|
type: AXMAuthenticationTypes.UsernameEmailPassword,
|
|
24
|
-
|
|
24
|
+
authConfig: { ...environment.oidcConfig },
|
|
25
25
|
signinPage: {
|
|
26
26
|
description: `In this kind of post, the blogger introduces a person they’ve
|
|
27
27
|
interviewed and provides some background information about the
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AXPEntity } from '@acorex/platform/common';
|
|
2
|
+
import { AXPEntityDefinitionLoader } from '@acorex/platform/layout/entity';
|
|
2
3
|
import { Injectable, Injector, inject } from '@angular/core';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
5
|
-
export class AXPRootEntityLoader implements
|
|
6
|
+
export class AXPRootEntityLoader implements AXPEntityDefinitionLoader {
|
|
6
7
|
private injector = inject(Injector);
|
|
7
8
|
|
|
8
|
-
async get(moduleName: string, entityName: string): Promise<
|
|
9
|
+
async get(moduleName: string, entityName: string): Promise<AXPEntity | null> {
|
|
9
10
|
return new Promise(async (resolve) => {
|
|
10
11
|
switch (entityName) {
|
|
11
12
|
case 'sample': {
|
|
12
13
|
const entity = (await import('../<%= name %>/sample/sample.entity')).entityFactory;
|
|
13
|
-
resolve(entity(this.injector));
|
|
14
|
+
resolve(entity(this.injector) as any);
|
|
14
15
|
break;
|
|
15
16
|
}
|
|
16
17
|
default:
|
package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template
CHANGED
|
@@ -1,73 +1,70 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AXPCommonModule,
|
|
3
|
+
AXPComponentSlotModule,
|
|
2
4
|
AXPFooterTextSlotComponent,
|
|
5
|
+
AXPMenuItem,
|
|
3
6
|
AXPNavBarSlotComponent,
|
|
4
7
|
AXPThemeSlotComponent,
|
|
5
8
|
AXP_ENTITY_LOADER,
|
|
6
|
-
|
|
9
|
+
AXP_MENU_LOADER,
|
|
10
|
+
AXP_PLATFORM_CONFIG_TOKEN,
|
|
7
11
|
} from '@acorex/platform/common';
|
|
12
|
+
import { AXPLayoutModule } from '@acorex/platform/layouts';
|
|
8
13
|
import { NgModule, inject } from '@angular/core';
|
|
9
|
-
import { AXPRootMenuLoader } from './menu.loader';
|
|
10
|
-
import { AXPRootEntityLoader } from './entity.loader';
|
|
11
|
-
import { AXPCommonModule, AXPMenuItem, AXPNavigateAction, AXP_MENU_LOADER, AXP_PLATFORM_CONFIG_TOKEN } from '@acorex/platform/common';
|
|
12
14
|
import pkg from '../../../../../../package.json';
|
|
13
|
-
|
|
15
|
+
import { AXPRootEntityLoader } from './entity.loader';
|
|
16
|
+
import { AXPRootMenuLoader } from './menu.loader';
|
|
17
|
+
import { AXPEntityModule, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
|
|
18
|
+
import { AXPDefaultThemeModule } from '@acorex/platform/themes/default';
|
|
14
19
|
|
|
15
20
|
@NgModule({
|
|
16
21
|
imports: [
|
|
17
|
-
|
|
22
|
+
AXPDefaultThemeModule,
|
|
18
23
|
AXPCommonModule,
|
|
19
24
|
AXPLayoutModule,
|
|
25
|
+
AXPEntityModule,
|
|
20
26
|
AXPComponentSlotModule.forRoot({
|
|
21
|
-
|
|
27
|
+
'footer-start': [
|
|
22
28
|
{
|
|
23
|
-
name:
|
|
29
|
+
name: 'version',
|
|
24
30
|
component: AXPFooterTextSlotComponent,
|
|
25
31
|
options: () => {
|
|
26
32
|
return { text: `v${pkg.version}` };
|
|
27
|
-
}
|
|
33
|
+
},
|
|
28
34
|
},
|
|
29
35
|
{
|
|
30
|
-
name:
|
|
36
|
+
name: 'copyright',
|
|
31
37
|
component: AXPFooterTextSlotComponent,
|
|
32
38
|
options: () => {
|
|
33
39
|
const a = inject(AXP_PLATFORM_CONFIG_TOKEN);
|
|
34
40
|
return { text: a.copyright };
|
|
35
|
-
}
|
|
41
|
+
},
|
|
36
42
|
},
|
|
37
43
|
],
|
|
38
|
-
|
|
44
|
+
'auth-footer-links': [
|
|
39
45
|
{
|
|
40
|
-
name:
|
|
46
|
+
name: 'links',
|
|
41
47
|
component: AXPNavBarSlotComponent,
|
|
42
|
-
|
|
43
|
-
const items: AXPMenuItem[] = [
|
|
44
|
-
// {
|
|
45
|
-
// text: 'About',
|
|
46
|
-
// command: AXPNavigateAction({ payload: { commands: ['asc/help/about'] } })
|
|
47
|
-
// }
|
|
48
|
-
];
|
|
49
|
-
return { items };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
48
|
+
},
|
|
52
49
|
],
|
|
53
|
-
|
|
50
|
+
'header-end': [
|
|
54
51
|
{
|
|
55
52
|
name: 'theme',
|
|
56
53
|
component: AXPThemeSlotComponent,
|
|
57
54
|
},
|
|
58
55
|
],
|
|
59
|
-
})
|
|
56
|
+
}),
|
|
60
57
|
],
|
|
61
58
|
exports: [],
|
|
62
59
|
providers: [
|
|
63
60
|
{
|
|
64
61
|
provide: AXP_MENU_LOADER,
|
|
65
|
-
useClass: AXPRootMenuLoader
|
|
62
|
+
useClass: AXPRootMenuLoader,
|
|
66
63
|
},
|
|
67
64
|
{
|
|
68
|
-
provide:
|
|
69
|
-
useClass: AXPRootEntityLoader
|
|
65
|
+
provide: AXP_ENTITY_DEFINITION_LOADER,
|
|
66
|
+
useClass: AXPRootEntityLoader,
|
|
70
67
|
},
|
|
71
68
|
],
|
|
72
69
|
})
|
|
73
|
-
export class AXPLayoutRootModule {
|
|
70
|
+
export class AXPLayoutRootModule {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AXPDataGenerator } from '@acorex/platform/common';
|
|
2
|
+
|
|
3
|
+
export const USERS = Array.from({ length: 20 }).map((_, i) => {
|
|
4
|
+
const firstName = AXPDataGenerator.firstName();
|
|
5
|
+
const lastName = AXPDataGenerator.lastName();
|
|
6
|
+
return {
|
|
7
|
+
id: AXPDataGenerator.uuid(),
|
|
8
|
+
firstname: firstName,
|
|
9
|
+
lastname: lastName,
|
|
10
|
+
phone: AXPDataGenerator.phone(),
|
|
11
|
+
email: AXPDataGenerator.email(firstName, lastName),
|
|
12
|
+
address: AXPDataGenerator.address(),
|
|
13
|
+
};
|
|
14
|
+
});
|