@tsed/schema 6.75.10 → 6.77.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.
- package/lib/decorators/class/children.d.ts +11 -0
- package/lib/decorators/common/jsonEntityFn.d.ts +1 -1
- package/lib/decorators/index.d.ts +1 -0
- package/lib/domain/JsonEntityStore.d.ts +13 -14
- package/lib/domain/JsonOperation.d.ts +1 -0
- package/lib/domain/JsonOperationPathsMap.d.ts +7 -0
- package/lib/domain/JsonOperationRoute.d.ts +16 -0
- package/lib/domain/index.d.ts +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +189 -38
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +186 -39
- package/lib/index.modern.js.map +1 -1
- package/lib/utils/concatPath.d.ts +1 -0
- package/lib/utils/getJsonEntityStore.d.ts +4 -1
- package/lib/utils/getOperationsRoutes.d.ts +8 -0
- package/lib/utils/getOperationsStores.d.ts +1 -1
- package/package.json +5 -5
package/lib/index.modern.js
CHANGED
|
@@ -176,11 +176,22 @@ function execMapper(type, schema, options) {
|
|
|
176
176
|
*/
|
|
177
177
|
const JsonEntitiesContainer = new Map();
|
|
178
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @ignore
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
function isJsonEntityStore(model) {
|
|
184
|
+
return model.isStore;
|
|
185
|
+
}
|
|
179
186
|
/**
|
|
180
187
|
* @ignore
|
|
181
188
|
*/
|
|
182
189
|
|
|
183
190
|
function getJsonEntityStore(...args) {
|
|
191
|
+
if (isJsonEntityStore(args[0])) {
|
|
192
|
+
return args[0];
|
|
193
|
+
}
|
|
194
|
+
|
|
184
195
|
const store = Store.from(...args);
|
|
185
196
|
|
|
186
197
|
if (!store.has("JsonEntityStore")) {
|
|
@@ -197,9 +208,6 @@ function getJsonEntityStore(...args) {
|
|
|
197
208
|
|
|
198
209
|
return store.get("JsonEntityStore");
|
|
199
210
|
}
|
|
200
|
-
function isJsonEntityStore(model) {
|
|
201
|
-
return model.isStore;
|
|
202
|
-
}
|
|
203
211
|
|
|
204
212
|
class JsonLazyRef {
|
|
205
213
|
constructor(getType) {
|
|
@@ -2011,11 +2019,6 @@ class JsonEntityStore extends Entity {
|
|
|
2011
2019
|
*/
|
|
2012
2020
|
|
|
2013
2021
|
this.children = new Map();
|
|
2014
|
-
/**
|
|
2015
|
-
* Path used to generate open spec.
|
|
2016
|
-
*/
|
|
2017
|
-
|
|
2018
|
-
this.path = "/";
|
|
2019
2022
|
this.store = options.store;
|
|
2020
2023
|
/* istanbul ignore next */
|
|
2021
2024
|
|
|
@@ -2025,6 +2028,14 @@ class JsonEntityStore extends Entity {
|
|
|
2025
2028
|
|
|
2026
2029
|
this.build();
|
|
2027
2030
|
}
|
|
2031
|
+
|
|
2032
|
+
get path() {
|
|
2033
|
+
return this.store.get("path", "/");
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
set path(path) {
|
|
2037
|
+
this.store.set("path", path);
|
|
2038
|
+
}
|
|
2028
2039
|
/**
|
|
2029
2040
|
* Return the JsonSchema
|
|
2030
2041
|
*/
|
|
@@ -2183,6 +2194,10 @@ class JsonEntityStore extends Entity {
|
|
|
2183
2194
|
return this.from(target, propertyKey, descriptorOf(target, propertyKey));
|
|
2184
2195
|
}
|
|
2185
2196
|
|
|
2197
|
+
get(key, defaultValue) {
|
|
2198
|
+
return this.store.get(key, defaultValue);
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2186
2201
|
getResponseOptions(status, contentType = "application/json") {
|
|
2187
2202
|
var _this$operation, _this$operation$getRe;
|
|
2188
2203
|
|
|
@@ -2863,7 +2878,7 @@ function get$1(entity, options) {
|
|
|
2863
2878
|
}
|
|
2864
2879
|
|
|
2865
2880
|
function getJsonSchema(model, options = {}) {
|
|
2866
|
-
const entity =
|
|
2881
|
+
const entity = getJsonEntityStore(model);
|
|
2867
2882
|
options = _extends({
|
|
2868
2883
|
endpoint: true,
|
|
2869
2884
|
groups: []
|
|
@@ -2927,6 +2942,35 @@ function getProperties(target, options = {}) {
|
|
|
2927
2942
|
return map;
|
|
2928
2943
|
}
|
|
2929
2944
|
|
|
2945
|
+
class JsonOperationPathsMap extends Map {
|
|
2946
|
+
constructor() {
|
|
2947
|
+
super(...arguments);
|
|
2948
|
+
|
|
2949
|
+
this.getKey = (method, path) => `${method}-${path}`;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
setOperationPath(operationPath) {
|
|
2953
|
+
if (operationPath.method !== OperationMethods.CUSTOM) {
|
|
2954
|
+
const key = this.getKey(operationPath.method, operationPath.path);
|
|
2955
|
+
this.updateFinalRouteState(key);
|
|
2956
|
+
this.updateFinalRouteState(this.getKey(OperationMethods.ALL, operationPath.path));
|
|
2957
|
+
this.setFinalRoute(key, operationPath);
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2961
|
+
updateFinalRouteState(key) {
|
|
2962
|
+
if (this.has(key)) {
|
|
2963
|
+
this.get(key).isFinal = false;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
setFinalRoute(key, operationPath) {
|
|
2968
|
+
this.set(key, operationPath);
|
|
2969
|
+
operationPath.isFinal = true;
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2930
2974
|
/**
|
|
2931
2975
|
* @ignore
|
|
2932
2976
|
*/
|
|
@@ -2936,6 +2980,7 @@ function getOperationsStores(target) {
|
|
|
2936
2980
|
|
|
2937
2981
|
if (!store.$operations) {
|
|
2938
2982
|
const stores = getInheritedStores(store);
|
|
2983
|
+
const operationPaths = new JsonOperationPathsMap();
|
|
2939
2984
|
store.$operations = new Map();
|
|
2940
2985
|
stores.forEach(currentStore => {
|
|
2941
2986
|
currentStore.children.forEach(propStore => {
|
|
@@ -2944,11 +2989,94 @@ function getOperationsStores(target) {
|
|
|
2944
2989
|
}
|
|
2945
2990
|
});
|
|
2946
2991
|
});
|
|
2992
|
+
store.$operations.forEach(store => {
|
|
2993
|
+
var _store$operation;
|
|
2994
|
+
|
|
2995
|
+
(_store$operation = store.operation) == null ? void 0 : _store$operation.operationPaths.forEach(operationPath => {
|
|
2996
|
+
operationPaths.setOperationPath(operationPath);
|
|
2997
|
+
});
|
|
2998
|
+
});
|
|
2999
|
+
operationPaths.clear();
|
|
2947
3000
|
}
|
|
2948
3001
|
|
|
2949
3002
|
return store.$operations;
|
|
2950
3003
|
}
|
|
2951
3004
|
|
|
3005
|
+
function concatPath(basePath, path) {
|
|
3006
|
+
return ((basePath || "") + (path || "")).replace(/\/\//gi, "/");
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
class JsonOperationRoute {
|
|
3010
|
+
constructor(options) {
|
|
3011
|
+
Object.assign(this, options);
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
get path() {
|
|
3015
|
+
var _this$operationPath;
|
|
3016
|
+
|
|
3017
|
+
return (_this$operationPath = this.operationPath) == null ? void 0 : _this$operationPath.path;
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
get fullPath() {
|
|
3021
|
+
return concatPath(this.basePath, this.path);
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
get method() {
|
|
3025
|
+
var _this$operationPath2;
|
|
3026
|
+
|
|
3027
|
+
return ((_this$operationPath2 = this.operationPath) == null ? void 0 : _this$operationPath2.method) || "USE";
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
get isFinal() {
|
|
3031
|
+
var _this$operationPath3;
|
|
3032
|
+
|
|
3033
|
+
return !!((_this$operationPath3 = this.operationPath) != null && _this$operationPath3.isFinal);
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
get propertyKey() {
|
|
3037
|
+
return this.endpoint.propertyKey;
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
get store() {
|
|
3041
|
+
return this.endpoint.store;
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
function getOperationsRoutes(token, options = {}) {
|
|
3047
|
+
const store = token.isStore ? token : getJsonEntityStore(token);
|
|
3048
|
+
const basePath = ((options.basePath || "") + (store.path || "")).replace(/\/\//gi, "/");
|
|
3049
|
+
let operationsRoutes = [];
|
|
3050
|
+
|
|
3051
|
+
if (options.withChildren) {
|
|
3052
|
+
const children = store.get("childrenControllers", []);
|
|
3053
|
+
operationsRoutes = children.reduce((operationsRoutes, token) => {
|
|
3054
|
+
return operationsRoutes.concat(getOperationsRoutes(token, _extends({}, options, {
|
|
3055
|
+
basePath
|
|
3056
|
+
})));
|
|
3057
|
+
}, operationsRoutes);
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
return [...getOperationsStores(token).values()].reduce((routes, endpoint) => {
|
|
3061
|
+
const {
|
|
3062
|
+
operation
|
|
3063
|
+
} = endpoint;
|
|
3064
|
+
|
|
3065
|
+
if (operation) {
|
|
3066
|
+
operation.operationPaths.forEach(operationPath => {
|
|
3067
|
+
routes.push(new JsonOperationRoute({
|
|
3068
|
+
basePath,
|
|
3069
|
+
token,
|
|
3070
|
+
endpoint,
|
|
3071
|
+
operationPath
|
|
3072
|
+
}));
|
|
3073
|
+
});
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
return routes;
|
|
3077
|
+
}, operationsRoutes);
|
|
3078
|
+
}
|
|
3079
|
+
|
|
2952
3080
|
/**
|
|
2953
3081
|
* Return a sanitized path
|
|
2954
3082
|
* @param path
|
|
@@ -3589,6 +3717,54 @@ function getStatusModel(status) {
|
|
|
3589
3717
|
return statusesModel.get(status);
|
|
3590
3718
|
}
|
|
3591
3719
|
|
|
3720
|
+
/**
|
|
3721
|
+
* Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
|
|
3722
|
+
*
|
|
3723
|
+
* ## Usage
|
|
3724
|
+
*
|
|
3725
|
+
* ```typescript
|
|
3726
|
+
* export function Description(description: any) {
|
|
3727
|
+
* return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {
|
|
3728
|
+
* entity.itemSchema.description(description)
|
|
3729
|
+
* });
|
|
3730
|
+
* }
|
|
3731
|
+
* ```
|
|
3732
|
+
*
|
|
3733
|
+
* @param fn
|
|
3734
|
+
* @decorator
|
|
3735
|
+
* @utils
|
|
3736
|
+
* @model
|
|
3737
|
+
*/
|
|
3738
|
+
|
|
3739
|
+
function JsonEntityFn(fn) {
|
|
3740
|
+
return (...parameters) => {
|
|
3741
|
+
const result = fn(getJsonEntityStore(...parameters), parameters);
|
|
3742
|
+
|
|
3743
|
+
if (typeof result === "function") {
|
|
3744
|
+
result(...parameters);
|
|
3745
|
+
}
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
/**
|
|
3750
|
+
* Add Children class to compose routes
|
|
3751
|
+
*
|
|
3752
|
+
* @decorator
|
|
3753
|
+
* @swagger
|
|
3754
|
+
* @schema
|
|
3755
|
+
* @classDecorator
|
|
3756
|
+
* @param children
|
|
3757
|
+
*/
|
|
3758
|
+
|
|
3759
|
+
function Children(...children) {
|
|
3760
|
+
return JsonEntityFn(store => {
|
|
3761
|
+
store.store.set("childrenControllers", children);
|
|
3762
|
+
children.forEach(childToken => {
|
|
3763
|
+
Store.from(childToken).set("parentController", store.token);
|
|
3764
|
+
});
|
|
3765
|
+
});
|
|
3766
|
+
}
|
|
3767
|
+
|
|
3592
3768
|
/**
|
|
3593
3769
|
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
3594
3770
|
*
|
|
@@ -3723,35 +3899,6 @@ function CollectionContains(type) {
|
|
|
3723
3899
|
return CollectionOf(type).Contains();
|
|
3724
3900
|
}
|
|
3725
3901
|
|
|
3726
|
-
/**
|
|
3727
|
-
* Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
|
|
3728
|
-
*
|
|
3729
|
-
* ## Usage
|
|
3730
|
-
*
|
|
3731
|
-
* ```typescript
|
|
3732
|
-
* export function Description(description: any) {
|
|
3733
|
-
* return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {
|
|
3734
|
-
* entity.itemSchema.description(description)
|
|
3735
|
-
* });
|
|
3736
|
-
* }
|
|
3737
|
-
* ```
|
|
3738
|
-
*
|
|
3739
|
-
* @param fn
|
|
3740
|
-
* @decorator
|
|
3741
|
-
* @utils
|
|
3742
|
-
* @model
|
|
3743
|
-
*/
|
|
3744
|
-
|
|
3745
|
-
function JsonEntityFn(fn) {
|
|
3746
|
-
return (...parameters) => {
|
|
3747
|
-
const result = fn(getJsonEntityStore(...parameters), parameters);
|
|
3748
|
-
|
|
3749
|
-
if (typeof result === "function") {
|
|
3750
|
-
result(...parameters);
|
|
3751
|
-
}
|
|
3752
|
-
};
|
|
3753
|
-
}
|
|
3754
|
-
|
|
3755
3902
|
/**
|
|
3756
3903
|
* The value `maxItems` MUST be a non-negative integer.
|
|
3757
3904
|
*
|
|
@@ -7778,5 +7925,5 @@ function JsonEntityComponent(type) {
|
|
|
7778
7925
|
};
|
|
7779
7926
|
}
|
|
7780
7927
|
|
|
7781
|
-
export { AdditionalProperties, All, AllOf, Allow, Any, AnyOf, ArrayOf, CollectionContains, CollectionOf, Const, Consumes, ContentType, CustomKey, CustomKeys, DateFormat, DateTime, Default, Delete, Deprecated, Description, Email, Enum, Example, Examples, ExclusiveMaximum, ExclusiveMinimum, For, Format, ForwardGroups, GenericOf, Generics, Get, Groups, HTTP_METHODS, HTTP_STATUS_MESSAGES, Head, Header, Hidden, Ignore, In, Integer, JSON_TYPES, JsonEntityComponent, JsonEntityFn, JsonEntityStore, JsonFormatTypes, JsonLazyRef, JsonMap, JsonMedia, JsonOperation, JsonParameter, JsonParameterTypes, JsonRequestBody, JsonResponse, JsonSchema, Location, MapOf, Max, MaxItems, MaxLength, MaxProperties, Maximum, Min, MinItems, MinLength, MinProperties, Minimum, MultipleOf, Name, Nullable, OneOf, OperationId, OperationMethods, OperationPath, Optional, Options, Partial, Patch, Path, Pattern, Post, Produces, Property, Put, ReadOnly, Redirect, Required, RequiredGroups, Returns, Route, Schema, Security, SpecTypes, Status, Summary, Tags, TimeFormat, Title, UniqueItems, Uri, Url, WriteOnly, allOf, alterIgnore, any, anyOf, array, boolean, date, datetime, defineStatusModel, email, formatParameterType, from, getGenericsMap, getJsonSchema, getJsonType, getOperationsStores, getProperties, getPropertiesStores, getSpec, getStatusConstant, getStatusMessage, getStatusModel, integer, isParameterType, isRedirectionStatus, isSuccessStatus, lazyRef, map, mapGenericsOptions, mapHeaders, mergeSpec, number, object, oneOf, parameters, popGenerics, schemesReducer, security, set, string, tagsReducer, time, uri, url };
|
|
7928
|
+
export { AdditionalProperties, All, AllOf, Allow, Any, AnyOf, ArrayOf, Children, CollectionContains, CollectionOf, Const, Consumes, ContentType, CustomKey, CustomKeys, DateFormat, DateTime, Default, Delete, Deprecated, Description, Email, Enum, Example, Examples, ExclusiveMaximum, ExclusiveMinimum, For, Format, ForwardGroups, GenericOf, Generics, Get, Groups, HTTP_METHODS, HTTP_STATUS_MESSAGES, Head, Header, Hidden, Ignore, In, Integer, JSON_TYPES, JsonEntityComponent, JsonEntityFn, JsonEntityStore, JsonFormatTypes, JsonLazyRef, JsonMap, JsonMedia, JsonOperation, JsonOperationRoute, JsonParameter, JsonParameterTypes, JsonRequestBody, JsonResponse, JsonSchema, Location, MapOf, Max, MaxItems, MaxLength, MaxProperties, Maximum, Min, MinItems, MinLength, MinProperties, Minimum, MultipleOf, Name, Nullable, OneOf, OperationId, OperationMethods, OperationPath, Optional, Options, Partial, Patch, Path, Pattern, Post, Produces, Property, Put, ReadOnly, Redirect, Required, RequiredGroups, Returns, Route, Schema, Security, SpecTypes, Status, Summary, Tags, TimeFormat, Title, UniqueItems, Uri, Url, WriteOnly, allOf, alterIgnore, any, anyOf, array, boolean, concatPath, date, datetime, defineStatusModel, email, formatParameterType, from, getGenericsMap, getJsonSchema, getJsonType, getOperationsRoutes, getOperationsStores, getProperties, getPropertiesStores, getSpec, getStatusConstant, getStatusMessage, getStatusModel, integer, isParameterType, isRedirectionStatus, isSuccessStatus, lazyRef, map, mapGenericsOptions, mapHeaders, mergeSpec, number, object, oneOf, parameters, popGenerics, schemesReducer, security, set, string, tagsReducer, time, uri, url };
|
|
7782
7929
|
//# sourceMappingURL=index.modern.js.map
|