@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,698 @@
1
+ import { map } from 'rxjs/operators';
2
+ import { CommonsInternalError, FilterMatchMode, TypeRegistry, CommonsFeatureTypeEnum } from '@mediusinc/mng-commons/core';
3
+ import { inject, Injector, APP_INITIALIZER } from '@angular/core';
4
+ import { TableviewDataProviderInst, TableviewInputBuilder, TableviewDescriptor } from '@mediusinc/mng-commons/tableview/api';
5
+ import { ModelUtil } from '@mediusinc/mng-commons/model';
6
+ import { HttpClient, HttpParams } from '@angular/common/http';
7
+ import { ObjectSerializer } from '@mediusinc/mng-commons-data-api-class';
8
+ import { of } from 'rxjs';
9
+
10
+ /**
11
+ * Generated API
12
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
13
+ *
14
+ * The version of the OpenAPI document: 1.0
15
+ *
16
+ *
17
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
18
+ * https://openapi-generator.tech
19
+ * Do not edit the class manually.
20
+ */
21
+ var MediusFilterMatchType;
22
+ (function (MediusFilterMatchType) {
23
+ MediusFilterMatchType["Equals"] = "EQUALS";
24
+ MediusFilterMatchType["NotEquals"] = "NOT_EQUALS";
25
+ MediusFilterMatchType["FromTo"] = "FROM_TO";
26
+ MediusFilterMatchType["Contains"] = "CONTAINS";
27
+ MediusFilterMatchType["StartsWith"] = "STARTS_WITH";
28
+ MediusFilterMatchType["EndsWith"] = "ENDS_WITH";
29
+ MediusFilterMatchType["In"] = "IN";
30
+ MediusFilterMatchType["NotIn"] = "NOT_IN";
31
+ MediusFilterMatchType["SmallerThan"] = "SMALLER_THAN";
32
+ MediusFilterMatchType["GreaterThan"] = "GREATER_THAN";
33
+ MediusFilterMatchType["Exists"] = "EXISTS";
34
+ MediusFilterMatchType["DoesNotExist"] = "DOES_NOT_EXIST";
35
+ })(MediusFilterMatchType || (MediusFilterMatchType = {}));
36
+
37
+ class MediusFilterParam {
38
+ static { this.attributeTypeMap = [
39
+ {
40
+ name: 'property',
41
+ baseName: 'property',
42
+ type: 'string'
43
+ },
44
+ {
45
+ name: 'filterValue',
46
+ baseName: 'filter_value',
47
+ type: 'object'
48
+ },
49
+ {
50
+ name: 'filterValueTo',
51
+ baseName: 'filter_value_to',
52
+ type: 'object'
53
+ },
54
+ {
55
+ name: 'filterMatchType',
56
+ baseName: 'filter_match_type',
57
+ type: 'FilterMatchType'
58
+ },
59
+ {
60
+ name: 'filterMatchCaseSensitive',
61
+ baseName: 'filter_match_case_sensitive',
62
+ type: 'boolean'
63
+ }
64
+ ]; }
65
+ static getAttributeTypeMap() {
66
+ return MediusFilterParam.attributeTypeMap;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Generated API
72
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
73
+ *
74
+ * The version of the OpenAPI document: 1.0
75
+ *
76
+ *
77
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
78
+ * https://openapi-generator.tech
79
+ * Do not edit the class manually.
80
+ */
81
+ var MediusQueryMode;
82
+ (function (MediusQueryMode) {
83
+ MediusQueryMode["Count"] = "COUNT";
84
+ MediusQueryMode["Data"] = "DATA";
85
+ MediusQueryMode["All"] = "ALL";
86
+ })(MediusQueryMode || (MediusQueryMode = {}));
87
+
88
+ class MediusQueryParam {
89
+ static { this.attributeTypeMap = [
90
+ {
91
+ name: 'sortProperty',
92
+ baseName: 'sort_property',
93
+ type: 'Array<string>'
94
+ },
95
+ {
96
+ name: 'sortAsc',
97
+ baseName: 'sort_asc',
98
+ type: 'Array<boolean>'
99
+ },
100
+ {
101
+ name: 'itemsOffset',
102
+ baseName: 'items_offset',
103
+ type: 'number'
104
+ },
105
+ {
106
+ name: 'itemsPerPage',
107
+ baseName: 'items_per_page',
108
+ type: 'number'
109
+ },
110
+ {
111
+ name: 'filterParams',
112
+ baseName: 'filter_params',
113
+ type: 'Array<FilterParam>'
114
+ },
115
+ {
116
+ name: 'filterAllParam',
117
+ baseName: 'filter_all_param',
118
+ type: 'string'
119
+ },
120
+ {
121
+ name: 'filterAllProperties',
122
+ baseName: 'filter_all_properties',
123
+ type: 'Array<string>'
124
+ },
125
+ {
126
+ name: 'validateProperties',
127
+ baseName: 'validate_properties',
128
+ type: 'Array<string>'
129
+ },
130
+ {
131
+ name: 'selectInTwoSteps',
132
+ baseName: 'select_in_two_steps',
133
+ type: 'boolean'
134
+ },
135
+ {
136
+ name: 'sortEnumByOrdinal',
137
+ baseName: 'sort_enum_by_ordinal',
138
+ type: 'boolean'
139
+ },
140
+ {
141
+ name: 'groupByProperties',
142
+ baseName: 'group_by_properties',
143
+ type: 'Array<string>'
144
+ },
145
+ {
146
+ name: 'queryMode',
147
+ baseName: 'query_mode',
148
+ type: 'QueryMode'
149
+ }
150
+ ]; }
151
+ static getAttributeTypeMap() {
152
+ return MediusQueryParam.attributeTypeMap;
153
+ }
154
+ }
155
+
156
+ class MediusQueryParamBuilder {
157
+ constructor(queryParam) {
158
+ this.queryParam = queryParam;
159
+ }
160
+ /**
161
+ * Creates a new instance of `MediusQueryParamBuilder` with the specified `itemsPerPage` and `itemsOffset` values.
162
+ *
163
+ * @param {number} [itemsPerPage=50] - The number of items per page.
164
+ * @param {number} [itemsOffset=0] - The offset value for the items.
165
+ *
166
+ * @returns {MediusQueryParamBuilder} A new instance of `MediusQueryParamBuilder`.
167
+ *
168
+ * @deprecated
169
+ */
170
+ static create(itemsPerPage = 50, itemsOffset = 0) {
171
+ const queryParam = new MediusQueryParam();
172
+ queryParam.itemsPerPage = itemsPerPage;
173
+ queryParam.itemsOffset = itemsOffset;
174
+ queryParam.queryMode = MediusQueryMode.All;
175
+ return new MediusQueryParamBuilder(queryParam);
176
+ }
177
+ /**
178
+ * Creates a new instance of MediusQueryParamBuilder based on an existing MediusQueryParam object.
179
+ *
180
+ * @param {MediusQueryParam} queryParam - The existing MediusQueryParam object to create from.
181
+ * @param {number} [itemsPerPage] - The number of items per page for the new instance. If not provided, default value is used.
182
+ * @param {number} [itemsOffset] - The offset for the new instance. If not provided, default value is used.
183
+ *
184
+ * @returns {MediusQueryParamBuilder} - A new instance of MediusQueryParamBuilder.
185
+ *
186
+ * @deprecated
187
+ */
188
+ static createFromExisting(queryParam, itemsPerPage, itemsOffset) {
189
+ queryParam.itemsPerPage = itemsPerPage ?? queryParam.itemsPerPage ?? 50;
190
+ queryParam.itemsOffset = itemsOffset ?? queryParam.itemsOffset ?? 0;
191
+ queryParam.queryMode = queryParam.queryMode ?? MediusQueryMode.All;
192
+ return new MediusQueryParamBuilder(queryParam);
193
+ }
194
+ withItemsPerPage(itemsPerPage) {
195
+ this.queryParam.itemsPerPage = itemsPerPage;
196
+ return this;
197
+ }
198
+ withItemsOffset(itemsOffset) {
199
+ this.queryParam.itemsOffset = itemsOffset;
200
+ return this;
201
+ }
202
+ withQueryMode(queryMode) {
203
+ this.queryParam.queryMode = queryMode;
204
+ return this;
205
+ }
206
+ withSort(property, asc = true) {
207
+ if (!this.queryParam.sortProperty || !this.queryParam.sortAsc) {
208
+ this.queryParam.sortProperty = [];
209
+ this.queryParam.sortAsc = [];
210
+ }
211
+ this.queryParam.sortProperty.push(property);
212
+ this.queryParam.sortAsc.push(asc);
213
+ return this;
214
+ }
215
+ withFilter(property, value, valueTo = undefined, matchType = MediusFilterMatchType.Contains, matchCaseSensitive = false) {
216
+ if (!this.queryParam.filterParams) {
217
+ this.queryParam.filterParams = [];
218
+ }
219
+ const filterParam = new MediusFilterParam();
220
+ filterParam.property = property;
221
+ filterParam.filterValue = value;
222
+ filterParam.filterValueTo = valueTo;
223
+ filterParam.filterMatchType = matchType;
224
+ filterParam.filterMatchCaseSensitive = matchCaseSensitive;
225
+ this.queryParam.filterParams.push(filterParam);
226
+ return this;
227
+ }
228
+ build() {
229
+ const queryParam = this.queryParam;
230
+ this.queryParam = new MediusQueryParam();
231
+ return queryParam;
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Converts the given DataListParams object to an ObsoleteV1QueryParam object.
237
+ *
238
+ * @param {DataListParams} params - The object to convert.
239
+ * @param {QueryParamMap} map - The configuration object used to map sort and filter properties.
240
+ *
241
+ * @returns The converted ObsoleteV1QueryParam object if params is not null or undefined, otherwise returns undefined.
242
+ *
243
+ * @deprecated
244
+ */
245
+ function toV1QueryParam(params, map) {
246
+ if (!params)
247
+ return undefined;
248
+ const builder = MediusQueryParamBuilder.create();
249
+ if (params.offset !== undefined) {
250
+ builder.withItemsOffset(params.offset);
251
+ }
252
+ if (params.limit !== undefined) {
253
+ builder.withItemsPerPage(params.limit);
254
+ }
255
+ if (Array.isArray(params.sort)) {
256
+ params.sort.forEach(s => builder.withSort(map?.mapSort(s.property) ?? s.property, s.ascending));
257
+ }
258
+ if (typeof params.filters === 'object') {
259
+ Object.entries(params.filters).forEach(([key, value]) => {
260
+ const filter = value;
261
+ if (filter.value != null) {
262
+ const matchMode = filter.matchMode ? toV1FilterMatchType(filter.matchMode) : MediusFilterMatchType.Equals;
263
+ let value = undefined;
264
+ let valueTo = undefined;
265
+ if (matchMode === MediusFilterMatchType.FromTo) {
266
+ if (Array.isArray(filter.value)) {
267
+ if (filter.value.length > 0)
268
+ value = filter.value[0];
269
+ if (filter.value.length > 1)
270
+ valueTo = filter.value[1];
271
+ }
272
+ }
273
+ else {
274
+ value = filter.value;
275
+ }
276
+ builder.withFilter(map?.mapFilter(key) ?? key, value, valueTo, matchMode, filter.caseSensitive);
277
+ }
278
+ });
279
+ }
280
+ return builder.build();
281
+ }
282
+ function toV1FilterMatchType(match) {
283
+ switch (match) {
284
+ case FilterMatchMode.Equals:
285
+ return MediusFilterMatchType.Equals;
286
+ case FilterMatchMode.NotEquals:
287
+ return MediusFilterMatchType.NotEquals;
288
+ case FilterMatchMode.Contains:
289
+ return MediusFilterMatchType.Contains;
290
+ case FilterMatchMode.In:
291
+ return MediusFilterMatchType.In;
292
+ case FilterMatchMode.NotIn:
293
+ return MediusFilterMatchType.NotIn;
294
+ case FilterMatchMode.StartsWith:
295
+ return MediusFilterMatchType.StartsWith;
296
+ case FilterMatchMode.EndsWith:
297
+ return MediusFilterMatchType.EndsWith;
298
+ case FilterMatchMode.LessThan:
299
+ return MediusFilterMatchType.SmallerThan;
300
+ case FilterMatchMode.GreaterThan:
301
+ return MediusFilterMatchType.GreaterThan;
302
+ case FilterMatchMode.Between:
303
+ return MediusFilterMatchType.FromTo;
304
+ case FilterMatchMode.Exists:
305
+ return MediusFilterMatchType.Exists;
306
+ case FilterMatchMode.DoesNotExist:
307
+ return MediusFilterMatchType.DoesNotExist;
308
+ case FilterMatchMode.NotContains:
309
+ case FilterMatchMode.LessThanOrEqualTo:
310
+ case FilterMatchMode.GreaterThanOrEqualTo:
311
+ default:
312
+ throw new CommonsInternalError(`Filter match type '${match}' not supported.`);
313
+ }
314
+ }
315
+ /**
316
+ * Convert a query result from an obsolete API version 1 to a `DataListResult`
317
+ *
318
+ * @param {DataListParams} params - The data list parameters for the query
319
+ * @param {Service} service - The service object used to make the API call
320
+ * @param {function} apiOperation - The API operation function that returns an `Observable<MediusQueryResult<Item>>`
321
+ * @param {any} additionalParams - Additional parameters to pass to the API operation function (optional)
322
+ *
323
+ * @returns {Observable<DataListResult<Item>>} - An observable that emits a `DataListResult` object
324
+ *
325
+ * @deprecated
326
+ */
327
+ function executeV1GetAll(params, service, apiOperation, additionalParams) {
328
+ const queryParam = toV1QueryParam(params);
329
+ return apiOperation
330
+ .bind(service)(queryParam, ...(additionalParams ?? []))
331
+ .pipe(map(res => ({ data: res.pageData ?? [], totalCount: res.allDataCount })));
332
+ }
333
+
334
+ /**
335
+ * A data provider for a CRUD table view that uses an obsolete version 1 API service.
336
+ *
337
+ * @typeparam Model - The type of the data model.
338
+ * @typeparam Service - The type of the API service.
339
+ * @typeparam Sorts - The type for available sort keys on get all operation.
340
+ * @typeparam Filters - The type for available sort keys on get all operation.
341
+ *
342
+ * @deprecated
343
+ */
344
+ class TableviewCrudV1DataProviderInst extends TableviewDataProviderInst {
345
+ constructor(type, serviceType, idPropertyName, useGetAllForFetch = false) {
346
+ super(type, serviceType);
347
+ this.withGetAll((params, service, locale) => service.getAllPost(toV1QueryParam(params), undefined, locale).pipe(map(res => ({ data: res.pageData ?? [], totalCount: res.allDataCount ?? res.pageData?.length ?? 0 }))));
348
+ if (useGetAllForFetch) {
349
+ const selectedIdPropertyName = idPropertyName ?? ModelUtil.findIdAttribute(type) ?? 'id';
350
+ this.withFetch((id, service) => {
351
+ const qp = MediusQueryParamBuilder.create(10, 0).withFilter(selectedIdPropertyName, id, id, MediusFilterMatchType.Equals, true).build();
352
+ return service.getAllPost(qp).pipe(map(res => res.pageData[0]));
353
+ });
354
+ }
355
+ else {
356
+ this.withFetch((id, service, locale) => service.getByIdGet(id, undefined, locale));
357
+ }
358
+ this.withCreate((item, service) => service.createPost(item));
359
+ this.withUpdate((id, item, service) => service.updatePut(id, item));
360
+ this.withDelete((id, item, service) => service.removeDelete(id, item));
361
+ }
362
+ }
363
+ class TableviewCrudV1DataProvider extends TableviewCrudV1DataProviderInst {
364
+ /**
365
+ * @deprecated
366
+ */
367
+ static create(type, serviceType, idProperty, useGetAllForFetch = false) {
368
+ return TableviewCrudV1DataProvider.createUnsafe(type, serviceType, idProperty, useGetAllForFetch);
369
+ }
370
+ /**
371
+ * @deprecated
372
+ */
373
+ static createUnsafe(type, serviceType, idProperty, useGetAllForFetch = false) {
374
+ return new TableviewCrudV1DataProviderInst(type, serviceType, idProperty, useGetAllForFetch);
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Creates a tableview with the given class, service based on data API v1 (obsolete) and optional class/model configuration.
380
+ *
381
+ * @param {ClassType<Model>} type - The class representing the model.
382
+ * @param {ServiceClassType<Service>} service - The class type of the service implementing `IMngCrudObsoleteV1ApiService` and `IMngGetAllObsoleteV1ApiService`.
383
+ * @param {{ idProperty?: keyof Model; titleProperty?: keyof Model; i18nBaseKey?: ClassType<any> | string; }} [modelConfig] - Additional optional model configuration.
384
+ * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
385
+ *
386
+ * @returns {Tableview} - The built table view.
387
+ *
388
+ * @deprecated
389
+ */
390
+ function tableviewCrudV1(type, service, modelConfig, buildFn) {
391
+ const builder = new TableviewInputBuilder(TableviewDescriptor.fromClass(type, modelConfig?.idProperty, modelConfig?.titleProperty, modelConfig?.i18nBaseKey), TableviewCrudV1DataProvider.create(type, service, modelConfig?.idProperty), inject(Injector));
392
+ buildFn?.(builder);
393
+ return builder.build();
394
+ }
395
+
396
+ class MediusQueryResult {
397
+ static fromArray(pageData, allDataCount) {
398
+ const mqr = new MediusQueryResult();
399
+ mqr.allDataCount = allDataCount ?? pageData.length;
400
+ mqr.pageData = pageData;
401
+ return mqr;
402
+ }
403
+ static { this.attributeTypeMap = [
404
+ {
405
+ name: 'allDataCount',
406
+ baseName: 'all_data_count',
407
+ type: 'number'
408
+ },
409
+ {
410
+ name: 'pageData',
411
+ baseName: 'page_data',
412
+ type: 'Array<T>'
413
+ }
414
+ ]; }
415
+ static getAttributeTypeMap() {
416
+ return MediusQueryResult.attributeTypeMap;
417
+ }
418
+ }
419
+
420
+ /**
421
+ * This is an abstract class that provides base functionality for API services.
422
+ *
423
+ * @deprecated
424
+ */
425
+ class ACommonsBaseV1ApiService {
426
+ constructor() {
427
+ this.objectSerializer = ObjectSerializer.get();
428
+ this.http = inject(HttpClient);
429
+ }
430
+ getUrl(...pathSegments) {
431
+ let baseUrl = this.getBasePath();
432
+ if (baseUrl.endsWith('/')) {
433
+ baseUrl = baseUrl.substring(0, baseUrl.length - 1);
434
+ }
435
+ const serviceBasePath = this.getServiceBasePath();
436
+ let path = [serviceBasePath, ...pathSegments].filter(s => s && s.length).join('/');
437
+ // omit first and last '/'
438
+ if (path.startsWith('/')) {
439
+ path = path.substring(1);
440
+ }
441
+ if (path.endsWith('/')) {
442
+ path = path.substring(0, path.length - 1);
443
+ }
444
+ // replace any double '//' from path that could come from joining paths
445
+ path = path.replace('//', '/');
446
+ return `${baseUrl}/${path}`;
447
+ }
448
+ serializeQueryParam(queryParam, type = 'QueryParam') {
449
+ return this.objectSerializer.serialize(queryParam, type);
450
+ }
451
+ deserializeQueryResult(item, qrType) {
452
+ return this.deserializeClass(item, qrType);
453
+ }
454
+ deserializeClass(item, type) {
455
+ return this.objectSerializer.deserializeClass(item, type);
456
+ }
457
+ deserializeClassArray(item, type) {
458
+ return this.objectSerializer.deserializeClassArray(item, type);
459
+ }
460
+ serializeClass(item, type) {
461
+ return this.objectSerializer.serializeClass(item, type);
462
+ }
463
+ serializeClassArray(item, type) {
464
+ return this.objectSerializer.serializeClassArray(item, type);
465
+ }
466
+ }
467
+ /**
468
+ * Represents an abstract base class for the ACommonsV1ApiService.
469
+ *
470
+ * @typeparam T The main type of data to be handled by the service.
471
+ *
472
+ * @deprecated
473
+ */
474
+ class ACommonsV1ApiService extends ACommonsBaseV1ApiService {
475
+ constructor(type) {
476
+ super();
477
+ this.type = type;
478
+ }
479
+ deserialize(item) {
480
+ return this.deserializeClass(item, this.type);
481
+ }
482
+ serialize(item) {
483
+ return this.serializeClass(item, this.type);
484
+ }
485
+ }
486
+
487
+ /**
488
+ * An abstract class representing a service for retrieving all obsolete entities.
489
+ *
490
+ * @typeparam T The main type of data to be handled by the service.
491
+ * @typeparam QRT The type of the query result in get all operation.
492
+ *
493
+ * @deprecated
494
+ */
495
+ class ACommonsGetAllV1ApiService extends ACommonsV1ApiService {
496
+ constructor(type, queryResultType) {
497
+ super(type);
498
+ this.queryResultType = queryResultType;
499
+ }
500
+ getAllPost(queryParamBody, params, locale) {
501
+ const url = this.getUrl(this.getGetAllPostPath());
502
+ if (params && locale) {
503
+ params = params.set('lang', locale);
504
+ }
505
+ else if (locale) {
506
+ params = new HttpParams().set('lang', locale);
507
+ }
508
+ return this.http
509
+ .post(url, queryParamBody ? this.serializeQueryParam(queryParamBody) : undefined, {
510
+ withCredentials: true,
511
+ observe: 'body',
512
+ reportProgress: false,
513
+ params: params
514
+ })
515
+ .pipe(map(res => this.deserializeQueryResult(res, this.queryResultType)));
516
+ }
517
+ getGetAllPostPath() {
518
+ return '/get-all';
519
+ }
520
+ }
521
+
522
+ /**
523
+ * Abstract class for creating CRUD API service implementation.
524
+ *
525
+ * @typeparam T The type of the entity.
526
+ * @typeparam QRT The type of the query result.
527
+ *
528
+ * @deprecated
529
+ */
530
+ class ACommonsCrudV1ApiService extends ACommonsGetAllV1ApiService {
531
+ constructor(type, queryResultType) {
532
+ super(type, queryResultType);
533
+ }
534
+ createPost(item, params) {
535
+ const url = this.getUrl(this.getCreatePostPath(item));
536
+ return this.http
537
+ .post(url, this.serialize(item), {
538
+ withCredentials: true,
539
+ observe: 'body',
540
+ reportProgress: false,
541
+ params: params
542
+ })
543
+ .pipe(map(res => this.deserialize(res)));
544
+ }
545
+ getByIdGet(id, params, locale) {
546
+ const url = this.getUrl(this.getGetByIdGetPath(id));
547
+ if (params && locale) {
548
+ params = params.set('lang', locale);
549
+ }
550
+ else if (locale) {
551
+ params = new HttpParams().set('lang', locale);
552
+ }
553
+ return this.http
554
+ .get(url, {
555
+ withCredentials: true,
556
+ observe: 'body',
557
+ reportProgress: false,
558
+ params: params
559
+ })
560
+ .pipe(map(res => this.deserialize(res)));
561
+ }
562
+ updatePut(id, item, params) {
563
+ const url = this.getUrl(this.getUpdatePutPath(id, item));
564
+ return this.http
565
+ .put(url, this.serialize(item), {
566
+ withCredentials: true,
567
+ observe: 'body',
568
+ reportProgress: false,
569
+ params: params
570
+ })
571
+ .pipe(map(res => this.deserialize(res)));
572
+ }
573
+ removeDelete(id, item, params) {
574
+ const url = this.getUrl(this.getRemoveDeletePath(id, item));
575
+ return this.http
576
+ .request('delete', url, {
577
+ withCredentials: true,
578
+ observe: 'body',
579
+ reportProgress: false,
580
+ body: item ? this.serialize(item) : undefined,
581
+ params: params
582
+ })
583
+ .pipe(map(res => (res ? this.deserialize(res) : null)));
584
+ }
585
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
586
+ getCreatePostPath(item) {
587
+ return '';
588
+ }
589
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
590
+ getUpdatePutPath(id, item) {
591
+ return `/${id}`;
592
+ }
593
+ getGetByIdGetPath(id) {
594
+ return `/${id}`;
595
+ }
596
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
597
+ getRemoveDeletePath(id, item) {
598
+ return `/${id}`;
599
+ }
600
+ }
601
+
602
+ /**
603
+ * A class representing a mapping of query parameters.
604
+ *
605
+ * @typeparam Sorts - The type for available sort keys on get all operation.
606
+ * @typeparam Filters - The type for available sort keys on get all operation.
607
+ *
608
+ * @deprecated
609
+ */
610
+ class QueryParamMap {
611
+ constructor(_params) {
612
+ this._params = _params;
613
+ this._sorts = {};
614
+ this._filters = {};
615
+ // empty line
616
+ }
617
+ static create() {
618
+ return new QueryParamMap();
619
+ }
620
+ static forParams(params) {
621
+ return new QueryParamMap(params);
622
+ }
623
+ withSortMap(sort, mapTo) {
624
+ this._sorts[sort] = mapTo;
625
+ return this;
626
+ }
627
+ withFilterMap(filter, mapTo) {
628
+ this._filters[filter] = mapTo;
629
+ return this;
630
+ }
631
+ mapSort(sort) {
632
+ return this._sorts[sort] ?? sort;
633
+ }
634
+ mapFilter(filter) {
635
+ return this._filters[filter] ?? filter;
636
+ }
637
+ mapParams() {
638
+ if (!this._params) {
639
+ return undefined;
640
+ }
641
+ const params = {
642
+ offset: this._params.offset,
643
+ limit: this._params.limit,
644
+ search: this._params.search,
645
+ sort: this._params.sort?.map(s => ({ property: this.mapSort(s.property), ascending: s.ascending }))
646
+ };
647
+ if (this._params.filters) {
648
+ params.filters = {};
649
+ Object.entries(this._params.filters).forEach(([key, value]) => {
650
+ params.filters[this.mapFilter(key)] = {
651
+ ...value
652
+ };
653
+ });
654
+ }
655
+ return params;
656
+ }
657
+ }
658
+
659
+ function initializeDataApiObsolete(config) {
660
+ return () => {
661
+ const typeRegistry = TypeRegistry.get();
662
+ typeRegistry.registerType(MediusFilterParam, 'FilterParam');
663
+ typeRegistry.registerType(MediusQueryParam, 'QueryParam');
664
+ typeRegistry.registerEnum(MediusFilterMatchType, 'FilterMatchType');
665
+ typeRegistry.registerEnum(MediusQueryMode, 'QueryMode');
666
+ ObjectSerializer.get().configure({ ...(config?.serialization ?? {}) });
667
+ return of(void 0);
668
+ };
669
+ }
670
+ /**
671
+ * Prepares providers for usage of the Obsolete Data API functionalities.
672
+ *
673
+ * @returns {CommonsFeature} The `CommonsFeature` object with the Data API Obsolete configuration.
674
+ *
675
+ * @deprecated.
676
+ */
677
+ function withDataApiV1() {
678
+ return {
679
+ type: CommonsFeatureTypeEnum.DataApiAsClassV1,
680
+ providers: [
681
+ {
682
+ provide: APP_INITIALIZER,
683
+ useFactory: initializeDataApiObsolete,
684
+ deps: [],
685
+ multi: true
686
+ }
687
+ ]
688
+ };
689
+ }
690
+
691
+ // helpers
692
+
693
+ /**
694
+ * Generated bundle index. Do not edit.
695
+ */
696
+
697
+ export { ACommonsBaseV1ApiService, ACommonsCrudV1ApiService, ACommonsGetAllV1ApiService, ACommonsV1ApiService, MediusFilterMatchType, MediusFilterParam, MediusQueryMode, MediusQueryParam, MediusQueryParamBuilder, MediusQueryResult, QueryParamMap, TableviewCrudV1DataProvider, TableviewCrudV1DataProviderInst, executeV1GetAll, tableviewCrudV1, toV1FilterMatchType, toV1QueryParam, withDataApiV1 };
698
+ //# sourceMappingURL=mediusinc-mng-commons-data-api-class-v1.mjs.map