@rexeus/typeweaver-types 0.6.3 → 0.6.5

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 CHANGED
@@ -68,22 +68,34 @@ var RequestGenerator = class {
68
68
  const ownErrorResponses = [];
69
69
  const sharedSuccessResponses = [];
70
70
  const sharedErrorResponses = [];
71
+ const entityErrorResponses = [];
71
72
  for (const response of responses) {
72
73
  const { statusCode, name, isReference } = response;
73
74
  if (isReference) {
74
75
  const sharedResponse = context.resources.sharedResponseResources.find((resource) => resource.name === name);
75
- let responsePath;
76
- if (!sharedResponse) {
76
+ if (sharedResponse) {
77
+ const responsePath = _rexeus_typeweaver_gen.Path.relative(outputDir, `${sharedResponse.outputDir}/${node_path.default.basename(sharedResponse.outputFileName, ".ts")}`);
78
+ if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push({
79
+ name,
80
+ path: responsePath
81
+ });
82
+ else sharedErrorResponses.push({
83
+ name,
84
+ path: responsePath
85
+ });
86
+ } else {
77
87
  const entityResponse = (context.resources.entityResources[operationResource.entityName]?.responses)?.find((r) => r.name === name);
78
- if (entityResponse) responsePath = _rexeus_typeweaver_gen.Path.relative(outputDir, `${entityResponse.outputDir}/${node_path.default.basename(entityResponse.outputFileName, ".ts")}`);
79
- else throw new Error(`Shared response '${response.name}' not found in shared or entity resources`);
80
- } else responsePath = _rexeus_typeweaver_gen.Path.relative(outputDir, `${sharedResponse.outputDir}/${node_path.default.basename(sharedResponse.outputFileName, ".ts")}`);
81
- const assembledResponse = {
82
- name,
83
- path: responsePath
84
- };
85
- if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push(assembledResponse);
86
- else sharedErrorResponses.push(assembledResponse);
88
+ if (!entityResponse) throw new Error(`Shared response '${response.name}' not found in shared or entity resources`);
89
+ const responsePath = _rexeus_typeweaver_gen.Path.relative(outputDir, `${entityResponse.outputDir}/${node_path.default.basename(entityResponse.outputFileName, ".ts")}`);
90
+ if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push({
91
+ name,
92
+ path: responsePath
93
+ });
94
+ else entityErrorResponses.push({
95
+ name,
96
+ path: responsePath
97
+ });
98
+ }
87
99
  continue;
88
100
  }
89
101
  const assembledResponse = { name };
@@ -104,9 +116,10 @@ var RequestGenerator = class {
104
116
  ownErrorResponses,
105
117
  sharedSuccessResponses,
106
118
  sharedErrorResponses,
119
+ entityErrorResponses,
107
120
  responseFile: _rexeus_typeweaver_gen.Path.relative(outputDir, `${outputDir}/${node_path.default.basename(outputResponseFileName, ".ts")}`),
108
121
  responseValidationFile: _rexeus_typeweaver_gen.Path.relative(outputDir, `${outputDir}/${node_path.default.basename(outputResponseValidationFileName, ".ts")}`),
109
- hasErrorResponses: ownErrorResponses.length > 0 || sharedErrorResponses.length > 0,
122
+ hasErrorResponses: ownErrorResponses.length > 0 || entityErrorResponses.length > 0 || sharedErrorResponses.length > 0,
110
123
  hasSuccessResponses: ownSuccessResponses.length > 0 || sharedSuccessResponses.length > 0
111
124
  });
112
125
  const relativePath = node_path.default.relative(context.outputDir, operationResource.outputRequestFile);
@@ -13011,6 +13024,7 @@ var ResponseGenerator = class {
13011
13024
  const { responses, operationId } = definition;
13012
13025
  const pascalCaseOperationId = case$1.default.pascal(operationId);
13013
13026
  const ownResponses = [];
13027
+ const entityResponses = [];
13014
13028
  const sharedResponses = [];
13015
13029
  for (const response of responses) {
13016
13030
  const { statusCode, name, body, header, isReference } = response;
@@ -13023,7 +13037,7 @@ var ResponseGenerator = class {
13023
13037
  else {
13024
13038
  const entityResponse = (context.resources.entityResources[resource.entityName]?.responses)?.find((r) => r.name === name);
13025
13039
  if (!entityResponse) throw new Error(`Response ${name} not found in shared or entity-specific responses`);
13026
- sharedResponses.push({
13040
+ entityResponses.push({
13027
13041
  name,
13028
13042
  path: _rexeus_typeweaver_gen.Path.relative(outputDir, `${entityResponse.outputDir}/${node_path.default.basename(entityResponse.outputFileName, ".ts")}`)
13029
13043
  });
@@ -13043,6 +13057,7 @@ var ResponseGenerator = class {
13043
13057
  pascalCaseOperationId,
13044
13058
  coreDir: context.coreDir,
13045
13059
  ownResponses,
13060
+ entityResponses,
13046
13061
  sharedResponses,
13047
13062
  responseFile: _rexeus_typeweaver_gen.Path.relative(outputDir, `${outputDir}/${node_path.default.basename(outputResponseFileName, ".ts")}`),
13048
13063
  sourcePath: _rexeus_typeweaver_gen.Path.relative(outputDir, `${sourceDir}/${node_path.default.relative(sourceDir, sourceFile).replace(/\.ts$/, "")}`)
package/dist/index.mjs CHANGED
@@ -43,22 +43,34 @@ var RequestGenerator = class {
43
43
  const ownErrorResponses = [];
44
44
  const sharedSuccessResponses = [];
45
45
  const sharedErrorResponses = [];
46
+ const entityErrorResponses = [];
46
47
  for (const response of responses) {
47
48
  const { statusCode, name, isReference } = response;
48
49
  if (isReference) {
49
50
  const sharedResponse = context.resources.sharedResponseResources.find((resource) => resource.name === name);
50
- let responsePath;
51
- if (!sharedResponse) {
51
+ if (sharedResponse) {
52
+ const responsePath = Path.relative(outputDir, `${sharedResponse.outputDir}/${path.basename(sharedResponse.outputFileName, ".ts")}`);
53
+ if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push({
54
+ name,
55
+ path: responsePath
56
+ });
57
+ else sharedErrorResponses.push({
58
+ name,
59
+ path: responsePath
60
+ });
61
+ } else {
52
62
  const entityResponse = (context.resources.entityResources[operationResource.entityName]?.responses)?.find((r) => r.name === name);
53
- if (entityResponse) responsePath = Path.relative(outputDir, `${entityResponse.outputDir}/${path.basename(entityResponse.outputFileName, ".ts")}`);
54
- else throw new Error(`Shared response '${response.name}' not found in shared or entity resources`);
55
- } else responsePath = Path.relative(outputDir, `${sharedResponse.outputDir}/${path.basename(sharedResponse.outputFileName, ".ts")}`);
56
- const assembledResponse = {
57
- name,
58
- path: responsePath
59
- };
60
- if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push(assembledResponse);
61
- else sharedErrorResponses.push(assembledResponse);
63
+ if (!entityResponse) throw new Error(`Shared response '${response.name}' not found in shared or entity resources`);
64
+ const responsePath = Path.relative(outputDir, `${entityResponse.outputDir}/${path.basename(entityResponse.outputFileName, ".ts")}`);
65
+ if (statusCode >= 200 && statusCode < 300) sharedSuccessResponses.push({
66
+ name,
67
+ path: responsePath
68
+ });
69
+ else entityErrorResponses.push({
70
+ name,
71
+ path: responsePath
72
+ });
73
+ }
62
74
  continue;
63
75
  }
64
76
  const assembledResponse = { name };
@@ -79,9 +91,10 @@ var RequestGenerator = class {
79
91
  ownErrorResponses,
80
92
  sharedSuccessResponses,
81
93
  sharedErrorResponses,
94
+ entityErrorResponses,
82
95
  responseFile: Path.relative(outputDir, `${outputDir}/${path.basename(outputResponseFileName, ".ts")}`),
83
96
  responseValidationFile: Path.relative(outputDir, `${outputDir}/${path.basename(outputResponseValidationFileName, ".ts")}`),
84
- hasErrorResponses: ownErrorResponses.length > 0 || sharedErrorResponses.length > 0,
97
+ hasErrorResponses: ownErrorResponses.length > 0 || entityErrorResponses.length > 0 || sharedErrorResponses.length > 0,
85
98
  hasSuccessResponses: ownSuccessResponses.length > 0 || sharedSuccessResponses.length > 0
86
99
  });
87
100
  const relativePath = path.relative(context.outputDir, operationResource.outputRequestFile);
@@ -12986,6 +12999,7 @@ var ResponseGenerator = class {
12986
12999
  const { responses, operationId } = definition;
12987
13000
  const pascalCaseOperationId = Case.pascal(operationId);
12988
13001
  const ownResponses = [];
13002
+ const entityResponses = [];
12989
13003
  const sharedResponses = [];
12990
13004
  for (const response of responses) {
12991
13005
  const { statusCode, name, body, header, isReference } = response;
@@ -12998,7 +13012,7 @@ var ResponseGenerator = class {
12998
13012
  else {
12999
13013
  const entityResponse = (context.resources.entityResources[resource.entityName]?.responses)?.find((r) => r.name === name);
13000
13014
  if (!entityResponse) throw new Error(`Response ${name} not found in shared or entity-specific responses`);
13001
- sharedResponses.push({
13015
+ entityResponses.push({
13002
13016
  name,
13003
13017
  path: Path.relative(outputDir, `${entityResponse.outputDir}/${path.basename(entityResponse.outputFileName, ".ts")}`)
13004
13018
  });
@@ -13018,6 +13032,7 @@ var ResponseGenerator = class {
13018
13032
  pascalCaseOperationId,
13019
13033
  coreDir: context.coreDir,
13020
13034
  ownResponses,
13035
+ entityResponses,
13021
13036
  sharedResponses,
13022
13037
  responseFile: Path.relative(outputDir, `${outputDir}/${path.basename(outputResponseFileName, ".ts")}`),
13023
13038
  sourcePath: Path.relative(outputDir, `${sourceDir}/${path.relative(sourceDir, sourceFile).replace(/\.ts$/, "")}`)