fern-api 0.30.8-rc5 → 0.30.8-rc6

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 +160 -5
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -349832,6 +349832,12 @@ var init_WebhookGroupId = __esm({
349832
349832
  }
349833
349833
  });
349834
349834
 
349835
+ // pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/api/resources/commons/types/WebhookId.js
349836
+ var init_WebhookId = __esm({
349837
+ "pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/api/resources/commons/types/WebhookId.js"() {
349838
+ }
349839
+ });
349840
+
349835
349841
  // pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/api/resources/commons/types/WebSocketChannelId.js
349836
349842
  var init_WebSocketChannelId = __esm({
349837
349843
  "pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/api/resources/commons/types/WebSocketChannelId.js"() {
@@ -349905,6 +349911,7 @@ var init_types3 = __esm({
349905
349911
  init_TypeId();
349906
349912
  init_ErrorId();
349907
349913
  init_WebhookGroupId();
349914
+ init_WebhookId();
349908
349915
  init_WebSocketChannelId();
349909
349916
  init_FeatureId();
349910
349917
  init_Declaration();
@@ -354729,6 +354736,15 @@ var init_WebhookGroupId2 = __esm({
354729
354736
  }
354730
354737
  });
354731
354738
 
354739
+ // pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/serialization/resources/commons/types/WebhookId.js
354740
+ var WebhookId2;
354741
+ var init_WebhookId2 = __esm({
354742
+ "pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/serialization/resources/commons/types/WebhookId.js"() {
354743
+ init_core2();
354744
+ WebhookId2 = schemas_exports4.string();
354745
+ }
354746
+ });
354747
+
354732
354748
  // pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/serialization/resources/commons/types/WebSocketChannelId.js
354733
354749
  var WebSocketChannelId;
354734
354750
  var init_WebSocketChannelId2 = __esm({
@@ -354808,6 +354824,7 @@ var init_types15 = __esm({
354808
354824
  init_TypeId2();
354809
354825
  init_ErrorId2();
354810
354826
  init_WebhookGroupId2();
354827
+ init_WebhookId2();
354811
354828
  init_WebSocketChannelId2();
354812
354829
  init_FeatureId2();
354813
354830
  init_Declaration2();
@@ -354837,6 +354854,7 @@ __export(commons_exports12, {
354837
354854
  TypeId: () => TypeId,
354838
354855
  WebSocketChannelId: () => WebSocketChannelId,
354839
354856
  WebhookGroupId: () => WebhookGroupId,
354857
+ WebhookId: () => WebhookId2,
354840
354858
  WithDocs: () => WithDocs,
354841
354859
  WithJsonExample: () => WithJsonExample
354842
354860
  });
@@ -357458,6 +357476,7 @@ var init_Webhook2 = __esm({
357458
357476
  "pnp:/home/circleci/project/packages/ir-sdk/lib/sdk/serialization/resources/webhooks/types/Webhook.js"() {
357459
357477
  init_core2();
357460
357478
  Webhook = schemas_exports4.objectWithoutOptionalProperties({
357479
+ id: schemas_exports4.lazy(async () => (await Promise.resolve().then(() => (init_serialization2(), serialization_exports2))).WebhookId).optional(),
357461
357480
  name: schemas_exports4.lazyObject(async () => (await Promise.resolve().then(() => (init_serialization2(), serialization_exports2))).WebhookName),
357462
357481
  displayName: schemas_exports4.string().optional(),
357463
357482
  method: schemas_exports4.lazy(async () => (await Promise.resolve().then(() => (init_serialization2(), serialization_exports2))).WebhookHttpMethod),
@@ -358023,6 +358042,7 @@ __export(serialization_exports2, {
358023
358042
  WebhookGroup: () => WebhookGroup,
358024
358043
  WebhookGroupId: () => WebhookGroupId,
358025
358044
  WebhookHttpMethod: () => WebhookHttpMethod4,
358045
+ WebhookId: () => WebhookId2,
358026
358046
  WebhookName: () => WebhookName,
358027
358047
  WebhookPayload: () => WebhookPayload2,
358028
358048
  WebhookPayloadReference: () => WebhookPayloadReference,
@@ -1054368,7 +1054388,7 @@ var AccessTokenPosthogManager = class {
1054368
1054388
  properties: {
1054369
1054389
  ...event,
1054370
1054390
  ...event.properties,
1054371
- version: "0.30.8-rc5",
1054391
+ version: "0.30.8-rc6",
1054372
1054392
  usingAccessToken: true
1054373
1054393
  }
1054374
1054394
  });
@@ -1054430,7 +1054450,7 @@ var UserPosthogManager = class {
1054430
1054450
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1054431
1054451
  event: "CLI",
1054432
1054452
  properties: {
1054433
- version: "0.30.8-rc5",
1054453
+ version: "0.30.8-rc6",
1054434
1054454
  ...event,
1054435
1054455
  ...event.properties
1054436
1054456
  }
@@ -1080373,10 +1080393,10 @@ var CliContext = class {
1080373
1080393
  return "fern-api";
1080374
1080394
  }
1080375
1080395
  getPackageVersion() {
1080376
- if ("0.30.8-rc5" == null) {
1080396
+ if ("0.30.8-rc6" == null) {
1080377
1080397
  this.logger.error("CLI_VERSION is not defined");
1080378
1080398
  }
1080379
- return "0.30.8-rc5";
1080399
+ return "0.30.8-rc6";
1080380
1080400
  }
1080381
1080401
  getCliName() {
1080382
1080402
  if ("fern" == null) {
@@ -1081205,6 +1081225,10 @@ var IdGenerator = {
1081205
1081225
  const joinedFernFilePath = stringifyFernFilepath(fernFilepath);
1081206
1081226
  return `webhooks_${joinedFernFilePath}`;
1081207
1081227
  },
1081228
+ generateWebhookId: (fernFilepath, webhookId) => {
1081229
+ const joinedFernFilePath = stringifyFernFilepath(fernFilepath);
1081230
+ return `webhooks_${joinedFernFilePath}.${webhookId}`;
1081231
+ },
1081208
1081232
  generateWebSocketChannelId: (fernFilepath) => {
1081209
1081233
  const joinedFernFilePath = stringifyFernFilepath(fernFilepath);
1081210
1081234
  return `channel_${joinedFernFilePath}`;
@@ -1084896,6 +1084920,7 @@ async function convertWebhookGroup({ webhooks, file, typeResolver, exampleResolv
1084896
1084920
  const webhookGroup = [];
1084897
1084921
  for (const [webhookId, webhook] of Object.entries(webhooks)) {
1084898
1084922
  webhookGroup.push({
1084923
+ id: IdGenerator.generateWebhookId(file.fernFilepath, webhookId),
1084899
1084924
  availability: convertAvailability2(webhook.availability),
1084900
1084925
  displayName: webhook["display-name"],
1084901
1084926
  docs: webhook.docs,
@@ -1085787,13 +1085812,17 @@ var FilteredIrImpl = class {
1085787
1085812
  services = /* @__PURE__ */ new Set();
1085788
1085813
  endpoints = /* @__PURE__ */ new Set();
1085789
1085814
  requestProperties;
1085815
+ webhooks = /* @__PURE__ */ new Set();
1085816
+ webhookPayloadProperties;
1085790
1085817
  subpackages = /* @__PURE__ */ new Set();
1085791
- constructor({ types: types3, errors, services, endpoints, subpackages, requestProperties, properties }) {
1085818
+ constructor({ types: types3, errors, services, endpoints, webhooks, subpackages, requestProperties, webhookPayloadProperties, properties }) {
1085792
1085819
  this.types = types3;
1085793
1085820
  this.properties = properties;
1085794
1085821
  this.errors = errors;
1085795
1085822
  this.services = services;
1085796
1085823
  this.endpoints = endpoints;
1085824
+ this.webhooks = webhooks;
1085825
+ this.webhookPayloadProperties = webhookPayloadProperties;
1085797
1085826
  this.subpackages = subpackages;
1085798
1085827
  this.requestProperties = requestProperties;
1085799
1085828
  }
@@ -1085841,6 +1085870,19 @@ var FilteredIrImpl = class {
1085841
1085870
  hasSubpackage(subpackageId) {
1085842
1085871
  return this.subpackages.has(subpackageId);
1085843
1085872
  }
1085873
+ hasWebhook(webhook) {
1085874
+ if (webhook.id) {
1085875
+ return this.webhooks.has(webhook.id);
1085876
+ }
1085877
+ return true;
1085878
+ }
1085879
+ hasWebhookPayloadProperty(webhookId, property5) {
1085880
+ const properties = this.webhookPayloadProperties[webhookId];
1085881
+ if (properties == null) {
1085882
+ return true;
1085883
+ }
1085884
+ return properties.has(property5);
1085885
+ }
1085844
1085886
  };
1085845
1085887
 
1085846
1085888
  // pnp:/home/circleci/project/packages/cli/generation/ir-generator/lib/filtered-ir/IrGraph.js
@@ -1085848,13 +1085890,16 @@ var IrGraph = class {
1085848
1085890
  types = {};
1085849
1085891
  properties = {};
1085850
1085892
  requestProperties = {};
1085893
+ webhookProperties = {};
1085851
1085894
  errors = {};
1085852
1085895
  endpoints = {};
1085896
+ webhooks = {};
1085853
1085897
  audiences;
1085854
1085898
  typesReferencedByService = {};
1085855
1085899
  typesNeededForAudience = /* @__PURE__ */ new Set();
1085856
1085900
  servicesNeededForAudience = /* @__PURE__ */ new Set();
1085857
1085901
  endpointsNeededForAudience = /* @__PURE__ */ new Set();
1085902
+ webhooksNeededForAudience = /* @__PURE__ */ new Set();
1085858
1085903
  subpackagesNeededForAudience = /* @__PURE__ */ new Set();
1085859
1085904
  constructor(audiences) {
1085860
1085905
  this.audiences = audiencesFromConfig(audiences);
@@ -1086015,6 +1086060,56 @@ var IrGraph = class {
1086015
1086060
  this.addSubpackages(declaredServiceName.fernFilepath);
1086016
1086061
  }
1086017
1086062
  }
1086063
+ addWebhook(file, webhook, rawWebhook) {
1086064
+ const webhookId = webhook.id;
1086065
+ if (webhookId == null) {
1086066
+ return;
1086067
+ }
1086068
+ const referencedTypes = /* @__PURE__ */ new Set();
1086069
+ const referencedSubpackages = /* @__PURE__ */ new Set();
1086070
+ if (webhook.payload != null) {
1086071
+ WebhookPayload._visit(webhook.payload, {
1086072
+ inlinedPayload: (inlinedPayload) => {
1086073
+ for (const extension3 of inlinedPayload.extends) {
1086074
+ populateReferencesFromTypeName(extension3, referencedTypes, referencedSubpackages);
1086075
+ }
1086076
+ for (const property5 of inlinedPayload.properties) {
1086077
+ populateReferencesFromTypeReference(property5.valueType, referencedTypes, referencedSubpackages);
1086078
+ }
1086079
+ if ((rawWebhook == null ? void 0 : rawWebhook.payload) != null && typeof rawWebhook.payload === "object" && !isReferencedWebhookPayloadSchema2(rawWebhook.payload)) {
1086080
+ const propertiesByAudience = getPropertiesForAudience(rawWebhook.payload.properties ?? {});
1086081
+ this.webhookProperties[webhookId] = {
1086082
+ webhookId,
1086083
+ propertiesByAudience
1086084
+ };
1086085
+ }
1086086
+ },
1086087
+ reference: ({ payloadType }) => {
1086088
+ populateReferencesFromTypeReference(payloadType, referencedTypes, referencedSubpackages);
1086089
+ },
1086090
+ _other: () => {
1086091
+ var _a5;
1086092
+ throw new Error("Unknown WebhookPayload: " + ((_a5 = webhook.payload) == null ? void 0 : _a5.type));
1086093
+ }
1086094
+ });
1086095
+ }
1086096
+ referencedSubpackages.add(file.fernFilepath);
1086097
+ this.webhooks[webhookId] = {
1086098
+ webhookId,
1086099
+ referencedTypes,
1086100
+ referencedSubpackages
1086101
+ };
1086102
+ }
1086103
+ markWebhookForAudiences(file, webhook, audiences) {
1086104
+ const webhookId = webhook.id;
1086105
+ if (webhookId == null) {
1086106
+ return;
1086107
+ }
1086108
+ if (this.hasAudience(audiences)) {
1086109
+ this.webhooksNeededForAudience.add(webhookId);
1086110
+ this.addSubpackages(file.fernFilepath);
1086111
+ }
1086112
+ }
1086018
1086113
  build() {
1086019
1086114
  const typeIds = /* @__PURE__ */ new Set();
1086020
1086115
  const errorIds = /* @__PURE__ */ new Set();
@@ -1086031,8 +1086126,13 @@ var IrGraph = class {
1086031
1086126
  this.addReferencedTypes(typeIds, endpointNode.referencedTypes);
1086032
1086127
  }
1086033
1086128
  this.addReferencedTypes(typeIds, this.typesNeededForAudience);
1086129
+ for (const webhookId of this.webhooksNeededForAudience.keys()) {
1086130
+ const webhookNode = this.getWebhookNode(webhookId);
1086131
+ this.addReferencedTypes(typeIds, webhookNode.referencedTypes);
1086132
+ }
1086034
1086133
  const properties = {};
1086035
1086134
  const requestProperties = {};
1086135
+ const webhookPayloadProperties = {};
1086036
1086136
  if (this.audiences.type === "filtered") {
1086037
1086137
  for (const [typeId, typePropertiesNode] of Object.entries(this.properties)) {
1086038
1086138
  if (!typeIds.has(typeId)) {
@@ -1086068,6 +1086168,23 @@ var IrGraph = class {
1086068
1086168
  requestProperties[endpointId] = propertiesForEndpoint;
1086069
1086169
  }
1086070
1086170
  }
1086171
+ for (const [webhookId, webhookPaylodPropertiesNode] of Object.entries(this.webhookProperties)) {
1086172
+ if (!this.webhooksNeededForAudience.has(webhookId)) {
1086173
+ continue;
1086174
+ }
1086175
+ const propertiesForWebhook = /* @__PURE__ */ new Set();
1086176
+ for (const audience of this.audiences.audiences) {
1086177
+ const propertiesForAudience = webhookPaylodPropertiesNode.propertiesByAudience[audience];
1086178
+ if (propertiesForAudience != null) {
1086179
+ propertiesForAudience.forEach((property5) => {
1086180
+ propertiesForWebhook.add(property5);
1086181
+ });
1086182
+ }
1086183
+ }
1086184
+ if (propertiesForWebhook.size > 0) {
1086185
+ requestProperties[webhookId] = propertiesForWebhook;
1086186
+ }
1086187
+ }
1086071
1086188
  }
1086072
1086189
  return new FilteredIrImpl({
1086073
1086190
  types: typeIds,
@@ -1086076,6 +1086193,8 @@ var IrGraph = class {
1086076
1086193
  requestProperties,
1086077
1086194
  services: this.servicesNeededForAudience,
1086078
1086195
  endpoints: this.endpointsNeededForAudience,
1086196
+ webhooks: this.webhooksNeededForAudience,
1086197
+ webhookPayloadProperties,
1086079
1086198
  subpackages: this.subpackagesNeededForAudience
1086080
1086199
  });
1086081
1086200
  }
@@ -1086136,6 +1086255,13 @@ var IrGraph = class {
1086136
1086255
  }
1086137
1086256
  return endpointNode;
1086138
1086257
  }
1086258
+ getWebhookNode(webhookId) {
1086259
+ const webhookNode = this.webhooks[webhookId];
1086260
+ if (webhookNode == null) {
1086261
+ throw new Error(`Failed to find webhook node with id ${webhookId}`);
1086262
+ }
1086263
+ return webhookNode;
1086264
+ }
1086139
1086265
  hasNoAudiences() {
1086140
1086266
  return this.audiences.type === "none";
1086141
1086267
  }
@@ -1087462,6 +1087588,19 @@ async function generateIntermediateRepresentation({ workspace, generationLanguag
1087462
1087588
  exampleResolver,
1087463
1087589
  workspace
1087464
1087590
  });
1087591
+ const webhooksByOriginalName = {};
1087592
+ for (const convertedWebhook of convertedWebhookGroup) {
1087593
+ webhooksByOriginalName[convertedWebhook.name.originalName] = convertedWebhook;
1087594
+ }
1087595
+ Object.entries(webhooks).forEach(([key2, webhook]) => {
1087596
+ const irWebhook = webhooksByOriginalName[key2];
1087597
+ if (irWebhook != null) {
1087598
+ irGraph.addWebhook(file, irWebhook, webhook);
1087599
+ if (webhook.audiences != null) {
1087600
+ irGraph.markWebhookForAudiences(file, irWebhook, webhook.audiences);
1087601
+ }
1087602
+ }
1087603
+ });
1087465
1087604
  intermediateRepresentation.webhookGroups[webhookGroupId] = convertedWebhookGroup;
1087466
1087605
  packageTreeGenerator.addWebhookGroup(webhookGroupId, file.fernFilepath);
1087467
1087606
  },
@@ -1087611,6 +1087750,21 @@ function filterIntermediateRepresentationForAudiences(intermediateRepresentation
1087611
1087750
  }
1087612
1087751
  return [typeId, typeDeclaration];
1087613
1087752
  }));
1087753
+ const filteredWebhookGroups = Object.fromEntries(Object.entries(intermediateRepresentation.webhookGroups).map(([webhookGroupId, webhookGroup]) => {
1087754
+ const filteredWebhooks = webhookGroup.filter((webhook) => filteredIr.hasWebhook(webhook)).map((webhook) => {
1087755
+ const webhookId = webhook.id;
1087756
+ if (webhook.payload.type === "inlinedPayload" && webhookId != null) {
1087757
+ webhook.payload = {
1087758
+ ...webhook.payload,
1087759
+ properties: webhook.payload.properties.filter((property5) => {
1087760
+ return filteredIr.hasWebhookPayloadProperty(webhookId, property5.name.wireValue);
1087761
+ })
1087762
+ };
1087763
+ }
1087764
+ return webhook;
1087765
+ });
1087766
+ return [webhookGroupId, filteredWebhooks];
1087767
+ }));
1087614
1087768
  return {
1087615
1087769
  ...intermediateRepresentation,
1087616
1087770
  types: filteredTypesAndProperties,
@@ -1087645,6 +1087799,7 @@ function filterIntermediateRepresentationForAudiences(intermediateRepresentation
1087645
1087799
  return httpEndpoint;
1087646
1087800
  })
1087647
1087801
  })),
1087802
+ webhookGroups: filteredWebhookGroups,
1087648
1087803
  serviceTypeReferenceInfo: filterServiceTypeReferenceInfoForAudiences(intermediateRepresentation.serviceTypeReferenceInfo, filteredIr)
1087649
1087804
  };
1087650
1087805
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.30.8-rc5",
3
+ "version": "0.30.8-rc6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",