@weclapp/sdk 2.0.0-dev.53 → 2.0.0-dev.55
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 +8 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -821,6 +821,8 @@ const generateRemoveEndpoint = ({ endpoint, options }) => {
|
|
|
821
821
|
};
|
|
822
822
|
};
|
|
823
823
|
|
|
824
|
+
const generateTupleArray = (values) => `(${concat(values.map(generateString), ' | ')})[]`;
|
|
825
|
+
|
|
824
826
|
const excludedParameters = [
|
|
825
827
|
'page',
|
|
826
828
|
'pageSize',
|
|
@@ -830,8 +832,9 @@ const excludedParameters = [
|
|
|
830
832
|
'includeReferencedEntities',
|
|
831
833
|
'additionalProperties'
|
|
832
834
|
];
|
|
833
|
-
const resolveAdditionalPropertiesSchema = ({ responses }) => {
|
|
834
|
-
const
|
|
835
|
+
const resolveAdditionalPropertiesSchema = ({ responses }, contextResponses) => {
|
|
836
|
+
const response = resolveResponsesObject(responses);
|
|
837
|
+
const body = response && isReferenceObject(response) ? contextResponses.get(getRefName(response)) : response;
|
|
835
838
|
if (isResponseObject(body)) {
|
|
836
839
|
const schema = body?.content?.['application/json']?.schema;
|
|
837
840
|
if (isObjectSchemaObject(schema)) {
|
|
@@ -901,14 +904,14 @@ const generateSomeEndpoint = ({ endpoint, operationObject, entities, context, op
|
|
|
901
904
|
const filterTypeSource = generateInterfaceType(filterTypeName, [], [`${relatedEntity.filterInterfaceName}`]);
|
|
902
905
|
const referencesTypeName = `${functionTypeName}_References`;
|
|
903
906
|
const referencesTypeSource = generateInterfaceType(referencesTypeName, resolveReferences(endpoint.service, entities));
|
|
904
|
-
const
|
|
905
|
-
const
|
|
907
|
+
const additionalPropertiesSchema = resolveAdditionalPropertiesSchema(operationObject, context.responses);
|
|
908
|
+
const additionalPropertyTypeName = `${functionTypeName}_AdditionalPropertyNames`;
|
|
909
|
+
const additionalPropertyTypeSource = generateType(additionalPropertyTypeName, additionalPropertiesSchema ? generateTupleArray(Object.keys(additionalPropertiesSchema?.properties)) : '[]');
|
|
906
910
|
const queryTypeName = `${functionTypeName}_Query`;
|
|
907
911
|
const queryTypeSource = generateType(queryTypeName, `SomeQuery<${relatedEntity.interfaceName}, ${filterTypeName}, ${referencesTypeName}, ${additionalPropertyTypeName}> & ${parametersTypeName}`);
|
|
908
912
|
const referencedEntitiesTypeName = `${functionTypeName}_ReferencedEntities`;
|
|
909
913
|
const referencedEntitiesTypeSource = generateInterfaceType(referencedEntitiesTypeName, resolveReferencedEntities(endpoint.service, entities));
|
|
910
914
|
const additionalPropertiesTypeName = `${functionTypeName}_AdditionalProperties`;
|
|
911
|
-
const additionalPropertiesSchema = resolveAdditionalPropertiesSchema(operationObject);
|
|
912
915
|
const additionalPropertiesTypeSource = generateType(additionalPropertiesTypeName, additionalPropertiesSchema ? convertToTypeScriptType(additionalPropertiesSchema).toString() : '{}');
|
|
913
916
|
const functionTypeSource = generateArrowFunctionType({
|
|
914
917
|
type: functionTypeName,
|