fern-api 0.17.1-rc0 → 0.17.2

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 +220 -107
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -735189,7 +735189,7 @@ var AccessTokenPosthogManager = class {
735189
735189
  properties: {
735190
735190
  ...event,
735191
735191
  ...event.properties,
735192
- version: "0.17.1-rc0",
735192
+ version: "0.17.2",
735193
735193
  usingAccessToken: true
735194
735194
  }
735195
735195
  });
@@ -735251,7 +735251,7 @@ var UserPosthogManager = class {
735251
735251
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
735252
735252
  event: "CLI",
735253
735253
  properties: {
735254
- version: "0.17.1-rc0",
735254
+ version: "0.17.2",
735255
735255
  ...event,
735256
735256
  ...event.properties
735257
735257
  }
@@ -751420,15 +751420,10 @@ var ExampleTypeFactory = class {
751420
751420
  constructor(schemas) {
751421
751421
  this.schemas = schemas;
751422
751422
  }
751423
- buildExample({
751424
- schema: schema2,
751425
- example,
751426
- isOptional = false,
751427
- parameter = false
751428
- }) {
751429
- return this.buildExampleHelper({ schema: schema2, isOptional, visitedSchemaIds: /* @__PURE__ */ new Set(), example, parameter });
751423
+ buildExample({ schema: schema2, example, options }) {
751424
+ return this.buildExampleHelper({ schema: schema2, visitedSchemaIds: /* @__PURE__ */ new Set(), example, options, depth: 0 });
751430
751425
  }
751431
- buildExampleHelper({ example, schema: schema2, isOptional, visitedSchemaIds, parameter = false }) {
751426
+ buildExampleHelper({ example, schema: schema2, depth, visitedSchemaIds, options }) {
751432
751427
  var _a2, _b2;
751433
751428
  switch (schema2.type) {
751434
751429
  case "enum":
@@ -751438,25 +751433,53 @@ var ExampleTypeFactory = class {
751438
751433
  return schema2.values[0] != null ? import_example2.FullExample.enum((_a2 = schema2.values[0]) == null ? void 0 : _a2.value) : void 0;
751439
751434
  case "literal":
751440
751435
  return import_example2.FullExample.literal(schema2.value);
751441
- case "nullable":
751442
- return this.buildExampleHelper({
751436
+ case "nullable": {
751437
+ if (example == null && !this.hasExample(schema2.value) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
751438
+ return void 0;
751439
+ }
751440
+ const result2 = this.buildExampleHelper({
751443
751441
  schema: schema2.value,
751444
- isOptional: true,
751445
751442
  visitedSchemaIds,
751446
751443
  example,
751447
- parameter
751444
+ depth,
751445
+ options
751448
751446
  });
751449
- case "optional":
751450
- return this.buildExampleHelper({
751447
+ if (result2 != null && result2.type === "array" && result2.array.length === 0) {
751448
+ return void 0;
751449
+ }
751450
+ if (result2 != null && result2.type === "map" && result2.map.length === 0) {
751451
+ return void 0;
751452
+ }
751453
+ if (result2 != null && result2.type === "object" && Object.keys(result2.properties).length === 0) {
751454
+ return void 0;
751455
+ }
751456
+ return result2;
751457
+ }
751458
+ case "optional": {
751459
+ if (example == null && !this.hasExample(schema2.value) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
751460
+ return void 0;
751461
+ }
751462
+ const result2 = this.buildExampleHelper({
751451
751463
  schema: schema2.value,
751452
- isOptional: true,
751453
751464
  visitedSchemaIds,
751454
751465
  example,
751455
- parameter
751466
+ depth,
751467
+ options
751456
751468
  });
751469
+ if (result2 != null && result2.type === "array" && result2.array.length === 0) {
751470
+ return void 0;
751471
+ }
751472
+ if (result2 != null && result2.type === "map" && result2.map.length === 0) {
751473
+ return void 0;
751474
+ }
751475
+ if (result2 != null && result2.type === "object" && Object.keys(result2.properties).length === 0) {
751476
+ return void 0;
751477
+ }
751478
+ return result2;
751479
+ }
751457
751480
  case "primitive": {
751458
- const primitiveExample = this.buildExampleFromPrimitive({ schema: schema2.schema, example, isOptional });
751459
- return primitiveExample != null ? import_example2.FullExample.primitive(primitiveExample) : void 0;
751481
+ const primitiveExample = this.buildExampleFromPrimitive({ schema: schema2.schema, example, options });
751482
+ return import_example2.FullExample.primitive(primitiveExample);
751460
751483
  }
751461
751484
  case "reference": {
751462
751485
  const referencedSchemaWithExample = this.schemas[schema2.schema];
@@ -751465,9 +751488,9 @@ var ExampleTypeFactory = class {
751465
751488
  const referencedExample = this.buildExampleHelper({
751466
751489
  example,
751467
751490
  schema: referencedSchemaWithExample,
751468
- isOptional,
751469
751491
  visitedSchemaIds,
751470
- parameter
751492
+ depth,
751493
+ options
751471
751494
  });
751472
751495
  visitedSchemaIds.delete(schema2.schema);
751473
751496
  return referencedExample;
@@ -751508,9 +751531,9 @@ var ExampleTypeFactory = class {
751508
751531
  const propertyExample = this.buildExampleHelper({
751509
751532
  schema: schema3,
751510
751533
  example: fullExample[property3],
751511
- isOptional: !required,
751512
751534
  visitedSchemaIds,
751513
- parameter
751535
+ depth: depth + 1,
751536
+ options
751514
751537
  });
751515
751538
  if (propertyExample != null) {
751516
751539
  result2[property3] = propertyExample;
@@ -751521,9 +751544,9 @@ var ExampleTypeFactory = class {
751521
751544
  const propertyExample = this.buildExampleHelper({
751522
751545
  schema: schema3,
751523
751546
  example: fullExample == null ? void 0 : fullExample[property3],
751524
- isOptional: !required,
751525
751547
  visitedSchemaIds,
751526
- parameter
751548
+ depth: depth + 1,
751549
+ options
751527
751550
  });
751528
751551
  if (propertyExample != null) {
751529
751552
  result2[property3] = propertyExample;
@@ -751542,9 +751565,9 @@ var ExampleTypeFactory = class {
751542
751565
  return this.buildExampleHelper({
751543
751566
  example,
751544
751567
  schema: schema2.oneOf.schemas[0],
751545
- isOptional,
751546
751568
  visitedSchemaIds,
751547
- parameter
751569
+ depth,
751570
+ options
751548
751571
  });
751549
751572
  }
751550
751573
  break;
@@ -751558,30 +751581,45 @@ var ExampleTypeFactory = class {
751558
751581
  return import_example2.FullExample.unknown(fullExample);
751559
751582
  }
751560
751583
  }
751561
- if (isOptional) {
751584
+ if (options.ignoreOptionals || this.exceedsMaxDepth(depth, options)) {
751562
751585
  return void 0;
751563
- } else if (parameter) {
751564
- return import_example2.FullExample.primitive(import_example2.PrimitiveExample.string("string"));
751565
751586
  }
751566
- return import_example2.FullExample.map([]);
751587
+ if (options.isParameter) {
751588
+ return import_example2.FullExample.primitive(import_example2.PrimitiveExample.string(options.name ?? "string"));
751589
+ }
751590
+ return import_example2.FullExample.map([
751591
+ {
751592
+ key: import_example2.PrimitiveExample.string("key"),
751593
+ value: import_example2.FullExample.primitive(import_example2.PrimitiveExample.string("value"))
751594
+ }
751595
+ ]);
751567
751596
  case "array": {
751568
751597
  const fullExample = getFullExampleAsArray(example);
751569
- if (isOptional && fullExample == null) {
751570
- return void 0;
751571
- }
751572
751598
  const itemExamples = [];
751573
- for (const item of fullExample ?? []) {
751574
- const itemExample = this.buildExampleHelper({
751575
- example: item,
751576
- schema: schema2.value,
751577
- isOptional: true,
751578
- visitedSchemaIds,
751579
- parameter
751580
- });
751581
- if (itemExample != null) {
751582
- itemExamples.push(itemExample);
751599
+ if (fullExample != null && fullExample.length > 0) {
751600
+ for (const item of fullExample) {
751601
+ const itemExample2 = this.buildExampleHelper({
751602
+ example: item,
751603
+ schema: schema2.value,
751604
+ depth: depth + 1,
751605
+ visitedSchemaIds,
751606
+ options
751607
+ });
751608
+ if (itemExample2 != null) {
751609
+ itemExamples.push(itemExample2);
751610
+ }
751583
751611
  }
751584
751612
  }
751613
+ const itemExample = this.buildExampleHelper({
751614
+ example: void 0,
751615
+ schema: schema2.value,
751616
+ depth: depth + 1,
751617
+ visitedSchemaIds,
751618
+ options
751619
+ });
751620
+ if (itemExample != null) {
751621
+ itemExamples.push(itemExample);
751622
+ }
751585
751623
  return import_example2.FullExample.array(itemExamples);
751586
751624
  }
751587
751625
  case "map": {
@@ -751592,16 +751630,16 @@ var ExampleTypeFactory = class {
751592
751630
  const keyExample2 = this.buildExampleFromPrimitive({
751593
751631
  schema: schema2.key.schema,
751594
751632
  example: key2,
751595
- isOptional
751633
+ options
751596
751634
  });
751597
751635
  const valueExample2 = this.buildExampleHelper({
751598
751636
  example: value,
751599
751637
  schema: schema2.value,
751600
- isOptional,
751601
751638
  visitedSchemaIds,
751602
- parameter
751639
+ depth: depth + 1,
751640
+ options
751603
751641
  });
751604
- if (keyExample2 != null && valueExample2 != null) {
751642
+ if (valueExample2 != null) {
751605
751643
  kvs.push({
751606
751644
  key: keyExample2,
751607
751645
  value: valueExample2
@@ -751613,16 +751651,16 @@ var ExampleTypeFactory = class {
751613
751651
  const keyExample = this.buildExampleFromPrimitive({
751614
751652
  schema: schema2.key.schema,
751615
751653
  example: void 0,
751616
- isOptional
751654
+ options
751617
751655
  });
751618
751656
  const valueExample = this.buildExampleHelper({
751619
751657
  example: void 0,
751620
751658
  schema: schema2.value,
751621
- isOptional,
751622
751659
  visitedSchemaIds,
751623
- parameter
751660
+ depth: depth + 1,
751661
+ options
751624
751662
  });
751625
- if (keyExample != null && valueExample != null) {
751663
+ if (valueExample != null) {
751626
751664
  return import_example2.FullExample.map([
751627
751665
  {
751628
751666
  key: keyExample,
@@ -751630,7 +751668,7 @@ var ExampleTypeFactory = class {
751630
751668
  }
751631
751669
  ]);
751632
751670
  }
751633
- return isOptional ? void 0 : import_example2.FullExample.map([]);
751671
+ return import_example2.FullExample.map([]);
751634
751672
  }
751635
751673
  case "object": {
751636
751674
  const result2 = {};
@@ -751642,25 +751680,82 @@ var ExampleTypeFactory = class {
751642
751680
  const propertyExample = this.buildExampleHelper({
751643
751681
  schema: schema3,
751644
751682
  example: fullExample[property3],
751645
- isOptional: !required,
751646
751683
  visitedSchemaIds,
751647
- parameter
751684
+ depth: depth + 1,
751685
+ options: {
751686
+ ...options,
751687
+ name: property3
751688
+ }
751648
751689
  });
751649
751690
  if (propertyExample != null) {
751650
751691
  result2[property3] = propertyExample;
751651
751692
  } else if (required) {
751652
- return void 0;
751693
+ const generatedExample = this.buildExampleHelper({
751694
+ schema: schema3,
751695
+ example: fullExample[property3],
751696
+ visitedSchemaIds,
751697
+ depth: depth + 1,
751698
+ options: {
751699
+ ...options,
751700
+ name: property3
751701
+ }
751702
+ });
751703
+ if (generatedExample == null) {
751704
+ return void 0;
751705
+ }
751706
+ result2[property3] = generatedExample;
751653
751707
  }
751654
751708
  }
751655
- const a2 = import_example2.FullExample.object({
751709
+ return import_example2.FullExample.object({
751656
751710
  properties: result2
751657
751711
  });
751658
- return a2;
751659
751712
  }
751660
751713
  default:
751661
751714
  assertNever(schema2);
751662
751715
  }
751663
751716
  }
751717
+ hasExample(schema2) {
751718
+ switch (schema2.type) {
751719
+ case "array":
751720
+ return this.hasExample(schema2.value);
751721
+ case "enum":
751722
+ return schema2.example != null;
751723
+ case "literal":
751724
+ return false;
751725
+ case "map":
751726
+ return schema2.key.schema.example != null && this.hasExample(schema2.value);
751727
+ case "object": {
751728
+ const objectExample = schema2.fullExamples != null && schema2.fullExamples.length > 0;
751729
+ if (objectExample) {
751730
+ return true;
751731
+ }
751732
+ for (const property3 of schema2.properties) {
751733
+ if (this.hasExample(property3.schema)) {
751734
+ return true;
751735
+ }
751736
+ }
751737
+ return false;
751738
+ }
751739
+ case "primitive":
751740
+ return schema2.schema.example != null;
751741
+ case "reference": {
751742
+ const resolvedSchema = this.schemas[schema2.schema];
751743
+ if (resolvedSchema != null) {
751744
+ return this.hasExample(resolvedSchema);
751745
+ }
751746
+ return false;
751747
+ }
751748
+ case "unknown":
751749
+ return schema2.example != null;
751750
+ case "oneOf":
751751
+ return Object.values(schema2.oneOf.schemas).some((schema3) => this.hasExample(schema3));
751752
+ default:
751753
+ return false;
751754
+ }
751755
+ }
751756
+ exceedsMaxDepth(depth, options) {
751757
+ return depth > (options.maxDepth ?? 0);
751758
+ }
751664
751759
  getAllProperties(object2) {
751665
751760
  let properties = {};
751666
751761
  for (const property3 of object2.properties) {
@@ -751716,89 +751811,80 @@ var ExampleTypeFactory = class {
751716
751811
  }
751717
751812
  return schema2;
751718
751813
  }
751719
- buildExampleFromPrimitive({ isOptional, example, schema: schema2 }) {
751814
+ buildExampleFromPrimitive({ example, schema: schema2, options }) {
751720
751815
  switch (schema2.type) {
751721
751816
  case "string":
751722
751817
  if (example != null && typeof example === "string") {
751723
751818
  return import_example2.PrimitiveExample.string(example);
751724
751819
  } else if (schema2.example != null) {
751725
751820
  return import_example2.PrimitiveExample.string(schema2.example);
751726
- } else if (!isOptional) {
751727
- return import_example2.PrimitiveExample.string("string");
751821
+ } else {
751822
+ return import_example2.PrimitiveExample.string(options.name ?? "string");
751728
751823
  }
751729
- return void 0;
751730
751824
  case "base64":
751731
751825
  if (example != null && typeof example === "string") {
751732
751826
  return import_example2.PrimitiveExample.base64(example);
751733
751827
  } else if (schema2.example != null) {
751734
751828
  return import_example2.PrimitiveExample.base64(schema2.example);
751735
- } else if (!isOptional) {
751829
+ } else {
751736
751830
  return import_example2.PrimitiveExample.base64("SGVsbG8gd29ybGQh");
751737
751831
  }
751738
- return void 0;
751739
751832
  case "boolean":
751740
751833
  if (example != null && typeof example === "boolean") {
751741
751834
  return import_example2.PrimitiveExample.boolean(example);
751742
751835
  } else if (schema2.example != null) {
751743
751836
  return import_example2.PrimitiveExample.boolean(schema2.example);
751744
- } else if (!isOptional) {
751837
+ } else {
751745
751838
  return import_example2.PrimitiveExample.boolean(true);
751746
751839
  }
751747
- return void 0;
751748
751840
  case "date":
751749
751841
  if (example != null && typeof example === "string") {
751750
751842
  return import_example2.PrimitiveExample.date(example);
751751
751843
  } else if (schema2.example != null) {
751752
751844
  return import_example2.PrimitiveExample.date(schema2.example);
751753
- } else if (!isOptional) {
751845
+ } else {
751754
751846
  return import_example2.PrimitiveExample.date("2023-01-15");
751755
751847
  }
751756
- return void 0;
751757
751848
  case "datetime":
751758
751849
  if (example != null && typeof example === "string") {
751759
751850
  return import_example2.PrimitiveExample.datetime(example);
751760
751851
  } else if (schema2.example != null) {
751761
751852
  return import_example2.PrimitiveExample.datetime(schema2.example);
751762
- } else if (!isOptional) {
751853
+ } else {
751763
751854
  return import_example2.PrimitiveExample.datetime("2024-01-15T09:30:00Z");
751764
751855
  }
751765
- return void 0;
751766
751856
  case "double":
751767
751857
  if (example != null && typeof example === "number") {
751768
751858
  return import_example2.PrimitiveExample.double(example);
751769
751859
  } else if (schema2.example != null) {
751770
751860
  return import_example2.PrimitiveExample.double(schema2.example);
751771
- } else if (!isOptional) {
751861
+ } else {
751772
751862
  return import_example2.PrimitiveExample.double(1.1);
751773
751863
  }
751774
- return void 0;
751775
751864
  case "float":
751776
751865
  if (example != null && typeof example === "number") {
751777
751866
  return import_example2.PrimitiveExample.float(example);
751778
751867
  } else if (schema2.example != null) {
751779
751868
  return import_example2.PrimitiveExample.float(schema2.example);
751780
- } else if (!isOptional) {
751869
+ } else {
751781
751870
  return import_example2.PrimitiveExample.float(1.1);
751782
751871
  }
751783
- return void 0;
751784
751872
  case "int":
751785
751873
  if (example != null && typeof example === "number") {
751786
751874
  return import_example2.PrimitiveExample.int(example);
751787
751875
  } else if (schema2.example != null) {
751788
751876
  return import_example2.PrimitiveExample.int(1);
751789
- } else if (!isOptional) {
751877
+ } else {
751790
751878
  return import_example2.PrimitiveExample.int(1);
751791
751879
  }
751792
- return void 0;
751793
751880
  case "int64":
751794
751881
  if (example != null && typeof example === "number") {
751795
751882
  return import_example2.PrimitiveExample.int64(example);
751796
751883
  } else if (schema2.example != null) {
751797
751884
  return import_example2.PrimitiveExample.int64(schema2.example);
751798
- } else if (!isOptional) {
751885
+ } else {
751799
751886
  return import_example2.PrimitiveExample.int64(1e6);
751800
751887
  }
751801
- return void 0;
751802
751888
  default:
751803
751889
  assertNever(schema2);
751804
751890
  }
@@ -751834,8 +751920,10 @@ var ExampleEndpointFactory = class {
751834
751920
  requestExample = this.exampleTypeFactory.buildExample({
751835
751921
  schema: requestSchemaIdResponse.schema,
751836
751922
  example: (_a2 = requestSchemaIdResponse.example) == null ? void 0 : _a2.value,
751837
- isOptional: !required,
751838
- parameter: false
751923
+ options: {
751924
+ isParameter: false,
751925
+ ignoreOptionals: true
751926
+ }
751839
751927
  });
751840
751928
  if (required && requestExample == null) {
751841
751929
  return void 0;
@@ -751847,8 +751935,11 @@ var ExampleEndpointFactory = class {
751847
751935
  responseExample = this.exampleTypeFactory.buildExample({
751848
751936
  schema: responseSchemaIdResponse.schema,
751849
751937
  example: (_b2 = responseSchemaIdResponse.example) == null ? void 0 : _b2.value,
751850
- isOptional: !required,
751851
- parameter: false
751938
+ options: {
751939
+ isParameter: false,
751940
+ ignoreOptionals: false,
751941
+ maxDepth: 3
751942
+ }
751852
751943
  });
751853
751944
  if (required && responseExample == null) {
751854
751945
  return void 0;
@@ -751859,9 +751950,12 @@ var ExampleEndpointFactory = class {
751859
751950
  const required = this.isSchemaRequired(pathParameter.schema);
751860
751951
  let example = this.exampleTypeFactory.buildExample({
751861
751952
  schema: pathParameter.schema,
751862
- isOptional: !required,
751863
751953
  example: void 0,
751864
- parameter: true
751954
+ options: {
751955
+ name: pathParameter.name,
751956
+ isParameter: true,
751957
+ ignoreOptionals: true
751958
+ }
751865
751959
  });
751866
751960
  if (example != null && !isExamplePrimitive(example)) {
751867
751961
  example = void 0;
@@ -751880,9 +751974,12 @@ var ExampleEndpointFactory = class {
751880
751974
  const required = this.isSchemaRequired(queryParameter.schema);
751881
751975
  let example = this.exampleTypeFactory.buildExample({
751882
751976
  schema: queryParameter.schema,
751883
- isOptional: !required,
751884
751977
  example: void 0,
751885
- parameter: true
751978
+ options: {
751979
+ name: queryParameter.name,
751980
+ isParameter: true,
751981
+ ignoreOptionals: true
751982
+ }
751886
751983
  });
751887
751984
  if (example != null && !isExamplePrimitive(example)) {
751888
751985
  example = void 0;
@@ -751901,9 +751998,12 @@ var ExampleEndpointFactory = class {
751901
751998
  const required = this.isSchemaRequired(header.schema);
751902
751999
  let example = this.exampleTypeFactory.buildExample({
751903
752000
  schema: header.schema,
751904
- isOptional: !required,
751905
752001
  example: void 0,
751906
- parameter: true
752002
+ options: {
752003
+ name: header.name,
752004
+ isParameter: true,
752005
+ ignoreOptionals: true
752006
+ }
751907
752007
  });
751908
752008
  if (example != null && !isExamplePrimitive(example)) {
751909
752009
  example = void 0;
@@ -760945,10 +761045,10 @@ var CliContext = class {
760945
761045
  return "fern-api";
760946
761046
  }
760947
761047
  getPackageVersion() {
760948
- if ("0.17.1-rc0" == null) {
761048
+ if ("0.17.2" == null) {
760949
761049
  this.logger.error("CLI_VERSION is not defined");
760950
761050
  }
760951
- return "0.17.1-rc0";
761051
+ return "0.17.2";
760952
761052
  }
760953
761053
  getCliName() {
760954
761054
  if ("fern" == null) {
@@ -777187,13 +777287,20 @@ function getColorType({ background, accentPrimary }) {
777187
777287
  function convertThemedColorConfig(rawConfig, context, theme) {
777188
777288
  let accentPrimaryColor = getColorInstanceFromRawConfig(rawConfig.accentPrimary, context, "accentPrimary", theme);
777189
777289
  let backgroundColor = getColorInstanceFromRawConfig(rawConfig.background, context, "background", theme);
777190
- backgroundColor = enforceTheme(backgroundColor, context, "background", theme);
777191
- accentPrimaryColor = enforceTheme(accentPrimaryColor, context, "accentPrimary", theme === "dark" ? "light" : "dark");
777192
- if (accentPrimaryColor != null && backgroundColor != null) {
777193
- if (!tinycolor.isReadable(accentPrimaryColor, backgroundColor)) {
777194
- const ratio = tinycolor.readability(accentPrimaryColor, backgroundColor);
777195
- accentPrimaryColor = tinycolor.mostReadable(backgroundColor, accentPrimaryColor.monochromatic(3));
777196
- context.logger.warn(`The accent color is not readable on the background color in ${theme} mode. The contrast ratio is ${ratio}. We've adjusted the accent color to ${accentPrimaryColor.toHexString()} to improve readability.`);
777290
+ if (backgroundColor != null) {
777291
+ const newBackgroundColor = enforceBackgroundTheme(tinycolor(backgroundColor.toString()), theme);
777292
+ if (newBackgroundColor.toHexString() !== backgroundColor.toHexString()) {
777293
+ context.logger.warn(`The chosen shade, 'backgroundColor' in ${theme} mode, fails to meet minimum contrast requirements. The brightness is ${backgroundColor.getBrightness()}. To enhance accessibility and ensure content readability, Fern will adjust from ${backgroundColor.toHexString()} to a more contrast-rich ${newBackgroundColor.toHexString()}.`);
777294
+ backgroundColor = newBackgroundColor;
777295
+ }
777296
+ }
777297
+ if (accentPrimaryColor != null) {
777298
+ const backgroundColorWithFallback = backgroundColor ?? tinycolor(theme === "dark" ? "#000" : "#FFF");
777299
+ const newAccentPrimaryColor = increaseForegroundContrast(tinycolor(accentPrimaryColor.toString()), backgroundColorWithFallback);
777300
+ if (newAccentPrimaryColor.toHexString() !== accentPrimaryColor.toHexString()) {
777301
+ const ratio = tinycolor.readability(accentPrimaryColor, backgroundColorWithFallback);
777302
+ context.logger.warn(`The chosen shade, 'accentColor' in ${theme} mode, fails to meet minimum contrast requirements. The contrast ratio is ${ratio}, which is below WCAG AA requirements (4.5:1). To enhance accessibility and ensure content readability, Fern will adjust from ${accentPrimaryColor.toHexString()} to a more contrast-rich ${newAccentPrimaryColor.toHexString()}.`);
777303
+ accentPrimaryColor = newAccentPrimaryColor;
777197
777304
  }
777198
777305
  }
777199
777306
  return {
@@ -777201,25 +777308,31 @@ function convertThemedColorConfig(rawConfig, context, theme) {
777201
777308
  background: toRgb2(backgroundColor)
777202
777309
  };
777203
777310
  }
777204
- function enforceTheme(color3, context, key2, theme) {
777205
- if (color3 == null) {
777206
- return void 0;
777311
+ function increaseForegroundContrast(foregroundColor, backgroundColor) {
777312
+ let newForgroundColor = foregroundColor;
777313
+ const dark = backgroundColor.isDark();
777314
+ while (!tinycolor.isReadable(newForgroundColor, backgroundColor)) {
777315
+ if (dark ? newForgroundColor.getBrightness() === 255 : newForgroundColor.getBrightness() === 0) {
777316
+ break;
777317
+ }
777318
+ newForgroundColor = dark ? newForgroundColor.lighten(1) : newForgroundColor.darken(1);
777207
777319
  }
777320
+ return newForgroundColor;
777321
+ }
777322
+ function enforceBackgroundTheme(color3, theme) {
777208
777323
  if (theme === "dark" && color3.isDark()) {
777209
777324
  return color3;
777210
777325
  } else if (theme === "light" && color3.isLight()) {
777211
777326
  return color3;
777212
777327
  }
777213
- const newColor = getOppositeLuminance(color3);
777214
- context.logger.warn(`The ${key2} color should be ${theme}. We've adjusted the color to ${newColor.toHexString()} to match the theme by flipping its luminance.`);
777215
- return newColor;
777328
+ return getOppositeBrightness(color3);
777216
777329
  }
777217
- function getOppositeLuminance(color3) {
777330
+ function getOppositeBrightness(color3) {
777218
777331
  if (color3 == null) {
777219
777332
  return void 0;
777220
777333
  }
777221
- const { h: h3, s: s2, l: l2 } = color3.toHsl();
777222
- return tinycolor({ h: h3, s: s2, l: 1 - l2 });
777334
+ const { h: h3, s: s2, v: v2 } = color3.toHsv();
777335
+ return tinycolor({ h: h3, s: s2, v: 1 - v2 });
777223
777336
  }
777224
777337
  function toRgb2(color3) {
777225
777338
  if (color3 == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.17.1-rc0",
3
+ "version": "0.17.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",