routesync 1.0.23 → 1.0.25
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/cli.js +34 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9108,22 +9108,42 @@ var NextActionGenerator = class {
|
|
|
9108
9108
|
const ContractName = `${TitleCaseGroup}${TitleCaseAction}Contract`;
|
|
9109
9109
|
const hasBody = route.schema && route.schema.rules && Object.keys(route.schema.rules).length > 0;
|
|
9110
9110
|
const hasQuery = route.method === "GET";
|
|
9111
|
-
const hasParams = route.path.includes("
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
else if (hasQuery) payloadType = `${ContractName}['request']['query']`;
|
|
9115
|
-
else if (hasParams) payloadType = `${ContractName}['request']['params']`;
|
|
9116
|
-
const payloadParam = hasBody || hasQuery || hasParams ? `payload: ${payloadType}` : `payload?: unknown`;
|
|
9117
|
-
lines.push(`export async function ${actionName}Action(${payloadParam}) {`);
|
|
9111
|
+
const hasParams = route.path.includes("{");
|
|
9112
|
+
const count = (hasBody ? 1 : 0) + (hasQuery ? 1 : 0) + (hasParams ? 1 : 0);
|
|
9113
|
+
let payloadParam = "";
|
|
9118
9114
|
const args = [];
|
|
9119
|
-
if (
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9115
|
+
if (count > 1) {
|
|
9116
|
+
const props = [];
|
|
9117
|
+
if (hasParams) {
|
|
9118
|
+
props.push(`params: ${ContractName}['request']['params']`);
|
|
9119
|
+
args.push(`params: payload.params`);
|
|
9120
|
+
}
|
|
9121
|
+
if (hasQuery) {
|
|
9122
|
+
props.push(`query?: ${ContractName}['request']['query']`);
|
|
9123
|
+
args.push(`query: payload.query`);
|
|
9124
|
+
}
|
|
9125
|
+
if (hasBody) {
|
|
9126
|
+
props.push(`body: ${ContractName}['request']['body']`);
|
|
9127
|
+
args.push(`body: payload.body`);
|
|
9128
|
+
}
|
|
9129
|
+
payloadParam = `payload: { ${props.join(", ")} }`;
|
|
9130
|
+
} else if (count === 1) {
|
|
9131
|
+
if (hasParams) {
|
|
9132
|
+
payloadParam = `payload: ${ContractName}['request']['params']`;
|
|
9133
|
+
args.push(`params: payload`);
|
|
9134
|
+
}
|
|
9135
|
+
if (hasQuery) {
|
|
9136
|
+
payloadParam = `payload?: ${ContractName}['request']['query']`;
|
|
9137
|
+
args.push(`query: payload`);
|
|
9138
|
+
}
|
|
9139
|
+
if (hasBody) {
|
|
9140
|
+
payloadParam = `payload: ${ContractName}['request']['body']`;
|
|
9141
|
+
args.push(`body: payload`);
|
|
9142
|
+
}
|
|
9143
|
+
} else {
|
|
9144
|
+
payloadParam = `payload?: unknown`;
|
|
9126
9145
|
}
|
|
9146
|
+
lines.push(`export async function ${actionName}Action(${payloadParam}) {`);
|
|
9127
9147
|
if (route.auth) {
|
|
9128
9148
|
args.push(`headers: await getAuthHeaders()`);
|
|
9129
9149
|
}
|