@povio/openapi-codegen-cli 4.0.0-rc.3 → 4.0.0-rc.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.
Files changed (29) hide show
  1. package/README.md +38 -11
  2. package/dist/{config-CiLFKLAY.d.mts → config-D8ANLlqk.d.mts} +1 -1
  3. package/dist/config.d.mts +2 -2
  4. package/dist/{generate.runner-Sh0Ps6AW.mjs → generate.runner-LDL6Lbgl.mjs} +8 -110
  5. package/dist/{generate.utils-BJxdEik8.cjs → generate.utils-BFeGvk98.cjs} +4 -269
  6. package/dist/{generateCodeFromOpenAPIDoc-B8FAsxWE.mjs → generateCodeFromOpenAPIDoc-B7VWwIbb.mjs} +198 -502
  7. package/dist/{generateCodeFromOpenAPIDoc-Bbi8fYi2.cjs → generateCodeFromOpenAPIDoc-CpAdx6I3.cjs} +241 -528
  8. package/dist/generator.d.mts +1 -1
  9. package/dist/generator.mjs +3 -3
  10. package/dist/{getDataFromOpenAPIDoc-CXYNMMMt.mjs → getDataFromOpenAPIDoc-C0iehdg8.mjs} +19 -2
  11. package/dist/index.d.mts +4 -4
  12. package/dist/metro.cjs +4 -3
  13. package/dist/metro.d.mts +3 -3
  14. package/dist/metro.mjs +1 -1
  15. package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
  16. package/dist/openapi-codegen-native-linux-x64.node +0 -0
  17. package/dist/openapi-codegen-native-win32-x64.node +0 -0
  18. package/dist/{openapi-codegen.runner-bJTFHTdn.mjs → openapi-codegen.runner-CmW9oZdT.mjs} +1 -1
  19. package/dist/{openapi-source.runner-DIOvAX_R.d.mts → openapi-source.runner-DES1kzvS.d.mts} +1 -1
  20. package/dist/{options-X0zju7gw.d.mts → options-B7-eMFcv.d.mts} +4 -10
  21. package/dist/query.d.mts +3 -3
  22. package/dist/queryConfig.context-DwVQWbtL.d.mts +71 -0
  23. package/dist/sh.mjs +8 -8
  24. package/dist/tiny.d.mts +1 -1
  25. package/dist/{useMutationEffects-CJJuL9Ak.d.mts → useMutationEffects-I4y5WUkj.d.mts} +1 -1
  26. package/dist/vite.d.mts +3 -3
  27. package/dist/vite.mjs +1 -1
  28. package/package.json +4 -4
  29. package/dist/queryConfig.context-DjhzewdL.d.mts +0 -56
@@ -94,16 +94,13 @@ const DEFAULT_GENERATE_OPTIONS = {
94
94
  ["acl"]: {
95
95
  outputFileNameSuffix: "acl",
96
96
  namespaceSuffix: "Acl"
97
- },
98
- ["configs"]: {
99
- outputFileNameSuffix: "configs",
100
- namespaceSuffix: "Configs"
101
97
  }
102
98
  },
103
99
  baseUrl: "",
104
100
  modelsOnly: false,
105
101
  standalone: false,
106
102
  compileSchemas: false,
103
+ lazySchemas: false,
107
104
  schemaSuffix: SCHEMA_SUFFIX,
108
105
  enumSuffix: ENUM_SUFFIX,
109
106
  modelsInCommon: false,
@@ -138,12 +135,7 @@ const DEFAULT_GENERATE_OPTIONS = {
138
135
  checkAcl: true,
139
136
  abilityContextGenericAppAbilities: false,
140
137
  abilityContextImportPath: "",
141
- aclCheckImportPath: "@povio/openapi-codegen-cli/acl",
142
- builderConfigs: false,
143
- filterParamName: "filter",
144
- dataResponseParamNames: ["data", "items"],
145
- dynamicInputsImportPath: "@povio/ui",
146
- dynamicColumnsImportPath: "@povio/ui"
138
+ aclCheckImportPath: "@povio/openapi-codegen-cli/acl"
147
139
  };
148
140
  //#endregion
149
141
  //#region src/generators/utils/object.utils.ts
@@ -401,10 +393,6 @@ const ERROR_HANDLERS = {
401
393
  SharedErrorHandler: "SharedErrorHandler"
402
394
  };
403
395
  ERROR_HANDLERS.ErrorHandler, ERROR_HANDLERS.SharedErrorHandler;
404
- const BUILDERS_UTILS = {
405
- dynamicInputs: "dynamicInputs",
406
- dynamicColumns: "dynamicColumns"
407
- };
408
396
  const QUERY_MODULE_ENUM = "QueryModule";
409
397
  const QUERY_MODULES_FILE = {
410
398
  fileName: "queryModules",
@@ -985,33 +973,6 @@ function getRequestConfigTypeName(restClient) {
985
973
  return restClient === "native" ? NATIVE_REQUEST_CONFIG_TYPE : AXIOS_REQUEST_CONFIG_TYPE;
986
974
  }
987
975
  //#endregion
988
- //#region src/generators/utils/endpoint.utils.ts
989
- const isGetEndpoint = (endpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET;
990
- const isPaginatedGetEndpoint = (endpoint, options) => isGetEndpoint(endpoint) && Object.values(options.infiniteQueryParamNames).every((infiniteQueryParam) => endpoint.parameters.some((param) => param.name === infiniteQueryParam && param.type === "Query"));
991
- const isReadAllEndpoint = (endpoint, options) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET && !isPathSegmentParam(endpoint.pathSegments.at(-1)) && isPaginatedGetEndpoint(endpoint, options);
992
- const isReadEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.GET && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
993
- const isCreateEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.POST && hasMatchingPathWithoutTrailingParam(endpoint, readAllEndpoint);
994
- const isUpdateEndpoint = (endpoint, readAllEndpoint) => [openapi_types.OpenAPIV3.HttpMethods.PUT, openapi_types.OpenAPIV3.HttpMethods.PATCH].includes(endpoint.method) && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
995
- const isDeleteEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.DELETE && hasMatchingPathWithTrailingParam(endpoint, readAllEndpoint);
996
- const isBulkDeleteEndpoint = (endpoint, readAllEndpoint) => endpoint.method === openapi_types.OpenAPIV3.HttpMethods.DELETE && hasMatchingPathWithoutTrailingParam(endpoint, readAllEndpoint);
997
- const getPathSegments = (path) => path.split("/").filter(Boolean);
998
- const isPathSegmentParam = (pathSegment) => pathSegment?.startsWith(":");
999
- const hasMatchingPath = (endpoint, readAllEndpoint) => readAllEndpoint.pathSegments.every((segment, index) => isPathSegmentParam(segment) && isPathSegmentParam(endpoint.pathSegments[index]) || segment === endpoint.pathSegments[index]);
1000
- const hasMatchingPathWithoutTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length === readAllEndpoint.pathSegments.length && hasMatchingPath(endpoint, readAllEndpoint);
1001
- const hasMatchingPathWithTrailingParam = (endpoint, readAllEndpoint) => endpoint.pathSegments.length - 1 === readAllEndpoint.pathSegments.length && isPathSegmentParam(endpoint.pathSegments.at(-1)) && hasMatchingPath(endpoint, readAllEndpoint);
1002
- //#endregion
1003
- //#region src/generators/utils/query.utils.ts
1004
- const isQuery = (endpoint) => isGetEndpoint(endpoint);
1005
- const isMutation = (endpoint) => !isGetEndpoint(endpoint) || !!endpoint.mediaDownload;
1006
- const isInfiniteQuery = (endpoint, options) => isPaginatedGetEndpoint(endpoint, options);
1007
- const getDestructuredVariables = (resolver, endpoint, updateQueryEndpoints) => {
1008
- const requiredUpdateQueryParams = updateQueryEndpoints.reduce((acc, updateEndpoint) => [...acc, ...mapEndpointParamsToFunctionParams(resolver, updateEndpoint, { includeOnlyRequiredParams: true }).map((param) => param.name)], []);
1009
- return mapEndpointParamsToFunctionParams(resolver, endpoint, {
1010
- includeOnlyRequiredParams: true,
1011
- excludeBodyParam: true
1012
- }).filter((param) => requiredUpdateQueryParams.includes(param.name)).map((param) => param.name);
1013
- };
1014
- //#endregion
1015
976
  //#region src/generators/utils/ts.utils.ts
1016
977
  function primitiveTypeToTsType(type) {
1017
978
  switch (type) {
@@ -1135,9 +1096,8 @@ function createEndpointConfig(endpoint) {
1135
1096
  };
1136
1097
  }
1137
1098
  /** Renders the body of a media-upload mutationFn: call the endpoint (without the file arg) to
1138
- * get upload instructions, then upload the file itself to the returned URL. Shared between
1139
- * renderMutation (*.queries.ts) and renderMutationContent (*.configs.ts / builderConfigs) so
1140
- * both mutation paths stay in sync. Lines are relative to the caller's own indent. */
1099
+ * get upload instructions, then upload the file itself to the returned URL. Lines are relative
1100
+ * to the caller's own indent. */
1141
1101
  function renderMediaUploadMutationBody({ resolver, endpointFunction, resolvedEndpointArgs }) {
1142
1102
  return [
1143
1103
  `const uploadInstructions = await ${endpointFunction}(${resolvedEndpointArgs}${resolver.options.axiosRequestConfig ? `${resolvedEndpointArgs ? ", " : ""}${AXIOS_REQUEST_CONFIG_NAME}` : ""});`,
@@ -1168,49 +1128,6 @@ function renderMediaUploadMutationBody({ resolver, endpointFunction, resolvedEnd
1168
1128
  ];
1169
1129
  }
1170
1130
  //#endregion
1171
- //#region src/generators/utils/generate/generate.query.utils.ts
1172
- const operationNameByEndpoint = /* @__PURE__ */ new WeakMap();
1173
- const capitalizedOperationNameByEndpoint = /* @__PURE__ */ new WeakMap();
1174
- function getOperationName(endpoint) {
1175
- let name = operationNameByEndpoint.get(endpoint);
1176
- if (name === void 0) {
1177
- name = snakeToCamel(endpoint.operationName);
1178
- operationNameByEndpoint.set(endpoint, name);
1179
- }
1180
- return name;
1181
- }
1182
- function getCapitalizedOperationName(endpoint) {
1183
- let name = capitalizedOperationNameByEndpoint.get(endpoint);
1184
- if (name === void 0) {
1185
- name = capitalize(getOperationName(endpoint));
1186
- capitalizedOperationNameByEndpoint.set(endpoint, name);
1187
- }
1188
- return name;
1189
- }
1190
- const getQueryName = (endpoint, mutation) => {
1191
- const addMutationSuffix = isQuery(endpoint) && isMutation(endpoint) && mutation;
1192
- return `use${getCapitalizedOperationName(endpoint)}${addMutationSuffix ? "Mutation" : ""}`;
1193
- };
1194
- const getInfiniteQueryName = (endpoint) => `use${getCapitalizedOperationName(endpoint)}Infinite`;
1195
- const getQueryOptionsName = (endpoint) => `${getOperationName(endpoint)}QueryOptions`;
1196
- const getInfiniteQueryOptionsName = (endpoint) => `${getOperationName(endpoint)}InfiniteQueryOptions`;
1197
- const getPrefetchQueryName = (endpoint) => `prefetch${getCapitalizedOperationName(endpoint)}`;
1198
- const getPrefetchInfiniteQueryName = (endpoint) => `prefetch${getCapitalizedOperationName(endpoint)}Infinite`;
1199
- const getImportedQueryName = (endpoint, options) => {
1200
- return `${options.tsNamespaces ? `${getNamespaceName({
1201
- type: "queries",
1202
- tag: getEndpointTag(endpoint, options),
1203
- options
1204
- })}.` : ""}${getQueryName(endpoint)}`;
1205
- };
1206
- const getImportedInfiniteQueryName = (endpoint, options) => {
1207
- return `${options.tsNamespaces ? `${getNamespaceName({
1208
- type: "queries",
1209
- tag: getEndpointTag(endpoint, options),
1210
- options
1211
- })}.` : ""}${getInfiniteQueryName(endpoint)}`;
1212
- };
1213
- //#endregion
1214
1131
  //#region src/generators/utils/generate/generate.imports.utils.ts
1215
1132
  function getModelsImports({ resolver, tag, zodSchemas = [], zodSchemasAsTypes = [] }) {
1216
1133
  const type = "models";
@@ -1246,26 +1163,6 @@ function getEndpointsImports({ tag, endpoints, options }) {
1246
1163
  options
1247
1164
  });
1248
1165
  }
1249
- function getQueriesImports({ tag, endpoints, options }) {
1250
- return getImports({
1251
- type: "queries",
1252
- tag,
1253
- entities: endpoints,
1254
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1255
- getEntityName: getQueryName,
1256
- options
1257
- });
1258
- }
1259
- function getInfiniteQueriesImports({ tag, endpoints, options }) {
1260
- return getImports({
1261
- type: "queries",
1262
- tag,
1263
- entities: endpoints,
1264
- getTag: (endpoint) => getEndpointTag(endpoint, options),
1265
- getEntityName: getInfiniteQueryName,
1266
- options
1267
- });
1268
- }
1269
1166
  function getAclImports({ tag, endpoints, options }) {
1270
1167
  return getImports({
1271
1168
  type: "acl",
@@ -1433,12 +1330,6 @@ Object.defineProperty(exports, "BODY_PARAMETER_NAME", {
1433
1330
  return BODY_PARAMETER_NAME;
1434
1331
  }
1435
1332
  });
1436
- Object.defineProperty(exports, "BUILDERS_UTILS", {
1437
- enumerable: true,
1438
- get: function() {
1439
- return BUILDERS_UTILS;
1440
- }
1441
- });
1442
1333
  Object.defineProperty(exports, "CONFIG_PACKAGE_IMPORT_PATH", {
1443
1334
  enumerable: true,
1444
1335
  get: function() {
@@ -1589,12 +1480,6 @@ Object.defineProperty(exports, "autocorrectRef", {
1589
1480
  return autocorrectRef;
1590
1481
  }
1591
1482
  });
1592
- Object.defineProperty(exports, "camelToSpaceSeparated", {
1593
- enumerable: true,
1594
- get: function() {
1595
- return camelToSpaceSeparated;
1596
- }
1597
- });
1598
1483
  Object.defineProperty(exports, "capitalize", {
1599
1484
  enumerable: true,
1600
1485
  get: function() {
@@ -1703,12 +1588,6 @@ Object.defineProperty(exports, "getBodyZodSchemaName", {
1703
1588
  return getBodyZodSchemaName;
1704
1589
  }
1705
1590
  });
1706
- Object.defineProperty(exports, "getDestructuredVariables", {
1707
- enumerable: true,
1708
- get: function() {
1709
- return getDestructuredVariables;
1710
- }
1711
- });
1712
1591
  Object.defineProperty(exports, "getEndpointBody", {
1713
1592
  enumerable: true,
1714
1593
  get: function() {
@@ -1763,30 +1642,12 @@ Object.defineProperty(exports, "getImportPath", {
1763
1642
  return getImportPath;
1764
1643
  }
1765
1644
  });
1766
- Object.defineProperty(exports, "getImportedAbilityFunctionName", {
1767
- enumerable: true,
1768
- get: function() {
1769
- return getImportedAbilityFunctionName;
1770
- }
1771
- });
1772
1645
  Object.defineProperty(exports, "getImportedEndpointName", {
1773
1646
  enumerable: true,
1774
1647
  get: function() {
1775
1648
  return getImportedEndpointName;
1776
1649
  }
1777
1650
  });
1778
- Object.defineProperty(exports, "getImportedInfiniteQueryName", {
1779
- enumerable: true,
1780
- get: function() {
1781
- return getImportedInfiniteQueryName;
1782
- }
1783
- });
1784
- Object.defineProperty(exports, "getImportedQueryName", {
1785
- enumerable: true,
1786
- get: function() {
1787
- return getImportedQueryName;
1788
- }
1789
- });
1790
1651
  Object.defineProperty(exports, "getImportedZodSchemaInferedTypeName", {
1791
1652
  enumerable: true,
1792
1653
  get: function() {
@@ -1799,24 +1660,6 @@ Object.defineProperty(exports, "getImportedZodSchemaName", {
1799
1660
  return getImportedZodSchemaName;
1800
1661
  }
1801
1662
  });
1802
- Object.defineProperty(exports, "getInfiniteQueriesImports", {
1803
- enumerable: true,
1804
- get: function() {
1805
- return getInfiniteQueriesImports;
1806
- }
1807
- });
1808
- Object.defineProperty(exports, "getInfiniteQueryName", {
1809
- enumerable: true,
1810
- get: function() {
1811
- return getInfiniteQueryName;
1812
- }
1813
- });
1814
- Object.defineProperty(exports, "getInfiniteQueryOptionsName", {
1815
- enumerable: true,
1816
- get: function() {
1817
- return getInfiniteQueryOptionsName;
1818
- }
1819
- });
1820
1663
  Object.defineProperty(exports, "getModelsImports", {
1821
1664
  enumerable: true,
1822
1665
  get: function() {
@@ -1859,48 +1702,12 @@ Object.defineProperty(exports, "getParameterEnumNames", {
1859
1702
  return getParameterEnumNames;
1860
1703
  }
1861
1704
  });
1862
- Object.defineProperty(exports, "getPathSegments", {
1863
- enumerable: true,
1864
- get: function() {
1865
- return getPathSegments;
1866
- }
1867
- });
1868
- Object.defineProperty(exports, "getPrefetchInfiniteQueryName", {
1869
- enumerable: true,
1870
- get: function() {
1871
- return getPrefetchInfiniteQueryName;
1872
- }
1873
- });
1874
- Object.defineProperty(exports, "getPrefetchQueryName", {
1875
- enumerable: true,
1876
- get: function() {
1877
- return getPrefetchQueryName;
1878
- }
1879
- });
1880
- Object.defineProperty(exports, "getQueriesImports", {
1881
- enumerable: true,
1882
- get: function() {
1883
- return getQueriesImports;
1884
- }
1885
- });
1886
1705
  Object.defineProperty(exports, "getQueryModulesImportPath", {
1887
1706
  enumerable: true,
1888
1707
  get: function() {
1889
1708
  return getQueryModulesImportPath;
1890
1709
  }
1891
1710
  });
1892
- Object.defineProperty(exports, "getQueryName", {
1893
- enumerable: true,
1894
- get: function() {
1895
- return getQueryName;
1896
- }
1897
- });
1898
- Object.defineProperty(exports, "getQueryOptionsName", {
1899
- enumerable: true,
1900
- get: function() {
1901
- return getQueryOptionsName;
1902
- }
1903
- });
1904
1711
  Object.defineProperty(exports, "getQueryTypesImportPath", {
1905
1712
  enumerable: true,
1906
1713
  get: function() {
@@ -2021,24 +1828,6 @@ Object.defineProperty(exports, "isArraySchemaObject", {
2021
1828
  return isArraySchemaObject;
2022
1829
  }
2023
1830
  });
2024
- Object.defineProperty(exports, "isBulkDeleteEndpoint", {
2025
- enumerable: true,
2026
- get: function() {
2027
- return isBulkDeleteEndpoint;
2028
- }
2029
- });
2030
- Object.defineProperty(exports, "isCreateEndpoint", {
2031
- enumerable: true,
2032
- get: function() {
2033
- return isCreateEndpoint;
2034
- }
2035
- });
2036
- Object.defineProperty(exports, "isDeleteEndpoint", {
2037
- enumerable: true,
2038
- get: function() {
2039
- return isDeleteEndpoint;
2040
- }
2041
- });
2042
1831
  Object.defineProperty(exports, "isEnumZodSchema", {
2043
1832
  enumerable: true,
2044
1833
  get: function() {
@@ -2051,12 +1840,6 @@ Object.defineProperty(exports, "isErrorStatus", {
2051
1840
  return isErrorStatus;
2052
1841
  }
2053
1842
  });
2054
- Object.defineProperty(exports, "isInfiniteQuery", {
2055
- enumerable: true,
2056
- get: function() {
2057
- return isInfiniteQuery;
2058
- }
2059
- });
2060
1843
  Object.defineProperty(exports, "isMainResponseStatus", {
2061
1844
  enumerable: true,
2062
1845
  get: function() {
@@ -2069,12 +1852,6 @@ Object.defineProperty(exports, "isMediaTypeAllowed", {
2069
1852
  return isMediaTypeAllowed;
2070
1853
  }
2071
1854
  });
2072
- Object.defineProperty(exports, "isMutation", {
2073
- enumerable: true,
2074
- get: function() {
2075
- return isMutation;
2076
- }
2077
- });
2078
1855
  Object.defineProperty(exports, "isNamedZodSchema", {
2079
1856
  enumerable: true,
2080
1857
  get: function() {
@@ -2093,36 +1870,12 @@ Object.defineProperty(exports, "isPathExcluded", {
2093
1870
  return isPathExcluded;
2094
1871
  }
2095
1872
  });
2096
- Object.defineProperty(exports, "isPathSegmentParam", {
2097
- enumerable: true,
2098
- get: function() {
2099
- return isPathSegmentParam;
2100
- }
2101
- });
2102
1873
  Object.defineProperty(exports, "isPrimitiveType", {
2103
1874
  enumerable: true,
2104
1875
  get: function() {
2105
1876
  return isPrimitiveType;
2106
1877
  }
2107
1878
  });
2108
- Object.defineProperty(exports, "isQuery", {
2109
- enumerable: true,
2110
- get: function() {
2111
- return isQuery;
2112
- }
2113
- });
2114
- Object.defineProperty(exports, "isReadAllEndpoint", {
2115
- enumerable: true,
2116
- get: function() {
2117
- return isReadAllEndpoint;
2118
- }
2119
- });
2120
- Object.defineProperty(exports, "isReadEndpoint", {
2121
- enumerable: true,
2122
- get: function() {
2123
- return isReadEndpoint;
2124
- }
2125
- });
2126
1879
  Object.defineProperty(exports, "isReferenceObject", {
2127
1880
  enumerable: true,
2128
1881
  get: function() {
@@ -2147,36 +1900,18 @@ Object.defineProperty(exports, "isTagIncluded", {
2147
1900
  return isTagIncluded;
2148
1901
  }
2149
1902
  });
2150
- Object.defineProperty(exports, "isUpdateEndpoint", {
2151
- enumerable: true,
2152
- get: function() {
2153
- return isUpdateEndpoint;
2154
- }
2155
- });
2156
1903
  Object.defineProperty(exports, "iterateSchema", {
2157
1904
  enumerable: true,
2158
1905
  get: function() {
2159
1906
  return iterateSchema;
2160
1907
  }
2161
1908
  });
2162
- Object.defineProperty(exports, "kebabToCamel", {
2163
- enumerable: true,
2164
- get: function() {
2165
- return kebabToCamel;
2166
- }
2167
- });
2168
1909
  Object.defineProperty(exports, "mapEndpointParamsToFunctionParams", {
2169
1910
  enumerable: true,
2170
1911
  get: function() {
2171
1912
  return mapEndpointParamsToFunctionParams;
2172
1913
  }
2173
1914
  });
2174
- Object.defineProperty(exports, "mergeImports", {
2175
- enumerable: true,
2176
- get: function() {
2177
- return mergeImports;
2178
- }
2179
- });
2180
1915
  Object.defineProperty(exports, "pathParamToVariableName", {
2181
1916
  enumerable: true,
2182
1917
  get: function() {