fern-api 0.33.0 → 0.33.2-rc0

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 (2) hide show
  1. package/bundle.cjs +67 -16
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -1164516,7 +1164516,7 @@ var AccessTokenPosthogManager = class {
1164516
1164516
  properties: {
1164517
1164517
  ...event,
1164518
1164518
  ...event.properties,
1164519
- version: "0.33.0",
1164519
+ version: "0.33.2-rc0",
1164520
1164520
  usingAccessToken: true
1164521
1164521
  }
1164522
1164522
  });
@@ -1164578,7 +1164578,7 @@ var UserPosthogManager = class {
1164578
1164578
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1164579
1164579
  event: "CLI",
1164580
1164580
  properties: {
1164581
- version: "0.33.0",
1164581
+ version: "0.33.2-rc0",
1164582
1164582
  ...event,
1164583
1164583
  ...event.properties
1164584
1164584
  }
@@ -1188015,9 +1188015,18 @@ var FernDefinitionBuilderImpl = class {
1188015
1188015
  this.rootApiFile.environments[name3] = schema2;
1188016
1188016
  }
1188017
1188017
  getGlobalHeaderNames() {
1188018
- return new Set(Object.keys(this.rootApiFile.headers ?? {}));
1188018
+ const headerNames = Object.keys(this.rootApiFile.headers ?? {});
1188019
+ const maybeVersionHeader = this.getVersionHeader();
1188020
+ if (maybeVersionHeader != null) {
1188021
+ headerNames.push(maybeVersionHeader);
1188022
+ }
1188023
+ return new Set(headerNames);
1188019
1188024
  }
1188020
1188025
  addGlobalHeader({ name: name3, schema: schema2 }) {
1188026
+ const maybeVersionHeader = this.getVersionHeader();
1188027
+ if (maybeVersionHeader != null && maybeVersionHeader === name3) {
1188028
+ return;
1188029
+ }
1188021
1188030
  if (this.rootApiFile.headers == null) {
1188022
1188031
  this.rootApiFile.headers = {};
1188023
1188032
  }
@@ -1188278,6 +1188287,12 @@ var FernDefinitionBuilderImpl = class {
1188278
1188287
  return (_a5 = this.definitionFiles)[file] ?? (_a5[file] = {});
1188279
1188288
  }
1188280
1188289
  }
1188290
+ getVersionHeader() {
1188291
+ if (this.rootApiFile.version == null) {
1188292
+ return void 0;
1188293
+ }
1188294
+ return typeof this.rootApiFile.version.header === "string" ? this.rootApiFile.version.header : this.rootApiFile.version.header.value;
1188295
+ }
1188281
1188296
  };
1188282
1188297
  function getSharedEnvironmentBasePath(rootApiFile) {
1188283
1188298
  if (rootApiFile.environments == null) {
@@ -1192289,10 +1192304,10 @@ var CliContext = class {
1192289
1192304
  return "fern-api";
1192290
1192305
  }
1192291
1192306
  getPackageVersion() {
1192292
- if ("0.33.0" == null) {
1192307
+ if ("0.33.2-rc0" == null) {
1192293
1192308
  this.logger.error("CLI_VERSION is not defined");
1192294
1192309
  }
1192295
- return "0.33.0";
1192310
+ return "0.33.2-rc0";
1192296
1192311
  }
1192297
1192312
  getCliName() {
1192298
1192313
  if ("fern" == null) {
@@ -1196999,8 +1197014,8 @@ function isReferencedWebhookPayloadSchema2(payload) {
1196999
1197014
  return payload.type != null;
1197000
1197015
  }
1197001
1197016
 
1197002
- // pnp:/home/runner/work/fern/fern/packages/cli/generation/ir-generator/lib/utils/getPropertiesForAudience.js
1197003
- function getPropertiesForAudience(properties) {
1197017
+ // pnp:/home/runner/work/fern/fern/packages/cli/generation/ir-generator/lib/utils/getPropertiesByAudience.js
1197018
+ function getPropertiesByAudience(properties) {
1197004
1197019
  var _a5;
1197005
1197020
  const propertiesByAudience = {};
1197006
1197021
  for (const [property5, propertyDeclaration] of Object.entries(properties)) {
@@ -1197159,7 +1197174,7 @@ async function convertTypeDeclaration({ typeName, typeDeclaration, file, typeRes
1197159
1197174
  const referencedTypes = getReferencedTypesFromRawDeclaration({ typeDeclaration, file, typeResolver });
1197160
1197175
  let propertiesByAudience = {};
1197161
1197176
  if (isRawObjectDefinition(typeDeclaration)) {
1197162
- propertiesByAudience = getPropertiesForAudience(typeDeclaration.properties ?? {});
1197177
+ propertiesByAudience = getPropertiesByAudience(typeDeclaration.properties ?? {});
1197163
1197178
  }
1197164
1197179
  return {
1197165
1197180
  propertiesByAudience,
@@ -1197831,10 +1197846,11 @@ var FilteredIrImpl = class {
1197831
1197846
  services = /* @__PURE__ */ new Set();
1197832
1197847
  endpoints = /* @__PURE__ */ new Set();
1197833
1197848
  requestProperties;
1197849
+ queryParameters;
1197834
1197850
  webhooks = /* @__PURE__ */ new Set();
1197835
1197851
  webhookPayloadProperties;
1197836
1197852
  subpackages = /* @__PURE__ */ new Set();
1197837
- constructor({ types: types3, errors, services, endpoints, webhooks, subpackages, requestProperties, webhookPayloadProperties, properties }) {
1197853
+ constructor({ types: types3, errors, services, endpoints, webhooks, subpackages, queryParameters, requestProperties, webhookPayloadProperties, properties }) {
1197838
1197854
  this.types = types3;
1197839
1197855
  this.properties = properties;
1197840
1197856
  this.errors = errors;
@@ -1197844,6 +1197860,7 @@ var FilteredIrImpl = class {
1197844
1197860
  this.webhookPayloadProperties = webhookPayloadProperties;
1197845
1197861
  this.subpackages = subpackages;
1197846
1197862
  this.requestProperties = requestProperties;
1197863
+ this.queryParameters = queryParameters;
1197847
1197864
  }
1197848
1197865
  hasTypeId(typeId) {
1197849
1197866
  return this.types.has(typeId);
@@ -1197886,6 +1197903,13 @@ var FilteredIrImpl = class {
1197886
1197903
  }
1197887
1197904
  return properties.has(property5);
1197888
1197905
  }
1197906
+ hasQueryParameter(endpoint, parameter) {
1197907
+ const parameters = this.queryParameters[endpoint];
1197908
+ if (parameters == null) {
1197909
+ return true;
1197910
+ }
1197911
+ return parameters.has(parameter);
1197912
+ }
1197889
1197913
  hasSubpackage(subpackageId) {
1197890
1197914
  return this.subpackages.has(subpackageId);
1197891
1197915
  }
@@ -1197908,6 +1197932,7 @@ var FilteredIrImpl = class {
1197908
1197932
  var IrGraph = class {
1197909
1197933
  types = {};
1197910
1197934
  properties = {};
1197935
+ queryParameters = {};
1197911
1197936
  requestProperties = {};
1197912
1197937
  webhookProperties = {};
1197913
1197938
  errors = {};
@@ -1197984,6 +1198009,13 @@ var IrGraph = class {
1197984
1198009
  for (const queryParameter of httpEndpoint.queryParameters) {
1197985
1198010
  populateReferencesFromTypeReference(queryParameter.valueType, referencedTypes, referencedSubpackages);
1197986
1198011
  }
1198012
+ if (rawEndpoint != null && rawEndpoint.request != null && typeof rawEndpoint.request !== "string") {
1198013
+ const parametersByAudience = getPropertiesByAudience(rawEndpoint.request["query-parameters"] ?? {});
1198014
+ this.queryParameters[endpointId] = {
1198015
+ endpointId,
1198016
+ parametersByAudience
1198017
+ };
1198018
+ }
1197987
1198019
  if (httpEndpoint.requestBody != null) {
1197988
1198020
  HttpRequestBody._visit(httpEndpoint.requestBody, {
1197989
1198021
  inlinedRequestBody: (inlinedRequestBody) => {
@@ -1197994,7 +1198026,7 @@ var IrGraph = class {
1197994
1198026
  populateReferencesFromTypeReference(property5.valueType, referencedTypes, referencedSubpackages);
1197995
1198027
  }
1197996
1198028
  if (rawEndpoint != null && typeof rawEndpoint.request === "object" && typeof rawEndpoint.request.body === "object" && isInlineRequestBody(rawEndpoint.request.body)) {
1197997
- const propertiesByAudience = getPropertiesForAudience(rawEndpoint.request.body.properties ?? {});
1198029
+ const propertiesByAudience = getPropertiesByAudience(rawEndpoint.request.body.properties ?? {});
1197998
1198030
  this.requestProperties[endpointId] = {
1197999
1198031
  endpointId,
1198000
1198032
  propertiesByAudience
@@ -1198109,7 +1198141,7 @@ var IrGraph = class {
1198109
1198141
  populateReferencesFromTypeReference(property5.valueType, referencedTypes, referencedSubpackages);
1198110
1198142
  }
1198111
1198143
  if ((rawWebhook == null ? void 0 : rawWebhook.payload) != null && typeof rawWebhook.payload === "object" && !isReferencedWebhookPayloadSchema2(rawWebhook.payload)) {
1198112
- const propertiesByAudience = getPropertiesForAudience(rawWebhook.payload.properties ?? {});
1198144
+ const propertiesByAudience = getPropertiesByAudience(rawWebhook.payload.properties ?? {});
1198113
1198145
  this.webhookProperties[webhookId] = {
1198114
1198146
  webhookId,
1198115
1198147
  propertiesByAudience
@@ -1198164,6 +1198196,7 @@ var IrGraph = class {
1198164
1198196
  }
1198165
1198197
  const properties = {};
1198166
1198198
  const requestProperties = {};
1198199
+ const queryParameters = {};
1198167
1198200
  const webhookPayloadProperties = {};
1198168
1198201
  if (this.audiences.type === "filtered") {
1198169
1198202
  for (const [typeId, typePropertiesNode] of Object.entries(this.properties)) {
@@ -1198182,6 +1198215,7 @@ var IrGraph = class {
1198182
1198215
  if (propertiesForTypeId.size > 0) {
1198183
1198216
  properties[typeId] = propertiesForTypeId;
1198184
1198217
  }
1198218
+ properties[typeId] = propertiesForTypeId.size > 0 ? propertiesForTypeId : void 0;
1198185
1198219
  }
1198186
1198220
  for (const [endpointId, requestPropertiesNode] of Object.entries(this.requestProperties)) {
1198187
1198221
  if (!this.endpointsNeededForAudience.has(endpointId)) {
@@ -1198196,9 +1198230,22 @@ var IrGraph = class {
1198196
1198230
  });
1198197
1198231
  }
1198198
1198232
  }
1198199
- if (propertiesForEndpoint.size > 0) {
1198200
- requestProperties[endpointId] = propertiesForEndpoint;
1198233
+ requestProperties[endpointId] = propertiesForEndpoint.size > 0 ? propertiesForEndpoint : void 0;
1198234
+ }
1198235
+ for (const [endpointId, queryParametersNode] of Object.entries(this.queryParameters)) {
1198236
+ if (!this.endpointsNeededForAudience.has(endpointId)) {
1198237
+ continue;
1198201
1198238
  }
1198239
+ const parametersForEndpoint = /* @__PURE__ */ new Set();
1198240
+ for (const audience of this.audiences.audiences) {
1198241
+ const parametersByAudience = queryParametersNode.parametersByAudience[audience];
1198242
+ if (parametersByAudience != null) {
1198243
+ parametersByAudience.forEach((parameter) => {
1198244
+ parametersForEndpoint.add(parameter);
1198245
+ });
1198246
+ }
1198247
+ }
1198248
+ queryParameters[endpointId] = parametersForEndpoint.size > 0 ? parametersForEndpoint : void 0;
1198202
1198249
  }
1198203
1198250
  for (const [webhookId, webhookPaylodPropertiesNode] of Object.entries(this.webhookProperties)) {
1198204
1198251
  if (!this.webhooksNeededForAudience.has(webhookId)) {
@@ -1198213,9 +1198260,7 @@ var IrGraph = class {
1198213
1198260
  });
1198214
1198261
  }
1198215
1198262
  }
1198216
- if (propertiesForWebhook.size > 0) {
1198217
- requestProperties[webhookId] = propertiesForWebhook;
1198218
- }
1198263
+ webhookPayloadProperties[webhookId] = propertiesForWebhook.size > 0 ? propertiesForWebhook : void 0;
1198219
1198264
  }
1198220
1198265
  }
1198221
1198266
  return new FilteredIrImpl({
@@ -1198223,6 +1198268,7 @@ var IrGraph = class {
1198223
1198268
  properties,
1198224
1198269
  errors: errorIds,
1198225
1198270
  requestProperties,
1198271
+ queryParameters,
1198226
1198272
  services: this.servicesNeededForAudience,
1198227
1198273
  endpoints: this.endpointsNeededForAudience,
1198228
1198274
  webhooks: this.webhooksNeededForAudience,
@@ -1199857,6 +1199903,11 @@ function filterIntermediateRepresentationForAudiences(intermediateRepresentation
1199857
1199903
  example: userSpecified.example != null ? filterEndpointExample({ filteredIr, example: userSpecified.example }) : void 0
1199858
1199904
  };
1199859
1199905
  });
1199906
+ if (httpEndpoint.queryParameters.length > 0) {
1199907
+ httpEndpoint.queryParameters = httpEndpoint.queryParameters.filter((queryParameter) => {
1199908
+ return filteredIr.hasQueryParameter(httpEndpoint.id, queryParameter.name.wireValue);
1199909
+ });
1199910
+ }
1199860
1199911
  if (((_a5 = httpEndpoint.requestBody) == null ? void 0 : _a5.type) === "inlinedRequestBody") {
1199861
1199912
  return {
1199862
1199913
  ...httpEndpoint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.33.0",
3
+ "version": "0.33.2-rc0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",