@hey-api/openapi-python 0.0.0-next-20260628165159 → 0.0.0-next-20260628214738

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/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { S as PyDsl, _ as reserved, a as coerce, b as PyDslContext, c as defineConfigTable, d as utils, f as createClient, g as KwargPyDsl, h as PythonRenderer, i as applyNaming, l as definePluginConfig, m as $, n as OperationPath, o as defaultPaginationKeywords, p as defaultPlugins, r as OperationStrategy, s as defineConfig, t as Logger, u as toCase, v as keywords, x as ctx, y as regexp } from "./src-VTH6sW4O.mjs";
1
+ import { S as PyDsl, _ as reserved, a as coerce, b as PyDslContext, c as defineConfigTable, d as utils, f as createClient, g as KwargPyDsl, h as PythonRenderer, i as applyNaming, l as definePluginConfig, m as $, n as OperationPath, o as defaultPaginationKeywords, p as defaultPlugins, r as OperationStrategy, s as defineConfig, t as Logger, u as toCase, v as keywords, x as ctx, y as regexp } from "./src-CKlNbgoN.mjs";
2
2
  import { t as plugins_exports } from "./plugins.mjs";
3
3
  export { $, KwargPyDsl, Logger, OperationPath, OperationStrategy, PyDsl, PyDslContext, PythonRenderer, applyNaming, coerce, createClient, ctx, defaultPaginationKeywords, defaultPlugins, defineConfig, defineConfigTable, definePluginConfig, keywords, plugins_exports as plugins, regexp, reserved, toCase, utils };
package/dist/run.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { f as createClient } from "./src-VTH6sW4O.mjs";
2
+ import { f as createClient } from "./src-CKlNbgoN.mjs";
3
3
  import { runCli } from "@hey-api/codegen-cli";
4
4
  //#region package.json
5
- var version = "0.0.0-next-20260628165159";
5
+ var version = "0.0.0-next-20260628214738";
6
6
  //#endregion
7
7
  //#region src/run.ts
8
8
  const binName = Object.keys({ "openapi-python": "./bin/run.js" })[0];
@@ -5,6 +5,7 @@ import { ConfigError, ConfigValidationError, Context, InputError, IntentContext,
5
5
  import colors from "ansi-colors";
6
6
  import colorSupport from "color-support";
7
7
  import fs from "node:fs";
8
+ import os from "node:os";
8
9
  import path from "node:path";
9
10
  import { $RefParser, ResolverError } from "@hey-api/json-schema-ref-parser";
10
11
  import { format } from "@lukeed/ms";
@@ -122,12 +123,69 @@ function getClientPlugin(config) {
122
123
  };
123
124
  }
124
125
  //#endregion
126
+ //#region src/sea.ts
127
+ const SEA_MANIFEST_KEY = "clients/__manifest__.json";
128
+ function seaAssetKey(clientName, fileName) {
129
+ return `clients/${clientName}/${fileName}`;
130
+ }
131
+ //#endregion
125
132
  //#region src/generate/client.ts
133
+ let _sea;
134
+ let _manifest;
135
+ let _seaExtractDir;
136
+ function getSeaExtractDir() {
137
+ if (!_seaExtractDir) _seaExtractDir = fs.mkdtempSync(path.join(os.tmpdir(), "hey-api-sea-"));
138
+ return _seaExtractDir;
139
+ }
140
+ function cleanupSeaExtract() {
141
+ if (_seaExtractDir) {
142
+ fs.rmSync(_seaExtractDir, {
143
+ force: true,
144
+ recursive: true
145
+ });
146
+ _seaExtractDir = void 0;
147
+ }
148
+ }
149
+ async function getSea() {
150
+ if (!_sea) _sea = await import("node:sea");
151
+ return _sea;
152
+ }
153
+ async function getSeaManifest() {
154
+ if (!_manifest) {
155
+ const sea = await getSea();
156
+ _manifest = JSON.parse(sea.getAsset(SEA_MANIFEST_KEY, "utf-8"));
157
+ }
158
+ return _manifest;
159
+ }
160
+ async function isSea() {
161
+ try {
162
+ return (await getSea()).isSea();
163
+ } catch {
164
+ return false;
165
+ }
166
+ }
167
+ async function extractSeaClientFiles(clientName) {
168
+ const sea = await getSea();
169
+ const manifest = await getSeaManifest();
170
+ const tmpDir = path.resolve(getSeaExtractDir(), clientName);
171
+ fs.mkdirSync(tmpDir, { recursive: true });
172
+ const files = manifest[clientName];
173
+ if (files) for (const file of files) {
174
+ if (file.includes("..") || path.isAbsolute(file)) throw new Error(`Invalid SEA asset filename: ${file}`);
175
+ const content = sea.getAsset(seaAssetKey(clientName, file), "utf-8");
176
+ fs.writeFileSync(path.resolve(tmpDir, file), content);
177
+ }
178
+ return tmpDir;
179
+ }
126
180
  /**
127
181
  * Returns paths to client bundle files based on execution context
128
182
  */
129
- function getClientBundlePaths(pluginName) {
183
+ async function getClientBundlePaths(pluginName) {
130
184
  const clientName = pluginName.slice(16);
185
+ if (await isSea()) return {
186
+ clientPath: await extractSeaClientFiles(clientName),
187
+ corePath: await extractSeaClientFiles("core")
188
+ };
131
189
  if (isEnvironment("development")) {
132
190
  const pluginsDir = path.resolve(import.meta.dirname, "..", "plugins", "@hey-api");
133
191
  return {
@@ -196,7 +254,7 @@ function replaceImports({ filePath, header, renamed }) {
196
254
  /**
197
255
  * Creates a `client` folder containing the same modules as the client package.
198
256
  */
199
- function generateClientBundle({ header, outputPath, plugin, project }) {
257
+ async function generateClientBundle({ header, outputPath, plugin, project }) {
200
258
  const renamed = /* @__PURE__ */ new Map();
201
259
  const headerPrefix = outputHeaderToPrefix({
202
260
  defaultValue: ["# This file is auto-generated by @hey-api/openapi-python"],
@@ -204,7 +262,7 @@ function generateClientBundle({ header, outputPath, plugin, project }) {
204
262
  project
205
263
  });
206
264
  if (plugin.name.startsWith("@hey-api/client-")) {
207
- const { clientPath } = getClientBundlePaths(plugin.name);
265
+ const { clientPath } = await getClientBundlePaths(plugin.name);
208
266
  const clientOutputPath = path.resolve(outputPath, "client");
209
267
  ensureDirSync(clientOutputPath);
210
268
  copyRecursivePnP(clientPath, clientOutputPath);
@@ -6562,7 +6620,7 @@ async function generateOutput(context) {
6562
6620
  }
6563
6621
  const config = getTypedConfig(context);
6564
6622
  const client = getClientPlugin(config);
6565
- if ("bundle" in client.config && client.config.bundle && !config.dryRun) config._FRAGILE_CLIENT_BUNDLE_RENAMED = generateClientBundle({
6623
+ if ("bundle" in client.config && client.config.bundle && !config.dryRun) config._FRAGILE_CLIENT_BUNDLE_RENAMED = await generateClientBundle({
6566
6624
  header: config.output.header,
6567
6625
  outputPath,
6568
6626
  plugin: client,
@@ -6709,6 +6767,7 @@ async function createClient$1({ config, dependencies, jobIndex, logger, watches:
6709
6767
  eventParser.timeEnd();
6710
6768
  const eventGenerator = logger.timeEvent("generator");
6711
6769
  const { fileCount } = await generateOutput(context);
6770
+ cleanupSeaExtract();
6712
6771
  eventGenerator.timeEnd();
6713
6772
  const totalMs = Date.now() - jobStart;
6714
6773
  const eventPostprocess = logger.timeEvent("postprocess");
@@ -6811,4 +6870,4 @@ async function defineConfig$1(config) {
6811
6870
  //#endregion
6812
6871
  export { PyDsl as S, reserved as _, coerce$1 as a, PyDslContext as b, defineConfigTable as c, utils as d, createClient as f, KwargPyDsl as g, PythonRenderer as h, applyNaming$1 as i, definePluginConfig$1 as l, $$1 as m, OperationPath$1 as n, defaultPaginationKeywords as o, defaultPlugins as p, OperationStrategy$1 as r, defineConfig$1 as s, Logger$1 as t, toCase$1 as u, keywords as v, ctx as x, regexp as y };
6813
6872
 
6814
- //# sourceMappingURL=src-VTH6sW4O.mjs.map
6873
+ //# sourceMappingURL=src-CKlNbgoN.mjs.map