nicot 1.4.1 → 1.4.2
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/dist/index.cjs +107 -53
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +61 -7
- package/dist/index.mjs.map +4 -4
- package/dist/src/restful.d.ts +3 -3
- package/dist/src/utility/get-api-property.d.ts +3 -0
- package/dist/src/utility/patch-column-in-get.d.ts +1 -1
- package/dist/src/utility/swagger-decorators.d.ts +23 -0
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -3011,11 +3011,11 @@ import {
|
|
|
3011
3011
|
MergeMethodDecorators,
|
|
3012
3012
|
PaginatedReturnMessageDto as PaginatedReturnMessageDto2,
|
|
3013
3013
|
ReturnMessageDto as ReturnMessageDto2,
|
|
3014
|
-
getApiProperty as getApiProperty2,
|
|
3015
3014
|
DataPipe,
|
|
3016
3015
|
ApiTypeResponse,
|
|
3017
3016
|
ApiBlankResponse,
|
|
3018
|
-
ApiError
|
|
3017
|
+
ApiError,
|
|
3018
|
+
RenameClass
|
|
3019
3019
|
} from "nesties";
|
|
3020
3020
|
import {
|
|
3021
3021
|
ApiBody,
|
|
@@ -3029,7 +3029,6 @@ import {
|
|
|
3029
3029
|
PickType as PickType2
|
|
3030
3030
|
} from "@nestjs/swagger";
|
|
3031
3031
|
import _6, { upperFirst } from "lodash";
|
|
3032
|
-
import { RenameClass } from "nesties";
|
|
3033
3032
|
|
|
3034
3033
|
// src/bases/base-restful-controller.ts
|
|
3035
3034
|
var RestfulMethods = [
|
|
@@ -3095,9 +3094,64 @@ var OmitTypeExclude = (cl, keys) => {
|
|
|
3095
3094
|
};
|
|
3096
3095
|
|
|
3097
3096
|
// src/utility/patch-column-in-get.ts
|
|
3098
|
-
import { getApiProperty } from "nesties";
|
|
3099
3097
|
import _5 from "lodash";
|
|
3100
|
-
|
|
3098
|
+
|
|
3099
|
+
// src/utility/swagger-decorators.ts
|
|
3100
|
+
var DECORATORS_PREFIX = "swagger";
|
|
3101
|
+
var FALLBACK_DECORATORS = {
|
|
3102
|
+
API_OPERATION: `${DECORATORS_PREFIX}/apiOperation`,
|
|
3103
|
+
API_RESPONSE: `${DECORATORS_PREFIX}/apiResponse`,
|
|
3104
|
+
API_PRODUCES: `${DECORATORS_PREFIX}/apiProduces`,
|
|
3105
|
+
API_CONSUMES: `${DECORATORS_PREFIX}/apiConsumes`,
|
|
3106
|
+
API_TAGS: `${DECORATORS_PREFIX}/apiUseTags`,
|
|
3107
|
+
API_WEBHOOK: `${DECORATORS_PREFIX}/apiWebhook`,
|
|
3108
|
+
API_CALLBACKS: `${DECORATORS_PREFIX}/apiCallbacks`,
|
|
3109
|
+
API_PARAMETERS: `${DECORATORS_PREFIX}/apiParameters`,
|
|
3110
|
+
API_HEADERS: `${DECORATORS_PREFIX}/apiHeaders`,
|
|
3111
|
+
API_MODEL_PROPERTIES: `${DECORATORS_PREFIX}/apiModelProperties`,
|
|
3112
|
+
API_MODEL_PROPERTIES_ARRAY: `${DECORATORS_PREFIX}/apiModelPropertiesArray`,
|
|
3113
|
+
API_SECURITY: `${DECORATORS_PREFIX}/apiSecurity`,
|
|
3114
|
+
API_EXCLUDE_ENDPOINT: `${DECORATORS_PREFIX}/apiExcludeEndpoint`,
|
|
3115
|
+
API_INCLUDE_ENDPOINT: `${DECORATORS_PREFIX}/apiIncludeEndpoint`,
|
|
3116
|
+
API_EXCLUDE_CONTROLLER: `${DECORATORS_PREFIX}/apiExcludeController`,
|
|
3117
|
+
API_EXTRA_MODELS: `${DECORATORS_PREFIX}/apiExtraModels`,
|
|
3118
|
+
API_EXTENSION: `${DECORATORS_PREFIX}/apiExtension`,
|
|
3119
|
+
API_SCHEMA: `${DECORATORS_PREFIX}/apiSchema`,
|
|
3120
|
+
API_DEFAULT_GETTER: `${DECORATORS_PREFIX}/apiDefaultGetter`,
|
|
3121
|
+
API_LINK: `${DECORATORS_PREFIX}/apiLink`
|
|
3122
|
+
};
|
|
3123
|
+
function loadSwaggerDecorators() {
|
|
3124
|
+
try {
|
|
3125
|
+
const req = typeof __require === "function" ? __require : void 0;
|
|
3126
|
+
const decorators = req?.("@nestjs/swagger/dist/constants")?.DECORATORS;
|
|
3127
|
+
if (decorators) {
|
|
3128
|
+
return {
|
|
3129
|
+
...FALLBACK_DECORATORS,
|
|
3130
|
+
...decorators
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
} catch {
|
|
3134
|
+
}
|
|
3135
|
+
return FALLBACK_DECORATORS;
|
|
3136
|
+
}
|
|
3137
|
+
var DECORATORS = loadSwaggerDecorators();
|
|
3138
|
+
|
|
3139
|
+
// src/utility/get-api-property.ts
|
|
3140
|
+
var getApiProperty = (cls, key) => {
|
|
3141
|
+
let proto = cls.prototype;
|
|
3142
|
+
while (proto && proto !== Object.prototype) {
|
|
3143
|
+
const meta = Reflect.getMetadata(
|
|
3144
|
+
DECORATORS.API_MODEL_PROPERTIES,
|
|
3145
|
+
proto,
|
|
3146
|
+
key
|
|
3147
|
+
);
|
|
3148
|
+
if (meta) return meta;
|
|
3149
|
+
proto = Object.getPrototypeOf(proto);
|
|
3150
|
+
}
|
|
3151
|
+
return {};
|
|
3152
|
+
};
|
|
3153
|
+
|
|
3154
|
+
// src/utility/patch-column-in-get.ts
|
|
3101
3155
|
var PatchColumnsInGet = (cl, originalCl = cl, fieldsToOmit = []) => {
|
|
3102
3156
|
const omit2 = new Set(fieldsToOmit);
|
|
3103
3157
|
const useCl = originalCl || cl;
|
|
@@ -3445,7 +3499,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
3445
3499
|
if (outputFieldsToOmit.has(relation.propertyName)) continue;
|
|
3446
3500
|
if (nonTransformableTypes.has(relation.propertyClass)) continue;
|
|
3447
3501
|
const replace = (useClass) => {
|
|
3448
|
-
const oldApiProperty =
|
|
3502
|
+
const oldApiProperty = getApiProperty(
|
|
3449
3503
|
this.entityClass,
|
|
3450
3504
|
relation.propertyName
|
|
3451
3505
|
);
|
|
@@ -3488,7 +3542,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
3488
3542
|
"notRequiredButHasDefault"
|
|
3489
3543
|
).filter((f) => !outputFieldsToOmit.has(f));
|
|
3490
3544
|
for (const field of notRequiredButHasDefaultFields) {
|
|
3491
|
-
const oldApiProperty =
|
|
3545
|
+
const oldApiProperty = getApiProperty(resultDto, field);
|
|
3492
3546
|
ApiProperty5({
|
|
3493
3547
|
...oldApiProperty,
|
|
3494
3548
|
required: true
|