@opra/common 1.0.0-alpha.2 → 1.0.0-alpha.20
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.
- package/browser.js +5835 -5538
- package/cjs/document/api-document.js +28 -12
- package/cjs/document/common/data-type-map.js +1 -1
- package/cjs/document/common/document-element.js +5 -1
- package/cjs/document/constants.js +1 -1
- package/cjs/document/data-type/api-field.js +7 -2
- package/cjs/document/data-type/complex-type-base.js +6 -1
- package/cjs/document/data-type/complex-type.js +8 -5
- package/cjs/document/data-type/data-type.js +2 -1
- package/cjs/document/data-type/enum-type.js +5 -2
- package/cjs/document/data-type/extended-types/base64.type.js +6 -1
- package/cjs/document/data-type/extended-types/date-string.type.js +11 -4
- package/cjs/document/data-type/extended-types/date-time-string.type.js +11 -4
- package/cjs/document/data-type/extended-types/date-time.type.js +11 -4
- package/cjs/document/data-type/extended-types/date.type.js +11 -4
- package/cjs/document/data-type/extended-types/email.type.js +25 -11
- package/cjs/document/data-type/extended-types/field-path.type.js +13 -7
- package/cjs/document/data-type/extended-types/filter.type.js +25 -20
- package/cjs/document/data-type/extended-types/object-id.type.js +6 -1
- package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
- package/cjs/document/data-type/extended-types/time.type.js +11 -4
- package/cjs/document/data-type/extended-types/url.type.js +7 -2
- package/cjs/document/data-type/extended-types/uuid.type.js +8 -2
- package/cjs/document/data-type/mapped-type.js +12 -5
- package/cjs/document/data-type/mixin-type.js +5 -1
- package/cjs/document/data-type/omit-type.js +1 -2
- package/cjs/document/data-type/partial-type.js +1 -2
- package/cjs/document/data-type/pick-type.js +1 -2
- package/cjs/document/data-type/primitive-types/any.type.js +2 -1
- package/cjs/document/data-type/primitive-types/bigint.type.js +6 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +6 -1
- package/cjs/document/data-type/primitive-types/integer.type.js +6 -1
- package/cjs/document/data-type/primitive-types/null.type.js +6 -1
- package/cjs/document/data-type/primitive-types/number.type.js +10 -3
- package/cjs/document/data-type/primitive-types/object.type.js +2 -1
- package/cjs/document/data-type/primitive-types/string.type.js +14 -5
- package/cjs/document/data-type/required-type.js +1 -2
- package/cjs/document/data-type/simple-type.js +16 -10
- package/cjs/document/data-type/utils/create-mapped-class.js +3 -3
- package/cjs/document/data-type/utils/get-is-inherited-predicate-fn.js +1 -2
- package/cjs/document/decorators/api-field-decorator.js +1 -2
- package/cjs/document/decorators/complex-type.decorator.js +1 -2
- package/cjs/document/decorators/http-controller.decorator.js +26 -2
- package/cjs/document/decorators/http-operation-entity.decorator.js +59 -34
- package/cjs/document/decorators/http-operation.decorator.js +12 -6
- package/cjs/document/decorators/simple-type.decorator.js +2 -3
- package/cjs/document/factory/api-document.factory.js +14 -6
- package/cjs/document/factory/data-type.factory.js +98 -57
- package/cjs/document/factory/http-api.factory.js +4 -2
- package/cjs/document/http/http-api.js +2 -2
- package/cjs/document/http/http-controller.js +25 -13
- package/cjs/document/http/http-media-type.js +4 -2
- package/cjs/document/http/http-operation-response.js +2 -1
- package/cjs/document/http/http-operation.js +28 -4
- package/cjs/document/http/http-parameter.js +3 -1
- package/cjs/document/http/http-status-range.js +6 -4
- package/cjs/document/index.js +5 -5
- package/cjs/document/utils/parse-regexp.util.js +1 -2
- package/cjs/document/utils/string-compare.util.js +1 -2
- package/cjs/exception/index.js +5 -5
- package/cjs/filter/antlr/OpraFilterParser.js +28 -82
- package/cjs/filter/ast/index.js +1 -1
- package/cjs/filter/build.js +22 -25
- package/cjs/filter/filter-rules.js +4 -2
- package/cjs/filter/opra-filter.ns.js +2 -2
- package/cjs/filter/parse.js +2 -5
- package/cjs/filter/utils.js +2 -3
- package/cjs/helpers/function-utils.js +1 -2
- package/cjs/helpers/get-stack-filename.js +2 -3
- package/cjs/helpers/mixin-utils.js +4 -4
- package/cjs/helpers/monkey-patches.js +4 -2
- package/cjs/helpers/object-utils.js +3 -4
- package/cjs/helpers/parse-fields-projection.js +4 -6
- package/cjs/helpers/responsive-map.js +5 -4
- package/cjs/helpers/type-guards.js +10 -11
- package/cjs/i18n/i18n.js +4 -3
- package/cjs/i18n/index.js +1 -1
- package/cjs/i18n/string-utils.js +2 -3
- package/cjs/i18n/translate.js +1 -2
- package/cjs/index.js +1 -1
- package/cjs/schema/type-guards.js +7 -8
- package/esm/document/api-document.js +27 -12
- package/esm/document/common/data-type-map.js +1 -1
- package/esm/document/common/document-element.js +4 -1
- package/esm/document/constants.js +1 -1
- package/esm/document/data-type/api-field.js +7 -2
- package/esm/document/data-type/complex-type-base.js +6 -1
- package/esm/document/data-type/complex-type.js +8 -5
- package/esm/document/data-type/data-type.js +2 -1
- package/esm/document/data-type/enum-type.js +5 -2
- package/esm/document/data-type/extended-types/base64.type.js +7 -2
- package/esm/document/data-type/extended-types/date-string.type.js +12 -5
- package/esm/document/data-type/extended-types/date-time-string.type.js +12 -5
- package/esm/document/data-type/extended-types/date-time.type.js +12 -5
- package/esm/document/data-type/extended-types/date.type.js +12 -5
- package/esm/document/data-type/extended-types/email.type.js +26 -12
- package/esm/document/data-type/extended-types/field-path.type.js +14 -8
- package/esm/document/data-type/extended-types/filter.type.js +26 -21
- package/esm/document/data-type/extended-types/object-id.type.js +7 -2
- package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
- package/esm/document/data-type/extended-types/time.type.js +12 -5
- package/esm/document/data-type/extended-types/url.type.js +8 -3
- package/esm/document/data-type/extended-types/uuid.type.js +9 -3
- package/esm/document/data-type/mapped-type.js +12 -5
- package/esm/document/data-type/mixin-type.js +5 -1
- package/esm/document/data-type/primitive-types/any.type.js +3 -2
- package/esm/document/data-type/primitive-types/bigint.type.js +7 -2
- package/esm/document/data-type/primitive-types/boolean.type.js +7 -2
- package/esm/document/data-type/primitive-types/integer.type.js +7 -2
- package/esm/document/data-type/primitive-types/null.type.js +7 -2
- package/esm/document/data-type/primitive-types/number.type.js +11 -4
- package/esm/document/data-type/primitive-types/object.type.js +3 -2
- package/esm/document/data-type/primitive-types/string.type.js +15 -6
- package/esm/document/data-type/simple-type.js +16 -10
- package/esm/document/data-type/utils/create-mapped-class.js +2 -1
- package/esm/document/decorators/http-controller.decorator.js +25 -0
- package/esm/document/decorators/http-operation-entity.decorator.js +59 -34
- package/esm/document/decorators/http-operation.decorator.js +11 -4
- package/esm/document/factory/api-document.factory.js +14 -6
- package/esm/document/factory/data-type.factory.js +98 -57
- package/esm/document/factory/http-api.factory.js +4 -2
- package/esm/document/http/http-api.js +2 -2
- package/esm/document/http/http-controller.js +24 -13
- package/esm/document/http/http-media-type.js +4 -2
- package/esm/document/http/http-operation-response.js +2 -1
- package/esm/document/http/http-operation.js +27 -4
- package/esm/document/http/http-parameter.js +3 -1
- package/esm/document/http/http-status-range.js +6 -4
- package/esm/document/index.js +5 -5
- package/esm/exception/index.js +5 -5
- package/esm/filter/antlr/OpraFilterParser.js +28 -82
- package/esm/filter/ast/index.js +1 -1
- package/esm/filter/build.js +1 -3
- package/esm/filter/filter-rules.js +4 -2
- package/esm/filter/opra-filter.ns.js +2 -2
- package/esm/filter/parse.js +1 -3
- package/esm/helpers/mixin-utils.js +2 -1
- package/esm/helpers/monkey-patches.js +4 -2
- package/esm/helpers/parse-fields-projection.js +1 -3
- package/esm/helpers/responsive-map.js +5 -4
- package/esm/i18n/i18n.js +4 -3
- package/esm/i18n/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +9 -8
- package/types/document/api-document.d.ts +4 -6
- package/types/document/common/document-element.d.ts +1 -0
- package/types/document/data-type/api-field.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +4 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +3 -3
- package/types/document/data-type/mixin-type.d.ts +2 -2
- package/types/document/data-type/simple-type.d.ts +4 -2
- package/types/document/decorators/http-controller.decorator.d.ts +1 -0
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/document/factory/data-type.factory.d.ts +5 -0
- package/types/document/http/http-controller.d.ts +1 -0
- package/types/document/http/http-operation.d.ts +4 -2
- package/types/document/http/http-parameter.d.ts +3 -2
- package/types/document/http/http-status-range.d.ts +2 -1
- package/types/document/index.d.ts +5 -5
- package/types/exception/index.d.ts +5 -5
- package/types/filter/ast/index.d.ts +1 -1
- package/types/filter/opra-filter.ns.d.ts +2 -2
- package/types/helpers/type-guards.d.ts +0 -2
- package/types/i18n/i18n.d.ts +21 -19
- package/types/index.d.ts +1 -1
- package/types/schema/data-type/data-type.interface.d.ts +1 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +2 -2
- package/types/schema/data-type/simple-type.interface.d.ts +4 -0
- package/types/schema/data-type-container.interface.d.ts +1 -1
- package/types/schema/document.interface.d.ts +14 -2
- package/types/schema/http/http-controller.interface.d.ts +2 -2
- package/types/schema/http/http-media-type.interface.d.ts +1 -1
- package/types/schema/http/http-operation-response.interface.d.ts +2 -2
- package/types/schema/http/http-operation.interface.d.ts +8 -4
- package/types/schema/http/http-parameter.interface.d.ts +5 -1
- package/types/schema/index.d.ts +1 -0
|
@@ -23,8 +23,8 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
23
23
|
/** Initialize the decorator and the chain */
|
|
24
24
|
const decoratorChain = [];
|
|
25
25
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
26
|
-
description: args.description,
|
|
27
26
|
method: 'POST',
|
|
27
|
+
...args,
|
|
28
28
|
composition: 'Entity.Create',
|
|
29
29
|
requestBody: {
|
|
30
30
|
immediateFetch: true,
|
|
@@ -53,8 +53,6 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
53
53
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
54
54
|
contentType: index_js_2.MimeTypes.opra_response_json,
|
|
55
55
|
});
|
|
56
|
-
if (typeof args.type === 'function')
|
|
57
|
-
decorator.UseType(args.type);
|
|
58
56
|
decoratorChain.push((operationMeta) => {
|
|
59
57
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
60
58
|
compositionOptions.type = getDataTypeName(args.type);
|
|
@@ -74,8 +72,8 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
74
72
|
/** Initialize the decorator and the chain */
|
|
75
73
|
const decoratorChain = [];
|
|
76
74
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
77
|
-
description: args.description,
|
|
78
75
|
method: 'DELETE',
|
|
76
|
+
...args,
|
|
79
77
|
composition: 'Entity.Delete',
|
|
80
78
|
}));
|
|
81
79
|
decorator
|
|
@@ -87,17 +85,28 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
87
85
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
88
86
|
contentType: index_js_2.MimeTypes.opra_response_json,
|
|
89
87
|
});
|
|
90
|
-
if (typeof args.type === 'function')
|
|
91
|
-
decorator.UseType(args.type);
|
|
92
88
|
/**
|
|
93
89
|
*
|
|
94
90
|
*/
|
|
95
91
|
decorator.KeyParam = (name, prmOptions) => {
|
|
96
|
-
|
|
92
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
93
|
+
? {
|
|
94
|
+
name,
|
|
95
|
+
location: 'path',
|
|
96
|
+
type: prmOptions,
|
|
97
|
+
keyParam: true,
|
|
98
|
+
}
|
|
99
|
+
: {
|
|
100
|
+
...prmOptions,
|
|
101
|
+
name,
|
|
102
|
+
location: 'path',
|
|
103
|
+
keyParam: true,
|
|
104
|
+
};
|
|
105
|
+
decorator.PathParam(name, paramMeta);
|
|
97
106
|
decoratorChain.push((meta) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
meta.
|
|
107
|
+
if (!meta.path?.includes(':' + name))
|
|
108
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
109
|
+
meta.mergePath = true;
|
|
101
110
|
});
|
|
102
111
|
return decorator;
|
|
103
112
|
};
|
|
@@ -123,8 +132,8 @@ http_operation_js_1.HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
|
|
|
123
132
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
124
133
|
filterType.rules = {};
|
|
125
134
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
126
|
-
description: args.description,
|
|
127
135
|
method: 'DELETE',
|
|
136
|
+
...args,
|
|
128
137
|
composition: 'Entity.DeleteMany',
|
|
129
138
|
}));
|
|
130
139
|
decorator
|
|
@@ -140,8 +149,6 @@ http_operation_js_1.HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
|
|
|
140
149
|
type: filterType,
|
|
141
150
|
description: 'Determines filter fields',
|
|
142
151
|
});
|
|
143
|
-
if (typeof args.type === 'function')
|
|
144
|
-
decorator.UseType(args.type);
|
|
145
152
|
decoratorChain.push((operationMeta) => {
|
|
146
153
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
147
154
|
compositionOptions.type = getDataTypeName(args.type);
|
|
@@ -171,8 +178,8 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
171
178
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
172
179
|
filterType.rules = {};
|
|
173
180
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
174
|
-
description: args.description,
|
|
175
181
|
method: 'GET',
|
|
182
|
+
...args,
|
|
176
183
|
composition: 'Entity.FindMany',
|
|
177
184
|
}));
|
|
178
185
|
decorator
|
|
@@ -221,8 +228,6 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
221
228
|
isArray: true,
|
|
222
229
|
arraySeparator: ',',
|
|
223
230
|
});
|
|
224
|
-
if (typeof args.type === 'function')
|
|
225
|
-
decorator.UseType(args.type);
|
|
226
231
|
decoratorChain.push((operationMeta) => {
|
|
227
232
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
228
233
|
compositionOptions.type = getDataTypeName(args.type);
|
|
@@ -263,8 +268,8 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
263
268
|
/** Initialize the decorator and the chain */
|
|
264
269
|
const decoratorChain = [];
|
|
265
270
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
266
|
-
description: args.description,
|
|
267
271
|
method: 'GET',
|
|
272
|
+
...args,
|
|
268
273
|
composition: 'Entity.Get',
|
|
269
274
|
}));
|
|
270
275
|
decorator
|
|
@@ -290,17 +295,28 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
290
295
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
291
296
|
contentType: index_js_2.MimeTypes.opra_response_json,
|
|
292
297
|
});
|
|
293
|
-
if (typeof args.type === 'function')
|
|
294
|
-
decorator.UseType(args.type);
|
|
295
298
|
/**
|
|
296
299
|
*
|
|
297
300
|
*/
|
|
298
301
|
decorator.KeyParam = (name, prmOptions) => {
|
|
299
|
-
|
|
302
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
303
|
+
? {
|
|
304
|
+
name,
|
|
305
|
+
location: 'path',
|
|
306
|
+
type: prmOptions,
|
|
307
|
+
keyParam: true,
|
|
308
|
+
}
|
|
309
|
+
: {
|
|
310
|
+
...prmOptions,
|
|
311
|
+
name,
|
|
312
|
+
location: 'path',
|
|
313
|
+
keyParam: true,
|
|
314
|
+
};
|
|
315
|
+
decorator.PathParam(name, paramMeta);
|
|
300
316
|
decoratorChain.push((meta) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
meta.
|
|
317
|
+
if (!meta.path?.includes(':' + name))
|
|
318
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
319
|
+
meta.mergePath = true;
|
|
304
320
|
});
|
|
305
321
|
return decorator;
|
|
306
322
|
};
|
|
@@ -326,8 +342,8 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
326
342
|
filterType.rules = {};
|
|
327
343
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
328
344
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
329
|
-
description: args.description,
|
|
330
345
|
method: 'PATCH',
|
|
346
|
+
...args,
|
|
331
347
|
composition: 'Entity.UpdateMany',
|
|
332
348
|
requestBody: {
|
|
333
349
|
immediateFetch: true,
|
|
@@ -336,10 +352,8 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
336
352
|
required: true,
|
|
337
353
|
},
|
|
338
354
|
}));
|
|
339
|
-
decorator.RequestContent(args.requestBody?.type || args.type);
|
|
340
|
-
if (typeof args.type === 'function')
|
|
341
|
-
decorator.UseType(args.type);
|
|
342
355
|
decorator
|
|
356
|
+
.RequestContent(args.requestBody?.type || args.type)
|
|
343
357
|
.Response(index_js_2.HttpStatusCode.OK, {
|
|
344
358
|
description: 'Operation is successful. Returns OperationResult with "affected" field.',
|
|
345
359
|
contentType: index_js_2.MimeTypes.opra_response_json,
|
|
@@ -381,8 +395,8 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
381
395
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
382
396
|
filterType.rules = {};
|
|
383
397
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
384
|
-
description: args.description,
|
|
385
398
|
method: 'PATCH',
|
|
399
|
+
...args,
|
|
386
400
|
composition: 'Entity.Update',
|
|
387
401
|
requestBody: {
|
|
388
402
|
partial: 'deep',
|
|
@@ -419,17 +433,28 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
419
433
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
420
434
|
contentType: index_js_2.MimeTypes.opra_response_json,
|
|
421
435
|
});
|
|
422
|
-
if (typeof args.type === 'function')
|
|
423
|
-
decorator.UseType(args.type);
|
|
424
436
|
/**
|
|
425
437
|
*
|
|
426
438
|
*/
|
|
427
439
|
decorator.KeyParam = (name, prmOptions) => {
|
|
428
|
-
|
|
440
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
441
|
+
? {
|
|
442
|
+
name,
|
|
443
|
+
location: 'path',
|
|
444
|
+
type: prmOptions,
|
|
445
|
+
keyParam: true,
|
|
446
|
+
}
|
|
447
|
+
: {
|
|
448
|
+
...prmOptions,
|
|
449
|
+
name,
|
|
450
|
+
location: 'path',
|
|
451
|
+
keyParam: true,
|
|
452
|
+
};
|
|
453
|
+
decorator.PathParam(name, paramMeta);
|
|
429
454
|
decoratorChain.push((meta) => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
meta.
|
|
455
|
+
if (!meta.path?.includes(':' + name))
|
|
456
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
457
|
+
meta.mergePath = true;
|
|
433
458
|
});
|
|
434
459
|
return decorator;
|
|
435
460
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpOperationDecoratorFactory =
|
|
3
|
+
exports.HttpOperationDecoratorFactory = HttpOperationDecoratorFactory;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
6
|
const index_js_1 = require("../../http/index.js");
|
|
@@ -37,8 +37,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
37
37
|
type: arg1,
|
|
38
38
|
}
|
|
39
39
|
: { ...arg1, name, location: 'cookie' };
|
|
40
|
-
if (meta.parameters)
|
|
40
|
+
if (meta.parameters) {
|
|
41
41
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'cookie' && String(p.name) === String(name)));
|
|
42
|
+
}
|
|
42
43
|
else
|
|
43
44
|
meta.parameters = [];
|
|
44
45
|
meta.parameters.push(paramMeta);
|
|
@@ -57,8 +58,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
57
58
|
type: arg1,
|
|
58
59
|
}
|
|
59
60
|
: { ...arg1, name, location: 'header' };
|
|
60
|
-
if (meta.parameters)
|
|
61
|
+
if (meta.parameters) {
|
|
61
62
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'header' && String(p.name) === String(name)));
|
|
63
|
+
}
|
|
62
64
|
else
|
|
63
65
|
meta.parameters = [];
|
|
64
66
|
meta.parameters.push(paramMeta);
|
|
@@ -77,8 +79,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
77
79
|
type: arg1,
|
|
78
80
|
}
|
|
79
81
|
: { ...arg1, name, location: 'query' };
|
|
80
|
-
if (meta.parameters)
|
|
82
|
+
if (meta.parameters) {
|
|
81
83
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'query' && String(p.name) === String(name)));
|
|
84
|
+
}
|
|
82
85
|
else
|
|
83
86
|
meta.parameters = [];
|
|
84
87
|
meta.parameters.push(paramMeta);
|
|
@@ -97,8 +100,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
97
100
|
type: arg1,
|
|
98
101
|
}
|
|
99
102
|
: { ...arg1, name, location: 'path' };
|
|
100
|
-
if (meta.parameters)
|
|
103
|
+
if (meta.parameters) {
|
|
101
104
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'path' && String(p.name) === String(name)));
|
|
105
|
+
}
|
|
102
106
|
else
|
|
103
107
|
meta.parameters = [];
|
|
104
108
|
meta.parameters.push(paramMeta);
|
|
@@ -114,6 +118,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
114
118
|
responseMeta.contentType = responseMeta.contentType || index_js_1.MimeTypes.opra_response_json;
|
|
115
119
|
responseMeta.contentEncoding = responseMeta.contentEncoding || 'utf-8';
|
|
116
120
|
}
|
|
121
|
+
if (responseMeta.contentType === index_js_1.MimeTypes.opra_response_json) {
|
|
122
|
+
responseMeta.contentEncoding = responseMeta.contentEncoding || 'utf-8';
|
|
123
|
+
}
|
|
117
124
|
decoratorChain.push((meta) => {
|
|
118
125
|
meta.responses = meta.responses || [];
|
|
119
126
|
meta.responses.push(responseMeta);
|
|
@@ -180,4 +187,3 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
180
187
|
};
|
|
181
188
|
return decorator;
|
|
182
189
|
}
|
|
183
|
-
exports.HttpOperationDecoratorFactory = HttpOperationDecoratorFactory;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
|
|
4
|
+
exports.AttributeDecoratorFactory = AttributeDecoratorFactory;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
7
|
const index_js_1 = require("../../schema/index.js");
|
|
@@ -42,7 +43,6 @@ function SimpleTypeDecoratorFactory(options) {
|
|
|
42
43
|
};
|
|
43
44
|
return decorator;
|
|
44
45
|
}
|
|
45
|
-
exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
|
|
46
46
|
function AttributeDecoratorFactory(options) {
|
|
47
47
|
return (target, propertyKey) => {
|
|
48
48
|
if (typeof propertyKey !== 'string')
|
|
@@ -64,4 +64,3 @@ function AttributeDecoratorFactory(options) {
|
|
|
64
64
|
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target.constructor);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
exports.AttributeDecoratorFactory = AttributeDecoratorFactory;
|
|
@@ -43,9 +43,7 @@ class ApiDocumentFactory {
|
|
|
43
43
|
context.error.message = `(${l}) error${l > 1 ? 's' : ''} found in document schema.`;
|
|
44
44
|
if (context.showErrorDetails) {
|
|
45
45
|
context.error.message += context.error.details
|
|
46
|
-
.map(d => {
|
|
47
|
-
return `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : '');
|
|
48
|
-
})
|
|
46
|
+
.map(d => `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : ''))
|
|
49
47
|
.join('');
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -67,9 +65,14 @@ class ApiDocumentFactory {
|
|
|
67
65
|
else
|
|
68
66
|
init = schemaOrUrl;
|
|
69
67
|
// Add builtin data types if this document is the root
|
|
68
|
+
let builtinDocument;
|
|
70
69
|
if (!document[constants_js_1.BUILTIN]) {
|
|
71
|
-
const
|
|
72
|
-
|
|
70
|
+
const t = document.node.findDataType('string');
|
|
71
|
+
builtinDocument = t?.node.getDocument();
|
|
72
|
+
if (!builtinDocument) {
|
|
73
|
+
builtinDocument = await this.createBuiltinDocument(context);
|
|
74
|
+
document.references.set('opra', builtinDocument);
|
|
75
|
+
}
|
|
73
76
|
}
|
|
74
77
|
init.spec = init.spec || index_js_2.OpraSchema.SpecVersion;
|
|
75
78
|
document.url = init.url;
|
|
@@ -90,8 +93,12 @@ class ApiDocumentFactory {
|
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
92
95
|
const refDoc = new api_document_js_1.ApiDocument();
|
|
96
|
+
if (builtinDocument)
|
|
97
|
+
refDoc.references.set('opra', builtinDocument);
|
|
93
98
|
await this.initDocument(refDoc, context, r);
|
|
94
|
-
document
|
|
99
|
+
/** If same document already exists in document tree, we use it except the new one */
|
|
100
|
+
const preDoc = document.findDocument(refDoc.id);
|
|
101
|
+
document.references.set(ns, preDoc || refDoc);
|
|
95
102
|
});
|
|
96
103
|
}
|
|
97
104
|
});
|
|
@@ -112,6 +119,7 @@ class ApiDocumentFactory {
|
|
|
112
119
|
context.addError(`Unknown service protocol (${init.api.protocol})`);
|
|
113
120
|
});
|
|
114
121
|
}
|
|
122
|
+
document.invalidate();
|
|
115
123
|
}
|
|
116
124
|
/**
|
|
117
125
|
*
|