@rxap/open-api 12.2.3 → 13.0.0-next.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 (115) hide show
  1. package/data-source/package.json +5 -5
  2. package/data-source/table/package.json +5 -5
  3. package/esm2020/data-source/lib/error.mjs +8 -0
  4. package/esm2020/data-source/lib/open-api-data-source.loader.mjs +36 -0
  5. package/esm2020/data-source/lib/open-api.data-source.mjs +114 -0
  6. package/esm2020/data-source/public_api.mjs +6 -0
  7. package/esm2020/data-source/rxap-open-api-data-source.mjs +5 -0
  8. package/esm2020/data-source/table/lib/error.mjs +8 -0
  9. package/esm2020/data-source/table/lib/open-api-table.data-source.mjs +127 -0
  10. package/esm2020/data-source/table/lib/to-open-api-table-data-source.pipe.mjs +29 -0
  11. package/esm2020/data-source/table/lib/tokens.mjs +3 -0
  12. package/esm2020/data-source/table/public_api.mjs +5 -0
  13. package/esm2020/data-source/table/rxap-open-api-data-source-table.mjs +5 -0
  14. package/esm2020/index.mjs +7 -0
  15. package/esm2020/lib/error.mjs +7 -0
  16. package/esm2020/lib/open-api-config.service.mjs +128 -0
  17. package/esm2020/lib/open-api.mjs +2 -0
  18. package/esm2020/lib/schema-validation.mixin.mjs +253 -0
  19. package/esm2020/lib/tokens.mjs +6 -0
  20. package/esm2020/lib/utilities.mjs +16 -0
  21. package/esm2020/remote-method/lib/error.mjs +8 -0
  22. package/esm2020/remote-method/lib/open-api-remote-method.loader.mjs +37 -0
  23. package/esm2020/remote-method/lib/open-api.remote-method.mjs +111 -0
  24. package/esm2020/remote-method/public_api.mjs +4 -0
  25. package/esm2020/remote-method/rxap-open-api-remote-method.mjs +5 -0
  26. package/esm2020/rxap-open-api.mjs +5 -0
  27. package/{esm2015/data-source/table/lib/open-api-table.data-source.js → fesm2015/rxap-open-api-data-source-table.mjs} +91 -48
  28. package/fesm2015/rxap-open-api-data-source-table.mjs.map +1 -0
  29. package/{esm2015/data-source/lib/open-api.data-source.js → fesm2015/rxap-open-api-data-source.mjs} +86 -39
  30. package/fesm2015/rxap-open-api-data-source.mjs.map +1 -0
  31. package/fesm2015/{rxap-open-api-remote-method.js → rxap-open-api-remote-method.mjs} +38 -34
  32. package/fesm2015/rxap-open-api-remote-method.mjs.map +1 -0
  33. package/fesm2015/{rxap-open-api.js → rxap-open-api.mjs} +22 -13
  34. package/fesm2015/rxap-open-api.mjs.map +1 -0
  35. package/{fesm2015/rxap-open-api-data-source-table.js → fesm2020/rxap-open-api-data-source-table.mjs} +18 -20
  36. package/fesm2020/rxap-open-api-data-source-table.mjs.map +1 -0
  37. package/{fesm2015/rxap-open-api-data-source.js → fesm2020/rxap-open-api-data-source.mjs} +16 -17
  38. package/fesm2020/rxap-open-api-data-source.mjs.map +1 -0
  39. package/fesm2020/rxap-open-api-remote-method.mjs +154 -0
  40. package/fesm2020/rxap-open-api-remote-method.mjs.map +1 -0
  41. package/{esm2015/lib/schema-validation.mixin.js → fesm2020/rxap-open-api.mjs} +171 -9
  42. package/fesm2020/rxap-open-api.mjs.map +1 -0
  43. package/package.json +60 -22
  44. package/remote-method/package.json +5 -5
  45. package/src/schematics/ng-add/index.js +1 -1
  46. package/src/schematics/ng-add/index.js.map +1 -1
  47. package/src/schematics/open-api/coerce-open-api-project.js +4 -4
  48. package/src/schematics/open-api/coerce-open-api-project.js.map +1 -1
  49. package/src/schematics/open-api/create-directive.js +5 -5
  50. package/src/schematics/open-api/create-directive.js.map +1 -1
  51. package/src/schematics/open-api/generate-data-source.js +4 -4
  52. package/src/schematics/open-api/generate-data-source.js.map +1 -1
  53. package/src/schematics/open-api/generate-openapi-provider.js +1 -1
  54. package/src/schematics/open-api/generate-openapi-provider.js.map +1 -1
  55. package/src/schematics/open-api/generate-remote-method.js +10 -10
  56. package/src/schematics/open-api/generate-remote-method.js.map +1 -1
  57. package/src/schematics/open-api/index.js +18 -18
  58. package/src/schematics/open-api/index.js.map +1 -1
  59. package/bundles/rxap-open-api-data-source-table.umd.js +0 -536
  60. package/bundles/rxap-open-api-data-source-table.umd.js.map +0 -1
  61. package/bundles/rxap-open-api-data-source.umd.js +0 -526
  62. package/bundles/rxap-open-api-data-source.umd.js.map +0 -1
  63. package/bundles/rxap-open-api-remote-method.umd.js +0 -535
  64. package/bundles/rxap-open-api-remote-method.umd.js.map +0 -1
  65. package/bundles/rxap-open-api.umd.js +0 -856
  66. package/bundles/rxap-open-api.umd.js.map +0 -1
  67. package/esm2015/data-source/lib/error.js +0 -8
  68. package/esm2015/data-source/lib/error.js.map +0 -1
  69. package/esm2015/data-source/lib/open-api-data-source.loader.js +0 -36
  70. package/esm2015/data-source/lib/open-api-data-source.loader.js.map +0 -1
  71. package/esm2015/data-source/lib/open-api.data-source.js.map +0 -1
  72. package/esm2015/data-source/public_api.js +0 -6
  73. package/esm2015/data-source/public_api.js.map +0 -1
  74. package/esm2015/data-source/rxap-open-api-data-source.js +0 -5
  75. package/esm2015/data-source/rxap-open-api-data-source.js.map +0 -1
  76. package/esm2015/data-source/table/lib/error.js +0 -8
  77. package/esm2015/data-source/table/lib/error.js.map +0 -1
  78. package/esm2015/data-source/table/lib/open-api-table.data-source.js.map +0 -1
  79. package/esm2015/data-source/table/lib/to-open-api-table-data-source.pipe.js +0 -29
  80. package/esm2015/data-source/table/lib/to-open-api-table-data-source.pipe.js.map +0 -1
  81. package/esm2015/data-source/table/lib/tokens.js +0 -3
  82. package/esm2015/data-source/table/lib/tokens.js.map +0 -1
  83. package/esm2015/data-source/table/public_api.js +0 -5
  84. package/esm2015/data-source/table/public_api.js.map +0 -1
  85. package/esm2015/data-source/table/rxap-open-api-data-source-table.js +0 -5
  86. package/esm2015/data-source/table/rxap-open-api-data-source-table.js.map +0 -1
  87. package/esm2015/index.js +0 -7
  88. package/esm2015/index.js.map +0 -1
  89. package/esm2015/lib/error.js +0 -7
  90. package/esm2015/lib/error.js.map +0 -1
  91. package/esm2015/lib/open-api-config.service.js +0 -127
  92. package/esm2015/lib/open-api-config.service.js.map +0 -1
  93. package/esm2015/lib/open-api.js +0 -2
  94. package/esm2015/lib/open-api.js.map +0 -1
  95. package/esm2015/lib/schema-validation.mixin.js.map +0 -1
  96. package/esm2015/lib/tokens.js +0 -6
  97. package/esm2015/lib/tokens.js.map +0 -1
  98. package/esm2015/lib/utilities.js +0 -16
  99. package/esm2015/lib/utilities.js.map +0 -1
  100. package/esm2015/remote-method/lib/error.js +0 -8
  101. package/esm2015/remote-method/lib/error.js.map +0 -1
  102. package/esm2015/remote-method/lib/open-api-remote-method.loader.js +0 -37
  103. package/esm2015/remote-method/lib/open-api-remote-method.loader.js.map +0 -1
  104. package/esm2015/remote-method/lib/open-api.remote-method.js +0 -119
  105. package/esm2015/remote-method/lib/open-api.remote-method.js.map +0 -1
  106. package/esm2015/remote-method/public_api.js +0 -4
  107. package/esm2015/remote-method/public_api.js.map +0 -1
  108. package/esm2015/remote-method/rxap-open-api-remote-method.js +0 -5
  109. package/esm2015/remote-method/rxap-open-api-remote-method.js.map +0 -1
  110. package/esm2015/rxap-open-api.js +0 -5
  111. package/esm2015/rxap-open-api.js.map +0 -1
  112. package/fesm2015/rxap-open-api-data-source-table.js.map +0 -1
  113. package/fesm2015/rxap-open-api-data-source.js.map +0 -1
  114. package/fesm2015/rxap-open-api-remote-method.js.map +0 -1
  115. package/fesm2015/rxap-open-api.js.map +0 -1
@@ -1,856 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@rxap/utilities'), require('ajv-oai'), require('@angular/common/http')) :
3
- typeof define === 'function' && define.amd ? define('@rxap/open-api', ['exports', '@angular/core', '@rxap/utilities', 'ajv-oai', '@angular/common/http'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.rxap = global.rxap || {}, global.rxap['open-api'] = {}), global.ng.core, global.utilities, global.Ajv, global.ng.common.http));
5
- }(this, (function (exports, i0, utilities, Ajv, http) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var Ajv__namespace = /*#__PURE__*/_interopNamespace(Ajv);
29
-
30
- /*! *****************************************************************************
31
- Copyright (c) Microsoft Corporation.
32
-
33
- Permission to use, copy, modify, and/or distribute this software for any
34
- purpose with or without fee is hereby granted.
35
-
36
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
37
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
38
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
39
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
40
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42
- PERFORMANCE OF THIS SOFTWARE.
43
- ***************************************************************************** */
44
- /* global Reflect, Promise */
45
- var extendStatics = function (d, b) {
46
- extendStatics = Object.setPrototypeOf ||
47
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48
- function (d, b) { for (var p in b)
49
- if (Object.prototype.hasOwnProperty.call(b, p))
50
- d[p] = b[p]; };
51
- return extendStatics(d, b);
52
- };
53
- function __extends(d, b) {
54
- if (typeof b !== "function" && b !== null)
55
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
56
- extendStatics(d, b);
57
- function __() { this.constructor = d; }
58
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59
- }
60
- var __assign = function () {
61
- __assign = Object.assign || function __assign(t) {
62
- for (var s, i = 1, n = arguments.length; i < n; i++) {
63
- s = arguments[i];
64
- for (var p in s)
65
- if (Object.prototype.hasOwnProperty.call(s, p))
66
- t[p] = s[p];
67
- }
68
- return t;
69
- };
70
- return __assign.apply(this, arguments);
71
- };
72
- function __rest(s, e) {
73
- var t = {};
74
- for (var p in s)
75
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
76
- t[p] = s[p];
77
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
78
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
79
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
80
- t[p[i]] = s[p[i]];
81
- }
82
- return t;
83
- }
84
- function __decorate(decorators, target, key, desc) {
85
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
86
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
87
- r = Reflect.decorate(decorators, target, key, desc);
88
- else
89
- for (var i = decorators.length - 1; i >= 0; i--)
90
- if (d = decorators[i])
91
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
92
- return c > 3 && r && Object.defineProperty(target, key, r), r;
93
- }
94
- function __param(paramIndex, decorator) {
95
- return function (target, key) { decorator(target, key, paramIndex); };
96
- }
97
- function __metadata(metadataKey, metadataValue) {
98
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
99
- return Reflect.metadata(metadataKey, metadataValue);
100
- }
101
- function __awaiter(thisArg, _arguments, P, generator) {
102
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103
- return new (P || (P = Promise))(function (resolve, reject) {
104
- function fulfilled(value) { try {
105
- step(generator.next(value));
106
- }
107
- catch (e) {
108
- reject(e);
109
- } }
110
- function rejected(value) { try {
111
- step(generator["throw"](value));
112
- }
113
- catch (e) {
114
- reject(e);
115
- } }
116
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
117
- step((generator = generator.apply(thisArg, _arguments || [])).next());
118
- });
119
- }
120
- function __generator(thisArg, body) {
121
- var _ = { label: 0, sent: function () { if (t[0] & 1)
122
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
123
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
124
- function verb(n) { return function (v) { return step([n, v]); }; }
125
- function step(op) {
126
- if (f)
127
- throw new TypeError("Generator is already executing.");
128
- while (_)
129
- try {
130
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
131
- return t;
132
- if (y = 0, t)
133
- op = [op[0] & 2, t.value];
134
- switch (op[0]) {
135
- case 0:
136
- case 1:
137
- t = op;
138
- break;
139
- case 4:
140
- _.label++;
141
- return { value: op[1], done: false };
142
- case 5:
143
- _.label++;
144
- y = op[1];
145
- op = [0];
146
- continue;
147
- case 7:
148
- op = _.ops.pop();
149
- _.trys.pop();
150
- continue;
151
- default:
152
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
153
- _ = 0;
154
- continue;
155
- }
156
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
157
- _.label = op[1];
158
- break;
159
- }
160
- if (op[0] === 6 && _.label < t[1]) {
161
- _.label = t[1];
162
- t = op;
163
- break;
164
- }
165
- if (t && _.label < t[2]) {
166
- _.label = t[2];
167
- _.ops.push(op);
168
- break;
169
- }
170
- if (t[2])
171
- _.ops.pop();
172
- _.trys.pop();
173
- continue;
174
- }
175
- op = body.call(thisArg, _);
176
- }
177
- catch (e) {
178
- op = [6, e];
179
- y = 0;
180
- }
181
- finally {
182
- f = t = 0;
183
- }
184
- if (op[0] & 5)
185
- throw op[1];
186
- return { value: op[0] ? op[1] : void 0, done: true };
187
- }
188
- }
189
- var __createBinding = Object.create ? (function (o, m, k, k2) {
190
- if (k2 === undefined)
191
- k2 = k;
192
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
193
- }) : (function (o, m, k, k2) {
194
- if (k2 === undefined)
195
- k2 = k;
196
- o[k2] = m[k];
197
- });
198
- function __exportStar(m, o) {
199
- for (var p in m)
200
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
201
- __createBinding(o, m, p);
202
- }
203
- function __values(o) {
204
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
205
- if (m)
206
- return m.call(o);
207
- if (o && typeof o.length === "number")
208
- return {
209
- next: function () {
210
- if (o && i >= o.length)
211
- o = void 0;
212
- return { value: o && o[i++], done: !o };
213
- }
214
- };
215
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
216
- }
217
- function __read(o, n) {
218
- var m = typeof Symbol === "function" && o[Symbol.iterator];
219
- if (!m)
220
- return o;
221
- var i = m.call(o), r, ar = [], e;
222
- try {
223
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
224
- ar.push(r.value);
225
- }
226
- catch (error) {
227
- e = { error: error };
228
- }
229
- finally {
230
- try {
231
- if (r && !r.done && (m = i["return"]))
232
- m.call(i);
233
- }
234
- finally {
235
- if (e)
236
- throw e.error;
237
- }
238
- }
239
- return ar;
240
- }
241
- /** @deprecated */
242
- function __spread() {
243
- for (var ar = [], i = 0; i < arguments.length; i++)
244
- ar = ar.concat(__read(arguments[i]));
245
- return ar;
246
- }
247
- /** @deprecated */
248
- function __spreadArrays() {
249
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
250
- s += arguments[i].length;
251
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
252
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
253
- r[k] = a[j];
254
- return r;
255
- }
256
- function __spreadArray(to, from) {
257
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
258
- to[j] = from[i];
259
- return to;
260
- }
261
- function __await(v) {
262
- return this instanceof __await ? (this.v = v, this) : new __await(v);
263
- }
264
- function __asyncGenerator(thisArg, _arguments, generator) {
265
- if (!Symbol.asyncIterator)
266
- throw new TypeError("Symbol.asyncIterator is not defined.");
267
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
268
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
269
- function verb(n) { if (g[n])
270
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
271
- function resume(n, v) { try {
272
- step(g[n](v));
273
- }
274
- catch (e) {
275
- settle(q[0][3], e);
276
- } }
277
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
278
- function fulfill(value) { resume("next", value); }
279
- function reject(value) { resume("throw", value); }
280
- function settle(f, v) { if (f(v), q.shift(), q.length)
281
- resume(q[0][0], q[0][1]); }
282
- }
283
- function __asyncDelegator(o) {
284
- var i, p;
285
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
286
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
287
- }
288
- function __asyncValues(o) {
289
- if (!Symbol.asyncIterator)
290
- throw new TypeError("Symbol.asyncIterator is not defined.");
291
- var m = o[Symbol.asyncIterator], i;
292
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
293
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
294
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
295
- }
296
- function __makeTemplateObject(cooked, raw) {
297
- if (Object.defineProperty) {
298
- Object.defineProperty(cooked, "raw", { value: raw });
299
- }
300
- else {
301
- cooked.raw = raw;
302
- }
303
- return cooked;
304
- }
305
- ;
306
- var __setModuleDefault = Object.create ? (function (o, v) {
307
- Object.defineProperty(o, "default", { enumerable: true, value: v });
308
- }) : function (o, v) {
309
- o["default"] = v;
310
- };
311
- function __importStar(mod) {
312
- if (mod && mod.__esModule)
313
- return mod;
314
- var result = {};
315
- if (mod != null)
316
- for (var k in mod)
317
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
318
- __createBinding(result, mod, k);
319
- __setModuleDefault(result, mod);
320
- return result;
321
- }
322
- function __importDefault(mod) {
323
- return (mod && mod.__esModule) ? mod : { default: mod };
324
- }
325
- function __classPrivateFieldGet(receiver, state, kind, f) {
326
- if (kind === "a" && !f)
327
- throw new TypeError("Private accessor was defined without a getter");
328
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
329
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
330
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
331
- }
332
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
333
- if (kind === "m")
334
- throw new TypeError("Private method is not writable");
335
- if (kind === "a" && !f)
336
- throw new TypeError("Private accessor was defined without a setter");
337
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
338
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
339
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
340
- }
341
-
342
- var RXAP_OPEN_API_CONFIG = new i0.InjectionToken('rxap/open-api/config');
343
- var RXAP_OPEN_API_STRICT_VALIDATOR = new i0.InjectionToken('rxap/open-api/strict-validator');
344
- var DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new i0.InjectionToken('rxap/open-api/default-remote-method-meta-data');
345
- var DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new i0.InjectionToken('rxap/open-api/default-data-source-meta-data');
346
-
347
- var RxapOpenApiError = /** @class */ (function (_super) {
348
- __extends(RxapOpenApiError, _super);
349
- function RxapOpenApiError(message, code, scope) {
350
- return _super.call(this, '@rxap/open-api', message, code !== null && code !== void 0 ? code : '', scope) || this;
351
- }
352
- return RxapOpenApiError;
353
- }(utilities.RxapError));
354
-
355
- function IsReferenceObject(obj) {
356
- return !!obj && obj.hasOwnProperty('$ref');
357
- }
358
- function NotContainsReferenceObjects(array) {
359
- return !!array && array.every(function (item) { return !IsReferenceObject(item) && !!item; });
360
- }
361
- function IsOpenApiV3(obj) {
362
- return !!obj && obj.hasOwnProperty('openapi') && obj.openapi.match(/^3\./);
363
- }
364
- function AssertOpenApiV3(obj) {
365
- if (!IsOpenApiV3(obj)) {
366
- throw new RxapOpenApiError('Only openapi version 3.x.x is supported');
367
- }
368
- }
369
-
370
- var OpenApiConfigService = /** @class */ (function () {
371
- function OpenApiConfigService(config) {
372
- if (config === void 0) { config = null; }
373
- this.defaultServerIndex = OpenApiConfigService.DefaultServerIndex;
374
- config = config !== null && config !== void 0 ? config : OpenApiConfigService.Config;
375
- if (!config) {
376
- throw new Error('Could not load config');
377
- }
378
- this.config = config;
379
- this._operations = OpenApiConfigService.LoadOperations(config);
380
- }
381
- /**
382
- * Used to load the app open api config from a remote resource.
383
- *
384
- * Promise.all([ OpenApiDataSourceLoader.Load() ])
385
- * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))
386
- * .catch(err => console.error(err))
387
- *
388
- */
389
- OpenApiConfigService.Load = function (openApiUrl) {
390
- if (openApiUrl === void 0) { openApiUrl = 'openapi.json'; }
391
- return __awaiter(this, void 0, void 0, function () {
392
- var config, response, error_1, expandedConfig;
393
- return __generator(this, function (_a) {
394
- switch (_a.label) {
395
- case 0:
396
- if (!openApiUrl) {
397
- throw new Error('The open api url is not defined!');
398
- }
399
- config = null;
400
- _a.label = 1;
401
- case 1:
402
- _a.trys.push([1, 4, , 5]);
403
- return [4 /*yield*/, fetch(openApiUrl)];
404
- case 2:
405
- response = _a.sent();
406
- return [4 /*yield*/, response.json()];
407
- case 3:
408
- config = _a.sent();
409
- return [3 /*break*/, 5];
410
- case 4:
411
- error_1 = _a.sent();
412
- console.debug("Could not load the open api config from '" + openApiUrl + "'!", error_1);
413
- console.error("Could not load the open api config from '" + openApiUrl + "'!", error_1.message);
414
- return [3 /*break*/, 5];
415
- case 5:
416
- if (!config) return [3 /*break*/, 7];
417
- return [4 /*yield*/, this.ExpandOpenApi(config)];
418
- case 6:
419
- expandedConfig = _a.sent();
420
- AssertOpenApiV3(expandedConfig);
421
- this.Config = expandedConfig;
422
- return [3 /*break*/, 8];
423
- case 7:
424
- this.Config = null;
425
- _a.label = 8;
426
- case 8: return [2 /*return*/];
427
- }
428
- });
429
- });
430
- };
431
- OpenApiConfigService.GetOperation = function (operationId) {
432
- if (!this.Config) {
433
- throw new Error('Could not load open api config');
434
- }
435
- if (!this._operations) {
436
- this._operations = this.LoadOperations(this.Config);
437
- }
438
- if (!this._operations.has(operationId)) {
439
- throw new Error("The operation '" + operationId + "' is not defined in the openapi-json");
440
- }
441
- return this._operations.get(operationId);
442
- };
443
- OpenApiConfigService.LoadOperations = function (config) {
444
- var operations = new Map();
445
- Object.entries(config.paths)
446
- .filter(function (item) { return item[0] !== undefined; })
447
- .filter(function (_a) {
448
- var _b = __read(_a, 2), _ = _b[0], methods = _b[1];
449
- return methods &&
450
- Object.keys(methods).some(function (method) { return ['get', 'put', 'post', 'delete', 'patch'].includes(method); });
451
- })
452
- .forEach(function (_a) {
453
- var _b = __read(_a, 2), path = _b[0], methods = _b[1];
454
- return Object.entries(methods)
455
- .filter(function (item) { return item[0] !== undefined; })
456
- .forEach(function (_a) {
457
- var _b = __read(_a, 2), method = _b[0], operation = _b[1];
458
- if (!operation.operationId) {
459
- throw new Error('The OpenApu OperationId is not defined');
460
- }
461
- if (operations.has(operation.operationId)) {
462
- throw new Error("The OpenApi Operation '" + operation.operationId + "' is already defined.");
463
- }
464
- operations.set(operation.operationId, Object.assign(Object.assign({}, operation), { path: path, method: method.toUpperCase() }));
465
- });
466
- });
467
- return operations;
468
- };
469
- OpenApiConfigService.GetBaseUrl = function (config, serverIndex) {
470
- if (serverIndex === void 0) { serverIndex = this.DefaultServerIndex; }
471
- var server = config.servers ? config.servers[serverIndex] : null;
472
- if (!server) {
473
- console.debug("Could not extract the server config with the index '" + serverIndex + "' from the open api config", config);
474
- throw new Error("Could not extract the server config with the index '" + serverIndex + "' from the open api config");
475
- }
476
- return server.url;
477
- };
478
- /**
479
- * Replaces all $ref with the concrete definition
480
- *
481
- * @param config
482
- * @private
483
- */
484
- OpenApiConfigService.ExpandOpenApi = function (config) {
485
- return Promise.resolve(config);
486
- };
487
- OpenApiConfigService.prototype.getOperation = function (operationId) {
488
- if (!this._operations.has(operationId)) {
489
- console.debug("The operation '" + operationId + "' is not defined in the openapi-json", this.config);
490
- throw new Error("The operation '" + operationId + "' is not defined in the openapi-json");
491
- }
492
- return this._operations.get(operationId);
493
- };
494
- OpenApiConfigService.prototype.getBaseUrl = function (serverIndex) {
495
- if (serverIndex === void 0) { serverIndex = this.defaultServerIndex; }
496
- return OpenApiConfigService.GetBaseUrl(this.config, serverIndex);
497
- };
498
- OpenApiConfigService.prototype.insertServer = function (serverConfig, index) {
499
- if (index === void 0) { index = this.defaultServerIndex; }
500
- if (!this.config.servers) {
501
- this.config.servers = [];
502
- }
503
- this.config.servers.splice(index, 1, serverConfig);
504
- };
505
- return OpenApiConfigService;
506
- }());
507
- OpenApiConfigService.Config = null;
508
- OpenApiConfigService.DefaultServerIndex = 0;
509
- OpenApiConfigService._operations = null;
510
- OpenApiConfigService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: OpenApiConfigService, deps: [{ token: RXAP_OPEN_API_CONFIG, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
511
- OpenApiConfigService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: OpenApiConfigService, providedIn: 'root' });
512
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: OpenApiConfigService, decorators: [{
513
- type: i0.Injectable,
514
- args: [{ providedIn: 'root' }]
515
- }], ctorParameters: function () {
516
- return [{ type: undefined, decorators: [{
517
- type: i0.Optional
518
- }, {
519
- type: i0.Inject,
520
- args: [RXAP_OPEN_API_CONFIG]
521
- }] }];
522
- } });
523
-
524
- var SchemaValidationMixin = /** @class */ (function () {
525
- function SchemaValidationMixin() {
526
- }
527
- /**
528
- * Validates the parameters against the schema specified in the operation object
529
- *
530
- * @param operation
531
- * @param parameters
532
- * @param strict
533
- * @protected
534
- */
535
- SchemaValidationMixin.prototype.validateParameters = function (operation, parameters, strict) {
536
- var e_1, _b;
537
- if (strict === void 0) { strict = false; }
538
- var operationParameters = utilities.coerceArray(operation.parameters);
539
- if (!NotContainsReferenceObjects(operationParameters)) {
540
- throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');
541
- }
542
- if (parameters === undefined) {
543
- // TODO : find concept to definition witch parameter should not be checked if required
544
- // header parameters are never required if changes the semantic release manager breaks
545
- var requiredParameters = operationParameters.filter(function (parameter) { return parameter.required && parameter.in !== 'header'; });
546
- if (requiredParameters.length) {
547
- if (i0.isDevMode()) {
548
- console.debug('Some operation parameters are required!', requiredParameters.map(function (p) { return p.name; }));
549
- }
550
- this.validationError('Some operation parameters are required!', strict);
551
- }
552
- }
553
- else if (utilities.IsRecord(parameters)) {
554
- try {
555
- for (var operationParameters_1 = __values(operationParameters), operationParameters_1_1 = operationParameters_1.next(); !operationParameters_1_1.done; operationParameters_1_1 = operationParameters_1.next()) {
556
- var parameter = operationParameters_1_1.value;
557
- if (parameter.required) {
558
- // header parameters are never required if changes the semantic release manager breaks
559
- if (parameter.in !== 'header') {
560
- if (!parameters.hasOwnProperty(parameter.name)) {
561
- this.validationError("The operation parameter '" + parameter.name + "' is required!", strict);
562
- }
563
- }
564
- }
565
- if (parameter.schema) {
566
- if (parameters.hasOwnProperty(parameter.name)) {
567
- var value = parameters[parameter.name];
568
- if (!this.validate(parameter.schema, value)) {
569
- this.validationError("The parameter '" + parameter.name + "' is not valid against the schema!", strict, parameter.schema, value);
570
- }
571
- }
572
- }
573
- }
574
- }
575
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
576
- finally {
577
- try {
578
- if (operationParameters_1_1 && !operationParameters_1_1.done && (_b = operationParameters_1.return)) _b.call(operationParameters_1);
579
- }
580
- finally { if (e_1) throw e_1.error; }
581
- }
582
- }
583
- else {
584
- throw new Error('The parameters object is not a record');
585
- }
586
- };
587
- /**
588
- * Validates the http response against the schema specified in the operation object
589
- *
590
- * @param operation
591
- * @param response
592
- * @param strict
593
- * @protected
594
- */
595
- SchemaValidationMixin.prototype.validateResponse = function (operation, response, strict) {
596
- if (strict === void 0) { strict = false; }
597
- // region only validate the response if the content type is undefined or application/json
598
- var _a;
599
- var contentType = response.headers.get('Content-Type');
600
- if (contentType && contentType !== 'application/json') {
601
- if (i0.isDevMode()) {
602
- console.warn('Response validation is only supported for content type application/json');
603
- }
604
- return;
605
- }
606
- // endregion
607
- if (operation.responses) {
608
- var status = response.status;
609
- // region extract the response object based on the response status
610
- var responseObject = void 0;
611
- if (operation.responses[status]) {
612
- responseObject = operation.responses[status];
613
- }
614
- else {
615
- // use the default response object if no matching was found.
616
- responseObject = operation.responses.default;
617
- }
618
- // endregion
619
- if (responseObject) {
620
- if (IsReferenceObject(responseObject)) {
621
- throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');
622
- }
623
- // region validate the response against the schema if defined
624
- // TODO : create schema that validates all parameters at once
625
- if (responseObject.content && responseObject.content['application/json'] && responseObject.content['application/json'].schema) {
626
- var schema = responseObject.content['application/json'].schema;
627
- var data = (_a = response.body) !== null && _a !== void 0 ? _a : response.data;
628
- if (!this.validate(schema, data)) {
629
- this.validationError('The response is not valid ageist the operation schema!', strict, schema, data);
630
- }
631
- }
632
- // endregion
633
- }
634
- }
635
- };
636
- SchemaValidationMixin.prototype.validateRequestBody = function (operation, body, strict) {
637
- if (strict === void 0) { strict = false; }
638
- // only validate body if type of object
639
- if (typeof body !== 'object') {
640
- return;
641
- }
642
- if (operation.requestBody) {
643
- if (IsReferenceObject(operation.requestBody)) {
644
- throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');
645
- }
646
- if (body === undefined && operation.requestBody.required) {
647
- this.validationError('The request body is required!', strict);
648
- }
649
- if (operation.requestBody.content && operation.requestBody.content['application/json']) {
650
- var schema = operation.requestBody.content['application/json'].schema;
651
- if (schema) {
652
- if (!this.validate(schema, body)) {
653
- this.validationError('The request body is not valid!', strict, schema, body);
654
- }
655
- }
656
- }
657
- }
658
- };
659
- SchemaValidationMixin.prototype.validationError = function (message, strict, schema, value) {
660
- if (i0.isDevMode() && schema !== undefined) {
661
- // tslint:disable-next-line:no-console
662
- console.debug(message, { schema: schema, value: value });
663
- }
664
- if (strict || SchemaValidationMixin.STRICT) {
665
- throw new RxapOpenApiError(message, '', 'SchemaValidationMixin');
666
- }
667
- else {
668
- console.warn(message);
669
- }
670
- };
671
- SchemaValidationMixin.prototype.buildHttpParams = function (operationParameters, parameters, ignoreUndefined) {
672
- var e_2, _b, e_3, _c;
673
- if (ignoreUndefined === void 0) { ignoreUndefined = true; }
674
- var params = new http.HttpParams();
675
- if (utilities.IsRecord(parameters)) {
676
- try {
677
- for (var _d = __values(operationParameters.filter(function (p) { return p.in === 'query'; })), _e = _d.next(); !_e.done; _e = _d.next()) {
678
- var parameter = _e.value;
679
- var parameterName = parameter.name;
680
- if (parameters.hasOwnProperty(parameter.name)) {
681
- var value = parameters[parameter.name];
682
- if (value === undefined && ignoreUndefined) {
683
- continue;
684
- }
685
- if (Array.isArray(value)) {
686
- if (value.length) {
687
- var first = value.shift();
688
- params = params.set(parameterName, first);
689
- try {
690
- for (var value_1 = (e_3 = void 0, __values(value)), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
691
- var item = value_1_1.value;
692
- params = params.append(parameterName, item);
693
- }
694
- }
695
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
696
- finally {
697
- try {
698
- if (value_1_1 && !value_1_1.done && (_c = value_1.return)) _c.call(value_1);
699
- }
700
- finally { if (e_3) throw e_3.error; }
701
- }
702
- }
703
- }
704
- else {
705
- params = params.set(parameter.name, value);
706
- }
707
- }
708
- }
709
- }
710
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
711
- finally {
712
- try {
713
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
714
- }
715
- finally { if (e_2) throw e_2.error; }
716
- }
717
- }
718
- return params;
719
- };
720
- SchemaValidationMixin.prototype.buildHttpHeaders = function (operationParameters, parameters) {
721
- var e_4, _b, e_5, _c;
722
- var headers = new http.HttpHeaders();
723
- if (utilities.IsRecord(parameters)) {
724
- try {
725
- for (var _d = __values(operationParameters.filter(function (p) { return p.in === 'header'; })), _e = _d.next(); !_e.done; _e = _d.next()) {
726
- var parameter = _e.value;
727
- if (parameters.hasOwnProperty(parameter.name)) {
728
- var value = parameters[parameter.name];
729
- if (Array.isArray(value)) {
730
- if (value.length) {
731
- var first = value.shift();
732
- headers = headers.set(parameters.name, first);
733
- try {
734
- for (var value_2 = (e_5 = void 0, __values(value)), value_2_1 = value_2.next(); !value_2_1.done; value_2_1 = value_2.next()) {
735
- var item = value_2_1.value;
736
- headers = headers.append(parameters.name, item);
737
- }
738
- }
739
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
740
- finally {
741
- try {
742
- if (value_2_1 && !value_2_1.done && (_c = value_2.return)) _c.call(value_2);
743
- }
744
- finally { if (e_5) throw e_5.error; }
745
- }
746
- }
747
- }
748
- else {
749
- headers = headers.set(parameter.name, value);
750
- }
751
- }
752
- }
753
- }
754
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
755
- finally {
756
- try {
757
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
758
- }
759
- finally { if (e_4) throw e_4.error; }
760
- }
761
- }
762
- return headers;
763
- };
764
- SchemaValidationMixin.prototype.buildHttpPathParams = function (operationParameters, parameters) {
765
- var e_6, _b;
766
- var pathParams = {};
767
- if (utilities.IsRecord(parameters)) {
768
- try {
769
- for (var _c = __values(operationParameters.filter(function (p) { return p.in === 'path'; })), _d = _c.next(); !_d.done; _d = _c.next()) {
770
- var parameter = _d.value;
771
- if (parameters.hasOwnProperty(parameter.name)) {
772
- pathParams[parameter.name] = encodeURIComponent(parameters[parameter.name]);
773
- }
774
- }
775
- }
776
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
777
- finally {
778
- try {
779
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
780
- }
781
- finally { if (e_6) throw e_6.error; }
782
- }
783
- }
784
- return pathParams;
785
- };
786
- /**
787
- * Converts open api parameters into the corresponding http options to
788
- * create a http request. The transformation is guided by the openapi definition
789
- *
790
- * @param operation
791
- * @param parameters
792
- * @param requestBody
793
- * @param ignoreUndefined
794
- */
795
- SchemaValidationMixin.prototype.buildHttpOptions = function (operation, parameters, requestBody, ignoreUndefined) {
796
- if (ignoreUndefined === void 0) { ignoreUndefined = true; }
797
- var options = {};
798
- var operationParameters = utilities.coerceArray(operation.parameters);
799
- if (!NotContainsReferenceObjects(operationParameters)) {
800
- throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');
801
- }
802
- var params = this.buildHttpParams(operationParameters, parameters, ignoreUndefined);
803
- var headers = this.buildHttpHeaders(operationParameters, parameters);
804
- var pathParams = this.buildHttpPathParams(operationParameters, parameters);
805
- if (params.keys().length) {
806
- options.params = params;
807
- }
808
- if (headers.keys().length) {
809
- options.headers = headers;
810
- }
811
- if (Object.keys(pathParams).length) {
812
- options.pathParams = pathParams;
813
- }
814
- if (requestBody !== undefined) {
815
- options.body = requestBody;
816
- }
817
- return options;
818
- };
819
- SchemaValidationMixin.prototype.validate = function (schema, value) {
820
- var result;
821
- try {
822
- result = new Ajv__namespace().validate(schema, value);
823
- }
824
- catch (e) {
825
- console.error(e.message);
826
- return false;
827
- }
828
- if (utilities.isPromiseLike(result)) {
829
- throw new Error('Async schema validation is not yet supported. Ensure the all refs in the openapi schema are internal!');
830
- }
831
- return result;
832
- };
833
- return SchemaValidationMixin;
834
- }());
835
- SchemaValidationMixin.STRICT = false;
836
-
837
- /**
838
- * Generated bundle index. Do not edit.
839
- */
840
-
841
- exports.AssertOpenApiV3 = AssertOpenApiV3;
842
- exports.DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = DEFAULT_OPEN_API_DATA_SOURCE_META_DATA;
843
- exports.DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA;
844
- exports.IsOpenApiV3 = IsOpenApiV3;
845
- exports.IsReferenceObject = IsReferenceObject;
846
- exports.NotContainsReferenceObjects = NotContainsReferenceObjects;
847
- exports.OpenApiConfigService = OpenApiConfigService;
848
- exports.RXAP_OPEN_API_CONFIG = RXAP_OPEN_API_CONFIG;
849
- exports.RXAP_OPEN_API_STRICT_VALIDATOR = RXAP_OPEN_API_STRICT_VALIDATOR;
850
- exports.RxapOpenApiError = RxapOpenApiError;
851
- exports.SchemaValidationMixin = SchemaValidationMixin;
852
-
853
- Object.defineProperty(exports, '__esModule', { value: true });
854
-
855
- })));
856
- //# sourceMappingURL=rxap-open-api.umd.js.map