@rxap/open-api 21.0.1-dev.1 → 22.0.0-dev.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 (117) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/compodoc/changelog.html +30 -0
  3. package/compodoc/dependencies.html +10 -10
  4. package/compodoc/js/search/search_index.js +2 -2
  5. package/compodoc/properties.html +1 -1
  6. package/docs/documentation.json +139 -139
  7. package/docs/html/classes/OpenApiConfigService.html +3 -3
  8. package/docs/html/classes/OpenApiHttpResponseError.html +10 -10
  9. package/docs/html/classes/RxapOpenApiError.html +5 -5
  10. package/docs/html/classes/SchemaValidationMixin.html +5 -5
  11. package/docs/html/functions/AssertOpenApiV3.html +1 -1
  12. package/docs/html/functions/IsOpenApiV3.html +1 -1
  13. package/docs/html/functions/IsReferenceObject.html +1 -1
  14. package/docs/html/functions/NotContainsReferenceObjects.html +1 -1
  15. package/docs/html/functions/OpenApiInit.html +1 -1
  16. package/docs/html/functions/getJsonContentSchema.html +1 -1
  17. package/docs/html/functions/getJsonSchema.html +1 -1
  18. package/docs/html/functions/hasJsonContentSchema.html +1 -1
  19. package/docs/html/functions/hasJsonSchema.html +1 -1
  20. package/docs/html/functions/injectOpenApiBaseUrlHttpInterceptorFn.html +1 -1
  21. package/docs/html/index.html +2 -2
  22. package/docs/html/interfaces/OpenApiInitOptions.html +3 -3
  23. package/docs/html/interfaces/OpenApiMetaData.html +5 -5
  24. package/docs/html/interfaces/OperationObjectWithMetadata.html +2 -2
  25. package/docs/html/interfaces/SchemaValidationResponse.html +2 -2
  26. package/docs/html/modules.html +1 -1
  27. package/docs/html/types/OperationMap.html +1 -1
  28. package/docs/html/variables/DEFAULT_OPEN_API_DATA_SOURCE_META_DATA.html +1 -1
  29. package/docs/html/variables/DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA.html +1 -1
  30. package/docs/html/variables/DISABLE_SCHEMA_VALIDATION.html +1 -1
  31. package/docs/html/variables/DISABLE_VALIDATION.html +1 -1
  32. package/docs/html/variables/OPEN_API_OPERATION.html +1 -1
  33. package/docs/html/variables/OPEN_API_OPERATION_ID.html +1 -1
  34. package/docs/html/variables/OPEN_API_SERVER_ID.html +1 -1
  35. package/docs/html/variables/OPEN_API_SERVER_INDEX.html +1 -1
  36. package/docs/html/variables/RXAP_OPEN_API_CONFIG.html +1 -1
  37. package/docs/html/variables/RXAP_OPEN_API_STRICT_VALIDATOR.html +1 -1
  38. package/docs/markdown/README.md +1 -1
  39. package/docs/markdown/classes/OpenApiConfigService.md +14 -14
  40. package/docs/markdown/classes/OpenApiHttpResponseError.md +18 -18
  41. package/docs/markdown/classes/RxapOpenApiError.md +16 -16
  42. package/docs/markdown/classes/SchemaValidationMixin.md +13 -13
  43. package/docs/markdown/functions/AssertOpenApiV3.md +2 -2
  44. package/docs/markdown/functions/IsOpenApiV3.md +2 -2
  45. package/docs/markdown/functions/IsReferenceObject.md +2 -2
  46. package/docs/markdown/functions/NotContainsReferenceObjects.md +2 -2
  47. package/docs/markdown/functions/OpenApiInit.md +2 -2
  48. package/docs/markdown/functions/getJsonContentSchema.md +2 -2
  49. package/docs/markdown/functions/getJsonSchema.md +2 -2
  50. package/docs/markdown/functions/hasJsonContentSchema.md +2 -2
  51. package/docs/markdown/functions/hasJsonSchema.md +2 -2
  52. package/docs/markdown/functions/injectOpenApiBaseUrlHttpInterceptorFn.md +2 -2
  53. package/docs/markdown/globals.md +2 -2
  54. package/docs/markdown/interfaces/OpenApiInitOptions.md +4 -4
  55. package/docs/markdown/interfaces/OpenApiMetaData.md +7 -7
  56. package/docs/markdown/interfaces/OperationObjectWithMetadata.md +4 -4
  57. package/docs/markdown/interfaces/SchemaValidationResponse.md +6 -6
  58. package/docs/markdown/type-aliases/OperationMap.md +2 -2
  59. package/docs/markdown/variables/DEFAULT_OPEN_API_DATA_SOURCE_META_DATA.md +2 -2
  60. package/docs/markdown/variables/DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA.md +2 -2
  61. package/docs/markdown/variables/DISABLE_SCHEMA_VALIDATION.md +2 -2
  62. package/docs/markdown/variables/DISABLE_VALIDATION.md +2 -2
  63. package/docs/markdown/variables/OPEN_API_OPERATION.md +2 -2
  64. package/docs/markdown/variables/OPEN_API_OPERATION_ID.md +2 -2
  65. package/docs/markdown/variables/OPEN_API_SERVER_ID.md +2 -2
  66. package/docs/markdown/variables/OPEN_API_SERVER_INDEX.md +2 -2
  67. package/docs/markdown/variables/RXAP_OPEN_API_CONFIG.md +2 -2
  68. package/docs/markdown/variables/RXAP_OPEN_API_STRICT_VALIDATOR.md +2 -2
  69. package/docs/wiki/Class.OpenApiConfigService.md +13 -13
  70. package/docs/wiki/Class.OpenApiHttpResponseError.md +17 -17
  71. package/docs/wiki/Class.RxapOpenApiError.md +15 -15
  72. package/docs/wiki/Class.SchemaValidationMixin.md +12 -12
  73. package/docs/wiki/Function.AssertOpenApiV3.md +1 -1
  74. package/docs/wiki/Function.IsOpenApiV3.md +1 -1
  75. package/docs/wiki/Function.IsReferenceObject.md +1 -1
  76. package/docs/wiki/Function.NotContainsReferenceObjects.md +1 -1
  77. package/docs/wiki/Function.OpenApiInit.md +1 -1
  78. package/docs/wiki/Function.getJsonContentSchema.md +1 -1
  79. package/docs/wiki/Function.getJsonSchema.md +1 -1
  80. package/docs/wiki/Function.hasJsonContentSchema.md +1 -1
  81. package/docs/wiki/Function.hasJsonSchema.md +1 -1
  82. package/docs/wiki/Function.injectOpenApiBaseUrlHttpInterceptorFn.md +1 -1
  83. package/docs/wiki/Interface.OpenApiInitOptions.md +3 -3
  84. package/docs/wiki/Interface.OpenApiMetaData.md +6 -6
  85. package/docs/wiki/Interface.OperationObjectWithMetadata.md +3 -3
  86. package/docs/wiki/Interface.SchemaValidationResponse.md +5 -5
  87. package/docs/wiki/TypeAlias.OperationMap.md +1 -1
  88. package/docs/wiki/Variable.DEFAULT_OPEN_API_DATA_SOURCE_META_DATA.md +1 -1
  89. package/docs/wiki/Variable.DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA.md +1 -1
  90. package/docs/wiki/Variable.DISABLE_SCHEMA_VALIDATION.md +1 -1
  91. package/docs/wiki/Variable.DISABLE_VALIDATION.md +1 -1
  92. package/docs/wiki/Variable.OPEN_API_OPERATION.md +1 -1
  93. package/docs/wiki/Variable.OPEN_API_OPERATION_ID.md +1 -1
  94. package/docs/wiki/Variable.OPEN_API_SERVER_ID.md +1 -1
  95. package/docs/wiki/Variable.OPEN_API_SERVER_INDEX.md +1 -1
  96. package/docs/wiki/Variable.RXAP_OPEN_API_CONFIG.md +1 -1
  97. package/docs/wiki/Variable.RXAP_OPEN_API_STRICT_VALIDATOR.md +1 -1
  98. package/docs/wiki/globals.md +1 -1
  99. package/fesm2022/rxap-open-api-data-source-table.mjs +212 -162
  100. package/fesm2022/rxap-open-api-data-source-table.mjs.map +1 -1
  101. package/fesm2022/rxap-open-api-data-source.mjs +243 -188
  102. package/fesm2022/rxap-open-api-data-source.mjs.map +1 -1
  103. package/fesm2022/rxap-open-api-http-resource.mjs +13 -38
  104. package/fesm2022/rxap-open-api-http-resource.mjs.map +1 -1
  105. package/fesm2022/rxap-open-api-remote-method.mjs +295 -263
  106. package/fesm2022/rxap-open-api-remote-method.mjs.map +1 -1
  107. package/fesm2022/rxap-open-api-testing.mjs +55 -82
  108. package/fesm2022/rxap-open-api-testing.mjs.map +1 -1
  109. package/fesm2022/rxap-open-api.mjs +439 -633
  110. package/fesm2022/rxap-open-api.mjs.map +1 -1
  111. package/package.json +28 -28
  112. package/types/rxap-open-api-data-source-table.d.ts +47 -40
  113. package/types/rxap-open-api-data-source.d.ts +58 -52
  114. package/types/rxap-open-api-http-resource.d.ts +13 -17
  115. package/types/rxap-open-api-remote-method.d.ts +89 -86
  116. package/types/rxap-open-api-testing.d.ts +25 -28
  117. package/types/rxap-open-api.d.ts +153 -162
@@ -1,274 +1,306 @@
1
- import * as i2 from '@rxap/open-api';
2
- import { RxapOpenApiError, OPEN_API_OPERATION_ID, OPEN_API_SERVER_ID, OPEN_API_SERVER_INDEX, OpenApiHttpResponseError, OpenApiConfigService, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, SchemaValidationMixin } from '@rxap/open-api';
3
- import { BaseRemoteMethod, RxapRemoteMethod } from '@rxap/remote-method';
4
- import { coerceString } from '@rxap/utilities';
5
- import * as i0 from '@angular/core';
6
- import { isDevMode, Injector, Inject, Optional, Injectable, inject } from '@angular/core';
7
- import * as i1 from '@angular/common/http';
8
- import { HttpContext, HttpErrorResponse, HttpEventType, HttpClient } from '@angular/common/http';
9
- import { __decorate, __metadata } from 'tslib';
10
- import { Mixin } from '@rxap/mixin';
11
- import { BaseHttpRemoteMethod } from '@rxap/remote-method/http';
12
- import { firstValueFrom } from 'rxjs';
13
- import { retry, tap, filter, take, timeout } from 'rxjs/operators';
14
-
15
- class RxapOpenApiRemoteMethodError extends RxapOpenApiError {
16
- constructor(message, code, scope) {
17
- super(message, code, scope);
18
- this.addSubPackageName('remote-method');
19
- }
20
- }
21
-
22
- class GetPageAdapterRemoteMethod extends BaseRemoteMethod {
23
- constructor(remoteMethod, paginator, options) {
24
- super(null, remoteMethod.metadata);
25
- this.remoteMethod = remoteMethod;
26
- this.paginator = paginator;
27
- this.options = options;
28
- }
29
- static BuildFilter(filterEvent) {
30
- const filter = [];
31
- if (filterEvent && typeof filterEvent !== 'string') {
32
- for (const [key, value] of Object.entries(filterEvent)) {
33
- if (value !== null && value !== undefined && `${value}` !== '') {
34
- const valueString = coerceString(value);
35
- if (valueString) {
36
- filter.push([key, valueString].join('|'));
37
- }
38
- }
39
- }
40
- }
41
- return filter;
42
- }
43
- async _call(event) {
44
- const parameters = {
45
- pageIndex: event.page?.pageIndex ?? 0,
46
- pageSize: event.page?.pageSize ?? 10,
47
- sortBy: event.sort?.active ?? this.options?.sortBy ?? undefined,
48
- // use the || operator to set the default sort direction if the sort direction is undefined or an empty string
49
- sortDirection: event.sort?.direction ?? this.options?.sortDirection ?? undefined,
50
- filter: GetPageAdapterRemoteMethod.BuildFilter(event.filter),
51
- ...(event.parameters ?? {}),
52
- };
53
- const response = await this.remoteMethod.call({ parameters });
54
- if (event.setTotalLength) {
55
- event.setTotalLength(response.total);
56
- }
57
- if (this.paginator) {
58
- this.paginator.length = response.total;
59
- }
60
- return response.rows;
61
- }
62
- }
1
+ import * as i2 from "@rxap/open-api";
2
+ import { DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, OPEN_API_OPERATION_ID, OPEN_API_SERVER_ID, OPEN_API_SERVER_INDEX, OpenApiConfigService, OpenApiHttpResponseError, RXAP_OPEN_API_STRICT_VALIDATOR, RxapOpenApiError, SchemaValidationMixin } from "@rxap/open-api";
3
+ import { BaseRemoteMethod, RxapRemoteMethod } from "@rxap/remote-method";
4
+ import { coerceString } from "@rxap/utilities";
5
+ import * as i0 from "@angular/core";
6
+ import { Inject, Injectable, Injector, Optional, inject, isDevMode } from "@angular/core";
7
+ import * as i1 from "@angular/common/http";
8
+ import { HttpClient, HttpContext, HttpErrorResponse, HttpEventType } from "@angular/common/http";
9
+ import { __decorate, __metadata } from "tslib";
10
+ import { Mixin } from "@rxap/mixin";
11
+ import { BaseHttpRemoteMethod } from "@rxap/remote-method/http";
12
+ import { firstValueFrom } from "rxjs";
13
+ import { filter, retry, take, tap, timeout } from "rxjs/operators";
14
+ var RxapOpenApiRemoteMethodError = class extends RxapOpenApiError {
15
+ constructor(message, code, scope) {
16
+ super(message, code, scope);
17
+ this.addSubPackageName("remote-method");
18
+ }
19
+ };
20
+ var GetPageAdapterRemoteMethod = class GetPageAdapterRemoteMethod extends BaseRemoteMethod {
21
+ constructor(remoteMethod, paginator, options) {
22
+ super(null, remoteMethod.metadata);
23
+ this.remoteMethod = remoteMethod;
24
+ this.paginator = paginator;
25
+ this.options = options;
26
+ }
27
+ static BuildFilter(filterEvent) {
28
+ const filter = [];
29
+ if (filterEvent && typeof filterEvent !== "string") {
30
+ for (const [key, value] of Object.entries(filterEvent)) if (value !== null && value !== void 0 && `${value}` !== "") {
31
+ const valueString = coerceString(value);
32
+ if (valueString) filter.push([key, valueString].join("|"));
33
+ }
34
+ }
35
+ return filter;
36
+ }
37
+ async _call(event) {
38
+ const parameters = {
39
+ pageIndex: event.page?.pageIndex ?? 0,
40
+ pageSize: event.page?.pageSize ?? 10,
41
+ sortBy: event.sort?.active ?? this.options?.sortBy ?? void 0,
42
+ sortDirection: event.sort?.direction ?? this.options?.sortDirection ?? void 0,
43
+ filter: GetPageAdapterRemoteMethod.BuildFilter(event.filter),
44
+ ...event.parameters ?? {}
45
+ };
46
+ const response = await this.remoteMethod.call({ parameters });
47
+ if (event.setTotalLength) event.setTotalLength(response.total);
48
+ if (this.paginator) this.paginator.length = response.total;
49
+ return response.rows;
50
+ }
51
+ };
63
52
  function GetPageAdapterFactory(remoteMethod, paginator) {
64
- return new GetPageAdapterRemoteMethod(remoteMethod, paginator);
53
+ return new GetPageAdapterRemoteMethod(remoteMethod, paginator);
65
54
  }
66
55
  function GetPageAdapterFactoryWithOptions(options = {}) {
67
- return (remoteMethod, paginator) => {
68
- return new GetPageAdapterRemoteMethod(remoteMethod, paginator, options);
69
- };
56
+ return (remoteMethod, paginator) => {
57
+ return new GetPageAdapterRemoteMethod(remoteMethod, paginator, options);
58
+ };
70
59
  }
71
-
72
60
  function IsOperationFromMetadataInline(metadata) {
73
- return typeof metadata.operation === 'string';
61
+ return typeof metadata.operation === "string";
74
62
  }
75
63
  function RxapOpenApiRemoteMethod(operationOrId, serverIndex = 0) {
76
- return function (target) {
77
- const id = typeof operationOrId === 'string' ?
78
- operationOrId :
79
- (IsOperationFromMetadataInline(operationOrId) ?
80
- operationOrId.operationId :
81
- operationOrId.operation.operationId ?? operationOrId.fallbackId);
82
- if (!id) {
83
- throw new Error('The operationId for the open api remote method is not defined');
84
- }
85
- const metadata = {
86
- id,
87
- serverIndex,
88
- };
89
- if (typeof operationOrId !== 'string') {
90
- metadata.operation = operationOrId.operation;
91
- metadata.serverId = operationOrId.serverId;
92
- }
93
- RxapRemoteMethod(metadata)(target);
94
- };
64
+ return function(target) {
65
+ const id = typeof operationOrId === "string" ? operationOrId : IsOperationFromMetadataInline(operationOrId) ? operationOrId.operationId : operationOrId.operation.operationId ?? operationOrId.fallbackId;
66
+ if (!id) throw new Error("The operationId for the open api remote method is not defined");
67
+ const metadata = {
68
+ id,
69
+ serverIndex
70
+ };
71
+ if (typeof operationOrId !== "string") {
72
+ metadata.operation = operationOrId.operation;
73
+ metadata.serverId = operationOrId.serverId;
74
+ }
75
+ RxapRemoteMethod(metadata)(target);
76
+ };
95
77
  }
96
78
  let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod {
97
- constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
98
- super(http, injector, metadata);
99
- this.disableSchemaValidation = false;
100
- this.disableValidation = false;
101
- this.strict = false;
102
- this.metadata['operation'] ??= openApiConfigService.getOperation(this.metadata.id);
103
- if (typeof this.metadata['operation'] === 'string') {
104
- try {
105
- this.metadata['operation'] = JSON.parse(this.metadata['operation']);
106
- }
107
- catch (e) {
108
- throw new Error(`could not parse the remote method operation string into an object: ${this.constructor.name}`);
109
- }
110
- }
111
- const operation = this.metadata['operation'];
112
- this.applyMetadata({
113
- id: operation.operationId,
114
- url: () => openApiConfigService.getBaseUrl(this.metadata['serverIndex'], this.metadata['serverId']) +
115
- operation.path,
116
- method: operation.method,
117
- withCredentials: this.metadata.withCredentials ?? true,
118
- ignoreUndefined: this.metadata['ignoreUndefined'] ?? true,
119
- context: new HttpContext()
120
- .set(OPEN_API_OPERATION_ID, operation.operationId)
121
- .set(OPEN_API_SERVER_ID, this.metadata['serverId'])
122
- .set(OPEN_API_SERVER_INDEX, this.metadata['serverIndex'])
123
- });
124
- this.strict = strict || this.metadata['strict'] || false;
125
- this.disableSchemaValidation = disableSchemaValidation || this.metadata['disableSchemaValidation'] || false;
126
- this.disableValidation = disableValidation || this.metadata['disableValidation'] || false;
127
- }
128
- get operation() {
129
- return this.metadata['operation'];
130
- }
131
- /**
132
- * Instead of returning the response body the full response object is returned
133
- */
134
- async callWithResponse(args = {}) {
135
- this.init();
136
- this.executionsInProgress$.increase();
137
- const result = await this._callWithResponse(args);
138
- this.executionsInProgress$.decrease();
139
- if (result.body) {
140
- this.executed$.next(result.body);
141
- this.executed(result.body);
142
- }
143
- return result;
144
- }
145
- // TODO : update to the new call method concept (the remove of the _call method concept)
146
- _callWithResponse(args = {}) {
147
- if (!this.disableValidation) {
148
- this.validateParameters(this.operation, args.parameters, this.strict);
149
- this.validateRequestBody(this.operation, args.requestBody, this.strict);
150
- }
151
- return firstValueFrom(this.http.request(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata['ignoreUndefined']))).pipe(retry(this.metadata.retry ?? 0), tap({
152
- error: (error) => {
153
- if (error instanceof HttpErrorResponse) {
154
- this.interceptors?.forEach(interceptor => interceptor
155
- .next({
156
- response: error,
157
- parameters: args.parameters,
158
- requestBody: args.requestBody,
159
- }));
160
- }
161
- },
162
- }), filter((event) => event.type === HttpEventType.Response), tap((response) => {
163
- if (!this.disableValidation) {
164
- this.validateResponse(this.operation, response, this.strict);
165
- }
166
- }), tap((response) => {
167
- this.interceptors?.forEach(interceptor => interceptor
168
- .next({
169
- response,
170
- parameters: args.parameters,
171
- requestBody: args.requestBody,
172
- }));
173
- }), take(1), timeout(this.timeout)));
174
- }
175
- async _call(args = {}) {
176
- if (!this.disableValidation) {
177
- this.validateParameters(this.operation, args.parameters, this.strict);
178
- this.validateRequestBody(this.operation, args.requestBody, this.strict);
179
- }
180
- let response;
181
- try {
182
- response = await this._callWithResponse(args);
183
- }
184
- catch (error) {
185
- if (error instanceof HttpErrorResponse) {
186
- throw new OpenApiHttpResponseError(error, this.metadata);
187
- }
188
- else {
189
- throw error;
190
- }
191
- }
192
- if (response.body) {
193
- return response.body;
194
- }
195
- if (isDevMode()) {
196
- console.warn('The response body is empty!');
197
- }
198
- return null;
199
- }
200
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethod, deps: [{ token: HttpClient }, { token: Injector }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, optional: true }, { token: RXAP_OPEN_API_STRICT_VALIDATOR, optional: true }, { token: DISABLE_SCHEMA_VALIDATION, optional: true }, { token: DISABLE_VALIDATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
201
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethod }); }
79
+ constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
80
+ super(http, injector, metadata);
81
+ this.disableSchemaValidation = false;
82
+ this.disableValidation = false;
83
+ this.strict = false;
84
+ this.metadata["operation"] ??= openApiConfigService.getOperation(this.metadata.id);
85
+ if (typeof this.metadata["operation"] === "string") try {
86
+ this.metadata["operation"] = JSON.parse(this.metadata["operation"]);
87
+ } catch (e) {
88
+ throw new Error(`could not parse the remote method operation string into an object: ${this.constructor.name}`);
89
+ }
90
+ const operation = this.metadata["operation"];
91
+ this.applyMetadata({
92
+ id: operation.operationId,
93
+ url: () => openApiConfigService.getBaseUrl(this.metadata["serverIndex"], this.metadata["serverId"]) + operation.path,
94
+ method: operation.method,
95
+ withCredentials: this.metadata.withCredentials ?? true,
96
+ ignoreUndefined: this.metadata["ignoreUndefined"] ?? true,
97
+ context: new HttpContext().set(OPEN_API_OPERATION_ID, operation.operationId).set(OPEN_API_SERVER_ID, this.metadata["serverId"]).set(OPEN_API_SERVER_INDEX, this.metadata["serverIndex"])
98
+ });
99
+ this.strict = strict || this.metadata["strict"] || false;
100
+ this.disableSchemaValidation = disableSchemaValidation || this.metadata["disableSchemaValidation"] || false;
101
+ this.disableValidation = disableValidation || this.metadata["disableValidation"] || false;
102
+ }
103
+ get operation() {
104
+ return this.metadata["operation"];
105
+ }
106
+ async callWithResponse(args = {}) {
107
+ this.init();
108
+ this.executionsInProgress$.increase();
109
+ const result = await this._callWithResponse(args);
110
+ this.executionsInProgress$.decrease();
111
+ if (result.body) {
112
+ this.executed$.next(result.body);
113
+ this.executed(result.body);
114
+ }
115
+ return result;
116
+ }
117
+ _callWithResponse(args = {}) {
118
+ if (!this.disableValidation) {
119
+ this.validateParameters(this.operation, args.parameters, this.strict);
120
+ this.validateRequestBody(this.operation, args.requestBody, this.strict);
121
+ }
122
+ return firstValueFrom(this.http.request(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata["ignoreUndefined"]))).pipe(retry(this.metadata.retry ?? 0), tap({ error: (error) => {
123
+ if (error instanceof HttpErrorResponse) this.interceptors?.forEach((interceptor) => interceptor.next({
124
+ response: error,
125
+ parameters: args.parameters,
126
+ requestBody: args.requestBody
127
+ }));
128
+ } }), filter((event) => event.type === HttpEventType.Response), tap((response) => {
129
+ if (!this.disableValidation) this.validateResponse(this.operation, response, this.strict);
130
+ }), tap((response) => {
131
+ this.interceptors?.forEach((interceptor) => interceptor.next({
132
+ response,
133
+ parameters: args.parameters,
134
+ requestBody: args.requestBody
135
+ }));
136
+ }), take(1), timeout(this.timeout)));
137
+ }
138
+ async _call(args = {}) {
139
+ if (!this.disableValidation) {
140
+ this.validateParameters(this.operation, args.parameters, this.strict);
141
+ this.validateRequestBody(this.operation, args.requestBody, this.strict);
142
+ }
143
+ let response;
144
+ try {
145
+ response = await this._callWithResponse(args);
146
+ } catch (error) {
147
+ if (error instanceof HttpErrorResponse) throw new OpenApiHttpResponseError(error, this.metadata);
148
+ else throw error;
149
+ }
150
+ if (response.body) return response.body;
151
+ if (isDevMode()) console.warn("The response body is empty!");
152
+ return null;
153
+ }
154
+ static {
155
+ this.ɵfac = i0.ɵɵngDeclareFactory({
156
+ minVersion: "12.0.0",
157
+ version: "22.3.0",
158
+ ngImport: i0,
159
+ type: OpenApiRemoteMethod,
160
+ deps: [
161
+ { token: HttpClient },
162
+ { token: Injector },
163
+ { token: OpenApiConfigService },
164
+ {
165
+ token: DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA,
166
+ optional: true
167
+ },
168
+ {
169
+ token: RXAP_OPEN_API_STRICT_VALIDATOR,
170
+ optional: true
171
+ },
172
+ {
173
+ token: DISABLE_SCHEMA_VALIDATION,
174
+ optional: true
175
+ },
176
+ {
177
+ token: DISABLE_VALIDATION,
178
+ optional: true
179
+ }
180
+ ],
181
+ target: i0.ɵɵFactoryTarget.Injectable
182
+ });
183
+ }
184
+ static {
185
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
186
+ minVersion: "12.0.0",
187
+ version: "22.3.0",
188
+ ngImport: i0,
189
+ type: OpenApiRemoteMethod
190
+ });
191
+ }
202
192
  };
203
- OpenApiRemoteMethod = __decorate([
204
- Mixin(SchemaValidationMixin),
205
- __metadata("design:paramtypes", [HttpClient,
206
- Injector,
207
- OpenApiConfigService, Object, Object, Object, Object])
208
- ], OpenApiRemoteMethod);
209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethod, decorators: [{
210
- type: Injectable
211
- }], ctorParameters: () => [{ type: i1.HttpClient, decorators: [{
212
- type: Inject,
213
- args: [HttpClient]
214
- }] }, { type: i0.Injector, decorators: [{
215
- type: Inject,
216
- args: [Injector]
217
- }] }, { type: i2.OpenApiConfigService, decorators: [{
218
- type: Inject,
219
- args: [OpenApiConfigService]
220
- }] }, { type: undefined, decorators: [{
221
- type: Optional
222
- }, {
223
- type: Inject,
224
- args: [DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA]
225
- }] }, { type: undefined, decorators: [{
226
- type: Optional
227
- }, {
228
- type: Inject,
229
- args: [RXAP_OPEN_API_STRICT_VALIDATOR]
230
- }] }, { type: undefined, decorators: [{
231
- type: Optional
232
- }, {
233
- type: Inject,
234
- args: [DISABLE_SCHEMA_VALIDATION]
235
- }] }, { type: undefined, decorators: [{
236
- type: Optional
237
- }, {
238
- type: Inject,
239
- args: [DISABLE_VALIDATION]
240
- }] }] });
241
-
242
- class OpenApiRemoteMethodLoader {
243
- constructor() {
244
- this.openApiConfig = inject(OpenApiConfigService);
245
- this.http = inject(HttpClient);
246
- this.injector = inject(Injector);
247
- }
248
- load(definitionId) {
249
- const operation = this.openApiConfig.getOperation(definitionId);
250
- if (operation) {
251
- return new OpenApiRemoteMethod(this.http, this.injector, this.openApiConfig, {
252
- id: definitionId,
253
- operation,
254
- });
255
- }
256
- return null;
257
- }
258
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethodLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
259
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethodLoader, providedIn: 'root' }); }
260
- }
261
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: OpenApiRemoteMethodLoader, decorators: [{
262
- type: Injectable,
263
- args: [{ providedIn: 'root' }]
264
- }] });
265
-
266
- // region
267
- // endregion
268
-
269
- /**
270
- * Generated bundle index. Do not edit.
271
- */
272
-
193
+ OpenApiRemoteMethod = __decorate([Mixin(SchemaValidationMixin), __metadata("design:paramtypes", [
194
+ HttpClient,
195
+ Injector,
196
+ OpenApiConfigService,
197
+ Object,
198
+ Object,
199
+ Object,
200
+ Object
201
+ ])], OpenApiRemoteMethod);
202
+ i0.ɵɵngDeclareClassMetadata({
203
+ minVersion: "12.0.0",
204
+ version: "22.3.0",
205
+ ngImport: i0,
206
+ type: OpenApiRemoteMethod,
207
+ decorators: [{ type: Injectable }],
208
+ ctorParameters: () => [
209
+ {
210
+ type: i1.HttpClient,
211
+ decorators: [{
212
+ type: Inject,
213
+ args: [HttpClient]
214
+ }]
215
+ },
216
+ {
217
+ type: i0.Injector,
218
+ decorators: [{
219
+ type: Inject,
220
+ args: [Injector]
221
+ }]
222
+ },
223
+ {
224
+ type: i2.OpenApiConfigService,
225
+ decorators: [{
226
+ type: Inject,
227
+ args: [OpenApiConfigService]
228
+ }]
229
+ },
230
+ {
231
+ type: void 0,
232
+ decorators: [{ type: Optional }, {
233
+ type: Inject,
234
+ args: [DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA]
235
+ }]
236
+ },
237
+ {
238
+ type: void 0,
239
+ decorators: [{ type: Optional }, {
240
+ type: Inject,
241
+ args: [RXAP_OPEN_API_STRICT_VALIDATOR]
242
+ }]
243
+ },
244
+ {
245
+ type: void 0,
246
+ decorators: [{ type: Optional }, {
247
+ type: Inject,
248
+ args: [DISABLE_SCHEMA_VALIDATION]
249
+ }]
250
+ },
251
+ {
252
+ type: void 0,
253
+ decorators: [{ type: Optional }, {
254
+ type: Inject,
255
+ args: [DISABLE_VALIDATION]
256
+ }]
257
+ }
258
+ ]
259
+ });
260
+ var OpenApiRemoteMethodLoader = class OpenApiRemoteMethodLoader {
261
+ constructor() {
262
+ this.openApiConfig = inject(OpenApiConfigService);
263
+ this.http = inject(HttpClient);
264
+ this.injector = inject(Injector);
265
+ }
266
+ load(definitionId) {
267
+ const operation = this.openApiConfig.getOperation(definitionId);
268
+ if (operation) return new OpenApiRemoteMethod(this.http, this.injector, this.openApiConfig, {
269
+ id: definitionId,
270
+ operation
271
+ });
272
+ return null;
273
+ }
274
+ static {
275
+ this.ɵfac = i0.ɵɵngDeclareFactory({
276
+ minVersion: "12.0.0",
277
+ version: "22.3.0",
278
+ ngImport: i0,
279
+ type: OpenApiRemoteMethodLoader,
280
+ deps: [],
281
+ target: i0.ɵɵFactoryTarget.Injectable
282
+ });
283
+ }
284
+ static {
285
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
286
+ minVersion: "12.0.0",
287
+ version: "22.3.0",
288
+ ngImport: i0,
289
+ type: OpenApiRemoteMethodLoader,
290
+ providedIn: "root"
291
+ });
292
+ }
293
+ };
294
+ i0.ɵɵngDeclareClassMetadata({
295
+ minVersion: "12.0.0",
296
+ version: "22.3.0",
297
+ ngImport: i0,
298
+ type: OpenApiRemoteMethodLoader,
299
+ decorators: [{
300
+ type: Injectable,
301
+ args: [{ providedIn: "root" }]
302
+ }]
303
+ });
273
304
  export { GetPageAdapterFactory, GetPageAdapterFactoryWithOptions, GetPageAdapterRemoteMethod, IsOperationFromMetadataInline, OpenApiRemoteMethod, OpenApiRemoteMethodLoader, RxapOpenApiRemoteMethod, RxapOpenApiRemoteMethodError };
274
- //# sourceMappingURL=rxap-open-api-remote-method.mjs.map
305
+
306
+ //# sourceMappingURL=rxap-open-api-remote-method.mjs.map