@tsed/schema 6.114.17 → 6.115.1

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 (110) hide show
  1. package/lib/cjs/components/lazyRefMapper.js +1 -2
  2. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  3. package/lib/cjs/components/objectMapper.js +1 -1
  4. package/lib/cjs/components/objectMapper.js.map +1 -1
  5. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  6. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  7. package/lib/cjs/decorators/common/description.js +1 -2
  8. package/lib/cjs/decorators/common/description.js.map +1 -1
  9. package/lib/cjs/decorators/operations/redirect.js +1 -2
  10. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  11. package/lib/cjs/decorators/operations/returns.js +20 -20
  12. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  13. package/lib/cjs/decorators/operations/route.js +1 -4
  14. package/lib/cjs/decorators/operations/route.js.map +1 -1
  15. package/lib/cjs/domain/DecoratorContext.js +4 -1
  16. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  17. package/lib/cjs/domain/JsonClassStore.js +4 -7
  18. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  19. package/lib/cjs/domain/JsonEntityStore.js +37 -1
  20. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  21. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  22. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  23. package/lib/cjs/domain/JsonMethodStore.js +12 -12
  24. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  25. package/lib/cjs/domain/JsonOperation.js +12 -16
  26. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  27. package/lib/cjs/domain/JsonOperationPathsMap.js +1 -4
  28. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperationRoute.js +8 -6
  30. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  31. package/lib/cjs/domain/JsonParameter.js +4 -4
  32. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  33. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  34. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  35. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  36. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  37. package/lib/cjs/domain/JsonResponse.js +3 -6
  38. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  39. package/lib/cjs/domain/JsonSchema.js +58 -60
  40. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  41. package/lib/cjs/hooks/alterIgnore.js +2 -3
  42. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  43. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  44. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  45. package/lib/cjs/utils/getJsonSchema.js +1 -2
  46. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  47. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  48. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  49. package/lib/cjs/utils/mapNullableType.js +1 -1
  50. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  51. package/lib/cjs/utils/mergeOperation.js +1 -2
  52. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  53. package/lib/cjs/utils/transformToOS2.js +2 -2
  54. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  55. package/lib/esm/components/lazyRefMapper.js +1 -2
  56. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  57. package/lib/esm/components/objectMapper.js +1 -1
  58. package/lib/esm/components/objectMapper.js.map +1 -1
  59. package/lib/esm/constants/httpStatusMessages.js +2 -4
  60. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  61. package/lib/esm/decorators/common/description.js +1 -2
  62. package/lib/esm/decorators/common/description.js.map +1 -1
  63. package/lib/esm/decorators/operations/redirect.js +1 -2
  64. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  65. package/lib/esm/decorators/operations/returns.js +20 -20
  66. package/lib/esm/decorators/operations/returns.js.map +1 -1
  67. package/lib/esm/decorators/operations/route.js +1 -4
  68. package/lib/esm/decorators/operations/route.js.map +1 -1
  69. package/lib/esm/domain/DecoratorContext.js +4 -1
  70. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  71. package/lib/esm/domain/JsonClassStore.js +4 -7
  72. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  73. package/lib/esm/domain/JsonEntityStore.js +37 -1
  74. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  75. package/lib/esm/domain/JsonLazyRef.js +2 -1
  76. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  77. package/lib/esm/domain/JsonMethodStore.js +12 -12
  78. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  79. package/lib/esm/domain/JsonOperation.js +12 -16
  80. package/lib/esm/domain/JsonOperation.js.map +1 -1
  81. package/lib/esm/domain/JsonOperationPathsMap.js +1 -4
  82. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  83. package/lib/esm/domain/JsonOperationRoute.js +8 -6
  84. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  85. package/lib/esm/domain/JsonParameter.js +4 -4
  86. package/lib/esm/domain/JsonParameter.js.map +1 -1
  87. package/lib/esm/domain/JsonParameterStore.js +12 -5
  88. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  89. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  90. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  91. package/lib/esm/domain/JsonResponse.js +3 -6
  92. package/lib/esm/domain/JsonResponse.js.map +1 -1
  93. package/lib/esm/domain/JsonSchema.js +58 -60
  94. package/lib/esm/domain/JsonSchema.js.map +1 -1
  95. package/lib/esm/hooks/alterIgnore.js +2 -3
  96. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  97. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  98. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  99. package/lib/esm/utils/getJsonSchema.js +1 -2
  100. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  101. package/lib/esm/utils/getRequiredProperties.js +3 -3
  102. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  103. package/lib/esm/utils/mapNullableType.js +1 -1
  104. package/lib/esm/utils/mapNullableType.js.map +1 -1
  105. package/lib/esm/utils/mergeOperation.js +1 -2
  106. package/lib/esm/utils/mergeOperation.js.map +1 -1
  107. package/lib/esm/utils/transformToOS2.js +2 -2
  108. package/lib/esm/utils/transformToOS2.js.map +1 -1
  109. package/package.json +6 -6
  110. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAGpD,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAiB,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,aAAc,SAAQ,OAAiC;IAApE;;QACE,mBAAc,GAAkB,EAAE,CAAC;IAyIrC,CAAC;IApIC,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE;YAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,I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AC7B,GAAG,UAAU;gBACb,GAAG,MAAM;aACV,CAAC,CAAC;SACJ;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,eAAe,CAAC,SAAc,EAAE,OAA0B,EAAE,gBAAwC;QAC1G,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzD,OAAO,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACjD;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAC,WAAW,EAAE,GAAG,IAAI,EAAC,CAAgB,EAAE,EAAE;YAC7G,OAAO;gBACL,GAAG,MAAM;gBACT,WAAW,CAAC;oBACV,GAAG,SAAS;oBACZ,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC/C,WAAW;oBACX,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;iBAC5C,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {createRefName} from \"../utils/ref\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n switch (this.get(\"in\")) {\n case JsonParameterTypes.FILES:\n return this.getFileSchema(jsonSchema, parameter);\n case JsonParameterTypes.QUERY:\n if (jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n break;\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private getFileSchema(jsonSchema: any, parameter: Pick<any, string | number | symbol>) {\n const schema = {\n type: \"string\",\n format: \"binary\",\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const name = createRefName(this.$schema.getName(), options);\n const schema = options.schemas![name];\n\n if (options.schemas![name] && !schemasContainer.has(name)) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }, []);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAGpD,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAiB,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,aAAc,SAAQ,OAAiC;IAClE,cAAc,GAAkB,EAAE,CAAC;IACnC,MAAM,CAAW;IACjB,OAAO,CAAa;IACpB,UAAU,CAAS;IAEnB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AAY,CAAC,CAAC,CAAC,SAAS;iBAC5C,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {createRefName} from \"../utils/ref\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n switch (this.get(\"in\")) {\n case JsonParameterTypes.FILES:\n return this.getFileSchema(jsonSchema, parameter);\n case JsonParameterTypes.QUERY:\n if (jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n break;\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private getFileSchema(jsonSchema: any, parameter: Pick<any, string | number | symbol>) {\n const schema = {\n type: \"string\",\n format: \"binary\",\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const name = createRefName(this.$schema.getName(), options);\n const schema = options.schemas![name];\n\n if (options.schemas![name] && !schemasContainer.has(name)) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }, []);\n }\n}\n"]}
@@ -5,13 +5,20 @@ import { JsonParameter } from "./JsonParameter.js";
5
5
  import { JsonSchema } from "./JsonSchema.js";
6
6
  import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
7
7
  let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
8
+ paramType;
9
+ expression;
10
+ dataPath;
11
+ /**
12
+ * Define pipes can be called by the framework to transform input parameter
13
+ */
14
+ pipes;
15
+ /**
16
+ * Ref to JsonParameter when the decorated object is a parameter.
17
+ */
18
+ parameter = new JsonParameter();
19
+ parent = JsonEntityStore.fromMethod(this.target, this.propertyKey);
8
20
  constructor(options) {
9
21
  super(options);
10
- /**
11
- * Ref to JsonParameter when the decorated object is a parameter.
12
- */
13
- this.parameter = new JsonParameter();
14
- this.parent = JsonEntityStore.fromMethod(this.target, this.propertyKey);
15
22
  this.pipes = options.pipes || [];
16
23
  this.paramType = options.paramType || this.paramType;
17
24
  this.expression = options.expression || this.expression;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AAC/H,OAAO,EAAC,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAa7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,eAAe;IAcrD,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QAPjB;;WAEG;QACM,cAAS,GAAkB,IAAI,aAAa,EAAE,CAAC;QAC/C,WAAM,GAAoB,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAI3F,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC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M,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEpC,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;aACpD;YAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,KAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;SAC1E;IACH,CAAC;CACF,CAAA;AAhHY,kBAAkB;IAD9B,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC;;GAC7B,kBAAkB,CAgH9B;SAhHY,kBAAkB;AAsH/B,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC","sourcesContent":["import {ancestorsOf, DecoratorTypes, isClass, isCollection, isMethodDescriptor, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonParameterStoreOptions extends JsonEntityStoreOptions {\n dataPath?: string;\n paramType?: string;\n expression?: string;\n}\n\nexport interface PipeMethods<T = any, R = any> {\n transform(value: T, metadata: JsonParameterStore): R;\n}\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class JsonParameterStore extends JsonEntityStore {\n public paramType: string;\n public expression: string;\n public dataPath: string;\n /**\n * Define pipes can be called by the framework to transform input parameter\n */\n public pipes: Type<PipeMethods>[];\n /**\n * Ref to JsonParameter when the decorated object is a parameter.\n */\n readonly parameter: JsonParameter = new JsonParameter();\n readonly parent: JsonMethodStore = JsonEntityStore.fromMethod(this.target, this.propertyKey);\n\n constructor(options: JsonParameterStoreOptions) {\n super(options);\n this.pipes = options.pipes || [];\n this.paramType = options.paramType || this.paramType;\n this.expression = options.expression || this.expression;\n this.dataPath = options.dataPath || this.dataPath;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.parameter.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.parameter.nestedGenerics = nestedGenerics;\n }\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return !!this.parameter.get(\"required\");\n }\n\n set required(value: boolean) {\n this.parameter.required(value);\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {\n const params: T[] = [];\n\n const klass = ancestorsOf(target)\n .reverse()\n .find((target) => {\n return isMethodDescriptor(target, propertyKey) && JsonEntityStore.fromMethod(target, propertyKey).children.size;\n });\n\n if (klass) {\n JsonEntityStore.fromMethod(klass, propertyKey).children.forEach((param: T, index) => {\n params[+index] = param;\n });\n\n return params;\n }\n\n return [];\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, index: number) {\n return JsonEntityStore.from<JsonParameterStore>(prototypeOf(target), propertyKey, index);\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected getSchema(type: any) {\n if (isCollection(type) || !isClass(type)) {\n return JsonSchema.from({\n type\n });\n }\n\n return JsonEntityStore.from(type).schema;\n }\n\n protected build() {\n if (!this._type) {\n const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n if (!this._schema) {\n this.parent.children.set(this.index!, this);\n\n this._schema = this.getSchema(this.collectionType || this.type);\n\n this.parameter.schema(this._schema);\n\n if (this.collectionType) {\n this._schema.itemSchema(this.getSchema(this.type));\n }\n\n this.parent.operation.addParameter(this.index as number, this.parameter);\n }\n }\n}\n\n/**\n * @alias JsonParameterStore\n */\nexport type ParamMetadata = JsonParameterStore;\nexport const ParamMetadata = JsonParameterStore;\n"]}
1
+ {"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AAC/H,OAAO,EAAC,eAAe,EAAyB,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAa7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,eAAe;IAC9C,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,QAAQ,CAAS;IACxB;;OAEG;IACI,KAAK,CAAsB;IAClC;;OAEG;IACM,SAAS,GAAkB,IAAI,aAAa,EAAE,CAAC;IAC/C,MAAM,GAAoB,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAE7F,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;IACpD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CA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AAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;aACpD;YAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,KAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;SAC1E;IACH,CAAC;CACF,CAAA;AAhHY,kBAAkB;IAD9B,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC;;GAC7B,kBAAkB,CAgH9B;SAhHY,kBAAkB;AAsH/B,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC","sourcesContent":["import {ancestorsOf, DecoratorTypes, isClass, isCollection, isMethodDescriptor, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonParameterStoreOptions extends JsonEntityStoreOptions {\n dataPath?: string;\n paramType?: string;\n expression?: string;\n}\n\nexport interface PipeMethods<T = any, R = any> {\n transform(value: T, metadata: JsonParameterStore): R;\n}\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class JsonParameterStore extends JsonEntityStore {\n public paramType: string;\n public expression: string;\n public dataPath: string;\n /**\n * Define pipes can be called by the framework to transform input parameter\n */\n public pipes: Type<PipeMethods>[];\n /**\n * Ref to JsonParameter when the decorated object is a parameter.\n */\n readonly parameter: JsonParameter = new JsonParameter();\n readonly parent: JsonMethodStore = JsonEntityStore.fromMethod(this.target, this.propertyKey);\n\n constructor(options: JsonParameterStoreOptions) {\n super(options);\n this.pipes = options.pipes || [];\n this.paramType = options.paramType || this.paramType;\n this.expression = options.expression || this.expression;\n this.dataPath = options.dataPath || this.dataPath;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.parameter.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.parameter.nestedGenerics = nestedGenerics;\n }\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return !!this.parameter.get(\"required\");\n }\n\n set required(value: boolean) {\n this.parameter.required(value);\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {\n const params: T[] = [];\n\n const klass = ancestorsOf(target)\n .reverse()\n .find((target) => {\n return isMethodDescriptor(target, propertyKey) && JsonEntityStore.fromMethod(target, propertyKey).children.size;\n });\n\n if (klass) {\n JsonEntityStore.fromMethod(klass, propertyKey).children.forEach((param: T, index) => {\n params[+index] = param;\n });\n\n return params;\n }\n\n return [];\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, index: number) {\n return JsonEntityStore.from<JsonParameterStore>(prototypeOf(target), propertyKey, index);\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected getSchema(type: any) {\n if (isCollection(type) || !isClass(type)) {\n return JsonSchema.from({\n type\n });\n }\n\n return JsonEntityStore.from(type).schema;\n }\n\n protected build() {\n if (!this._type) {\n const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n if (!this._schema) {\n this.parent.children.set(this.index!, this);\n\n this._schema = this.getSchema(this.collectionType || this.type);\n\n this.parameter.schema(this._schema);\n\n if (this.collectionType) {\n this._schema.itemSchema(this.getSchema(this.type));\n }\n\n this.parent.operation.addParameter(this.index as number, this.parameter);\n }\n }\n}\n\n/**\n * @alias JsonParameterStore\n */\nexport type ParamMetadata = JsonParameterStore;\nexport const ParamMetadata = JsonParameterStore;\n"]}
@@ -4,10 +4,7 @@ import { JsonEntityStore } from "./JsonEntityStore.js";
4
4
  import { JsonSchema } from "./JsonSchema.js";
5
5
  import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
6
6
  let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore {
7
- constructor() {
8
- super(...arguments);
9
- this.parent = JsonEntityStore.from(this.target);
10
- }
7
+ parent = JsonEntityStore.from(this.target);
11
8
  /**
12
9
  * Return the required state.
13
10
  * @returns {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAI7E,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,eAAe;IAAtD;;QACW,WAAM,GAAmB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAkEtE,CAAC;IAhEC;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC/D;IACH,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CA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AI,CAAoB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;CACF,CAAA;AAnEY,iBAAiB;IAD7B,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,CAmE7B;SAnEY,iBAAiB;AAyE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC","sourcesContent":["import {DecoratorTypes, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\n\n@JsonEntityComponent(DecoratorTypes.PROP)\nexport class JsonPropertyStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return this.parent.schema.isRequired(this.propertyKey as string);\n }\n\n /**\n * Change the state of the required data.\n * @param value\n */\n set required(value: boolean) {\n if (value) {\n this.parent.schema.addRequired(this.propertyKey as string);\n } else {\n this.parent.schema.removeRequired(this.propertyKey as string);\n }\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(Metadata.getType(prototypeOf(this.target), this.propertyKey));\n }\n\n this._type = this._type || Object;\n\n const properties = this.parent.schema.get(\"properties\");\n\n let schema: JsonSchema = properties[this.propertyName];\n\n if (!schema) {\n this.parent.children.set(this.propertyName, this);\n\n schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n schema.itemSchema(this.type);\n }\n }\n\n this.parent.schema.addProperty(this.propertyName, schema);\n\n this._schema = schema;\n }\n\n static get(target: Type<any>, propertyKey: string | symbol) {\n return JsonEntityStore.from<JsonPropertyStore>(prototypeOf(target), propertyKey);\n }\n}\n\n/**\n * @alias JsonPropertyStore\n */\nexport type PropertyMetadata = JsonPropertyStore;\nexport const PropertyMetadata = JsonPropertyStore;\n"]}
1
+ {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAI7E,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,eAAe;IAC3C,MAAM,GAAmB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpE;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC/D;IACH,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,KAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,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AAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,CAmE7B;SAnEY,iBAAiB;AAyE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC","sourcesContent":["import {DecoratorTypes, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\n\n@JsonEntityComponent(DecoratorTypes.PROP)\nexport class JsonPropertyStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return this.parent.schema.isRequired(this.propertyKey as string);\n }\n\n /**\n * Change the state of the required data.\n * @param value\n */\n set required(value: boolean) {\n if (value) {\n this.parent.schema.addRequired(this.propertyKey as string);\n } else {\n this.parent.schema.removeRequired(this.propertyKey as string);\n }\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(Metadata.getType(prototypeOf(this.target), this.propertyKey));\n }\n\n this._type = this._type || Object;\n\n const properties = this.parent.schema.get(\"properties\");\n\n let schema: JsonSchema = properties[this.propertyName];\n\n if (!schema) {\n this.parent.children.set(this.propertyName, this);\n\n schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n schema.itemSchema(this.type);\n }\n }\n\n this.parent.schema.addProperty(this.propertyName, schema);\n\n this._schema = schema;\n }\n\n static get(target: Type<any>, propertyKey: string | symbol) {\n return JsonEntityStore.from<JsonPropertyStore>(prototypeOf(target), propertyKey);\n }\n}\n\n/**\n * @alias JsonPropertyStore\n */\nexport type PropertyMetadata = JsonPropertyStore;\nexport const PropertyMetadata = JsonPropertyStore;\n"]}
@@ -2,10 +2,7 @@ import { mapHeaders } from "../utils/mapHeaders.js";
2
2
  import { toJsonMapCollection } from "../utils/toJsonMapCollection.js";
3
3
  import { JsonMap } from "./JsonMap.js";
4
4
  export class JsonMedia extends JsonMap {
5
- constructor() {
6
- super(...arguments);
7
- this.groups = [];
8
- }
5
+ groups = [];
9
6
  schema(schema) {
10
7
  this.set("schema", schema);
11
8
  return this;
@@ -19,6 +16,7 @@ export class JsonMedia extends JsonMap {
19
16
  }
20
17
  }
21
18
  export class JsonResponse extends JsonMap {
19
+ status;
22
20
  constructor(obj = {}) {
23
21
  super(obj);
24
22
  this.content(obj.content || {});
@@ -39,9 +37,8 @@ export class JsonResponse extends JsonMap {
39
37
  return this.get("content");
40
38
  }
41
39
  getMedia(mediaType, create = true) {
42
- var _a;
43
40
  create && this.addMedia(mediaType);
44
- return (_a = this.getContent()) === null || _a === void 0 ? void 0 : _a.get(mediaType);
41
+ return this.getContent()?.get(mediaType);
45
42
  }
46
43
  addMedia(mediaType) {
47
44
  const content = this.get("content");
@@ -1 +1 @@
1
- {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAMlC,MAAM,OAAO,SAAU,SAAQ,OAAiC;IAAhE;;QACE,WAAM,GAAa,EAAE,CAAC;IAiBxB,CAAC;IAfC,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAa;QACpB,IAAI,CAAC,GAAG,CAAC,UAAU,E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AS,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;SACzC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;YACvB,OAAO,QAAQ,CAAC,OAAO,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,CAAgB,EAAE,EAAE;gBAClF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG;oBACtB,GAAG,KAAK;oBACR,MAAM,EAAE;wBACN,IAAI;qBACL;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OS3MediaType, OS3Response} from \"@tsed/openspec\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {mapHeaders} from \"../utils/mapHeaders\";\nimport {toJsonMapCollection} from \"../utils/toJsonMapCollection\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {SpecTypes} from \"./SpecTypes\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n\n schema(schema: JsonSchema) {\n this.set(\"schema\", schema);\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", examples);\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n return super.toJSON({...options, groups: this.groups});\n }\n}\n\nexport class JsonResponse extends JsonMap<JsonResponseOptions> {\n status: number;\n\n constructor(obj: Partial<JsonResponseOptions> = {}) {\n super(obj);\n\n this.content(obj.content || ({} as any));\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n headers(headers: Record<string, string | JsonHeader>): this {\n this.set(\"headers\", mapHeaders(headers));\n\n return this;\n }\n\n content(content: Record<string, OS3MediaType<JsonSchema>>) {\n this.set(\"content\", toJsonMapCollection(content, JsonMedia));\n\n return this;\n }\n\n getContent(): JsonMap<JsonMedia> {\n return this.get(\"content\")!;\n }\n\n getMedia(mediaType: string, create = true): JsonMedia {\n create && this.addMedia(mediaType);\n\n return this.getContent()?.get(mediaType) as any;\n }\n\n addMedia(mediaType: string) {\n const content = this.get(\"content\");\n\n if (!content.has(mediaType)) {\n content.set(mediaType, new JsonMedia());\n }\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const response = super.toJSON(options);\n\n if (this.status === 204) {\n delete response.content;\n }\n\n if (response.headers) {\n Object.entries(response.headers).forEach(([key, {type, ...props}]: [string, any]) => {\n response.headers[key] = {\n ...props,\n schema: {\n type\n }\n };\n });\n }\n\n return response;\n }\n}\n"]}
1
+ {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAMlC,MAAM,OAAO,SAAU,SAAQ,OAAiC;IAC9D,MAAM,GAAa,EAAE,CAAC;IAEtB,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ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AS,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;SACzC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;YACvB,OAAO,QAAQ,CAAC,OAAO,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,CAAgB,EAAE,EAAE;gBAClF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG;oBACtB,GAAG,KAAK;oBACR,MAAM,EAAE;wBACN,IAAI;qBACL;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OS3MediaType, OS3Response} from \"@tsed/openspec\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {mapHeaders} from \"../utils/mapHeaders\";\nimport {toJsonMapCollection} from \"../utils/toJsonMapCollection\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {SpecTypes} from \"./SpecTypes\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n\n schema(schema: JsonSchema) {\n this.set(\"schema\", schema);\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", examples);\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n return super.toJSON({...options, groups: this.groups});\n }\n}\n\nexport class JsonResponse extends JsonMap<JsonResponseOptions> {\n status: number;\n\n constructor(obj: Partial<JsonResponseOptions> = {}) {\n super(obj);\n\n this.content(obj.content || ({} as any));\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n headers(headers: Record<string, string | JsonHeader>): this {\n this.set(\"headers\", mapHeaders(headers));\n\n return this;\n }\n\n content(content: Record<string, OS3MediaType<JsonSchema>>) {\n this.set(\"content\", toJsonMapCollection(content, JsonMedia));\n\n return this;\n }\n\n getContent(): JsonMap<JsonMedia> {\n return this.get(\"content\")!;\n }\n\n getMedia(mediaType: string, create = true): JsonMedia {\n create && this.addMedia(mediaType);\n\n return this.getContent()?.get(mediaType) as any;\n }\n\n addMedia(mediaType: string) {\n const content = this.get(\"content\");\n\n if (!content.has(mediaType)) {\n content.set(mediaType, new JsonMedia());\n }\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const response = super.toJSON(options);\n\n if (this.status === 204) {\n delete response.content;\n }\n\n if (response.headers) {\n Object.entries(response.headers).forEach(([key, {type, ...props}]: [string, any]) => {\n response.headers[key] = {\n ...props,\n schema: {\n type\n }\n };\n });\n }\n\n return response;\n }\n}\n"]}
@@ -1,5 +1,3 @@
1
- var _JsonSchema_nullable, _JsonSchema_genericLabels, _JsonSchema_nestedGenerics, _JsonSchema_alias, _JsonSchema_itemSchema, _JsonSchema_target, _JsonSchema_isGeneric, _JsonSchema_isCollection, _JsonSchema_ref;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import { classOf, Hooks, isArray, isClass, isFunction, isObject, nameOf, uniq } from "@tsed/core";
4
2
  import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
5
3
  import { getComputedType } from "../utils/getComputedType.js";
@@ -33,55 +31,56 @@ function mapToJsonSchema(item) {
33
31
  return item;
34
32
  }
35
33
  export class JsonSchema extends Map {
34
+ isJsonSchema = true;
35
+ $hooks = new Hooks();
36
+ $required = new Set();
37
+ $allow = [];
38
+ $selfRequired;
39
+ $forwardGroups = false;
40
+ #nullable = false;
41
+ #genericLabels;
42
+ #nestedGenerics = [];
43
+ #alias = new Map();
44
+ #itemSchema;
45
+ #target;
46
+ #isGeneric = false;
47
+ #isCollection = false;
48
+ #ref = false;
36
49
  constructor(obj = {}) {
37
50
  super();
38
- this.isJsonSchema = true;
39
- this.$hooks = new Hooks();
40
- this.$required = new Set();
41
- this.$allow = [];
42
- this.$forwardGroups = false;
43
- _JsonSchema_nullable.set(this, false);
44
- _JsonSchema_genericLabels.set(this, void 0);
45
- _JsonSchema_nestedGenerics.set(this, []);
46
- _JsonSchema_alias.set(this, new Map());
47
- _JsonSchema_itemSchema.set(this, void 0);
48
- _JsonSchema_target.set(this, void 0);
49
- _JsonSchema_isGeneric.set(this, false);
50
- _JsonSchema_isCollection.set(this, false);
51
- _JsonSchema_ref.set(this, false);
52
51
  if (obj) {
53
52
  this.assign(obj);
54
53
  }
55
54
  }
56
55
  get alias() {
57
- return __classPrivateFieldGet(this, _JsonSchema_alias, "f");
56
+ return this.#alias;
58
57
  }
59
58
  get nestedGenerics() {
60
- return __classPrivateFieldGet(this, _JsonSchema_nestedGenerics, "f");
59
+ return this.#nestedGenerics;
61
60
  }
62
61
  set nestedGenerics(value) {
63
- __classPrivateFieldSet(this, _JsonSchema_nestedGenerics, value, "f");
62
+ this.#nestedGenerics = value;
64
63
  }
65
64
  get genericLabels() {
66
- return __classPrivateFieldGet(this, _JsonSchema_genericLabels, "f");
65
+ return this.#genericLabels;
67
66
  }
68
67
  set genericLabels(value) {
69
- __classPrivateFieldSet(this, _JsonSchema_genericLabels, value, "f");
68
+ this.#genericLabels = value;
70
69
  }
71
70
  get isClass() {
72
- return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(__classPrivateFieldGet(this, _JsonSchema_target, "f"));
71
+ return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target);
73
72
  }
74
73
  /**
75
74
  * Current schema is a collection
76
75
  */
77
76
  get isCollection() {
78
- return __classPrivateFieldGet(this, _JsonSchema_isCollection, "f");
77
+ return this.#isCollection;
79
78
  }
80
79
  /**
81
80
  * Current schema is a generic
82
81
  */
83
82
  get isGeneric() {
84
- return __classPrivateFieldGet(this, _JsonSchema_isGeneric, "f");
83
+ return this.#isGeneric;
85
84
  }
86
85
  /**
87
86
  * Current schema has generics items
@@ -96,10 +95,10 @@ export class JsonSchema extends Map {
96
95
  return this.getComputedType();
97
96
  }
98
97
  get canRef() {
99
- return __classPrivateFieldGet(this, _JsonSchema_ref, "f");
98
+ return this.#ref;
100
99
  }
101
100
  get isNullable() {
102
- return __classPrivateFieldGet(this, _JsonSchema_nullable, "f") || this.$allow.includes(null);
101
+ return this.#nullable || this.$allow.includes(null);
103
102
  }
104
103
  get isReadOnly() {
105
104
  return this.get("readOnly");
@@ -111,25 +110,25 @@ export class JsonSchema extends Map {
111
110
  return new JsonSchema(obj);
112
111
  }
113
112
  nullable(value) {
114
- __classPrivateFieldSet(this, _JsonSchema_nullable, value, "f");
113
+ this.#nullable = value;
115
114
  }
116
115
  itemSchema(obj = {}) {
117
- __classPrivateFieldSet(this, _JsonSchema_itemSchema, __classPrivateFieldGet(this, _JsonSchema_itemSchema, "f") || mapToJsonSchema(obj), "f");
118
- __classPrivateFieldGet(this, _JsonSchema_itemSchema, "f").assign(obj);
119
- return __classPrivateFieldGet(this, _JsonSchema_itemSchema, "f");
116
+ this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);
117
+ this.#itemSchema.assign(obj);
118
+ return this.#itemSchema;
120
119
  }
121
120
  getAliasOf(property) {
122
- return __classPrivateFieldGet(this, _JsonSchema_alias, "f").get(property);
121
+ return this.#alias.get(property);
123
122
  }
124
123
  addAlias(property, alias) {
125
- __classPrivateFieldGet(this, _JsonSchema_alias, "f").set(property, alias);
126
- __classPrivateFieldGet(this, _JsonSchema_alias, "f").set(alias, property);
124
+ this.#alias.set(property, alias);
125
+ this.#alias.set(alias, property);
127
126
  return this;
128
127
  }
129
128
  removeAlias(property) {
130
- const alias = __classPrivateFieldGet(this, _JsonSchema_alias, "f").get(property);
131
- alias && __classPrivateFieldGet(this, _JsonSchema_alias, "f").delete(alias);
132
- __classPrivateFieldGet(this, _JsonSchema_alias, "f").delete(property);
129
+ const alias = this.#alias.get(property);
130
+ alias && this.#alias.delete(alias);
131
+ this.#alias.delete(property);
133
132
  return this;
134
133
  }
135
134
  $id($id) {
@@ -149,7 +148,7 @@ export class JsonSchema extends Map {
149
148
  * @param name
150
149
  */
151
150
  label(name) {
152
- __classPrivateFieldSet(this, _JsonSchema_ref, true, "f");
151
+ this.#ref = true;
153
152
  super.set("name", name);
154
153
  return this;
155
154
  }
@@ -233,7 +232,7 @@ export class JsonSchema extends Map {
233
232
  * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9
234
233
  */
235
234
  items(items) {
236
- super.set("items", (__classPrivateFieldSet(this, _JsonSchema_itemSchema, mapToJsonSchema(items), "f")));
235
+ super.set("items", (this.#itemSchema = mapToJsonSchema(items)));
237
236
  return this;
238
237
  }
239
238
  /**
@@ -519,24 +518,24 @@ export class JsonSchema extends Map {
519
518
  switch (type) {
520
519
  case Map:
521
520
  super.set("type", getJsonType(type));
522
- __classPrivateFieldSet(this, _JsonSchema_target, type, "f");
523
- __classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
521
+ this.#target = type;
522
+ this.#isCollection = true;
524
523
  if (!this.has("additionalProperties")) {
525
524
  super.set("additionalProperties", this.itemSchema({}));
526
525
  }
527
526
  break;
528
527
  case Array:
529
528
  super.set("type", getJsonType(type));
530
- __classPrivateFieldSet(this, _JsonSchema_target, type, "f");
531
- __classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
529
+ this.#target = type;
530
+ this.#isCollection = true;
532
531
  if (!this.has("items")) {
533
532
  super.set("items", this.itemSchema({}));
534
533
  }
535
534
  break;
536
535
  case Set:
537
536
  super.set("type", getJsonType(type));
538
- __classPrivateFieldSet(this, _JsonSchema_target, type, "f");
539
- __classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
537
+ this.#target = type;
538
+ this.#isCollection = true;
540
539
  this.uniqueItems(true);
541
540
  if (!this.has("items")) {
542
541
  super.set("items", this.itemSchema({}));
@@ -552,7 +551,7 @@ export class JsonSchema extends Map {
552
551
  case Number:
553
552
  case String:
554
553
  super.set("type", getJsonType(type));
555
- __classPrivateFieldSet(this, _JsonSchema_target, type, "f");
554
+ this.#target = type;
556
555
  if (!this.has("properties")) {
557
556
  super.set("properties", {});
558
557
  }
@@ -560,7 +559,7 @@ export class JsonSchema extends Map {
560
559
  default:
561
560
  if (isClass(type) || isFunction(type)) {
562
561
  super.set("type", undefined);
563
- __classPrivateFieldSet(this, _JsonSchema_target, type, "f");
562
+ this.#target = type;
564
563
  if (!this.has("properties")) {
565
564
  super.set("properties", {});
566
565
  }
@@ -568,7 +567,7 @@ export class JsonSchema extends Map {
568
567
  else {
569
568
  const jsonType = getJsonType(type);
570
569
  if (jsonType === "generic") {
571
- __classPrivateFieldSet(this, _JsonSchema_isGeneric, true, "f");
570
+ this.#isGeneric = true;
572
571
  super.set("$ref", type);
573
572
  }
574
573
  else {
@@ -657,14 +656,14 @@ export class JsonSchema extends Map {
657
656
  obj.$required.forEach((key) => {
658
657
  this.$required.add(key);
659
658
  });
660
- __classPrivateFieldSet(this, _JsonSchema_ref, __classPrivateFieldGet(obj, _JsonSchema_ref, "f"), "f");
661
- __classPrivateFieldSet(this, _JsonSchema_alias, new Map(__classPrivateFieldGet(this, _JsonSchema_alias, "f").entries()), "f");
662
- __classPrivateFieldGet(obj, _JsonSchema_genericLabels, "f") && (__classPrivateFieldSet(this, _JsonSchema_genericLabels, [...__classPrivateFieldGet(obj, _JsonSchema_genericLabels, "f")], "f"));
663
- __classPrivateFieldSet(this, _JsonSchema_nestedGenerics, __classPrivateFieldGet(obj, _JsonSchema_nestedGenerics, "f").map((item) => [...item]), "f");
664
- __classPrivateFieldSet(this, _JsonSchema_target, __classPrivateFieldGet(obj, _JsonSchema_target, "f"), "f");
665
- __classPrivateFieldSet(this, _JsonSchema_isGeneric, __classPrivateFieldGet(obj, _JsonSchema_isGeneric, "f"), "f");
666
- __classPrivateFieldSet(this, _JsonSchema_isCollection, __classPrivateFieldGet(obj, _JsonSchema_isCollection, "f"), "f");
667
- __classPrivateFieldSet(this, _JsonSchema_ref, __classPrivateFieldGet(obj, _JsonSchema_ref, "f"), "f");
659
+ this.#ref = obj.#ref;
660
+ this.#alias = new Map(this.#alias.entries());
661
+ obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);
662
+ this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);
663
+ this.#target = obj.#target;
664
+ this.#isGeneric = obj.#isGeneric;
665
+ this.#isCollection = obj.#isCollection;
666
+ this.#ref = obj.#ref;
668
667
  super.set("type", obj.get("type"));
669
668
  }
670
669
  return this;
@@ -684,10 +683,10 @@ export class JsonSchema extends Map {
684
683
  * the function will be called to get the right type.
685
684
  */
686
685
  getComputedType() {
687
- return getComputedType(__classPrivateFieldGet(this, _JsonSchema_target, "f"));
686
+ return getComputedType(this.#target);
688
687
  }
689
688
  getComputedItemType() {
690
- return __classPrivateFieldGet(this, _JsonSchema_itemSchema, "f") ? __classPrivateFieldGet(this, _JsonSchema_itemSchema, "f").getComputedType() : this.getComputedType();
689
+ return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();
691
690
  }
692
691
  /**
693
692
  * Return the Json type as string
@@ -696,17 +695,16 @@ export class JsonSchema extends Map {
696
695
  return this.get("type") || getJsonType(this.getComputedType());
697
696
  }
698
697
  getTarget() {
699
- return __classPrivateFieldGet(this, _JsonSchema_target, "f");
698
+ return this.#target;
700
699
  }
701
700
  /**
702
701
  * Get the symbolic name of the entity
703
702
  */
704
703
  getName() {
705
- return this.get("name") || (__classPrivateFieldGet(this, _JsonSchema_target, "f") ? nameOf(classOf(this.getComputedType())) : "");
704
+ return this.get("name") || (this.#target ? nameOf(classOf(this.getComputedType())) : "");
706
705
  }
707
706
  clone() {
708
707
  return new JsonSchema(this);
709
708
  }
710
709
  }
711
- _JsonSchema_nullable = new WeakMap(), _JsonSchema_genericLabels = new WeakMap(), _JsonSchema_nestedGenerics = new WeakMap(), _JsonSchema_alias = new WeakMap(), _JsonSchema_itemSchema = new WeakMap(), _JsonSchema_target = new WeakMap(), _JsonSchema_isGeneric = new WeakMap(), _JsonSchema_isCollection = new WeakMap(), _JsonSchema_ref = new WeakMap();
712
710
  //# sourceMappingURL=JsonSchema.js.map