mobx-tanstack-query-api 0.38.2 → 0.39.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.
- package/cli.cjs +69 -54
- package/cli.cjs.map +1 -1
- package/cli.d.ts +15 -2
- package/cli.js +69 -54
- package/cli.js.map +1 -1
- package/package.json +2 -2
package/cli.cjs
CHANGED
|
@@ -913,7 +913,26 @@ const newEndpointTmpl = ({
|
|
|
913
913
|
openApiComponentsParameters: swaggerSchema?.components?.parameters ?? void 0,
|
|
914
914
|
queryParamName: queryName
|
|
915
915
|
}) : null;
|
|
916
|
-
const
|
|
916
|
+
const appendRuleOpt = zodContractsIsObject && zodContracts.appendRule != null ? zodContracts.appendRule : null;
|
|
917
|
+
const routeInfoForAppend = contractsVarName != null ? {
|
|
918
|
+
operationId: raw.operationId ?? "",
|
|
919
|
+
path: path2,
|
|
920
|
+
method,
|
|
921
|
+
contractName: contractsVarName
|
|
922
|
+
} : null;
|
|
923
|
+
const contractsLine = (() => {
|
|
924
|
+
if (contractsVarName == null) return "";
|
|
925
|
+
if (typeof appendRuleOpt === "string")
|
|
926
|
+
return `contracts: ${appendRuleOpt} ? ${contractsVarName} : undefined,`;
|
|
927
|
+
if (typeof appendRuleOpt === "function" && routeInfoForAppend) {
|
|
928
|
+
const include = appendRuleOpt(
|
|
929
|
+
routeInfoForAppend.contractName,
|
|
930
|
+
routeInfoForAppend
|
|
931
|
+
);
|
|
932
|
+
return include ? `contracts: ${contractsVarName},` : "contracts: undefined,";
|
|
933
|
+
}
|
|
934
|
+
return `contracts: ${contractsVarName},`;
|
|
935
|
+
})();
|
|
917
936
|
const validateContractsLine = (() => {
|
|
918
937
|
if (validateOpt === void 0) return "";
|
|
919
938
|
if (typeof validateOpt === "string")
|
|
@@ -1491,12 +1510,25 @@ const generateApi = async (params) => {
|
|
|
1491
1510
|
sortTypes: true,
|
|
1492
1511
|
templates: paths.templates.toString(),
|
|
1493
1512
|
primitiveTypeConstructs: (constructs) => {
|
|
1494
|
-
|
|
1513
|
+
const result = {
|
|
1495
1514
|
...constructs,
|
|
1496
1515
|
object: () => `Record<string, any>`,
|
|
1497
|
-
float: () => `number
|
|
1498
|
-
...params.otherCodegenParams?.primitiveTypeConstructs?.(constructs)
|
|
1516
|
+
float: () => `number`
|
|
1499
1517
|
};
|
|
1518
|
+
if (params.otherCodegenParams?.primitiveTypeConstructs) {
|
|
1519
|
+
if (typeof params.otherCodegenParams?.primitiveTypeConstructs === "function") {
|
|
1520
|
+
Object.assign(
|
|
1521
|
+
result,
|
|
1522
|
+
params.otherCodegenParams.primitiveTypeConstructs(result)
|
|
1523
|
+
);
|
|
1524
|
+
} else {
|
|
1525
|
+
Object.assign(
|
|
1526
|
+
result,
|
|
1527
|
+
params.otherCodegenParams.primitiveTypeConstructs
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
return result;
|
|
1500
1532
|
},
|
|
1501
1533
|
requestOptions: params.fetchSchemaRequestOptions,
|
|
1502
1534
|
...params.otherCodegenParams
|
|
@@ -1510,6 +1542,34 @@ const generateApi = async (params) => {
|
|
|
1510
1542
|
);
|
|
1511
1543
|
return;
|
|
1512
1544
|
}
|
|
1545
|
+
const prepareConfig = (config) => {
|
|
1546
|
+
config.routes.combined?.forEach((routeInfo) => {
|
|
1547
|
+
routeInfo.routes.sort(
|
|
1548
|
+
(routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage)
|
|
1549
|
+
);
|
|
1550
|
+
});
|
|
1551
|
+
return params.otherCodegenParams?.hooks?.onPrepareConfig?.(config);
|
|
1552
|
+
};
|
|
1553
|
+
const formatRouteName = (routeInfo, usageRouteName) => {
|
|
1554
|
+
let formattedRouteName = usageRouteName;
|
|
1555
|
+
if (params.addPathSegmentToRouteName === true || typeof params.addPathSegmentToRouteName === "number") {
|
|
1556
|
+
const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === "number" ? params.addPathSegmentToRouteName : 0;
|
|
1557
|
+
const pathSegments = routeInfo.route.split("/").filter(Boolean);
|
|
1558
|
+
const { _: _2 } = codegenProcess.getRenderTemplateData().utils;
|
|
1559
|
+
formattedRouteName = _2.camelCase(
|
|
1560
|
+
`${pathSegments[pathSegmentForSuffix] || ""}_${formattedRouteName}`
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
const endpointName = formattedRouteName;
|
|
1564
|
+
const resultRouteName = params?.formatEndpointName?.(endpointName, routeInfo) ?? swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(
|
|
1565
|
+
routeInfo,
|
|
1566
|
+
endpointName
|
|
1567
|
+
) ?? endpointName;
|
|
1568
|
+
return params.otherCodegenParams?.hooks?.onFormatRouteName?.(
|
|
1569
|
+
routeInfo,
|
|
1570
|
+
resultRouteName
|
|
1571
|
+
) ?? resultRouteName;
|
|
1572
|
+
};
|
|
1513
1573
|
const inputToCodegenInput = (input) => {
|
|
1514
1574
|
const inputData = {};
|
|
1515
1575
|
if (typeof input === "string") {
|
|
@@ -1526,32 +1586,11 @@ const generateApi = async (params) => {
|
|
|
1526
1586
|
...swaggerTypescriptApiCodegenBaseParams,
|
|
1527
1587
|
...inputToCodegenInput(params.mixinInput),
|
|
1528
1588
|
hooks: {
|
|
1529
|
-
onInit: (configuration) => {
|
|
1589
|
+
onInit: (configuration, codegenProcess2) => {
|
|
1530
1590
|
mixinSwaggerSchema = lodashEs.cloneDeep(configuration.swaggerSchema);
|
|
1531
1591
|
},
|
|
1532
|
-
onPrepareConfig:
|
|
1533
|
-
|
|
1534
|
-
routeInfo.routes.sort(
|
|
1535
|
-
(routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage)
|
|
1536
|
-
);
|
|
1537
|
-
});
|
|
1538
|
-
},
|
|
1539
|
-
onFormatRouteName: (routeInfo, usageRouteName) => {
|
|
1540
|
-
let formattedRouteName = usageRouteName;
|
|
1541
|
-
if (params.addPathSegmentToRouteName === true || typeof params.addPathSegmentToRouteName === "number") {
|
|
1542
|
-
const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === "number" ? params.addPathSegmentToRouteName : 0;
|
|
1543
|
-
const pathSegments = routeInfo.route.split("/").filter(Boolean);
|
|
1544
|
-
const { _: _2 } = codegenProcess.getRenderTemplateData().utils;
|
|
1545
|
-
formattedRouteName = _2.camelCase(
|
|
1546
|
-
`${pathSegments[pathSegmentForSuffix] || ""}_${formattedRouteName}`
|
|
1547
|
-
);
|
|
1548
|
-
}
|
|
1549
|
-
const endpointName = formattedRouteName;
|
|
1550
|
-
return params?.formatEndpointName?.(endpointName, routeInfo) ?? swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(
|
|
1551
|
-
routeInfo,
|
|
1552
|
-
endpointName
|
|
1553
|
-
) ?? endpointName;
|
|
1554
|
-
}
|
|
1592
|
+
onPrepareConfig: prepareConfig,
|
|
1593
|
+
onFormatRouteName: formatRouteName
|
|
1555
1594
|
}
|
|
1556
1595
|
});
|
|
1557
1596
|
}
|
|
@@ -1577,32 +1616,8 @@ const generateApi = async (params) => {
|
|
|
1577
1616
|
codeGenProcessFromInit
|
|
1578
1617
|
);
|
|
1579
1618
|
},
|
|
1580
|
-
onPrepareConfig:
|
|
1581
|
-
|
|
1582
|
-
routeInfo.routes.sort(
|
|
1583
|
-
(routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage)
|
|
1584
|
-
);
|
|
1585
|
-
});
|
|
1586
|
-
return swaggerTypescriptApiCodegenBaseParams?.hooks?.onPrepareConfig?.(
|
|
1587
|
-
config
|
|
1588
|
-
);
|
|
1589
|
-
},
|
|
1590
|
-
onFormatRouteName: (routeInfo, usageRouteName) => {
|
|
1591
|
-
let formattedRouteName = usageRouteName;
|
|
1592
|
-
if (params.addPathSegmentToRouteName === true || typeof params.addPathSegmentToRouteName === "number") {
|
|
1593
|
-
const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === "number" ? params.addPathSegmentToRouteName : 0;
|
|
1594
|
-
const pathSegments = routeInfo.route.split("/").filter(Boolean);
|
|
1595
|
-
const { _: _2 } = codegenProcess.getRenderTemplateData().utils;
|
|
1596
|
-
formattedRouteName = _2.camelCase(
|
|
1597
|
-
`${pathSegments[pathSegmentForSuffix] || ""}_${formattedRouteName}`
|
|
1598
|
-
);
|
|
1599
|
-
}
|
|
1600
|
-
const endpointName = formattedRouteName;
|
|
1601
|
-
return params?.formatEndpointName?.(endpointName, routeInfo) ?? swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(
|
|
1602
|
-
routeInfo,
|
|
1603
|
-
endpointName
|
|
1604
|
-
) ?? endpointName;
|
|
1605
|
-
}
|
|
1619
|
+
onPrepareConfig: prepareConfig,
|
|
1620
|
+
onFormatRouteName: formatRouteName
|
|
1606
1621
|
}
|
|
1607
1622
|
});
|
|
1608
1623
|
const utils = codegenProcess.getRenderTemplateData().utils;
|