@mediusinc/mng-commons-data-api-class 5.0.0-rc.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.
Files changed (63) hide show
  1. package/README.md +16 -0
  2. package/esm2022/index.mjs +9 -0
  3. package/esm2022/lib/models/query-result.model.mjs +24 -0
  4. package/esm2022/lib/serder/object-serializer.mjs +184 -0
  5. package/esm2022/lib/services/api.abstract.service.mjs +55 -0
  6. package/esm2022/lib/services/crud-api.abstract.service.mjs +82 -0
  7. package/esm2022/lib/services/get-all-api.abstract.service.mjs +49 -0
  8. package/esm2022/mediusinc-mng-commons-data-api-class.mjs +5 -0
  9. package/esm2022/tableview/index.mjs +3 -0
  10. package/esm2022/tableview/mediusinc-mng-commons-data-api-class-tableview.mjs +5 -0
  11. package/esm2022/tableview/tableview-crud-create.mjs +40 -0
  12. package/esm2022/tableview/tableview-crud.data-provider.mjs +50 -0
  13. package/esm2022/v1/helpers/query-param-convert.mjs +103 -0
  14. package/esm2022/v1/helpers/tableview-crud-create.mjs +21 -0
  15. package/esm2022/v1/index.mjs +21 -0
  16. package/esm2022/v1/mediusinc-mng-commons-data-api-class-v1.mjs +5 -0
  17. package/esm2022/v1/models/builders/query-param.builder.mjs +83 -0
  18. package/esm2022/v1/models/filter-match-type.model.mjs +27 -0
  19. package/esm2022/v1/models/filter-param.model.mjs +33 -0
  20. package/esm2022/v1/models/query-mode.model.mjs +18 -0
  21. package/esm2022/v1/models/query-param.model.mjs +68 -0
  22. package/esm2022/v1/models/query-result.model.mjs +24 -0
  23. package/esm2022/v1/provide.mjs +40 -0
  24. package/esm2022/v1/services/api.abstract.service.mjs +70 -0
  25. package/esm2022/v1/services/crud-api.abstract.service.mjs +83 -0
  26. package/esm2022/v1/services/get-all-api.abstract.service.mjs +38 -0
  27. package/esm2022/v1/tableview/tableview-crud.data-provider.mjs +50 -0
  28. package/esm2022/v1/utils/query-param-map.util.mjs +57 -0
  29. package/fesm2022/mediusinc-mng-commons-data-api-class-tableview.mjs +95 -0
  30. package/fesm2022/mediusinc-mng-commons-data-api-class-tableview.mjs.map +1 -0
  31. package/fesm2022/mediusinc-mng-commons-data-api-class-v1.mjs +698 -0
  32. package/fesm2022/mediusinc-mng-commons-data-api-class-v1.mjs.map +1 -0
  33. package/fesm2022/mediusinc-mng-commons-data-api-class.mjs +396 -0
  34. package/fesm2022/mediusinc-mng-commons-data-api-class.mjs.map +1 -0
  35. package/index.d.ts +5 -0
  36. package/lib/models/query-result.model.d.ts +13 -0
  37. package/lib/serder/object-serializer.d.ts +26 -0
  38. package/lib/services/api.abstract.service.d.ts +22 -0
  39. package/lib/services/crud-api.abstract.service.d.ts +25 -0
  40. package/lib/services/get-all-api.abstract.service.d.ts +14 -0
  41. package/openapi/model.mustache +83 -0
  42. package/openapi/models.mustache +6 -0
  43. package/package.json +41 -0
  44. package/tableview/README.md +10 -0
  45. package/tableview/index.d.ts +2 -0
  46. package/tableview/tableview-crud-create.d.ts +40 -0
  47. package/tableview/tableview-crud.data-provider.d.ts +16 -0
  48. package/v1/README.md +12 -0
  49. package/v1/helpers/query-param-convert.d.ts +23 -0
  50. package/v1/helpers/tableview-crud-create.d.ts +23 -0
  51. package/v1/index.d.ts +14 -0
  52. package/v1/models/builders/query-param.builder.d.ts +36 -0
  53. package/v1/models/filter-match-type.model.d.ts +25 -0
  54. package/v1/models/filter-param.model.d.ts +23 -0
  55. package/v1/models/query-mode.model.d.ts +16 -0
  56. package/v1/models/query-param.model.d.ts +31 -0
  57. package/v1/models/query-result.model.d.ts +24 -0
  58. package/v1/provide.d.ts +9 -0
  59. package/v1/services/api.abstract.service.d.ts +36 -0
  60. package/v1/services/crud-api.abstract.service.d.ts +37 -0
  61. package/v1/services/get-all-api.abstract.service.d.ts +30 -0
  62. package/v1/tableview/tableview-crud.data-provider.d.ts +29 -0
  63. package/v1/utils/query-param-map.util.d.ts +22 -0
@@ -0,0 +1,26 @@
1
+ import { ClassType } from '@mediusinc/mng-commons/core';
2
+ export declare class ObjectSerializer {
3
+ private static _instance;
4
+ private readonly _logCategory;
5
+ private readonly _primitives;
6
+ private dateTimeInUtc;
7
+ private dateTimeWithTimezone;
8
+ private dateTimeWithMillis;
9
+ get primitives(): string[];
10
+ /**
11
+ * Only use one instance of object (out of Angular context)
12
+ */
13
+ static get(): ObjectSerializer;
14
+ configure(config: {
15
+ dateTimeInUtc?: boolean;
16
+ dateTimeWithTimezone?: boolean;
17
+ dateTimeWithMillis?: boolean;
18
+ }): void;
19
+ findCorrectType(data: any, expectedTypeName: string): string;
20
+ serializeClass<T>(data: T, type: ClassType<T>): any;
21
+ serializeClassArray<T>(data: Array<T>, type: ClassType<T>): any;
22
+ serialize(data: any, typeName?: string, subtype?: string): any;
23
+ deserializeClass<T>(data: any, type: ClassType<T>): T;
24
+ deserializeClassArray<T>(data: any, type: ClassType<T>): Array<T>;
25
+ deserialize(data: any, type?: string): any;
26
+ }
@@ -0,0 +1,22 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { ClassType } from '@mediusinc/mng-commons/core';
3
+ import { ObjectSerializer } from '../serder/object-serializer';
4
+ export declare abstract class ACommonsBaseApiService {
5
+ protected readonly objectSerializer: ObjectSerializer;
6
+ protected readonly http: HttpClient;
7
+ protected constructor();
8
+ protected abstract getBasePath(): string;
9
+ protected abstract getServiceBasePath(): string | null;
10
+ protected getUrl(...pathSegments: Array<string>): string;
11
+ protected deserializeQueryResult<QR>(item: any, qrType: ClassType<QR>): QR;
12
+ protected deserializeClass<C>(item: any, type: ClassType<C>): C;
13
+ protected deserializeClassArray<C>(item: any, type: ClassType<C>): Array<C>;
14
+ protected serializeClass<C>(item: C, type: ClassType<C>): any;
15
+ protected serializeClassArray<C>(item: Array<C>, type: ClassType<C>): any;
16
+ }
17
+ export declare abstract class ACommonsApiService<T> extends ACommonsBaseApiService {
18
+ protected type: ClassType<T>;
19
+ protected constructor(type: ClassType<T>);
20
+ protected deserialize(item: any): T;
21
+ protected serialize(item: T): any;
22
+ }
@@ -0,0 +1,25 @@
1
+ import { HttpParams } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { ClassType, IdType } from '@mediusinc/mng-commons/core';
4
+ import { QueryResult } from '../models/query-result.model';
5
+ import { ACommonsGetAllApiService } from './get-all-api.abstract.service';
6
+ export interface ICommonsCrudApiService<FetchType, RequestType> {
7
+ createPost?(item: RequestType, params?: HttpParams): Observable<FetchType>;
8
+ getByIdGet?(id: IdType, params?: HttpParams, locale?: string): Observable<FetchType>;
9
+ updatePut?(id: IdType, item: RequestType, params?: HttpParams): Observable<FetchType>;
10
+ removeDelete?(id: IdType, item?: FetchType, params?: HttpParams): Observable<FetchType | null>;
11
+ }
12
+ export declare abstract class ACommonsCrudApiService<FetchType, RequestType, QueryResultType extends QueryResult<any>> extends ACommonsGetAllApiService<FetchType, QueryResultType> implements ICommonsCrudApiService<FetchType, RequestType> {
13
+ protected requestType: ClassType<RequestType>;
14
+ protected constructor(fetchType: ClassType<FetchType>, requestType: ClassType<RequestType>, queryResultType: ClassType<QueryResultType>);
15
+ createPost(item: RequestType, params?: HttpParams): Observable<FetchType>;
16
+ getByIdGet(id: IdType, params?: HttpParams, locale?: string): Observable<FetchType>;
17
+ updatePut(id: IdType, item: RequestType, params?: HttpParams): Observable<FetchType>;
18
+ removeDelete(id: IdType, item?: FetchType, params?: HttpParams): Observable<FetchType | null>;
19
+ protected getCreatePostPath(item: RequestType): string;
20
+ protected getUpdatePutPath(id: IdType, item: RequestType): string;
21
+ protected getGetByIdGetPath(id: IdType): string;
22
+ protected getRemoveDeletePath(id: IdType, item?: FetchType): string;
23
+ protected deserializeRequest(item: any): RequestType;
24
+ protected serializeRequest(item: RequestType): any;
25
+ }
@@ -0,0 +1,14 @@
1
+ import { HttpParams } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { ClassType, DataListParams } from '@mediusinc/mng-commons/core';
4
+ import { QueryResult } from '../models/query-result.model';
5
+ import { ACommonsApiService } from './api.abstract.service';
6
+ export interface ICommonsGetAllApiService<QRT extends QueryResult<any>> {
7
+ getAllGet(requestParams?: DataListParams<any, any>, params?: HttpParams, locale?: string): Observable<QRT>;
8
+ }
9
+ export declare abstract class ACommonsGetAllApiService<FetchType, QueryResultType extends QueryResult<any>> extends ACommonsApiService<FetchType> implements ICommonsGetAllApiService<QueryResultType> {
10
+ protected queryResultType: ClassType<QueryResultType>;
11
+ protected constructor(fetchType: ClassType<FetchType>, queryResultType: ClassType<QueryResultType>);
12
+ getAllGet(requestParams?: DataListParams, params?: HttpParams, locale?: string): Observable<QueryResultType>;
13
+ protected getGetAllGetPath(): string;
14
+ }
@@ -0,0 +1,83 @@
1
+ {{>licenseInfo}}
2
+
3
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
4
+
5
+ {{#models}}
6
+ {{#model}}
7
+ {{#isEnum}}
8
+ import {TypeRegistry} from '@mediusinc/mng-commons/core';
9
+ {{/isEnum}}
10
+ {{^isEnum}}
11
+ import {ClassAttributeDef, TypeRegistry, TypeName} from '@mediusinc/mng-commons/core';
12
+ {{/isEnum}}
13
+
14
+ {{#tsImports}}
15
+ {{=<% %>=}}
16
+ import {<%classname%>} from '<%filename%>';
17
+ <%={{ }}=%>
18
+ {{/tsImports}}
19
+ {{#description}}
20
+ /**
21
+ * {{{.}}}
22
+ */
23
+ {{/description}}
24
+ {{^isEnum}}
25
+ @TypeName('{{classname}}')
26
+ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
27
+ {{#vars}}
28
+ {{#description}}
29
+ /**
30
+ * {{{.}}}
31
+ */
32
+ {{/description}}
33
+ {{name}}?: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#isDate}}Date{{/isDate}}{{^isDate}}{{{dataType}}}{{/isDate}}{{#isNullable}}|null{{/isNullable}}{{/isEnum}}{{#jsonSchema.default}} = {{{.}}}{{/jsonSchema.default}}{{^jsonSchema.default}}{{#isNullable}} = null{{/isNullable}}{{/jsonSchema.default}};
34
+ {{/vars}}
35
+
36
+ {{#discriminator}}
37
+ public static discriminator?: string = '{{discriminatorName}}';
38
+ {{/discriminator}}
39
+ {{^discriminator}}
40
+ public static discriminator?: string;
41
+ {{/discriminator}}
42
+
43
+ {{^isArray}}
44
+ public static attributeTypeMap: Array<ClassAttributeDef> = [
45
+ {{#vars}}
46
+ {
47
+ name: '{{name}}',
48
+ baseName: '{{baseName}}',
49
+ type: '{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#isDate}}Date{{/isDate}}{{^isDate}}{{{dataType}}}{{/isDate}}{{/isEnum}}'{{#isDate}},
50
+ subtype: 'date'{{/isDate}}{{#isDateTime}},
51
+ subtype: 'dateTime'{{/isDateTime}}
52
+ }{{^-last}},
53
+ {{/-last}}
54
+ {{/vars}}
55
+
56
+ ];
57
+
58
+ public static getAttributeTypeMap() {
59
+ {{#parent}}
60
+ return super.getAttributeTypeMap().concat({{classname}}.attributeTypeMap);
61
+ {{/parent}}
62
+ {{^parent}}
63
+ return {{classname}}.attributeTypeMap;
64
+ {{/parent}}
65
+ }
66
+ {{/isArray}}
67
+ }
68
+
69
+ TypeRegistry.get().registerType({{classname}});
70
+ {{/isEnum}}
71
+ {{#isEnum}}
72
+ export enum {{classname}} {
73
+ {{#allowableValues}}
74
+ {{#enumVars}}
75
+ {{name}} = {{{value}}}{{^-last}},{{/-last}}
76
+ {{/enumVars}}
77
+ {{/allowableValues}}
78
+ }
79
+
80
+ TypeRegistry.get().registerEnum({{classname}}, '{{classname}}');
81
+ {{/isEnum}}
82
+ {{/model}}
83
+ {{/models}}
@@ -0,0 +1,6 @@
1
+ /* eslint-disable */
2
+ {{>licenseInfo}}
3
+ {{#models}}
4
+ {{#model}}
5
+ {{/model}}
6
+ {{/models}}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@mediusinc/mng-commons-data-api-class",
3
+ "version": "5.0.0-rc.0",
4
+ "peerDependencies": {
5
+ "@angular/common": "^17.2.0",
6
+ "@angular/core": "^17.2.0",
7
+ "@mediusinc/mng-commons": "~5.0.0-rc.0"
8
+ },
9
+ "dependencies": {
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "publishConfig": {
13
+ "directory": "dist"
14
+ },
15
+ "sideEffects": false,
16
+ "module": "fesm2022/mediusinc-mng-commons-data-api-class.mjs",
17
+ "typings": "index.d.ts",
18
+ "exports": {
19
+ "./package.json": {
20
+ "default": "./package.json"
21
+ },
22
+ ".": {
23
+ "types": "./index.d.ts",
24
+ "esm2022": "./esm2022/mediusinc-mng-commons-data-api-class.mjs",
25
+ "esm": "./esm2022/mediusinc-mng-commons-data-api-class.mjs",
26
+ "default": "./fesm2022/mediusinc-mng-commons-data-api-class.mjs"
27
+ },
28
+ "./tableview": {
29
+ "types": "./tableview/index.d.ts",
30
+ "esm2022": "./esm2022/tableview/mediusinc-mng-commons-data-api-class-tableview.mjs",
31
+ "esm": "./esm2022/tableview/mediusinc-mng-commons-data-api-class-tableview.mjs",
32
+ "default": "./fesm2022/mediusinc-mng-commons-data-api-class-tableview.mjs"
33
+ },
34
+ "./v1": {
35
+ "types": "./v1/index.d.ts",
36
+ "esm2022": "./esm2022/v1/mediusinc-mng-commons-data-api-class-v1.mjs",
37
+ "esm": "./esm2022/v1/mediusinc-mng-commons-data-api-class-v1.mjs",
38
+ "default": "./fesm2022/mediusinc-mng-commons-data-api-class-v1.mjs"
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,10 @@
1
+ # @mediusinc/mng-commons-data-api-class/tableview
2
+
3
+ Secondary entry point of `@mediusinc/mng-commons-data-api-class`. It can be used by importing from `@mediusinc/mng-commons-data-api-class/tableview`.
4
+
5
+ ## Dependencies within commons
6
+
7
+ - `@mediusinc/mng-commons-data-api-class`
8
+ - `@mediusinc/mng-commons/core`
9
+ - `@mediusinc/mng-commons/model`
10
+ - `@mediusinc/mng-commons/tableview/api`
@@ -0,0 +1,2 @@
1
+ export * from './tableview-crud.data-provider';
2
+ export * from './tableview-crud-create';
@@ -0,0 +1,40 @@
1
+ import { ICommonsCrudApiService, ICommonsGetAllApiService, QueryResult } from '@mediusinc/mng-commons-data-api-class';
2
+ import { ClassType, ServiceClassType } from '@mediusinc/mng-commons/core';
3
+ import { TypeDescriptor } from '@mediusinc/mng-commons/model';
4
+ import { TableviewDescriptorInst, TableviewInputBuilder } from '@mediusinc/mng-commons/tableview/api';
5
+ import { TableviewCrudDataProviderInst } from './tableview-crud.data-provider';
6
+ /**
7
+ * Creates a tableview with the given class, request class, service based on data API v2, sort, filters and optional class/model configuration.
8
+ * Sorts and filters are expected to be keys of class.
9
+ *
10
+ * @param {ClassType<Model>} type - The class representing the model.
11
+ * @param {ClassType<RequestModel>} requestType - The class representing the model for create and update operations.
12
+ * @param {ServiceClassType<Service>} service - The class type of the service implementing `IMngCrudApiService` and `IMngGetAllApiService`.
13
+ * @param {{ idProperty?: keyof Model; titleProperty?: keyof Model; i18nBaseKey?: ClassType<any> | string; }} [modelConfig] - Additional optional model configuration.
14
+ * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
15
+ *
16
+ * @returns A tableview instance with descriptor, data provider and actions.
17
+ */
18
+ export declare function tableviewCrud<Model, RequestModel, Service extends ICommonsCrudApiService<Model, RequestModel> & ICommonsGetAllApiService<QueryResult<Model>>, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, requestType: ClassType<RequestModel>, service: ServiceClassType<Service>, modelConfig?: {
19
+ idProperty?: keyof Model;
20
+ titleProperty?: keyof Model;
21
+ i18nBaseKey?: string;
22
+ }, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>, Sorts, Filters>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>>;
23
+ /**
24
+ * Creates a tableview with the given class, request class, service based on data API v2, sort, filters and optional class/model configuration.
25
+ *
26
+ * @param {ClassType<Model>} type - The class representing the model.
27
+ * @param {ClassType<RequestModel>} requestType - The class representing the model for create and update operations.
28
+ * @param {ServiceClassType<Service>} service - The class type of the service implementing `IMngCrudApiService` and `IMngGetAllApiService`.
29
+ * @param {TypeDescriptor<Sorts>} sorts - The available sort keys of get all request.
30
+ * @param {TypeDescriptor<Filters>} filters - The available filter keys of get all request.
31
+ * @param {{ idProperty?: keyof Model; titleProperty?: keyof Model; i18nBaseKey?: ClassType<any> | string; }} [modelConfig] - Additional optional model configuration.
32
+ * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
33
+ *
34
+ * @returns A tableview instance with descriptor, data provider and actions.
35
+ */
36
+ export declare function tableviewCrudWithSortAndFilter<Model, RequestModel, Service extends ICommonsCrudApiService<Model, RequestModel> & ICommonsGetAllApiService<QueryResult<Model>>, Sorts, Filters extends keyof any>(type: ClassType<Model>, requestType: ClassType<RequestModel>, service: ServiceClassType<Service>, sorts: TypeDescriptor<Sorts>, filters: TypeDescriptor<Filters>, modelConfig?: {
37
+ idProperty?: keyof Model;
38
+ titleProperty?: keyof Model;
39
+ i18nBaseKey?: string;
40
+ }, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>, Sorts, Filters>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>>;
@@ -0,0 +1,16 @@
1
+ import { Type } from '@angular/core';
2
+ import { ICommonsCrudApiService, ICommonsGetAllApiService, QueryResult } from '@mediusinc/mng-commons-data-api-class';
3
+ import { ClassType, ServiceClassType } from '@mediusinc/mng-commons/core';
4
+ import { TableviewDataProviderInst } from '@mediusinc/mng-commons/tableview/api';
5
+ export type ToRequestMapFnType<Model, RequestModel> = (item?: Model) => RequestModel;
6
+ export declare class TableviewCrudDataProviderInst<Model, RequestModel, Service extends ICommonsCrudApiService<Model, RequestModel> & ICommonsGetAllApiService<QueryResult<Model>>, Sorts = keyof Model, Filters extends keyof any = keyof Model> extends TableviewDataProviderInst<Model, Service, Sorts, Filters, ClassType<Model>, ServiceClassType<Service>> {
7
+ protected requestType: ClassType<RequestModel>;
8
+ private _toRequestMap;
9
+ protected constructor(type: ClassType<Model>, requestType: ClassType<RequestModel>, serviceType: Type<Service>, idPropertyName?: string, useGetAllForFetch?: boolean);
10
+ get toRequestMap(): ToRequestMapFnType<Model, RequestModel>;
11
+ withToRequestMap(fn: ToRequestMapFnType<Model, RequestModel>): this;
12
+ }
13
+ export declare class TableviewCrudDataProvider extends TableviewCrudDataProviderInst<any, any, any> {
14
+ static create<Model, RequestModel, Service extends ICommonsCrudApiService<Model, RequestModel> & ICommonsGetAllApiService<QueryResult<Model>>, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, requestType: ClassType<RequestModel>, serviceType: Type<Service>, idProperty?: keyof Model, useGetAllForFetch?: boolean): TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>;
15
+ static createUnsafe<Model, RequestModel, Service extends ICommonsCrudApiService<Model, RequestModel> & ICommonsGetAllApiService<QueryResult<Model>>, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, requestType: ClassType<RequestModel>, serviceType: Type<Service>, idProperty?: string, useGetAllForFetch?: boolean): TableviewCrudDataProviderInst<Model, RequestModel, Service, Sorts, Filters>;
16
+ }
package/v1/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @mediusinc/mng-commons-data-api-class/v1
2
+
3
+ Secondary entry pointof `@mediusinc/mng-commons-data-api-class`. It can be used by importing from `@mediusinc/mng-commons-data-api-class/v1`.
4
+
5
+ Use for data API integration with `medius-data` pre-v4 backend (aka Medius Query Param).
6
+
7
+ ## Dependencies within commons
8
+
9
+ - `@mediusinc/mng-commons-data-api-class`
10
+ - `@mediusinc/mng-commons/core`
11
+ - `@mediusinc/mng-commons/model`
12
+ - `@mediusinc/mng-commons/tableview/api`
@@ -0,0 +1,23 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DataListParams, DataListResult } from '@mediusinc/mng-commons/core';
3
+ import { MediusFilterMatchType } from '../models/filter-match-type.model';
4
+ import { MediusQueryParam } from '../models/query-param.model';
5
+ import { MediusQueryResult } from '../models/query-result.model';
6
+ import { QueryParamMap } from '../utils/query-param-map.util';
7
+ export declare function toV1QueryParam(): undefined;
8
+ export declare function toV1QueryParam<Sorts = string, Filters extends keyof any = string>(params: DataListParams<Sorts, Filters>, map?: QueryParamMap<Sorts, Filters>): MediusQueryParam;
9
+ export declare function toV1QueryParam<Sorts = string, Filters extends keyof any = string>(params: DataListParams<Sorts, Filters> | undefined, map?: QueryParamMap<Sorts, Filters>): MediusQueryParam | undefined;
10
+ export declare function toV1FilterMatchType(match: string): MediusFilterMatchType;
11
+ /**
12
+ * Convert a query result from an obsolete API version 1 to a `DataListResult`
13
+ *
14
+ * @param {DataListParams} params - The data list parameters for the query
15
+ * @param {Service} service - The service object used to make the API call
16
+ * @param {function} apiOperation - The API operation function that returns an `Observable<MediusQueryResult<Item>>`
17
+ * @param {any} additionalParams - Additional parameters to pass to the API operation function (optional)
18
+ *
19
+ * @returns {Observable<DataListResult<Item>>} - An observable that emits a `DataListResult` object
20
+ *
21
+ * @deprecated
22
+ */
23
+ export declare function executeV1GetAll<Item, Service>(params: DataListParams, service: Service, apiOperation: (qp: MediusQueryParam, ...additionalParams: any) => Observable<MediusQueryResult<Item>>, additionalParams?: any): Observable<DataListResult<Item>>;
@@ -0,0 +1,23 @@
1
+ import { ClassType, ServiceClassType } from '@mediusinc/mng-commons/core';
2
+ import { TableviewDescriptorInst, TableviewInputBuilder } from '@mediusinc/mng-commons/tableview/api';
3
+ import { MediusQueryResult } from '../models/query-result.model';
4
+ import { ICommonsCrudV1ApiService } from '../services/crud-api.abstract.service';
5
+ import { ICommonsGetAllV1ApiService } from '../services/get-all-api.abstract.service';
6
+ import { TableviewCrudV1DataProviderInst } from '../tableview/tableview-crud.data-provider';
7
+ /**
8
+ * Creates a tableview with the given class, service based on data API v1 (obsolete) and optional class/model configuration.
9
+ *
10
+ * @param {ClassType<Model>} type - The class representing the model.
11
+ * @param {ServiceClassType<Service>} service - The class type of the service implementing `IMngCrudObsoleteV1ApiService` and `IMngGetAllObsoleteV1ApiService`.
12
+ * @param {{ idProperty?: keyof Model; titleProperty?: keyof Model; i18nBaseKey?: ClassType<any> | string; }} [modelConfig] - Additional optional model configuration.
13
+ * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
14
+ *
15
+ * @returns {Tableview} - The built table view.
16
+ *
17
+ * @deprecated
18
+ */
19
+ export declare function tableviewCrudV1<Model, Service extends ICommonsCrudV1ApiService<Model> & ICommonsGetAllV1ApiService<MediusQueryResult<Model>>, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, service: ServiceClassType<Service>, modelConfig?: {
20
+ idProperty?: keyof Model;
21
+ titleProperty?: keyof Model;
22
+ i18nBaseKey?: ClassType<any> | string;
23
+ }, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudV1DataProviderInst<Model, Service, Sorts, Filters>, Sorts, Filters>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableviewDescriptorInst<Model, Sorts, Filters>, TableviewCrudV1DataProviderInst<Model, Service, Sorts, Filters>>;
package/v1/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from './helpers/query-param-convert';
2
+ export * from './helpers/tableview-crud-create';
3
+ export * from './models/builders/query-param.builder';
4
+ export * from './models/filter-match-type.model';
5
+ export * from './models/filter-param.model';
6
+ export * from './models/query-mode.model';
7
+ export * from './models/query-param.model';
8
+ export * from './models/query-result.model';
9
+ export * from './services/api.abstract.service';
10
+ export * from './services/crud-api.abstract.service';
11
+ export * from './services/get-all-api.abstract.service';
12
+ export * from './tableview/tableview-crud.data-provider';
13
+ export * from './utils/query-param-map.util';
14
+ export * from './provide';
@@ -0,0 +1,36 @@
1
+ import { MediusFilterMatchType } from '../filter-match-type.model';
2
+ import { MediusQueryMode } from '../query-mode.model';
3
+ import { MediusQueryParam } from '../query-param.model';
4
+ export declare class MediusQueryParamBuilder {
5
+ private queryParam;
6
+ private constructor();
7
+ /**
8
+ * Creates a new instance of `MediusQueryParamBuilder` with the specified `itemsPerPage` and `itemsOffset` values.
9
+ *
10
+ * @param {number} [itemsPerPage=50] - The number of items per page.
11
+ * @param {number} [itemsOffset=0] - The offset value for the items.
12
+ *
13
+ * @returns {MediusQueryParamBuilder} A new instance of `MediusQueryParamBuilder`.
14
+ *
15
+ * @deprecated
16
+ */
17
+ static create(itemsPerPage?: number, itemsOffset?: number): MediusQueryParamBuilder;
18
+ /**
19
+ * Creates a new instance of MediusQueryParamBuilder based on an existing MediusQueryParam object.
20
+ *
21
+ * @param {MediusQueryParam} queryParam - The existing MediusQueryParam object to create from.
22
+ * @param {number} [itemsPerPage] - The number of items per page for the new instance. If not provided, default value is used.
23
+ * @param {number} [itemsOffset] - The offset for the new instance. If not provided, default value is used.
24
+ *
25
+ * @returns {MediusQueryParamBuilder} - A new instance of MediusQueryParamBuilder.
26
+ *
27
+ * @deprecated
28
+ */
29
+ static createFromExisting(queryParam: MediusQueryParam, itemsPerPage?: number, itemsOffset?: number): MediusQueryParamBuilder;
30
+ withItemsPerPage(itemsPerPage: number): MediusQueryParamBuilder;
31
+ withItemsOffset(itemsOffset: number): MediusQueryParamBuilder;
32
+ withQueryMode(queryMode: MediusQueryMode): MediusQueryParamBuilder;
33
+ withSort(property: string, asc?: boolean): MediusQueryParamBuilder;
34
+ withFilter(property: string, value: any, valueTo?: any, matchType?: MediusFilterMatchType, matchCaseSensitive?: boolean): MediusQueryParamBuilder;
35
+ build(): MediusQueryParam;
36
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Generated API
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export declare enum MediusFilterMatchType {
13
+ Equals = "EQUALS",
14
+ NotEquals = "NOT_EQUALS",
15
+ FromTo = "FROM_TO",
16
+ Contains = "CONTAINS",
17
+ StartsWith = "STARTS_WITH",
18
+ EndsWith = "ENDS_WITH",
19
+ In = "IN",
20
+ NotIn = "NOT_IN",
21
+ SmallerThan = "SMALLER_THAN",
22
+ GreaterThan = "GREATER_THAN",
23
+ Exists = "EXISTS",
24
+ DoesNotExist = "DOES_NOT_EXIST"
25
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generated API
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { ClassAttributeDef } from '@mediusinc/mng-commons/core';
13
+ import { MediusFilterMatchType } from './filter-match-type.model';
14
+ export declare class MediusFilterParam {
15
+ property?: string;
16
+ filterValue?: any;
17
+ filterValueTo?: any;
18
+ filterMatchType?: MediusFilterMatchType;
19
+ filterMatchCaseSensitive?: boolean;
20
+ static discriminator?: string;
21
+ static attributeTypeMap: Array<ClassAttributeDef>;
22
+ static getAttributeTypeMap(): ClassAttributeDef[];
23
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Generated API
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export declare enum MediusQueryMode {
13
+ Count = "COUNT",
14
+ Data = "DATA",
15
+ All = "ALL"
16
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Generated API
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { ClassAttributeDef } from '@mediusinc/mng-commons/core';
13
+ import { MediusFilterParam } from './filter-param.model';
14
+ import { MediusQueryMode } from './query-mode.model';
15
+ export declare class MediusQueryParam {
16
+ sortProperty?: Array<string>;
17
+ sortAsc?: Array<boolean>;
18
+ itemsOffset?: number;
19
+ itemsPerPage?: number;
20
+ filterParams?: Array<MediusFilterParam>;
21
+ filterAllParam?: string;
22
+ filterAllProperties?: Array<string>;
23
+ validateProperties?: Array<string>;
24
+ selectInTwoSteps?: boolean;
25
+ sortEnumByOrdinal?: boolean;
26
+ groupByProperties?: Array<string>;
27
+ queryMode?: MediusQueryMode;
28
+ static discriminator?: string;
29
+ static attributeTypeMap: Array<ClassAttributeDef>;
30
+ static getAttributeTypeMap(): ClassAttributeDef[];
31
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generated API
3
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { ClassAttributeDef } from '@mediusinc/mng-commons/core';
13
+ export declare class MediusQueryResult<T> implements IMediusQueryResult<T> {
14
+ allDataCount?: number;
15
+ pageData?: Array<T>;
16
+ static discriminator?: string;
17
+ static fromArray<T>(pageData: T[], allDataCount?: number): MediusQueryResult<T>;
18
+ static attributeTypeMap: Array<ClassAttributeDef>;
19
+ static getAttributeTypeMap(): ClassAttributeDef[];
20
+ }
21
+ export interface IMediusQueryResult<T> {
22
+ allDataCount?: number;
23
+ pageData?: Array<T>;
24
+ }
@@ -0,0 +1,9 @@
1
+ import { CommonsFeature } from '@mediusinc/mng-commons/core';
2
+ /**
3
+ * Prepares providers for usage of the Obsolete Data API functionalities.
4
+ *
5
+ * @returns {CommonsFeature} The `CommonsFeature` object with the Data API Obsolete configuration.
6
+ *
7
+ * @deprecated.
8
+ */
9
+ export declare function withDataApiV1(): CommonsFeature;
@@ -0,0 +1,36 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { ObjectSerializer } from '@mediusinc/mng-commons-data-api-class';
3
+ import { ClassType } from '@mediusinc/mng-commons/core';
4
+ import { MediusQueryParam } from '../models/query-param.model';
5
+ /**
6
+ * This is an abstract class that provides base functionality for API services.
7
+ *
8
+ * @deprecated
9
+ */
10
+ export declare abstract class ACommonsBaseV1ApiService {
11
+ protected readonly objectSerializer: ObjectSerializer;
12
+ protected readonly http: HttpClient;
13
+ protected constructor();
14
+ protected abstract getBasePath(): string;
15
+ protected abstract getServiceBasePath(): string | null;
16
+ protected getUrl(...pathSegments: Array<string>): string;
17
+ protected serializeQueryParam(queryParam: MediusQueryParam, type?: string): any;
18
+ protected deserializeQueryResult<QR>(item: any, qrType: ClassType<QR>): QR;
19
+ protected deserializeClass<C>(item: any, type: ClassType<C>): C;
20
+ protected deserializeClassArray<C>(item: any, type: ClassType<C>): Array<C>;
21
+ protected serializeClass<C>(item: C, type: ClassType<C>): any;
22
+ protected serializeClassArray<C>(item: Array<C>, type: ClassType<C>): any;
23
+ }
24
+ /**
25
+ * Represents an abstract base class for the ACommonsV1ApiService.
26
+ *
27
+ * @typeparam T The main type of data to be handled by the service.
28
+ *
29
+ * @deprecated
30
+ */
31
+ export declare abstract class ACommonsV1ApiService<T> extends ACommonsBaseV1ApiService {
32
+ protected type: ClassType<T>;
33
+ protected constructor(type: ClassType<T>);
34
+ protected deserialize(item: any): T;
35
+ protected serialize(item: T): any;
36
+ }
@@ -0,0 +1,37 @@
1
+ import { HttpParams } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { ClassType, IdType } from '@mediusinc/mng-commons/core';
4
+ import { MediusQueryResult } from '../models/query-result.model';
5
+ import { ACommonsGetAllV1ApiService } from './get-all-api.abstract.service';
6
+ /**
7
+ * A service interface for CRUD operation on a resource.
8
+ *
9
+ * @typeparam T The main type of data to be handled by the service.
10
+ *
11
+ * @deprecated
12
+ */
13
+ export interface ICommonsCrudV1ApiService<T> {
14
+ createPost?(item: T, params?: HttpParams): Observable<T>;
15
+ getByIdGet?(id: IdType, params?: HttpParams, locale?: string): Observable<T>;
16
+ updatePut?(id: IdType, item: T, params?: HttpParams): Observable<T>;
17
+ removeDelete?(id: IdType, item?: T, params?: HttpParams): Observable<T | null>;
18
+ }
19
+ /**
20
+ * Abstract class for creating CRUD API service implementation.
21
+ *
22
+ * @typeparam T The type of the entity.
23
+ * @typeparam QRT The type of the query result.
24
+ *
25
+ * @deprecated
26
+ */
27
+ export declare abstract class ACommonsCrudV1ApiService<T, QRT extends MediusQueryResult<any>> extends ACommonsGetAllV1ApiService<T, QRT> implements ICommonsCrudV1ApiService<T> {
28
+ protected constructor(type: ClassType<T>, queryResultType: ClassType<QRT>);
29
+ createPost(item: T, params?: HttpParams): Observable<T>;
30
+ getByIdGet(id: IdType, params?: HttpParams, locale?: string): Observable<T>;
31
+ updatePut(id: IdType, item: T, params?: HttpParams): Observable<T>;
32
+ removeDelete(id: IdType, item?: T, params?: HttpParams): Observable<T | null>;
33
+ protected getCreatePostPath(item: T): string;
34
+ protected getUpdatePutPath(id: IdType, item: T): string;
35
+ protected getGetByIdGetPath(id: IdType): string;
36
+ protected getRemoveDeletePath(id: IdType, item?: T): string;
37
+ }