@processpuzzle/base-entity 0.3.0 → 0.3.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 (47) hide show
  1. package/README.md +129 -129
  2. package/fesm2022/processpuzzle-base-entity.mjs +175 -99
  3. package/fesm2022/processpuzzle-base-entity.mjs.map +1 -1
  4. package/index.d.ts +378 -3
  5. package/package.json +26 -16
  6. package/lib/base-entity/abstact-attr.descriptor.d.ts +0 -21
  7. package/lib/base-entity/base-entity-attr.descriptor.d.ts +0 -29
  8. package/lib/base-entity/base-entity.d.ts +0 -3
  9. package/lib/base-entity/base-entity.descriptor.d.ts +0 -7
  10. package/lib/base-entity/filter-attr-descriptor.d.ts +0 -3
  11. package/lib/base-entity/flexboxDescriptor.d.ts +0 -11
  12. package/lib/base-entity-container.component.d.ts +0 -15
  13. package/lib/base-entity-container.store.d.ts +0 -12
  14. package/lib/base-entity-service/base-entity-firestore.service.d.ts +0 -27
  15. package/lib/base-entity-service/base-entity-load-response.d.ts +0 -48
  16. package/lib/base-entity-service/base-entity-rest.service.d.ts +0 -26
  17. package/lib/base-entity-service/base-entity.service.d.ts +0 -14
  18. package/lib/base-entity-store/addEntity.d.ts +0 -9
  19. package/lib/base-entity-store/base-entity.store.d.ts +0 -78
  20. package/lib/base-entity-store/deleteAllEntities.d.ts +0 -9
  21. package/lib/base-entity-store/deleteEntity.d.ts +0 -9
  22. package/lib/base-entity-store/findByQuery.d.ts +0 -10
  23. package/lib/base-entity-store/updateEntity.d.ts +0 -9
  24. package/lib/base-entity.mapper.d.ts +0 -7
  25. package/lib/base-entity.routes.d.ts +0 -2
  26. package/lib/base-form/base-entity-form.builder.d.ts +0 -11
  27. package/lib/base-form/base-entity-form.component.d.ts +0 -24
  28. package/lib/base-form/base-form-control.component.d.ts +0 -17
  29. package/lib/base-form/base-form-host.directive.d.ts +0 -8
  30. package/lib/base-form/checkbox/checkbox.component.d.ts +0 -7
  31. package/lib/base-form/datepicker/datepicker.component.d.ts +0 -7
  32. package/lib/base-form/dropdown/dropdown.component.d.ts +0 -7
  33. package/lib/base-form/flex-box/flex-box-host.directive.d.ts +0 -8
  34. package/lib/base-form/flex-box/flex-box.component.d.ts +0 -11
  35. package/lib/base-form/foreign-key/foreign-key.component.d.ts +0 -8
  36. package/lib/base-form/label/label.component.d.ts +0 -7
  37. package/lib/base-form/radio/radio.component.d.ts +0 -7
  38. package/lib/base-form/textarea/textarea.component.d.ts +0 -7
  39. package/lib/base-form/textbox/textbox.component.d.ts +0 -7
  40. package/lib/base-form-navigator/base-form-navigator.store.d.ts +0 -30
  41. package/lib/base-form-navigator/base-url-segments.d.ts +0 -7
  42. package/lib/base-list/base-entity-list.component.d.ts +0 -38
  43. package/lib/base-statusbar/base-entity-statusbar.component.d.ts +0 -13
  44. package/lib/base-tabs/base-entity-tabs.component.d.ts +0 -18
  45. package/lib/base-tabs/base-entity-tabs.store.d.ts +0 -16
  46. package/lib/base-toolbar/base-entity-toolbar.component.d.ts +0 -19
  47. package/public-api.d.ts +0 -19
package/README.md CHANGED
@@ -1,129 +1,129 @@
1
- # @processpuzzle/base-entity
2
-
3
- ![Build and Test](https://github.com/ZsZs/processpuzzle/actions/workflows/build-base-entity.yml/badge.svg)
4
- [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=processpuzzle_base_entity)](https://sonarcloud.io/summary/new_code?id=processpuzzle_base_entity&branch=develop)
5
- [![Node version](https://img.shields.io/node/v/[%40processpuzzle%2base-entity].svg?style=flat)](https://nodejs.org/download/)
6
-
7
- ## Introduction
8
-
9
- Base-Entity is a run-time form and table generator base on Entity Descriptor and Entity Attribute Descriptor. To make it short:
10
-
11
- <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-bird-eye-view.png?raw=true">
12
- <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-bird-eye-view.png?raw=true" width=600px alt="Bird eye view">
13
- </a>
14
-
15
- From these **Inputs:**
16
-
17
- - Entity Descriptor => Describes the subject entity and probable it's associated entities.
18
- - Entity Attribute Descriptor => Specifies the presentation style of each attribute.
19
-
20
- generates these **Outputs:**
21
-
22
- - Reactive Form Component => Reactive Angular form, created dynamically, run-time.
23
- - Angular Material Table => Angular Material Table, create dynamically, run-time.
24
-
25
- Of course this is a very coarse, abstract view of the functionality. In more detail, the library offers the following classes:
26
-
27
- <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-architectural-context.png?raw=true">
28
- <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-architectural-context.png?raw=true" width=600px alt="Architectural Context">
29
- </a>
30
-
31
- - Base Entity => interface to implement from the subject Custom Entity
32
- - Base Entity Service => abstract class to extend by the Custom Service to deliver the Custom Entity
33
- - Base Entity Mapper => abstract class to extend to map the Custom Entity from/to DTO
34
- - Base Entity Store => signal store for the components generated by the library
35
- - Base Entity Container => Angular component to contain the generated table and form
36
- - Base Entity List => Angular Material Table to display the Custom Entities in a table form
37
- - Base Entity Form => Reactive Angular Form to facilitate CRUD on a single custom object
38
-
39
- ## Usage
40
-
41
- Basically the library user has to extend a couple of base classes. These extensions are minimal, it't more like configuration of the base class.
42
-
43
- <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-design_overview.png?raw=true">
44
- <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-design_overview.png?raw=true" width=600px alt="Design Overview">
45
- </a>
46
-
47
- ### Extend **Base Entity**
48
-
49
- As the **Base Entity** interface defines only an ID, you are almost completely free how you define your Entity to be managed by the library. For an example see the [sample entities](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), like TestEntity, TestEntityComponent and TrunkData.
50
-
51
- ```typescript
52
- export class TestEntity implements BaseEntity {
53
- id: string = uuidv4();
54
- name? = '';
55
- description?: string = '';
56
- boolean?: boolean;
57
- number?: number;
58
- date?: Date;
59
- selectable?: number;
60
- private enumValue: TestEnum;
61
- }
62
- ```
63
-
64
- The Base Entity Mapper increases the flexibility how you can define your Entity to be managed even more as it offers a mapping between the mostly predefined DTOs and the Entity in the front end. For an example see the [sample mappers](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), TestEntityMapper, TestEntityComponentMapper and TrunkDataMapper.
65
- ```typescript
66
- @Injectable({ providedIn: 'root' })
67
- export class TestEntityMapper implements BaseEntityMapper<TestEntity> {
68
- fromDto(dto: any): TestEntity {
69
- return new TestEntity(dto.id, dto.name, dto.description, dto.boolean, dto.number, dto.date, getEnumKeyByEnumValue<TestEnum>(TestEnum, dto.enumValue));
70
- }
71
-
72
- toDto(entity: TestEntity): any {
73
- return entity;
74
- }
75
- }
76
-
77
- function getEnumKeyByEnumValue<E>(myEnum: { [key: number]: string }, enumValue: any): E | undefined {
78
- return Object.values(myEnum)[enumValue] as E;
79
- }
80
- ```
81
- To be able to configure the rather generic Data Service (BaseEntityService), you have to subclass it and provide in the constructor the required mapper, configuration key and resource path for the base URL.
82
- For an example see the [sample data services](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), like TestEntityService, TestEntityComponentService and TrunkDataService.
83
- ```typescript
84
- @Injectable({ providedIn: 'root' })
85
- export class TestEntityService extends BaseEntityService<TestEntity> {
86
- constructor(protected override entityMapper: TestEntityMapper) {
87
- super(entityMapper, 'TEST_SERVICE_ROOT', 'test-entity');
88
- }
89
- }
90
- ```
91
- Of course, you are free to define your own data access methods as much they are needed by your custom Signal Store or other objects.
92
-
93
- The core piece of this library's domain layer is the BaseEntityStore, a signal store, which is used by the generated angular components.
94
- The BaseEntityStore provides methods for CRUD operations and enhanced usability status. For details see the diagram above, or the [source code](https://github.com/ZsZs/processpuzzle/blob/develop/libs/base-entity/src/lib/base-entity.store.ts)
95
- To be able to use it, you just have to define your own signal store, with the usage of BaseEntityStore (Signal Store Feature).
96
- ```typescript
97
- export const TestEntityStore = signalStore(
98
- { providedIn: 'root' },
99
- BaseEntityStore<TestEntity>(TestEntity, TestEntityService),
100
- BaseFormNavigatorStore<TestEntity>(TestEntity),
101
- BaseEntityTabsStore(),
102
- BaseEntityContainerStore(),
103
- );
104
- ```
105
- The BaseFormNavigatorStore, BaseEntityTabsStore and BaseEntityContainerStore provides additional enhanced usability services, which will be explained in the Design section.
106
-
107
- ```typescript
108
- const selectables = Object.keys(TestEnum)
109
- .filter((key: any) => parseInt(key) >= 0)
110
- .map((key: string) => ({ key: key, value: TestEnum[key as keyof typeof TestEnum] }));
111
-
112
- const nameAttr = new BaseEntityAttrDescriptor('name', FormControlType.TEXT_BOX, 'Name', undefined, true);
113
- const descriptionAttr = new BaseEntityAttrDescriptor('description', FormControlType.TEXTAREA, 'Description');
114
- const booleanAttr = new BaseEntityAttrDescriptor('boolean', FormControlType.CHECKBOX, 'Boolean');
115
- const numberAttr = new BaseEntityAttrDescriptor('number', FormControlType.TEXT_BOX, 'Number', undefined, false, { inputType: 'number' });
116
- const dateAttr = new BaseEntityAttrDescriptor('date', FormControlType.DATE, 'Date', undefined, false, { inputType: 'date' });
117
- const enumAttr = new BaseEntityAttrDescriptor('enumValue', FormControlType.DROPDOWN, 'Enum', selectables);
118
-
119
- export const testEntityDescriptors: BaseEntityAttrDescriptor<TestEntity>[] = [nameAttr, descriptionAttr, booleanAttr, numberAttr, dateAttr, enumAttr];
120
-
121
- const baseEntityDescriptor: BaseEntityDescriptor = {
122
- entityName: 'Test Entity',
123
- store: this.store,
124
- attrDescriptors: testEntityAttrDescriptors,
125
- entityTitle: "this.store.currentEntity() ? this.store.currentEntity().name : ''",
126
- };
127
- ```
128
-
129
-
1
+ # @processpuzzle/base-entity
2
+
3
+ ![Build and Test](https://github.com/ZsZs/processpuzzle/actions/workflows/build-base-entity.yml/badge.svg)
4
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=processpuzzle_base_entity&metric=alert_status)](https://sonarcloud.io/summary?id=processpuzzle_base_entity)
5
+ [![Node version](https://img.shields.io/npm/v/%40processpuzzle%2Fbase-entity?style=flat)](https://www.npmjs.com/package/@processpuzzle/base-entity)
6
+
7
+ ## Introduction
8
+
9
+ Base-Entity is a run-time form and table generator base on Entity Descriptor and Entity Attribute Descriptor. To make it short:
10
+
11
+ <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-bird-eye-view.png?raw=true">
12
+ <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-bird-eye-view.png?raw=true" width=600px alt="Bird eye view">
13
+ </a>
14
+
15
+ From these **Inputs:**
16
+
17
+ - Entity Descriptor => Describes the subject entity and probable it's associated entities.
18
+ - Entity Attribute Descriptor => Specifies the presentation style of each attribute.
19
+
20
+ generates these **Outputs:**
21
+
22
+ - Reactive Form Component => Reactive Angular form, created dynamically, run-time.
23
+ - Angular Material Table => Angular Material Table, create dynamically, run-time.
24
+
25
+ Of course this is a very coarse, abstract view of the functionality. In more detail, the library offers the following classes:
26
+
27
+ <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-architectural-context.png?raw=true">
28
+ <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-architectural-context.png?raw=true" width=600px alt="Architectural Context">
29
+ </a>
30
+
31
+ - Base Entity => interface to implement from the subject Custom Entity
32
+ - Base Entity Service => abstract class to extend by the Custom Service to deliver the Custom Entity
33
+ - Base Entity Mapper => abstract class to extend to map the Custom Entity from/to DTO
34
+ - Base Entity Store => signal store for the components generated by the library
35
+ - Base Entity Container => Angular component to contain the generated table and form
36
+ - Base Entity List => Angular Material Table to display the Custom Entities in a table form
37
+ - Base Entity Form => Reactive Angular Form to facilitate CRUD on a single custom object
38
+
39
+ ## Usage
40
+
41
+ Basically the library user has to extend a couple of base classes. These extensions are minimal, it't more like configuration of the base class.
42
+
43
+ <a href="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-design_overview.png?raw=true">
44
+ <img src="https://github.com/ZsZs/processpuzzle/blob/develop/docs/base-entity-design_overview.png?raw=true" width=600px alt="Design Overview">
45
+ </a>
46
+
47
+ ### Extend **Base Entity**
48
+
49
+ As the **Base Entity** interface defines only an ID, you are almost completely free how you define your Entity to be managed by the library. For an example see the [sample entities](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), like TestEntity, TestEntityComponent and TrunkData.
50
+
51
+ ```typescript
52
+ export class TestEntity implements BaseEntity {
53
+ id: string = uuidv4();
54
+ name? = '';
55
+ description?: string = '';
56
+ boolean?: boolean;
57
+ number?: number;
58
+ date?: Date;
59
+ selectable?: number;
60
+ private enumValue: TestEnum;
61
+ }
62
+ ```
63
+
64
+ The Base Entity Mapper increases the flexibility how you can define your Entity to be managed even more as it offers a mapping between the mostly predefined DTOs and the Entity in the front end. For an example see the [sample mappers](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), TestEntityMapper, TestEntityComponentMapper and TrunkDataMapper.
65
+ ```typescript
66
+ @Injectable({ providedIn: 'root' })
67
+ export class TestEntityMapper implements BaseEntityMapper<TestEntity> {
68
+ fromDto(dto: any): TestEntity {
69
+ return new TestEntity(dto.id, dto.name, dto.description, dto.boolean, dto.number, dto.date, getEnumKeyByEnumValue<TestEnum>(TestEnum, dto.enumValue));
70
+ }
71
+
72
+ toDto(entity: TestEntity): any {
73
+ return entity;
74
+ }
75
+ }
76
+
77
+ function getEnumKeyByEnumValue<E>(myEnum: { [key: number]: string }, enumValue: any): E | undefined {
78
+ return Object.values(myEnum)[enumValue] as E;
79
+ }
80
+ ```
81
+ To be able to configure the rather generic Data Service (BaseEntityService), you have to subclass it and provide in the constructor the required mapper, configuration key and resource path for the base URL.
82
+ For an example see the [sample data services](https://github.com/ZsZs/processpuzzle/tree/develop/apps/processpuzzle-testbed/src/app/content/base-forms), like TestEntityService, TestEntityComponentService and TrunkDataService.
83
+ ```typescript
84
+ @Injectable({ providedIn: 'root' })
85
+ export class TestEntityService extends BaseEntityService<TestEntity> {
86
+ constructor(protected override entityMapper: TestEntityMapper) {
87
+ super(entityMapper, 'TEST_SERVICE_ROOT', 'test-entity');
88
+ }
89
+ }
90
+ ```
91
+ Of course, you are free to define your own data access methods as much they are needed by your custom Signal Store or other objects.
92
+
93
+ The core piece of this library's domain layer is the BaseEntityStore, a signal store, which is used by the generated angular components.
94
+ The BaseEntityStore provides methods for CRUD operations and enhanced usability status. For details see the diagram above, or the [source code](https://github.com/ZsZs/processpuzzle/blob/develop/libs/base-entity/src/lib/base-entity.store.ts)
95
+ To be able to use it, you just have to define your own signal store, with the usage of BaseEntityStore (Signal Store Feature).
96
+ ```typescript
97
+ export const TestEntityStore = signalStore(
98
+ { providedIn: 'root' },
99
+ BaseEntityStore<TestEntity>(TestEntity, TestEntityService),
100
+ BaseFormNavigatorStore<TestEntity>(TestEntity),
101
+ BaseEntityTabsStore(),
102
+ BaseEntityContainerStore(),
103
+ );
104
+ ```
105
+ The BaseFormNavigatorStore, BaseEntityTabsStore and BaseEntityContainerStore provides additional enhanced usability services, which will be explained in the Design section.
106
+
107
+ ```typescript
108
+ const selectables = Object.keys(TestEnum)
109
+ .filter((key: any) => parseInt(key) >= 0)
110
+ .map((key: string) => ({ key: key, value: TestEnum[key as keyof typeof TestEnum] }));
111
+
112
+ const nameAttr = new BaseEntityAttrDescriptor('name', FormControlType.TEXT_BOX, 'Name', undefined, true);
113
+ const descriptionAttr = new BaseEntityAttrDescriptor('description', FormControlType.TEXTAREA, 'Description');
114
+ const booleanAttr = new BaseEntityAttrDescriptor('boolean', FormControlType.CHECKBOX, 'Boolean');
115
+ const numberAttr = new BaseEntityAttrDescriptor('number', FormControlType.TEXT_BOX, 'Number', undefined, false, { inputType: 'number' });
116
+ const dateAttr = new BaseEntityAttrDescriptor('date', FormControlType.DATE, 'Date', undefined, false, { inputType: 'date' });
117
+ const enumAttr = new BaseEntityAttrDescriptor('enumValue', FormControlType.DROPDOWN, 'Enum', selectables);
118
+
119
+ export const testEntityDescriptors: BaseEntityAttrDescriptor<TestEntity>[] = [nameAttr, descriptionAttr, booleanAttr, numberAttr, dateAttr, enumAttr];
120
+
121
+ const baseEntityDescriptor: BaseEntityDescriptor = {
122
+ entityName: 'Test Entity',
123
+ store: this.store,
124
+ attrDescriptors: testEntityAttrDescriptors,
125
+ entityTitle: "this.store.currentEntity() ? this.store.currentEntity().name : ''",
126
+ };
127
+ ```
128
+
129
+