@hey-api/openapi-ts 0.90.9 → 0.90.10

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.
@@ -5634,6 +5634,25 @@ const pathToJsonPointer = (path$4) => {
5634
5634
  const segments = path$4.map(encodeJsonPointerSegment).join("/");
5635
5635
  return "#" + (segments ? `/${segments}` : "");
5636
5636
  };
5637
+ /**
5638
+ * Checks if a $ref points to a top-level component (not a deep path reference).
5639
+ *
5640
+ * Top-level component references:
5641
+ * - OpenAPI 3.x: #/components/{type}/{name} (3 segments)
5642
+ * - OpenAPI 2.0: #/definitions/{name} (2 segments)
5643
+ *
5644
+ * Deep path references (4+ segments for 3.x, 3+ for 2.0) should be inlined
5645
+ * because they don't have corresponding registered symbols.
5646
+ *
5647
+ * @param $ref - The $ref string to check
5648
+ * @returns true if the ref points to a top-level component, false otherwise
5649
+ */
5650
+ const isTopLevelComponentRef = ($ref) => {
5651
+ const path$4 = jsonPointerToPath($ref);
5652
+ if (path$4[0] === "components") return path$4.length === 3;
5653
+ if (path$4[0] === "definitions") return path$4.length === 2;
5654
+ return false;
5655
+ };
5637
5656
  const resolveRef = ({ $ref, spec }) => {
5638
5657
  const path$4 = jsonPointerToPath(decodeURI($ref));
5639
5658
  let current = spec;
@@ -5652,7 +5671,7 @@ const resolveRef = ({ $ref, spec }) => {
5652
5671
  * - Prefixes all conflicting names with their location (e.g. path_foo, query_foo)
5653
5672
  * - Returns a flat map of resolved parameter names to their metadata
5654
5673
  */
5655
- const getSignatureParameters = ({ operation }) => {
5674
+ function getSignatureParameters({ operation }) {
5656
5675
  const locations = [
5657
5676
  "header",
5658
5677
  "path",
@@ -5739,7 +5758,10 @@ const getSignatureParameters = ({ operation }) => {
5739
5758
  name: "body",
5740
5759
  schema: operation.body.schema
5741
5760
  };
5742
- fields.push({ in: "body" });
5761
+ fields.push({
5762
+ key: "body",
5763
+ map: "body"
5764
+ });
5743
5765
  }
5744
5766
  }
5745
5767
  if (!Object.keys(signatureParameters).length) return;
@@ -5747,7 +5769,7 @@ const getSignatureParameters = ({ operation }) => {
5747
5769
  fields,
5748
5770
  parameters: signatureParameters
5749
5771
  };
5750
- };
5772
+ }
5751
5773
 
5752
5774
  //#endregion
5753
5775
  //#region src/plugins/@hey-api/sdk/shared/validator.ts
@@ -5799,7 +5821,7 @@ const operationOptionsType = ({ isDataAllowed = true, operation, plugin, throwOn
5799
5821
  if (throwOnError) return $.type(symbolOptions).generic(isDataAllowed ? symbolDataType ?? "unknown" : "never").generic(throwOnError);
5800
5822
  return $.type(symbolOptions).$if(!isDataAllowed || symbolDataType, (t) => t.generic(isDataAllowed ? symbolDataType : "never"));
5801
5823
  };
5802
- const operationParameters = ({ isRequiredOptions, operation, plugin }) => {
5824
+ function operationParameters({ isRequiredOptions, operation, plugin }) {
5803
5825
  const result = {
5804
5826
  argNames: [],
5805
5827
  fields: [],
@@ -5836,7 +5858,7 @@ const operationParameters = ({ isRequiredOptions, operation, plugin }) => {
5836
5858
  throwOnError: isNuxtClient ? void 0 : "ThrowOnError"
5837
5859
  }))));
5838
5860
  return result;
5839
- };
5861
+ }
5840
5862
  /**
5841
5863
  * Infers `responseType` value from provided response content type. This is
5842
5864
  * an adapted version of `getParseAs()` from the Fetch API client.
@@ -5859,7 +5881,7 @@ const getResponseType = (contentType) => {
5859
5881
  ].some((type) => cleanContent.startsWith(type))) return "blob";
5860
5882
  if (cleanContent.startsWith("text/")) return "text";
5861
5883
  };
5862
- const operationStatements = ({ isRequiredOptions, opParameters, operation, plugin }) => {
5884
+ function operationStatements({ isRequiredOptions, opParameters, operation, plugin }) {
5863
5885
  const client = getClientPlugin(plugin.context.config);
5864
5886
  const isNuxtClient = client.name === "@hey-api/client-nuxt";
5865
5887
  const symbolResponseType = plugin.querySymbol({
@@ -5990,7 +6012,7 @@ const operationStatements = ({ isRequiredOptions, opParameters, operation, plugi
5990
6012
  functionName = functionName.attr(operation.method);
5991
6013
  statements.push($.return(functionName.call(reqOptions).$if(isNuxtClient, (f$1) => f$1.generic(nuxtTypeComposable).generic($.type.or(symbolResponseType ?? "unknown", nuxtTypeDefault)).generic(symbolErrorType ?? "unknown").generic(nuxtTypeDefault), (f$1) => f$1.generic(symbolResponseType ?? "unknown").generic(symbolErrorType ?? "unknown").generic("ThrowOnError")).$if(plugin.config.responseStyle === "data", (f$1) => f$1.generic($.type.literal(plugin.config.responseStyle)))));
5992
6014
  return statements;
5993
- };
6015
+ }
5994
6016
 
5995
6017
  //#endregion
5996
6018
  //#region src/plugins/@hey-api/sdk/v1/node.ts
@@ -9147,7 +9169,13 @@ const createMutationOptions = ({ operation, plugin }) => {
9147
9169
  if (plugin.getPluginOrThrow("@hey-api/sdk").config.responseStyle === "data") statements.push($.return(awaitSdkFn));
9148
9170
  else statements.push($.const().object("data").assign(awaitSdkFn), $.return("data"));
9149
9171
  const mutationOptionsFn = "mutationOptions";
9150
- const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions));
9172
+ const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions), { meta: {
9173
+ category: "hook",
9174
+ resource: "operation",
9175
+ resourceId: operation.id,
9176
+ role: "mutationOptions",
9177
+ tool: plugin.name
9178
+ } });
9151
9179
  const statement = $.const(symbolMutationOptions).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions$1).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
9152
9180
  plugin.node(statement);
9153
9181
  };
@@ -18123,7 +18151,7 @@ const parseEnum$2 = ({ context, schema, state }) => {
18123
18151
  };
18124
18152
  const parseRef$2 = ({ context, schema, state }) => {
18125
18153
  const irSchema = {};
18126
- if (!schema.$ref.startsWith("#/definitions/")) {
18154
+ if (!isTopLevelComponentRef(schema.$ref)) {
18127
18155
  if (!state.circularReferenceTracker.has(schema.$ref)) {
18128
18156
  const refSchema = context.resolveRef(schema.$ref);
18129
18157
  const originalRef = state.$ref;
@@ -19423,7 +19451,7 @@ const parseOneOf$1 = ({ context, schema, state }) => {
19423
19451
  return irSchema;
19424
19452
  };
19425
19453
  const parseRef$1 = ({ context, schema, state }) => {
19426
- if (!schema.$ref.startsWith("#/components/")) {
19454
+ if (!isTopLevelComponentRef(schema.$ref)) {
19427
19455
  if (!state.circularReferenceTracker.has(schema.$ref)) {
19428
19456
  const refSchema = context.resolveRef(schema.$ref);
19429
19457
  const originalRef = state.$ref;
@@ -20771,7 +20799,7 @@ const parseOneOf = ({ context, schema, state }) => {
20771
20799
  return irSchema;
20772
20800
  };
20773
20801
  const parseRef = ({ context, schema, state }) => {
20774
- if (!schema.$ref.startsWith("#/components/")) {
20802
+ if (!isTopLevelComponentRef(schema.$ref)) {
20775
20803
  if (!state.circularReferenceTracker.has(schema.$ref)) {
20776
20804
  const refSchema = context.resolveRef(schema.$ref);
20777
20805
  const originalRef = state.$ref;
@@ -21771,4 +21799,4 @@ const parseOpenApiSpec = ({ config, dependencies, logger, spec }) => {
21771
21799
 
21772
21800
  //#endregion
21773
21801
  export { openGitHubIssueWithCrashReport as A, defaultPaginationKeywords as C, ConfigValidationError as D, ConfigError as E, shouldReportCrash as M, loadPackageJson as N, JobError as O, definePluginConfig as S, getLogs as T, regexp as _, defaultPlugins as a, OperationPath as b, clientDefaultConfig as c, $ as d, TypeScriptRenderer as f, keywords as g, reserved as h, resolveJobs as i, printCrashReport as j, logCrashReport as k, clientDefaultMeta as l, ctx as m, buildGraph as n, clientPluginHandler as o, TsDslContext as p, getSpec as r, generateClientBundle as s, parseOpenApiSpec as t, toCase as u, TsDsl as v, postprocessOutput as w, OperationStrategy as x, getClientPlugin as y };
21774
- //# sourceMappingURL=openApi-CE_z8tev.mjs.map
21802
+ //# sourceMappingURL=openApi-Gs-XGatv.mjs.map