@fairfox/polly 0.38.0 → 0.38.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.
@@ -4760,7 +4760,7 @@ class StructurizrDSLGenerator {
4760
4760
  }
4761
4761
  const properties = this.getComponentProperties(messageType, firstHandler, contextType);
4762
4762
  componentDefs.push({
4763
- id: this.toId(componentName),
4763
+ id: this.componentIdForMessageType(messageType, handlers),
4764
4764
  name: componentName,
4765
4765
  description,
4766
4766
  tags,
@@ -4942,8 +4942,8 @@ class StructurizrDSLGenerator {
4942
4942
  }
4943
4943
  for (const api of contextInfo.chromeAPIs) {
4944
4944
  const apiId = this.toId(`chrome_${api}`);
4945
- for (const [messageType, _handlers] of handlersByType) {
4946
- const componentId = this.toId(this.toComponentName(messageType));
4945
+ for (const [messageType, handlers] of handlersByType) {
4946
+ const componentId = this.componentIdForMessageType(messageType, handlers);
4947
4947
  const description = this.inferChromeAPIDescription(api, messageType);
4948
4948
  parts.push(` ${componentId} -> ${apiId} "${description}"`);
4949
4949
  }
@@ -5025,9 +5025,9 @@ class StructurizrDSLGenerator {
5025
5025
  classifyHandlersByType(handlersByType) {
5026
5026
  const stateHandlers = [];
5027
5027
  const queryHandlers = [];
5028
- for (const [messageType, _handlers] of handlersByType) {
5028
+ for (const [messageType, handlers] of handlersByType) {
5029
5029
  const type = messageType.toLowerCase();
5030
- const componentId = this.toId(this.toComponentName(messageType));
5030
+ const componentId = this.componentIdForMessageType(messageType, handlers);
5031
5031
  if (this.isStateHandler(type)) {
5032
5032
  stateHandlers.push(componentId);
5033
5033
  } else if (this.isQueryHandler(type)) {
@@ -5288,7 +5288,7 @@ class StructurizrDSLGenerator {
5288
5288
  parts.push(` dynamic ${scope} "${title}" "${description}" {`);
5289
5289
  let stepCount = 0;
5290
5290
  for (const { handler, contextName: _contextName } of handlers) {
5291
- const handlerComponentId = this.toId(`${handler.messageType}_handler`);
5291
+ const handlerComponentId = this.componentIdForMessageType(handler.messageType, [handler]);
5292
5292
  const relationships = handler.relationships || [];
5293
5293
  for (const rel of relationships) {
5294
5294
  const toComponent = this.toId(rel.to);
@@ -5599,6 +5599,10 @@ class StructurizrDSLGenerator {
5599
5599
  toComponentName(messageType) {
5600
5600
  return `${messageType.split("_").map((part) => this.capitalize(part.toLowerCase())).join(" ")} Handler`;
5601
5601
  }
5602
+ componentIdForMessageType(messageType, handlers) {
5603
+ const isRest = handlers[0]?.handlerKind === "rest";
5604
+ return this.toId(isRest ? messageType : this.toComponentName(messageType));
5605
+ }
5602
5606
  toId(name) {
5603
5607
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
5604
5608
  }
@@ -6244,4 +6248,4 @@ main().catch((_error) => {
6244
6248
  process.exit(1);
6245
6249
  });
6246
6250
 
6247
- //# debugId=D8A50515F91A187B64756E2164756E21
6251
+ //# debugId=AE16308C36D5CB6E64756E2164756E21