@wawjs/ngx-bos 22.0.0 → 22.0.1

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.
Files changed (49) hide show
  1. package/AGENTS.md +23 -23
  2. package/README.md +105 -105
  3. package/RELEASES.md +19 -19
  4. package/ai/architecture.md +40 -40
  5. package/ai/code-style.md +33 -33
  6. package/ai/decisions/2026-06-02-browser-only-bos-spa.md +16 -16
  7. package/ai/decisions/2026-06-02-package-boundary.md +22 -22
  8. package/ai/decisions/2026-06-02-version-start.md +12 -12
  9. package/ai/decisions/index.md +7 -7
  10. package/ai/onboarding.md +19 -19
  11. package/ai/task-execution.md +35 -35
  12. package/ai/tooling.md +33 -33
  13. package/fesm2022/wawjs-ngx-bos.mjs +2 -2
  14. package/fesm2022/wawjs-ngx-bos.mjs.map +1 -1
  15. package/package.json +1 -1
  16. package/src/feature/file/file.component.ts +220 -220
  17. package/src/feature/file/file.interface.ts +12 -12
  18. package/src/feature/file/file.service.ts +34 -34
  19. package/src/feature/file/pages/files/files.component.html +2 -2
  20. package/src/feature/file/pages/files/files.component.ts +117 -117
  21. package/src/feature/file/pages/files/files.routes.ts +9 -9
  22. package/src/feature/file/selectors/file/file-selector.component.ts +27 -27
  23. package/src/feature/user/guards/admins.guard.ts +22 -22
  24. package/src/feature/user/guards/authenticated.guard.ts +14 -14
  25. package/src/feature/user/guards/guest.guard.ts +14 -14
  26. package/src/feature/user/pages/clients/clients.component.ts +45 -45
  27. package/src/feature/user/pages/clients/clients.routes.ts +1 -1
  28. package/src/feature/user/pages/users/users.component.ts +57 -57
  29. package/src/feature/user/pages/users/users.routes.ts +1 -1
  30. package/src/feature/user/selectors/user/user-selector.component.ts +17 -17
  31. package/src/feature/user/user.const.ts +3 -3
  32. package/src/feature/user/user.form.ts +54 -54
  33. package/src/feature/user/user.interface.ts +12 -12
  34. package/src/feature/user/user.service.ts +176 -176
  35. package/src/form-components/ace/ace.component.ts +210 -210
  36. package/src/form-components/button/button.component.ts +31 -31
  37. package/src/form-components/file/file.component.ts +91 -91
  38. package/src/form-components/form-bridge.interface.ts +27 -27
  39. package/src/form-components/index.ts +85 -85
  40. package/src/form-components/input/input.component.ts +31 -31
  41. package/src/form-components/select/select.component.ts +31 -31
  42. package/src/form-components/tinymce/tinymce.component.ts +221 -221
  43. package/src/ngx-bos.config.ts +55 -55
  44. package/src/pages/form/form.component.ts +86 -86
  45. package/src/pages/form/form.routes.ts +1 -1
  46. package/src/pages/forms/forms.component.ts +15 -15
  47. package/src/pages/forms/forms.routes.ts +1 -1
  48. package/src/pipes/phone.pipe.ts +17 -17
  49. package/src/public-api.ts +36 -36
@@ -1,8 +1,8 @@
1
1
  import { User } from './user.interface';
2
2
 
3
- export const NEW_USER: User = {
4
- _id: '',
5
- data: {},
3
+ export const NEW_USER: User = {
4
+ _id: '',
5
+ data: {},
6
6
  is: {},
7
7
  roles: [],
8
8
  name: '',
@@ -1,54 +1,54 @@
1
- import { inject } from '@angular/core';
2
- import { FormComponentInterface } from '@wawjs/ngx-form';
3
- import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
4
-
5
- export const createUserFormComponents = (
6
- userForm: FormComponentInterface[] = [],
7
- ) => ({
8
- formId: 'user',
9
- title: 'Profile Settings',
10
- components: [
11
- {
12
- name: 'Input',
13
- key: 'name',
14
- focused: true,
15
- props: {
16
- placeholder: 'Enter name...',
17
- label: 'Name',
18
- },
19
- },
20
- {
21
- name: 'Input',
22
- key: 'email',
23
- props: {
24
- placeholder: 'Enter email...',
25
- label: 'Email',
26
- type: 'email',
27
- },
28
- },
29
- {
30
- name: 'Input',
31
- key: 'phone',
32
- props: {
33
- placeholder: 'Enter phone...',
34
- label: 'Phone',
35
- },
36
- },
37
- {
38
- name: 'Input',
39
- key: 'bio',
40
- props: {
41
- placeholder: 'Enter bio...',
42
- label: 'Biography',
43
- type: 'textarea',
44
- },
45
- },
46
- ...userForm,
47
- ],
48
- });
49
-
50
- export const userFormComponentsFactory = () => {
51
- const config = inject(NGX_BOS_CONFIG);
52
-
53
- return createUserFormComponents(config.userForm);
54
- };
1
+ import { inject } from '@angular/core';
2
+ import { FormComponentInterface } from '@wawjs/ngx-form';
3
+ import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
4
+
5
+ export const createUserFormComponents = (
6
+ userForm: FormComponentInterface[] = [],
7
+ ) => ({
8
+ formId: 'user',
9
+ title: 'Profile Settings',
10
+ components: [
11
+ {
12
+ name: 'Input',
13
+ key: 'name',
14
+ focused: true,
15
+ props: {
16
+ placeholder: 'Enter name...',
17
+ label: 'Name',
18
+ },
19
+ },
20
+ {
21
+ name: 'Input',
22
+ key: 'email',
23
+ props: {
24
+ placeholder: 'Enter email...',
25
+ label: 'Email',
26
+ type: 'email',
27
+ },
28
+ },
29
+ {
30
+ name: 'Input',
31
+ key: 'phone',
32
+ props: {
33
+ placeholder: 'Enter phone...',
34
+ label: 'Phone',
35
+ },
36
+ },
37
+ {
38
+ name: 'Input',
39
+ key: 'bio',
40
+ props: {
41
+ placeholder: 'Enter bio...',
42
+ label: 'Biography',
43
+ type: 'textarea',
44
+ },
45
+ },
46
+ ...userForm,
47
+ ],
48
+ });
49
+
50
+ export const userFormComponentsFactory = () => {
51
+ const config = inject(NGX_BOS_CONFIG);
52
+
53
+ return createUserFormComponents(config.userForm);
54
+ };
@@ -1,12 +1,12 @@
1
- import { CrudDocument } from '@wawjs/ngx-crud';
2
-
3
- export interface User extends CrudDocument<User> {
4
- data: Record<string, unknown>;
5
- is: Record<string, boolean>;
6
- roles: string[];
7
- name: string;
8
- phone: string;
9
- bio: string;
10
- email: string;
11
- thumb: string;
12
- }
1
+ import { CrudDocument } from '@wawjs/ngx-crud';
2
+
3
+ export interface User extends CrudDocument<User> {
4
+ data: Record<string, unknown>;
5
+ is: Record<string, boolean>;
6
+ roles: string[];
7
+ name: string;
8
+ phone: string;
9
+ bio: string;
10
+ email: string;
11
+ thumb: string;
12
+ }
@@ -1,176 +1,176 @@
1
- import { Service, computed, inject, signal } from '@angular/core';
2
- import { Router } from '@angular/router';
3
- import { AlertService } from '@wawjs/ngx-ui';
4
- import { CrudService } from '@wawjs/ngx-crud';
5
- import { EmitterService } from '@wawjs/ngx-core';
6
- import { HttpService } from '@wawjs/ngx-http';
7
- import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
8
- import { User } from './user.interface';
9
- @Service()
10
- export class UserService extends CrudService<User> {
11
- private readonly _userHttpService = inject(HttpService);
12
-
13
- private readonly _alertService = inject(AlertService);
14
-
15
- private readonly _router = inject(Router);
16
-
17
- private readonly _emitterService = inject(EmitterService);
18
-
19
- private readonly _bosConfig = inject(NGX_BOS_CONFIG);
20
-
21
- readonly url = this._bosConfig.url;
22
-
23
- roles = this._bosConfig.roles.concat(['admin']);
24
-
25
- employees = this._bosConfig.roles;
26
-
27
- users = signal<User[]>(this.documents());
28
-
29
- user = signal<User>(
30
- localStorage.getItem('waw_user')
31
- ? JSON.parse(localStorage.getItem('waw_user') as string)
32
- : this.prepareDocument()(),
33
- );
34
-
35
- thumb = computed(() => {
36
- const thumb = this.user().thumb;
37
-
38
- return !thumb || thumb.includes(this._bosConfig.defaultUserThumb)
39
- ? this._bosConfig.defaultUserThumb
40
- : this.url + thumb;
41
- });
42
-
43
- role(role: string): boolean {
44
- return !!(this.user().is || {})[role];
45
- }
46
-
47
- readonly usersByRole = computed<Record<string, User[]>>(() => {
48
- const splitted: Record<string, User[]> = {};
49
-
50
- for (const user of this.documents()) {
51
- for (const role of user.roles || []) {
52
- if (role === undefined || role === null) continue;
53
- (splitted[String(role)] ??= []).push(user);
54
- }
55
- }
56
-
57
- return splitted;
58
- });
59
-
60
- constructor() {
61
- super({
62
- name: 'user',
63
- replace: (user) => {
64
- user.roles = [];
65
- user.data = user.data || {};
66
- user.is = user.is || {};
67
-
68
- for (const field of this._bosConfig.userFields) {
69
- user.data[field] = user.data[field] || {};
70
- }
71
-
72
- for (const role of this.roles) {
73
- if (user.is[role]) {
74
- user.roles.push(role);
75
- }
76
- }
77
-
78
- return user;
79
- },
80
- });
81
-
82
- if (localStorage.getItem('waw_user')) {
83
- this.fetch({}, { name: 'me' }).subscribe((user: User) => {
84
- if (user) {
85
- if (
86
- !localStorage.getItem('waw_user') &&
87
- this._router.url === this._bosConfig.signPath
88
- ) {
89
- this._router.navigateByUrl(this._bosConfig.profilePath);
90
- }
91
-
92
- this.setUser(user);
93
- } else if (localStorage.getItem('waw_user')) {
94
- this.logout();
95
- }
96
- });
97
-
98
- this.get({
99
- query: this._bosConfig.appId ? 'appId=' + this._bosConfig.appId : '',
100
- });
101
- }
102
- }
103
-
104
- setUser(user: User) {
105
- this.user.set(user);
106
-
107
- localStorage.setItem('waw_user', JSON.stringify(user));
108
-
109
- this._emitterService.complete('us.user');
110
- }
111
-
112
- updateMe() {
113
- this.setUser(this.user());
114
-
115
- return this.update(this.user()).subscribe(() => {
116
- this._alertService.info({
117
- text: 'Profile information has been updated',
118
- });
119
- });
120
- }
121
-
122
- updateMeAfterWhile() {
123
- this.setUser(this.user());
124
-
125
- this.updateAfterWhile(this.user());
126
- }
127
-
128
- changePassword(oldPass: string, newPass: string) {
129
- return this._userHttpService.post(
130
- '/api/user/changePassword',
131
- {
132
- newPass: newPass,
133
- oldPass: oldPass,
134
- },
135
- (resp: boolean) => {
136
- if (resp) {
137
- this._alertService.info({
138
- text: 'Successfully changed password',
139
- });
140
- } else {
141
- this._alertService.error({
142
- text: 'Incorrect current password',
143
- });
144
- }
145
- },
146
- );
147
- }
148
-
149
- logout() {
150
- this.user.set(this.prepareDocument()());
151
-
152
- localStorage.removeItem('waw_user');
153
-
154
- this._userHttpService.remove('token');
155
-
156
- this._userHttpService.get('/api/user/logout');
157
-
158
- this._router.navigateByUrl(this._bosConfig.signPath);
159
-
160
- setTimeout(() => {
161
- location.reload();
162
- }, 100);
163
- }
164
-
165
- updateAdmin(user: User) {
166
- return this.update(user, {
167
- name: 'admin',
168
- });
169
- }
170
-
171
- deleteAdmin(user: User) {
172
- return this.delete(user, {
173
- name: 'admin',
174
- });
175
- }
176
- }
1
+ import { Service, computed, inject, signal } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { AlertService } from '@wawjs/ngx-ui';
4
+ import { CrudService } from '@wawjs/ngx-crud';
5
+ import { EmitterService } from '@wawjs/ngx-core';
6
+ import { HttpService } from '@wawjs/ngx-http';
7
+ import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
8
+ import { User } from './user.interface';
9
+ @Service()
10
+ export class UserService extends CrudService<User> {
11
+ private readonly _userHttpService = inject(HttpService);
12
+
13
+ private readonly _alertService = inject(AlertService);
14
+
15
+ private readonly _router = inject(Router);
16
+
17
+ private readonly _emitterService = inject(EmitterService);
18
+
19
+ private readonly _bosConfig = inject(NGX_BOS_CONFIG);
20
+
21
+ readonly url = this._bosConfig.url;
22
+
23
+ roles = this._bosConfig.roles.concat(['admin']);
24
+
25
+ employees = this._bosConfig.roles;
26
+
27
+ users = signal<User[]>(this.documents());
28
+
29
+ user = signal<User>(
30
+ localStorage.getItem('waw_user')
31
+ ? JSON.parse(localStorage.getItem('waw_user') as string)
32
+ : this.prepareDocument()(),
33
+ );
34
+
35
+ thumb = computed(() => {
36
+ const thumb = this.user().thumb;
37
+
38
+ return !thumb || thumb.includes(this._bosConfig.defaultUserThumb)
39
+ ? this._bosConfig.defaultUserThumb
40
+ : this.url + thumb;
41
+ });
42
+
43
+ role(role: string): boolean {
44
+ return !!(this.user().is || {})[role];
45
+ }
46
+
47
+ readonly usersByRole = computed<Record<string, User[]>>(() => {
48
+ const splitted: Record<string, User[]> = {};
49
+
50
+ for (const user of this.documents()) {
51
+ for (const role of user.roles || []) {
52
+ if (role === undefined || role === null) continue;
53
+ (splitted[String(role)] ??= []).push(user);
54
+ }
55
+ }
56
+
57
+ return splitted;
58
+ });
59
+
60
+ constructor() {
61
+ super({
62
+ name: 'user',
63
+ replace: (user) => {
64
+ user.roles = [];
65
+ user.data = user.data || {};
66
+ user.is = user.is || {};
67
+
68
+ for (const field of this._bosConfig.userFields) {
69
+ user.data[field] = user.data[field] || {};
70
+ }
71
+
72
+ for (const role of this.roles) {
73
+ if (user.is[role]) {
74
+ user.roles.push(role);
75
+ }
76
+ }
77
+
78
+ return user;
79
+ },
80
+ });
81
+
82
+ if (localStorage.getItem('waw_user')) {
83
+ this.fetch({}, { name: 'me' }).subscribe((user: User) => {
84
+ if (user) {
85
+ if (
86
+ !localStorage.getItem('waw_user') &&
87
+ this._router.url === this._bosConfig.signPath
88
+ ) {
89
+ this._router.navigateByUrl(this._bosConfig.profilePath);
90
+ }
91
+
92
+ this.setUser(user);
93
+ } else if (localStorage.getItem('waw_user')) {
94
+ this.logout();
95
+ }
96
+ });
97
+
98
+ this.get({
99
+ query: this._bosConfig.appId ? 'appId=' + this._bosConfig.appId : '',
100
+ });
101
+ }
102
+ }
103
+
104
+ setUser(user: User) {
105
+ this.user.set(user);
106
+
107
+ localStorage.setItem('waw_user', JSON.stringify(user));
108
+
109
+ this._emitterService.complete('us.user');
110
+ }
111
+
112
+ updateMe() {
113
+ this.setUser(this.user());
114
+
115
+ return this.update(this.user()).subscribe(() => {
116
+ this._alertService.info({
117
+ text: 'Profile information has been updated',
118
+ });
119
+ });
120
+ }
121
+
122
+ updateMeAfterWhile() {
123
+ this.setUser(this.user());
124
+
125
+ this.updateAfterWhile(this.user());
126
+ }
127
+
128
+ changePassword(oldPass: string, newPass: string) {
129
+ return this._userHttpService.post(
130
+ '/api/user/changePassword',
131
+ {
132
+ newPass: newPass,
133
+ oldPass: oldPass,
134
+ },
135
+ (resp: boolean) => {
136
+ if (resp) {
137
+ this._alertService.info({
138
+ text: 'Successfully changed password',
139
+ });
140
+ } else {
141
+ this._alertService.error({
142
+ text: 'Incorrect current password',
143
+ });
144
+ }
145
+ },
146
+ );
147
+ }
148
+
149
+ logout() {
150
+ this.user.set(this.prepareDocument()());
151
+
152
+ localStorage.removeItem('waw_user');
153
+
154
+ this._userHttpService.remove('token');
155
+
156
+ this._userHttpService.get('/api/user/logout');
157
+
158
+ this._router.navigateByUrl(this._bosConfig.signPath);
159
+
160
+ setTimeout(() => {
161
+ location.reload();
162
+ }, 100);
163
+ }
164
+
165
+ updateAdmin(user: User) {
166
+ return this.update(user, {
167
+ name: 'admin',
168
+ });
169
+ }
170
+
171
+ deleteAdmin(user: User) {
172
+ return this.delete(user, {
173
+ name: 'admin',
174
+ });
175
+ }
176
+ }