@fern-api/fern-api-dev 5.23.3-1840-g533c4e6a082 → 5.23.3-1852-g27d10f26ff8

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/cli.cjs +101 -14
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -702983,7 +702983,7 @@ var AccessTokenPosthogManager = class {
702983
702983
  properties: {
702984
702984
  ...event,
702985
702985
  ...event.properties,
702986
- version: "5.23.3-1840-g533c4e6a082",
702986
+ version: "5.23.3-1852-g27d10f26ff8",
702987
702987
  usingAccessToken: true,
702988
702988
  ...getRunIdProperties()
702989
702989
  }
@@ -703049,7 +703049,7 @@ var UserPosthogManager = class {
703049
703049
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
703050
703050
  event: "CLI",
703051
703051
  properties: {
703052
- version: "5.23.3-1840-g533c4e6a082",
703052
+ version: "5.23.3-1852-g27d10f26ff8",
703053
703053
  ...event,
703054
703054
  ...event.properties,
703055
703055
  usingAccessToken: false,
@@ -884215,7 +884215,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
884215
884215
  var LOGS_FOLDER_NAME = "logs";
884216
884216
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
884217
884217
  function getCliSource() {
884218
- const version7 = "5.23.3-1840-g533c4e6a082";
884218
+ const version7 = "5.23.3-1852-g27d10f26ff8";
884219
884219
  return `cli@${version7}`;
884220
884220
  }
884221
884221
  var DebugLogger = class {
@@ -909531,7 +909531,7 @@ var LegacyDocsPublisher = class {
909531
909531
  previewId,
909532
909532
  disableTemplates: void 0,
909533
909533
  skipUpload,
909534
- cliVersion: "5.23.3-1840-g533c4e6a082",
909534
+ cliVersion: "5.23.3-1852-g27d10f26ff8",
909535
909535
  loginCommand: "fern auth login"
909536
909536
  });
909537
909537
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -933550,6 +933550,10 @@ var Type31 = class _Type extends AstNode2 {
933550
933550
  isOptional() {
933551
933551
  return this.internalType.type === "optional";
933552
933552
  }
933553
+ /** Whether a value of this type can be compared to nil, and so can express its own absence. */
933554
+ isNilable() {
933555
+ return this.internalType.type === "optional" || NILABLE_TYPES.has(this.internalType.type);
933556
+ }
933553
933557
  isIterable() {
933554
933558
  return this.internalType.type === "slice" || this.internalType.type === "variadic";
933555
933559
  }
@@ -933668,7 +933672,7 @@ var Type31 = class _Type extends AstNode2 {
933668
933672
  });
933669
933673
  }
933670
933674
  static isAlreadyOptional(value2) {
933671
- return value2.internalType.type === "optional" || NILABLE_TYPES.has(value2.internalType.type);
933675
+ return value2.isNilable();
933672
933676
  }
933673
933677
  static isAlreadyVariadic(value2) {
933674
933678
  return value2.internalType.type === "variadic";
@@ -935527,7 +935531,10 @@ var EndpointSnippetGenerator2 = class {
935527
935531
  }
935528
935532
  this.context.errors.unscope();
935529
935533
  this.context.errors.scope(Scope4.RequestBody);
935530
- const requestArg = request7.body != null ? this.getBodyRequestArg({ body: request7.body, value: snippet.requestBody }) : void 0;
935534
+ const requestArg = request7.body != null ? this.callOmitsRequestBody({ request: request7, snippet }) ? (
935535
+ // Go has no optional parameters, so a call that leaves the body out passes nil.
935536
+ go_exports.TypeInstantiation.nop()
935537
+ ) : this.getBodyRequestArg({ body: request7.body, value: snippet.requestBody }) : void 0;
935531
935538
  this.context.errors.unscope();
935532
935539
  return { otherArgs, requestArg };
935533
935540
  }
@@ -935660,6 +935667,40 @@ var EndpointSnippetGenerator2 = class {
935660
935667
  assertNever(body);
935661
935668
  }
935662
935669
  }
935670
+ /**
935671
+ * Whether the call leaves the body out entirely, which a nil argument expresses. Applies only to
935672
+ * a body the caller may omit, and only once the generator opts in to that. An example that
935673
+ * supplies nothing for the body reaches the snippet generator as an absent or empty value, since
935674
+ * that is how the importer spells it.
935675
+ */
935676
+ callOmitsRequestBody({ request: request7, snippet }) {
935677
+ if (this.context.customConfig?.respectOptionalRequestBody !== true) {
935678
+ return false;
935679
+ }
935680
+ if (request7.bodyRequired !== false || request7.body == null) {
935681
+ return false;
935682
+ }
935683
+ if (!this.bodyParameterIsNilable({ body: request7.body })) {
935684
+ return false;
935685
+ }
935686
+ const value2 = snippet.requestBody;
935687
+ return value2 == null || typeof value2 === "object" && !Array.isArray(value2) && Object.keys(value2).length === 0;
935688
+ }
935689
+ /**
935690
+ * Whether the generated body parameter accepts nil, which mirrors the condition the SDK
935691
+ * generator applies before it lets a caller leave the body out. A value type keeps taking a
935692
+ * value, so an example for it must keep supplying one.
935693
+ */
935694
+ bodyParameterIsNilable({ body }) {
935695
+ switch (body.type) {
935696
+ case "bytes":
935697
+ return true;
935698
+ case "typeReference":
935699
+ return this.context.dynamicTypeMapper.convert({ typeReference: body.value }).isNilable();
935700
+ default:
935701
+ assertNever(body);
935702
+ }
935703
+ }
935663
935704
  getFileUploadRequestBodyStructFields({ filePropertyInfo }) {
935664
935705
  const inlineFileProperties = this.context.customConfig?.inlineFileProperties ?? true;
935665
935706
  if (inlineFileProperties) {
@@ -943179,7 +943220,8 @@ var EndpointSnippetGenerator4 = class {
943179
943220
  }
943180
943221
  this.context.errors.unscope();
943181
943222
  this.context.errors.scope(Scope4.RequestBody);
943182
- if (request7.body != null) {
943223
+ const omitBody = optionalIrPathParameters.length === 0 && this.callOmitsRequestBody({ request: request7, snippet });
943224
+ if (request7.body != null && !omitBody) {
943183
943225
  const bodyArg = this.getBodyRequestArg({ body: request7.body, value: snippet.requestBody });
943184
943226
  if (!php_exports.TypeLiteral.isNop(bodyArg)) {
943185
943227
  args.push(bodyArg);
@@ -943193,6 +943235,21 @@ var EndpointSnippetGenerator4 = class {
943193
943235
  this.context.errors.unscope();
943194
943236
  return args;
943195
943237
  }
943238
+ /**
943239
+ * Whether the snippet's call leaves the request body out. `bodyRequired` absent means required,
943240
+ * so a snippet only drops the argument when the API says the body is optional, the generator is
943241
+ * configured to respect that, and the snippet supplies no body of its own.
943242
+ */
943243
+ callOmitsRequestBody({ request: request7, snippet }) {
943244
+ if (this.context.customConfig?.respectOptionalRequestBody !== true) {
943245
+ return false;
943246
+ }
943247
+ if (request7.bodyRequired !== false) {
943248
+ return false;
943249
+ }
943250
+ const value2 = snippet.requestBody;
943251
+ return value2 == null || typeof value2 === "object" && !Array.isArray(value2) && Object.keys(value2).length === 0;
943252
+ }
943196
943253
  getBodyRequestArg({ body, value: value2 }) {
943197
943254
  switch (body.type) {
943198
943255
  case "bytes": {
@@ -946134,8 +946191,8 @@ var EndpointSnippetGenerator5 = class {
946134
946191
  this.context.errors.add({ severity: Severity.Warning, message });
946135
946192
  }
946136
946193
  getConstructorBasicAuthArg({ auth: auth8, values: values2 }) {
946137
- const usernameOmitted = "usernameOmit" in auth8 && auth8.usernameOmit === true;
946138
- const passwordOmitted = "passwordOmit" in auth8 && auth8.passwordOmit === true;
946194
+ const usernameOmitted = auth8.usernameOmit === true;
946195
+ const passwordOmitted = auth8.passwordOmit === true;
946139
946196
  const args = [];
946140
946197
  if (!usernameOmitted) {
946141
946198
  args.push({
@@ -946264,8 +946321,9 @@ var EndpointSnippetGenerator5 = class {
946264
946321
  const args = [];
946265
946322
  this.context.errors.scope(Scope4.PathParameters);
946266
946323
  const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
946324
+ const omitsRequestBody = this.callOmitsRequestBody({ request: request7, snippet });
946267
946325
  let bodyPropertyNames = /* @__PURE__ */ new Set();
946268
- if (request7.body != null) {
946326
+ if (request7.body != null && !omitsRequestBody) {
946269
946327
  const bodyArgs = this.getBodyRequestArgs({ body: request7.body, value: snippet.requestBody });
946270
946328
  bodyPropertyNames = new Set(bodyArgs.map((arg) => arg.name));
946271
946329
  if (request7.body.type === "typeReference") {
@@ -946295,12 +946353,26 @@ var EndpointSnippetGenerator5 = class {
946295
946353
  }
946296
946354
  this.context.errors.unscope();
946297
946355
  this.context.errors.scope(Scope4.RequestBody);
946298
- if (request7.body != null) {
946356
+ if (request7.body != null && !omitsRequestBody) {
946299
946357
  args.push(...this.getBodyRequestArgs({ body: request7.body, value: snippet.requestBody }));
946300
946358
  }
946301
946359
  this.context.errors.unscope();
946302
946360
  return args;
946303
946361
  }
946362
+ /**
946363
+ * Whether the call leaves the body out entirely, which the sentinel default allows. Applies
946364
+ * only to a body the caller may omit, and only once the generator opts in to that.
946365
+ */
946366
+ callOmitsRequestBody({ request: request7, snippet }) {
946367
+ if (this.context.customConfig.respect_optional_request_body !== true) {
946368
+ return false;
946369
+ }
946370
+ if (request7.bodyRequired !== false) {
946371
+ return false;
946372
+ }
946373
+ const value2 = snippet.requestBody;
946374
+ return value2 == null || typeof value2 === "object" && !Array.isArray(value2) && Object.keys(value2).length === 0;
946375
+ }
946304
946376
  getBodyRequestArgs({ body, value: value2 }) {
946305
946377
  switch (body.type) {
946306
946378
  case "bytes":
@@ -949529,7 +949601,7 @@ var EndpointSnippetGenerator6 = class {
949529
949601
  namedParameters: pathParameters,
949530
949602
  values: snippet.pathParameters
949531
949603
  }));
949532
- if (request7.body != null && snippet.requestBody != null) {
949604
+ if (request7.body != null && snippet.requestBody != null && !this.callOmitsRequestBody({ request: request7, snippet })) {
949533
949605
  switch (request7.body.type) {
949534
949606
  case "bytes":
949535
949607
  this.context.errors.add({
@@ -949578,6 +949650,21 @@ var EndpointSnippetGenerator6 = class {
949578
949650
  }
949579
949651
  return args;
949580
949652
  }
949653
+ /**
949654
+ * When the generator is configured to respect optional request bodies and the IR marks
949655
+ * the body as optional, a snippet whose example has no body omits the body arguments
949656
+ * entirely rather than passing an empty object.
949657
+ */
949658
+ callOmitsRequestBody({ request: request7, snippet }) {
949659
+ if (this.context.customConfig?.respectOptionalRequestBody !== true) {
949660
+ return false;
949661
+ }
949662
+ if (request7.bodyRequired !== false) {
949663
+ return false;
949664
+ }
949665
+ const value2 = snippet.requestBody;
949666
+ return value2 == null || typeof value2 === "object" && !Array.isArray(value2) && Object.keys(value2).length === 0;
949667
+ }
949581
949668
  getBodyArgsForNonObjectType({ namedType, typeRef, bodyValue }) {
949582
949669
  const args = [];
949583
949670
  switch (namedType.type) {
@@ -976451,7 +976538,7 @@ function getAutomationContextFromEnv() {
976451
976538
  config_branch: process.env.FERN_CONFIG_BRANCH,
976452
976539
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
976453
976540
  trigger: process.env.GITHUB_EVENT_NAME,
976454
- cli_version: "5.23.3-1840-g533c4e6a082"
976541
+ cli_version: "5.23.3-1852-g27d10f26ff8"
976455
976542
  };
976456
976543
  }
976457
976544
  function isAutomationMode() {
@@ -977283,7 +977370,7 @@ var CliContext = class _CliContext {
977283
977370
  if (false) {
977284
977371
  this.logger.error("CLI_VERSION is not defined");
977285
977372
  }
977286
- return "5.23.3-1840-g533c4e6a082";
977373
+ return "5.23.3-1852-g27d10f26ff8";
977287
977374
  }
977288
977375
  getCliName() {
977289
977376
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-1840-g533c4e6a082",
2
+ "version": "5.23.3-1852-g27d10f26ff8",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",