@weclapp/sdk 2.0.0-dev.41 → 2.0.0-dev.42
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 +22 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -458,7 +458,13 @@ const generateEntityFilterProps = (entities, enums) => {
|
|
|
458
458
|
const entityFilterProps = new Map();
|
|
459
459
|
const transformFilterProps = (props) => {
|
|
460
460
|
return props.map((prop) => {
|
|
461
|
-
if (!prop.type ||
|
|
461
|
+
if (!prop.type ||
|
|
462
|
+
enums.has(prop.type) ||
|
|
463
|
+
prop.type === 'string' ||
|
|
464
|
+
prop.type === 'number' ||
|
|
465
|
+
prop.type === 'boolean' ||
|
|
466
|
+
prop.type.endsWith('[]') ||
|
|
467
|
+
prop.type === '{}') {
|
|
462
468
|
return prop;
|
|
463
469
|
}
|
|
464
470
|
return { ...prop, type: `${pascalCase(prop.type)}_${FILTER_PROPS_SUFFIX}` };
|
|
@@ -636,7 +642,8 @@ const generateCountEndpoint = ({ aliases, path, target, endpoint }) => {
|
|
|
636
642
|
const functionTypeSource = generateArrowFunctionType({
|
|
637
643
|
type: functionTypeName,
|
|
638
644
|
params: [
|
|
639
|
-
`query${parametersType.isFullyOptional() ? '?' : ''}: CountQuery<${filterTypeName}>${path.parameters?.length ? ' & ' + parametersTypeName : ''}`,
|
|
645
|
+
`query${parametersType.isFullyOptional() ? '?' : ''}: CountQuery<${filterTypeName}>${path.parameters?.length ? ' & ' + parametersTypeName : ''}`,
|
|
646
|
+
'requestOptions?: RequestOptions'
|
|
640
647
|
],
|
|
641
648
|
returns: `${resolveResponseType(target)}<number>`
|
|
642
649
|
});
|
|
@@ -723,7 +730,11 @@ const generateGenericEndpoint = (suffix) => ({ target, method, path, endpoint })
|
|
|
723
730
|
const responseBody = generateResponseBodyType(path);
|
|
724
731
|
const functionTypeSource = generateArrowFunctionType({
|
|
725
732
|
type: functionTypeName,
|
|
726
|
-
params: [
|
|
733
|
+
params: [
|
|
734
|
+
...(hasId ? ['id: string'] : []),
|
|
735
|
+
`query${params.isFullyOptional() ? '?' : ''}: ${entityQuery}`,
|
|
736
|
+
'requestOptions?: RequestOptions'
|
|
737
|
+
],
|
|
727
738
|
returns: `${resolveResponseType(target)}<${wrapBody(responseBody, target).toString()}>`
|
|
728
739
|
});
|
|
729
740
|
const functionSource = generateArrowFunction({
|
|
@@ -907,7 +918,12 @@ const generateUpdateEndpoint = ({ target, path, endpoint }) => {
|
|
|
907
918
|
const functionTypeName = `${pascalCase(endpoint.service)}Service_${pascalCase(functionName)}`;
|
|
908
919
|
const functionTypeSource = generateArrowFunctionType({
|
|
909
920
|
type: functionTypeName,
|
|
910
|
-
params: [
|
|
921
|
+
params: [
|
|
922
|
+
'id: string',
|
|
923
|
+
`data: DeepPartial<${generateRequestBodyType(path).toString()}>`,
|
|
924
|
+
'options?: UpdateQuery',
|
|
925
|
+
'requestOptions?: RequestOptions'
|
|
926
|
+
],
|
|
911
927
|
returns: `${resolveResponseType(target)}<${generateResponseBodyType(path).toString()}>`
|
|
912
928
|
});
|
|
913
929
|
const functionSource = generateArrowFunction({
|
|
@@ -987,8 +1003,8 @@ const generateServices = (paths, entities, aliases, options) => {
|
|
|
987
1003
|
for (const { path, endpoint } of paths) {
|
|
988
1004
|
const generator = generators[endpoint.type];
|
|
989
1005
|
for (const [method, config] of Object.entries(path)) {
|
|
990
|
-
if ((method === 'get' && endpoint.type === WeclappEndpointType.ENTITY && !options.generateUnique)
|
|
991
|
-
|
|
1006
|
+
if ((method === 'get' && endpoint.type === WeclappEndpointType.ENTITY && !options.generateUnique) ||
|
|
1007
|
+
(method === 'post' && (endpoint.type === WeclappEndpointType.COUNT || endpoint.path.endsWith('query')))) {
|
|
992
1008
|
// Skip unique endpoints if generateUnique option is not set or if POST is used for filter queries
|
|
993
1009
|
continue;
|
|
994
1010
|
}
|