@opra/common 1.0.0-alpha.3 → 1.0.0-alpha.30
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 +6036 -5788
- package/cjs/document/api-document.js +12 -0
- package/cjs/document/common/api-base.js +1 -0
- package/cjs/document/common/document-element.js +5 -1
- package/cjs/document/data-type/api-field.js +12 -6
- package/cjs/document/data-type/complex-type-base.js +10 -3
- package/cjs/document/data-type/complex-type.js +6 -2
- 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 +4 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +6 -2
- package/cjs/document/data-type/extended-types/date-time-string.type.js +6 -2
- package/cjs/document/data-type/extended-types/date-time.type.js +6 -2
- package/cjs/document/data-type/extended-types/date.type.js +6 -2
- package/cjs/document/data-type/extended-types/email.type.js +6 -2
- package/cjs/document/data-type/extended-types/field-path.type.js +5 -3
- package/cjs/document/data-type/extended-types/filter.type.js +19 -17
- package/cjs/document/data-type/extended-types/object-id.type.js +4 -0
- package/cjs/document/data-type/extended-types/time.type.js +6 -2
- package/cjs/document/data-type/extended-types/url.type.js +6 -2
- package/cjs/document/data-type/extended-types/uuid.type.js +4 -0
- 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 +7 -2
- package/cjs/document/data-type/partial-type.js +7 -2
- package/cjs/document/data-type/pick-type.js +1 -2
- package/cjs/document/data-type/primitive-types/bigint.type.js +4 -0
- package/cjs/document/data-type/primitive-types/boolean.type.js +4 -0
- package/cjs/document/data-type/primitive-types/integer.type.js +4 -0
- package/cjs/document/data-type/primitive-types/null.type.js +4 -0
- package/cjs/document/data-type/primitive-types/number.type.js +4 -0
- package/cjs/document/data-type/primitive-types/object.type.js +0 -3
- package/cjs/document/data-type/primitive-types/string.type.js +4 -0
- package/cjs/document/data-type/required-type.js +1 -2
- package/cjs/document/data-type/simple-type.js +17 -16
- 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 +4 -6
- 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 +123 -93
- 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 -11
- package/cjs/document/factory/data-type.factory.js +97 -56
- package/cjs/document/factory/http-api.factory.js +3 -1
- package/cjs/document/http/http-api.js +2 -2
- package/cjs/document/http/http-controller.js +26 -14
- package/cjs/document/http/http-media-type.js +21 -4
- 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 +4 -0
- 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/exception/opra-exception.js +1 -0
- 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 +5 -6
- 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 +11 -0
- package/esm/document/common/api-base.js +1 -0
- package/esm/document/common/document-element.js +4 -1
- package/esm/document/data-type/api-field.js +12 -6
- package/esm/document/data-type/complex-type-base.js +10 -3
- package/esm/document/data-type/complex-type.js +6 -2
- 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 +4 -0
- package/esm/document/data-type/extended-types/date-string.type.js +6 -2
- package/esm/document/data-type/extended-types/date-time-string.type.js +6 -2
- package/esm/document/data-type/extended-types/date-time.type.js +6 -2
- package/esm/document/data-type/extended-types/date.type.js +6 -2
- package/esm/document/data-type/extended-types/email.type.js +6 -2
- package/esm/document/data-type/extended-types/field-path.type.js +5 -3
- package/esm/document/data-type/extended-types/filter.type.js +19 -17
- package/esm/document/data-type/extended-types/object-id.type.js +4 -0
- package/esm/document/data-type/extended-types/time.type.js +6 -2
- package/esm/document/data-type/extended-types/url.type.js +6 -2
- package/esm/document/data-type/extended-types/uuid.type.js +4 -0
- 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/omit-type.js +6 -0
- package/esm/document/data-type/partial-type.js +6 -0
- package/esm/document/data-type/primitive-types/bigint.type.js +4 -0
- package/esm/document/data-type/primitive-types/boolean.type.js +4 -0
- package/esm/document/data-type/primitive-types/integer.type.js +4 -0
- package/esm/document/data-type/primitive-types/null.type.js +4 -0
- package/esm/document/data-type/primitive-types/number.type.js +4 -0
- package/esm/document/data-type/primitive-types/object.type.js +0 -3
- package/esm/document/data-type/primitive-types/string.type.js +4 -0
- package/esm/document/data-type/simple-type.js +17 -16
- package/esm/document/data-type/utils/create-mapped-class.js +2 -1
- package/esm/document/decorators/api-field-decorator.js +1 -2
- package/esm/document/decorators/http-controller.decorator.js +25 -0
- package/esm/document/decorators/http-operation-entity.decorator.js +80 -50
- package/esm/document/decorators/http-operation.decorator.js +11 -4
- package/esm/document/factory/api-document.factory.js +14 -10
- package/esm/document/factory/data-type.factory.js +97 -56
- package/esm/document/factory/http-api.factory.js +3 -1
- package/esm/document/http/http-api.js +2 -2
- package/esm/document/http/http-controller.js +25 -14
- package/esm/document/http/http-media-type.js +20 -4
- 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 +4 -0
- 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/exception/opra-exception.js +1 -0
- 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/object-utils.js +2 -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 +11 -8
- package/types/document/api-document.d.ts +1 -0
- package/types/document/common/document-element.d.ts +1 -0
- package/types/document/data-type/api-field.d.ts +12 -0
- package/types/document/data-type/complex-type-base.d.ts +1 -1
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +5 -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/omit-type.d.ts +0 -6
- package/types/document/data-type/partial-type.d.ts +0 -6
- package/types/document/data-type/pick-type.d.ts +2 -2
- package/types/document/data-type/required-type.d.ts +7 -7
- 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/decorators/http-operation-entity.decorator.d.ts +1 -0
- 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-media-type.d.ts +2 -1
- package/types/document/http/http-operation.d.ts +5 -3
- 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 +1 -1
- 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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const filter_rules_js_1 = require("../../filter/filter-rules.js");
|
|
4
|
-
const index_js_1 = require("../../
|
|
5
|
-
const index_js_2 = require("../../http/index.js");
|
|
4
|
+
const index_js_1 = require("../../http/index.js");
|
|
6
5
|
const constants_js_1 = require("../constants.js");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const index_js_2 = require("../data-type/extended-types/index.js");
|
|
7
|
+
const index_js_3 = require("../data-type/primitive-types/index.js");
|
|
9
8
|
const http_operation_js_1 = require("../http/http-operation.js");
|
|
10
9
|
const http_operation_decorator_js_1 = require("./http-operation.decorator.js");
|
|
11
10
|
/** Implementation **/
|
|
@@ -22,20 +21,20 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
22
21
|
args = { ...arg1, type: arg0 };
|
|
23
22
|
/** Initialize the decorator and the chain */
|
|
24
23
|
const decoratorChain = [];
|
|
25
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
26
|
-
description: args.description,
|
|
24
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
27
25
|
method: 'POST',
|
|
26
|
+
...args,
|
|
28
27
|
composition: 'Entity.Create',
|
|
29
28
|
requestBody: {
|
|
30
29
|
immediateFetch: true,
|
|
31
30
|
...args.requestBody,
|
|
32
31
|
required: true,
|
|
33
32
|
},
|
|
34
|
-
})
|
|
33
|
+
});
|
|
35
34
|
decorator
|
|
36
35
|
.QueryParam('projection', {
|
|
37
36
|
description: 'Determines fields projection',
|
|
38
|
-
type: new
|
|
37
|
+
type: new index_js_2.FieldPathType({
|
|
39
38
|
dataType: args.type,
|
|
40
39
|
allowSigns: 'each',
|
|
41
40
|
}),
|
|
@@ -43,18 +42,16 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
43
42
|
arraySeparator: ',',
|
|
44
43
|
})
|
|
45
44
|
.RequestContent(args.requestBody?.type || args.type)
|
|
46
|
-
.Response(
|
|
45
|
+
.Response(index_js_1.HttpStatusCode.CREATED, {
|
|
47
46
|
description: 'Operation is successful. Returns OperationResult with "payload" field that contains the created resource.',
|
|
48
|
-
contentType:
|
|
47
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
49
48
|
type: args.type,
|
|
50
49
|
partial: 'deep',
|
|
51
50
|
})
|
|
52
|
-
.Response(
|
|
51
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
53
52
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
54
|
-
contentType:
|
|
53
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
55
54
|
});
|
|
56
|
-
if (typeof args.type === 'function')
|
|
57
|
-
decorator.UseType(args.type);
|
|
58
55
|
decoratorChain.push((operationMeta) => {
|
|
59
56
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
60
57
|
compositionOptions.type = getDataTypeName(args.type);
|
|
@@ -73,31 +70,42 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
73
70
|
args = { ...arg1, type: arg0 };
|
|
74
71
|
/** Initialize the decorator and the chain */
|
|
75
72
|
const decoratorChain = [];
|
|
76
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
77
|
-
description: args.description,
|
|
73
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
78
74
|
method: 'DELETE',
|
|
75
|
+
...args,
|
|
79
76
|
composition: 'Entity.Delete',
|
|
80
|
-
})
|
|
77
|
+
});
|
|
81
78
|
decorator
|
|
82
|
-
.Response(
|
|
79
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
83
80
|
description: 'Operation is successful. Returns OperationResult with "affected" field.',
|
|
84
|
-
contentType:
|
|
81
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
85
82
|
})
|
|
86
|
-
.Response(
|
|
83
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
87
84
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
88
|
-
contentType:
|
|
85
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
89
86
|
});
|
|
90
|
-
if (typeof args.type === 'function')
|
|
91
|
-
decorator.UseType(args.type);
|
|
92
87
|
/**
|
|
93
88
|
*
|
|
94
89
|
*/
|
|
95
90
|
decorator.KeyParam = (name, prmOptions) => {
|
|
96
|
-
|
|
91
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
92
|
+
? {
|
|
93
|
+
name,
|
|
94
|
+
location: 'path',
|
|
95
|
+
type: prmOptions,
|
|
96
|
+
keyParam: true,
|
|
97
|
+
}
|
|
98
|
+
: {
|
|
99
|
+
...prmOptions,
|
|
100
|
+
name,
|
|
101
|
+
location: 'path',
|
|
102
|
+
keyParam: true,
|
|
103
|
+
};
|
|
104
|
+
decorator.PathParam(name, paramMeta);
|
|
97
105
|
decoratorChain.push((meta) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
meta.
|
|
106
|
+
if (!meta.path?.includes(':' + name))
|
|
107
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
108
|
+
meta.mergePath = true;
|
|
101
109
|
});
|
|
102
110
|
return decorator;
|
|
103
111
|
};
|
|
@@ -120,28 +128,26 @@ http_operation_js_1.HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
|
|
|
120
128
|
/** Initialize the decorator and the chain */
|
|
121
129
|
const decoratorChain = [];
|
|
122
130
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
123
|
-
const filterType = new
|
|
131
|
+
const filterType = new index_js_2.FilterType({ dataType: args.type });
|
|
124
132
|
filterType.rules = {};
|
|
125
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
126
|
-
description: args.description,
|
|
133
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
127
134
|
method: 'DELETE',
|
|
135
|
+
...args,
|
|
128
136
|
composition: 'Entity.DeleteMany',
|
|
129
|
-
})
|
|
137
|
+
});
|
|
130
138
|
decorator
|
|
131
|
-
.Response(
|
|
139
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
132
140
|
description: 'Operation is successful. Returns OperationResult with "affected" field.',
|
|
133
|
-
contentType:
|
|
141
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
134
142
|
})
|
|
135
|
-
.Response(
|
|
143
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
136
144
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
137
|
-
contentType:
|
|
145
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
138
146
|
})
|
|
139
147
|
.QueryParam('filter', {
|
|
140
148
|
type: filterType,
|
|
141
149
|
description: 'Determines filter fields',
|
|
142
150
|
});
|
|
143
|
-
if (typeof args.type === 'function')
|
|
144
|
-
decorator.UseType(args.type);
|
|
145
151
|
decoratorChain.push((operationMeta) => {
|
|
146
152
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
147
153
|
compositionOptions.type = getDataTypeName(args.type);
|
|
@@ -168,32 +174,32 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
168
174
|
/** Initialize the decorator and the chain */
|
|
169
175
|
const decoratorChain = [];
|
|
170
176
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
171
|
-
const filterType = new
|
|
177
|
+
const filterType = new index_js_2.FilterType({ dataType: args.type });
|
|
172
178
|
filterType.rules = {};
|
|
173
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
174
|
-
description: args.description,
|
|
179
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
175
180
|
method: 'GET',
|
|
181
|
+
...args,
|
|
176
182
|
composition: 'Entity.FindMany',
|
|
177
|
-
})
|
|
183
|
+
});
|
|
178
184
|
decorator
|
|
179
|
-
.Response(
|
|
185
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
180
186
|
description: 'Operation is successful. Returns OperationResult with "payload" field that contains list of resources.',
|
|
181
|
-
contentType:
|
|
187
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
182
188
|
type: args.type,
|
|
183
189
|
partial: 'deep',
|
|
184
190
|
isArray: true,
|
|
185
191
|
})
|
|
186
|
-
.Response(
|
|
192
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
187
193
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
188
|
-
contentType:
|
|
194
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
189
195
|
})
|
|
190
196
|
.QueryParam('limit', {
|
|
191
197
|
description: 'Determines number of returning instances',
|
|
192
|
-
type: new
|
|
198
|
+
type: new index_js_3.IntegerType({ minValue: 1, maxValue: args.maxLimit }),
|
|
193
199
|
})
|
|
194
200
|
.QueryParam('skip', {
|
|
195
201
|
description: 'Determines number of returning instances',
|
|
196
|
-
type: new
|
|
202
|
+
type: new index_js_3.IntegerType({ minValue: 1 }),
|
|
197
203
|
})
|
|
198
204
|
.QueryParam('count', {
|
|
199
205
|
description: 'Counts all matching instances if enabled',
|
|
@@ -201,7 +207,7 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
201
207
|
})
|
|
202
208
|
.QueryParam('projection', {
|
|
203
209
|
description: 'Determines fields projection',
|
|
204
|
-
type: new
|
|
210
|
+
type: new index_js_2.FieldPathType({
|
|
205
211
|
dataType: args.type,
|
|
206
212
|
allowSigns: 'each',
|
|
207
213
|
}),
|
|
@@ -214,18 +220,22 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
214
220
|
})
|
|
215
221
|
.QueryParam('sort', {
|
|
216
222
|
description: 'Determines sort fields',
|
|
217
|
-
type: new
|
|
223
|
+
type: new index_js_2.FieldPathType({
|
|
218
224
|
dataType: args.type,
|
|
219
225
|
allowSigns: 'first',
|
|
220
226
|
}),
|
|
221
227
|
isArray: true,
|
|
222
228
|
arraySeparator: ',',
|
|
223
229
|
});
|
|
224
|
-
if (typeof args.type === 'function')
|
|
225
|
-
decorator.UseType(args.type);
|
|
226
230
|
decoratorChain.push((operationMeta) => {
|
|
227
231
|
const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
|
|
228
232
|
compositionOptions.type = getDataTypeName(args.type);
|
|
233
|
+
if (args.defaultLimit)
|
|
234
|
+
compositionOptions.defaultLimit = args.defaultLimit;
|
|
235
|
+
if (args.defaultProjection)
|
|
236
|
+
compositionOptions.defaultProjection = args.defaultProjection;
|
|
237
|
+
if (args.maxLimit)
|
|
238
|
+
compositionOptions.maxLimit = args.maxLimit;
|
|
229
239
|
});
|
|
230
240
|
decorator.DefaultSort = (...fields) => {
|
|
231
241
|
decoratorChain.push((operationMeta) => {
|
|
@@ -262,45 +272,56 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
262
272
|
args = { ...arg1, type: arg0 };
|
|
263
273
|
/** Initialize the decorator and the chain */
|
|
264
274
|
const decoratorChain = [];
|
|
265
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
266
|
-
description: args.description,
|
|
275
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
267
276
|
method: 'GET',
|
|
277
|
+
...args,
|
|
268
278
|
composition: 'Entity.Get',
|
|
269
|
-
})
|
|
279
|
+
});
|
|
270
280
|
decorator
|
|
271
281
|
.QueryParam('projection', {
|
|
272
282
|
description: 'Determines fields projection',
|
|
273
|
-
type: new
|
|
283
|
+
type: new index_js_2.FieldPathType({
|
|
274
284
|
dataType: args.type,
|
|
275
285
|
allowSigns: 'each',
|
|
276
286
|
}),
|
|
277
287
|
isArray: true,
|
|
278
288
|
arraySeparator: ',',
|
|
279
289
|
})
|
|
280
|
-
.Response(
|
|
290
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
281
291
|
description: 'Operation is successful. Returns OperationResult with "payload" field that contains the resource asked for.',
|
|
282
|
-
contentType:
|
|
292
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
283
293
|
type: args.type,
|
|
284
294
|
partial: 'deep',
|
|
285
295
|
})
|
|
286
|
-
.Response(
|
|
296
|
+
.Response(index_js_1.HttpStatusCode.NO_CONTENT, {
|
|
287
297
|
description: 'Operation is successful but no resource found',
|
|
288
298
|
})
|
|
289
|
-
.Response(
|
|
299
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
290
300
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
291
|
-
contentType:
|
|
301
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
292
302
|
});
|
|
293
|
-
if (typeof args.type === 'function')
|
|
294
|
-
decorator.UseType(args.type);
|
|
295
303
|
/**
|
|
296
304
|
*
|
|
297
305
|
*/
|
|
298
306
|
decorator.KeyParam = (name, prmOptions) => {
|
|
299
|
-
|
|
307
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
308
|
+
? {
|
|
309
|
+
name,
|
|
310
|
+
location: 'path',
|
|
311
|
+
type: prmOptions,
|
|
312
|
+
keyParam: true,
|
|
313
|
+
}
|
|
314
|
+
: {
|
|
315
|
+
...prmOptions,
|
|
316
|
+
name,
|
|
317
|
+
location: 'path',
|
|
318
|
+
keyParam: true,
|
|
319
|
+
};
|
|
320
|
+
decorator.PathParam(name, paramMeta);
|
|
300
321
|
decoratorChain.push((meta) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
meta.
|
|
322
|
+
if (!meta.path?.includes(':' + name))
|
|
323
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
324
|
+
meta.mergePath = true;
|
|
304
325
|
});
|
|
305
326
|
return decorator;
|
|
306
327
|
};
|
|
@@ -322,12 +343,12 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
322
343
|
args = { ...arg1, type: arg0 };
|
|
323
344
|
/** Initialize the decorator and the chain */
|
|
324
345
|
const decoratorChain = [];
|
|
325
|
-
const filterType = new
|
|
346
|
+
const filterType = new index_js_2.FilterType({ dataType: args.type });
|
|
326
347
|
filterType.rules = {};
|
|
327
348
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
328
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
329
|
-
description: args.description,
|
|
349
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
330
350
|
method: 'PATCH',
|
|
351
|
+
...args,
|
|
331
352
|
composition: 'Entity.UpdateMany',
|
|
332
353
|
requestBody: {
|
|
333
354
|
immediateFetch: true,
|
|
@@ -335,18 +356,16 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
335
356
|
...args.requestBody,
|
|
336
357
|
required: true,
|
|
337
358
|
},
|
|
338
|
-
})
|
|
339
|
-
decorator.RequestContent(args.requestBody?.type || args.type);
|
|
340
|
-
if (typeof args.type === 'function')
|
|
341
|
-
decorator.UseType(args.type);
|
|
359
|
+
});
|
|
342
360
|
decorator
|
|
343
|
-
.
|
|
361
|
+
.RequestContent(args.requestBody?.type || args.type)
|
|
362
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
344
363
|
description: 'Operation is successful. Returns OperationResult with "affected" field.',
|
|
345
|
-
contentType:
|
|
364
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
346
365
|
})
|
|
347
|
-
.Response(
|
|
366
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
348
367
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
349
|
-
contentType:
|
|
368
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
350
369
|
})
|
|
351
370
|
.QueryParam('filter', {
|
|
352
371
|
type: filterType,
|
|
@@ -378,11 +397,11 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
378
397
|
/** Initialize the decorator and the chain */
|
|
379
398
|
const decoratorChain = [];
|
|
380
399
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
381
|
-
const filterType = new
|
|
400
|
+
const filterType = new index_js_2.FilterType({ dataType: args.type });
|
|
382
401
|
filterType.rules = {};
|
|
383
|
-
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain,
|
|
384
|
-
description: args.description,
|
|
402
|
+
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
|
|
385
403
|
method: 'PATCH',
|
|
404
|
+
...args,
|
|
386
405
|
composition: 'Entity.Update',
|
|
387
406
|
requestBody: {
|
|
388
407
|
partial: 'deep',
|
|
@@ -390,11 +409,11 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
390
409
|
...args.requestBody,
|
|
391
410
|
required: true,
|
|
392
411
|
},
|
|
393
|
-
})
|
|
412
|
+
});
|
|
394
413
|
decorator
|
|
395
414
|
.QueryParam('projection', {
|
|
396
415
|
description: 'Determines fields projection',
|
|
397
|
-
type: new
|
|
416
|
+
type: new index_js_2.FieldPathType({
|
|
398
417
|
dataType: args.type,
|
|
399
418
|
allowSigns: 'each',
|
|
400
419
|
}),
|
|
@@ -406,30 +425,41 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
406
425
|
description: 'Determines filter fields',
|
|
407
426
|
})
|
|
408
427
|
.RequestContent(args.requestBody?.type || args.type)
|
|
409
|
-
.Response(
|
|
428
|
+
.Response(index_js_1.HttpStatusCode.OK, {
|
|
410
429
|
description: 'Operation is successful. Returns OperationResult with "payload" field that contains updated resource.',
|
|
411
|
-
contentType:
|
|
430
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
412
431
|
type: args.type,
|
|
413
432
|
partial: 'deep',
|
|
414
433
|
})
|
|
415
|
-
.Response(
|
|
434
|
+
.Response(index_js_1.HttpStatusCode.NO_CONTENT, {
|
|
416
435
|
description: 'Operation is successful but no resource found',
|
|
417
436
|
})
|
|
418
|
-
.Response(
|
|
437
|
+
.Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
|
|
419
438
|
description: 'The request was well-formed but was unable to process operation due to one or many errors.',
|
|
420
|
-
contentType:
|
|
439
|
+
contentType: index_js_1.MimeTypes.opra_response_json,
|
|
421
440
|
});
|
|
422
|
-
if (typeof args.type === 'function')
|
|
423
|
-
decorator.UseType(args.type);
|
|
424
441
|
/**
|
|
425
442
|
*
|
|
426
443
|
*/
|
|
427
444
|
decorator.KeyParam = (name, prmOptions) => {
|
|
428
|
-
|
|
445
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
446
|
+
? {
|
|
447
|
+
name,
|
|
448
|
+
location: 'path',
|
|
449
|
+
type: prmOptions,
|
|
450
|
+
keyParam: true,
|
|
451
|
+
}
|
|
452
|
+
: {
|
|
453
|
+
...prmOptions,
|
|
454
|
+
name,
|
|
455
|
+
location: 'path',
|
|
456
|
+
keyParam: true,
|
|
457
|
+
};
|
|
458
|
+
decorator.PathParam(name, paramMeta);
|
|
429
459
|
decoratorChain.push((meta) => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
meta.
|
|
460
|
+
if (!meta.path?.includes(':' + name))
|
|
461
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
462
|
+
meta.mergePath = true;
|
|
433
463
|
});
|
|
434
464
|
return decorator;
|
|
435
465
|
};
|
|
@@ -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;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiDocumentFactory = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
6
|
-
const ts_gems_1 = require("ts-gems");
|
|
7
4
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
5
|
const index_js_2 = require("../../schema/index.js");
|
|
9
6
|
const api_document_js_1 = require("../api-document.js");
|
|
@@ -46,9 +43,7 @@ class ApiDocumentFactory {
|
|
|
46
43
|
context.error.message = `(${l}) error${l > 1 ? 's' : ''} found in document schema.`;
|
|
47
44
|
if (context.showErrorDetails) {
|
|
48
45
|
context.error.message += context.error.details
|
|
49
|
-
.map(d => {
|
|
50
|
-
return `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : '');
|
|
51
|
-
})
|
|
46
|
+
.map(d => `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : ''))
|
|
52
47
|
.join('');
|
|
53
48
|
}
|
|
54
49
|
}
|
|
@@ -70,9 +65,14 @@ class ApiDocumentFactory {
|
|
|
70
65
|
else
|
|
71
66
|
init = schemaOrUrl;
|
|
72
67
|
// Add builtin data types if this document is the root
|
|
68
|
+
let builtinDocument;
|
|
73
69
|
if (!document[constants_js_1.BUILTIN]) {
|
|
74
|
-
const
|
|
75
|
-
|
|
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
|
+
}
|
|
76
76
|
}
|
|
77
77
|
init.spec = init.spec || index_js_2.OpraSchema.SpecVersion;
|
|
78
78
|
document.url = init.url;
|
|
@@ -93,8 +93,12 @@ class ApiDocumentFactory {
|
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
const refDoc = new api_document_js_1.ApiDocument();
|
|
96
|
+
if (builtinDocument)
|
|
97
|
+
refDoc.references.set('opra', builtinDocument);
|
|
96
98
|
await this.initDocument(refDoc, context, r);
|
|
97
|
-
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);
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
});
|
|
@@ -115,8 +119,7 @@ class ApiDocumentFactory {
|
|
|
115
119
|
context.addError(`Unknown service protocol (${init.api.protocol})`);
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
(0, ts_gems_1.asMutable)(document).id = node_crypto_1.default.createHash('md5').update(JSON.stringify(x)).digest('base64url');
|
|
122
|
+
document.invalidate();
|
|
120
123
|
}
|
|
121
124
|
/**
|
|
122
125
|
*
|