@hey-api/openapi-ts 0.91.0 → 0.91.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.
Files changed (42) hide show
  1. package/dist/clients/angular/client.ts +23 -49
  2. package/dist/clients/angular/types.ts +11 -34
  3. package/dist/clients/angular/utils.ts +6 -22
  4. package/dist/clients/axios/client.ts +16 -27
  5. package/dist/clients/axios/types.ts +17 -54
  6. package/dist/clients/axios/utils.ts +3 -8
  7. package/dist/clients/core/auth.ts +1 -2
  8. package/dist/clients/core/bodySerializer.ts +5 -21
  9. package/dist/clients/core/params.ts +3 -10
  10. package/dist/clients/core/pathSerializer.ts +4 -14
  11. package/dist/clients/core/queryKeySerializer.ts +6 -25
  12. package/dist/clients/core/serverSentEvents.ts +8 -31
  13. package/dist/clients/core/types.ts +4 -18
  14. package/dist/clients/core/utils.ts +1 -4
  15. package/dist/clients/fetch/client.ts +25 -48
  16. package/dist/clients/fetch/types.ts +12 -40
  17. package/dist/clients/fetch/utils.ts +6 -22
  18. package/dist/clients/ky/client.ts +27 -58
  19. package/dist/clients/ky/types.ts +14 -45
  20. package/dist/clients/ky/utils.ts +6 -22
  21. package/dist/clients/next/client.ts +30 -47
  22. package/dist/clients/next/types.ts +13 -47
  23. package/dist/clients/next/utils.ts +8 -31
  24. package/dist/clients/nuxt/client.ts +18 -37
  25. package/dist/clients/nuxt/types.ts +12 -31
  26. package/dist/clients/nuxt/utils.ts +5 -17
  27. package/dist/clients/ofetch/client.ts +34 -60
  28. package/dist/clients/ofetch/types.ts +13 -44
  29. package/dist/clients/ofetch/utils.ts +20 -58
  30. package/dist/index.d.mts.map +1 -1
  31. package/dist/index.mjs +2 -2
  32. package/dist/{init-kvO44gnv.mjs → init-CvGgSlz8.mjs} +41 -14
  33. package/dist/init-CvGgSlz8.mjs.map +1 -0
  34. package/dist/internal.mjs +1 -1
  35. package/dist/run.mjs +3 -3
  36. package/dist/run.mjs.map +1 -1
  37. package/dist/{src-Dmlg6WRV.mjs → src-Dgh53q8K.mjs} +5 -5
  38. package/dist/src-Dgh53q8K.mjs.map +1 -0
  39. package/dist/types-Ba27ofyy.d.mts.map +1 -1
  40. package/package.json +34 -35
  41. package/dist/init-kvO44gnv.mjs.map +0 -1
  42. package/dist/src-Dmlg6WRV.mjs.map +0 -1
@@ -5074,23 +5074,43 @@ const clientDefaultMeta = {
5074
5074
  //#region src/generate/client.ts
5075
5075
  const __filename = fileURLToPath(import.meta.url);
5076
5076
  const __dirname = path.dirname(__filename);
5077
+ function isDevMode() {
5078
+ return __dirname.includes(`${path.sep}src${path.sep}`);
5079
+ }
5080
+ /**
5081
+ * Returns paths to client bundle files based on execution context
5082
+ */
5083
+ function getClientBundlePaths(pluginName) {
5084
+ const clientName = pluginName.slice(16);
5085
+ if (isDevMode()) {
5086
+ const pluginsDir = path.resolve(__dirname, "..", "plugins", "@hey-api");
5087
+ return {
5088
+ clientPath: path.resolve(pluginsDir, `client-${clientName}`, "bundle"),
5089
+ corePath: path.resolve(pluginsDir, "client-core", "bundle")
5090
+ };
5091
+ }
5092
+ return {
5093
+ clientPath: path.resolve(__dirname, "clients", clientName),
5094
+ corePath: path.resolve(__dirname, "clients", "core")
5095
+ };
5096
+ }
5077
5097
  /**
5078
5098
  * Returns absolute path to the client folder. This is hard-coded for now.
5079
5099
  */
5080
- const clientFolderAbsolutePath = (config) => {
5100
+ function clientFolderAbsolutePath(config) {
5081
5101
  const client = getClientPlugin(config);
5082
5102
  if ("bundle" in client.config && client.config.bundle) {
5083
5103
  const renamed = config._FRAGILE_CLIENT_BUNDLE_RENAMED;
5084
5104
  return path.resolve(config.output.path, "client", `${renamed?.get("index") ?? "index"}.ts`);
5085
5105
  }
5086
5106
  return client.name;
5087
- };
5107
+ }
5088
5108
  /**
5089
5109
  * Recursively copies files and directories.
5090
5110
  * This is a PnP-compatible alternative to fs.cpSync that works with Yarn PnP's
5091
5111
  * virtualized filesystem.
5092
5112
  */
5093
- const copyRecursivePnP = (src, dest) => {
5113
+ function copyRecursivePnP(src, dest) {
5094
5114
  if (fs.statSync(src).isDirectory()) {
5095
5115
  if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
5096
5116
  const files = fs.readdirSync(src);
@@ -5099,8 +5119,8 @@ const copyRecursivePnP = (src, dest) => {
5099
5119
  const content = fs.readFileSync(src);
5100
5120
  fs.writeFileSync(dest, content);
5101
5121
  }
5102
- };
5103
- const renameFile = ({ filePath, project, renamed }) => {
5122
+ }
5123
+ function renameFile({ filePath, project, renamed }) {
5104
5124
  const extension = path.extname(filePath);
5105
5125
  const name = path.basename(filePath, extension);
5106
5126
  const renamedName = project.fileName?.(name) || name;
@@ -5109,9 +5129,13 @@ const renameFile = ({ filePath, project, renamed }) => {
5109
5129
  fs.renameSync(filePath, path.resolve(outputPath, `${renamedName}${extension}`));
5110
5130
  renamed.set(name, renamedName);
5111
5131
  }
5112
- };
5113
- const replaceImports = ({ filePath, meta, renamed }) => {
5132
+ }
5133
+ function replaceImports({ filePath, isDevMode: isDevMode$1, meta, renamed }) {
5114
5134
  let content = fs.readFileSync(filePath, "utf8");
5135
+ if (isDevMode$1) {
5136
+ content = content.replace(/from\s+['"]\.\.\/\.\.\/client-core\/bundle\//g, "from '../core/");
5137
+ content = content.replace(/from\s+['"]\.\.\/\.\.\/client-core\/bundle['"]/g, "from '../core'");
5138
+ }
5115
5139
  content = content.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g, (match, importPath) => {
5116
5140
  const importIndex = match.indexOf(importPath);
5117
5141
  const extension = path.extname(importPath);
@@ -5124,20 +5148,21 @@ const replaceImports = ({ filePath, meta, renamed }) => {
5124
5148
 
5125
5149
  ${content}`;
5126
5150
  fs.writeFileSync(filePath, content, "utf8");
5127
- };
5151
+ }
5128
5152
  /**
5129
5153
  * Creates a `client` folder containing the same modules as the client package.
5130
5154
  */
5131
- const generateClientBundle = ({ meta, outputPath, plugin, project }) => {
5155
+ function generateClientBundle({ meta, outputPath, plugin, project }) {
5132
5156
  const renamed = /* @__PURE__ */ new Map();
5157
+ const devMode = isDevMode();
5133
5158
  if (plugin.name.startsWith("@hey-api/client-")) {
5159
+ const { clientPath, corePath } = getClientBundlePaths(plugin.name);
5134
5160
  const coreOutputPath = path.resolve(outputPath, "core");
5135
5161
  ensureDirSync(coreOutputPath);
5136
- copyRecursivePnP(path.resolve(__dirname, "clients", "core"), coreOutputPath);
5162
+ copyRecursivePnP(corePath, coreOutputPath);
5137
5163
  const clientOutputPath = path.resolve(outputPath, "client");
5138
5164
  ensureDirSync(clientOutputPath);
5139
- const clientDistFolderName = plugin.name.slice(16);
5140
- copyRecursivePnP(path.resolve(__dirname, "clients", clientDistFolderName), clientOutputPath);
5165
+ copyRecursivePnP(clientPath, clientOutputPath);
5141
5166
  if (project) {
5142
5167
  const copiedCoreFiles = fs.readdirSync(coreOutputPath);
5143
5168
  for (const file of copiedCoreFiles) renameFile({
@@ -5155,12 +5180,14 @@ const generateClientBundle = ({ meta, outputPath, plugin, project }) => {
5155
5180
  const coreFiles = fs.readdirSync(coreOutputPath);
5156
5181
  for (const file of coreFiles) replaceImports({
5157
5182
  filePath: path.resolve(coreOutputPath, file),
5183
+ isDevMode: devMode,
5158
5184
  meta,
5159
5185
  renamed
5160
5186
  });
5161
5187
  const clientFiles = fs.readdirSync(clientOutputPath);
5162
5188
  for (const file of clientFiles) replaceImports({
5163
5189
  filePath: path.resolve(clientOutputPath, file),
5190
+ isDevMode: devMode,
5164
5191
  meta,
5165
5192
  renamed
5166
5193
  });
@@ -5183,7 +5210,7 @@ const generateClientBundle = ({ meta, outputPath, plugin, project }) => {
5183
5210
  const dirPath = path.resolve(outputPath, "client");
5184
5211
  ensureDirSync(dirPath);
5185
5212
  for (const file of distFiles) fs.copyFileSync(path.resolve(clientDistPath, file), path.resolve(dirPath, file));
5186
- };
5213
+ }
5187
5214
 
5188
5215
  //#endregion
5189
5216
  //#region src/plugins/@hey-api/client-core/client.ts
@@ -13560,4 +13587,4 @@ async function resolveJobs({ logger, userConfigs }) {
13560
13587
 
13561
13588
  //#endregion
13562
13589
  export { postProcessors as _, clientDefaultConfig as a, TypeScriptRenderer as c, reserved as d, keywords as f, getTypedConfig as g, getClientPlugin as h, generateClientBundle as i, TsDslContext as l, TsDsl as m, defaultPlugins as n, clientDefaultMeta as o, regexp as p, clientPluginHandler as r, $ as s, resolveJobs as t, ctx as u };
13563
- //# sourceMappingURL=init-kvO44gnv.mjs.map
13590
+ //# sourceMappingURL=init-CvGgSlz8.mjs.map