@salesforcedevs/docs-components 1.3.172 → 1.3.173

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.172",
3
+ "version": "1.3.173",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "5ee185196e3f394e324227f4ca61d8578e6ec8d2"
27
+ "gitHead": "85f6ef2fd7789804c470b862101492739432cc04"
28
28
  }
@@ -1,4 +1,9 @@
1
- import { AmfHelperMixin } from "@api-components/amf-helper-mixin";
1
+ // @ts-nocheck not going to check this file because it deals almost entirely with the AmfHelperMixin, which is terrible and not worth messing with. We should just upgrade our LWC version instead.
2
+ import {
3
+ AmfHelperMixin,
4
+ EndPoint,
5
+ Operation
6
+ } from "@api-components/amf-helper-mixin";
2
7
  import { normalizeDomId } from "dxUtils/normalizers";
3
8
 
4
9
  const ID_PROPERTY = "@id";
@@ -7,7 +12,7 @@ const TYPE_PROPERTY = "@type";
7
12
  export class AmfModelParser extends AmfHelperMixin(Object) {
8
13
  _parsedModel = null;
9
14
 
10
- constructor(api) {
15
+ constructor(api: any) {
11
16
  super();
12
17
  if (api) {
13
18
  this.amf = Array.isArray(api) ? api[0] : api;
@@ -517,7 +522,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
517
522
  * @param {string} selected Currently selected `@id`.
518
523
  * @return {any|undefined} Model definition for an endpoint fragment.
519
524
  */
520
- computeEndpointApiModel(model, selectedId) {
525
+ computeEndpointApiModel(model, selectedId): EndPoint {
521
526
  const webApi = this._computeApi(model);
522
527
  return this._computeEndpointModel(webApi, selectedId);
523
528
  }
@@ -529,7 +534,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
529
534
  * @param {string} selected Currently selected `@id`.
530
535
  * @return {any|undefined} Model definition for an endpoint fragment.
531
536
  */
532
- computeMethodApiModel(model, selected) {
537
+ computeMethodApiModel(model, selected): Operation | undefined {
533
538
  const webApi = this._computeApi(model);
534
539
  return this._computeMethodModel(webApi, selected);
535
540
  }
@@ -541,7 +546,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
541
546
  * @param {string} selected Currently selected `@id`.
542
547
  * @return {any|undefined} Model definition for an endpoint fragment.
543
548
  */
544
- computeEndpointApiMethodModel(model, selected) {
549
+ computeEndpointApiMethodModel(model, selected): EndPoint | undefined {
545
550
  const webApi = this._computeApi(model);
546
551
  return this._computeMethodEndpoint(webApi, selected);
547
552
  }
@@ -2,7 +2,7 @@ import { LightningElement, api, track } from "lwc";
2
2
  import { noCase } from "no-case";
3
3
  import { sentenceCase } from "sentence-case";
4
4
  import qs from "query-string";
5
- import { AmfModelParser } from "./utils";
5
+ import { AmfModelParser } from "doc/amfModelParser";
6
6
  import { normalizeBoolean } from "dxUtils/normalizers";
7
7
  import { CoveoAnalyticsClient } from "coveo.analytics";
8
8
  import type {
@@ -30,18 +30,26 @@ import { restoreScroll } from "dx/scrollManager";
30
30
  import { DocPhaseInfo } from "typings/custom";
31
31
  import { oldVersionDocInfo } from "docUtils/utils";
32
32
 
33
+ type NavigationItem = {
34
+ label: string;
35
+ name: string;
36
+ isExpanded: boolean;
37
+ children: ParsedMarkdownTopic[];
38
+ isChildrenLoading: boolean;
39
+ };
40
+
33
41
  export default class AmfReference extends LightningElement {
34
- @api breadcrumbs?: string | null | undefined = null;
42
+ @api breadcrumbs: string | null = null;
35
43
  @api sidebarHeader!: string;
36
44
  @api coveoOrganizationId!: string;
37
45
  @api coveoPublicAccessToken!: string;
38
46
  @api coveoAnalyticsToken!: string;
39
47
  @api coveoAdvancedQueryConfig!: string;
40
48
  @api coveoSearchHub!: string;
41
- @api useOldSidebar?: boolean = false;
49
+ @api useOldSidebar: boolean = false;
42
50
  @api tocTitle?: string;
43
51
  @api tocOptions?: string;
44
- @track navigation = [];
52
+ @track navigation = [] as NavigationItem[];
45
53
  @track versions: Array<ReferenceVersion> = [];
46
54
  @track showVersionBanner = false;
47
55
 
@@ -125,8 +133,8 @@ export default class AmfReference extends LightningElement {
125
133
  }
126
134
 
127
135
  @api
128
- get docPhaseInfo() {
129
- return this.selectedReferenceDocPhase;
136
+ get docPhaseInfo(): string | null {
137
+ return this.selectedReferenceDocPhase || null;
130
138
  }
131
139
 
132
140
  set docPhaseInfo(value: string) {
@@ -151,12 +159,12 @@ export default class AmfReference extends LightningElement {
151
159
  protected _referenceSetConfig!: ReferenceSetConfig;
152
160
  protected _currentReferenceId = "";
153
161
 
154
- protected parentReferenceUrls = [];
162
+ protected parentReferenceUrls = [] as string[];
155
163
  protected amfMap: Record<string, AmfModelRecord> = {};
156
- protected amfFetchPromiseMap = {};
164
+ protected amfFetchPromiseMap = {} as any;
157
165
  protected metadata: { [key: string]: AmfMetadataTopic } = {};
158
166
  protected selectedTopic?: AmfMetaTopicType = undefined;
159
- protected selectedSidebarValue = undefined;
167
+ protected selectedSidebarValue: string | undefined = undefined;
160
168
 
161
169
  protected selectedVersion: ReferenceVersion | null = null;
162
170
 
@@ -347,13 +355,13 @@ export default class AmfReference extends LightningElement {
347
355
  /**
348
356
  * Returns the selected version or the first available version.
349
357
  */
350
- private getSelectedVersion(): ReferenceVersion {
358
+ private getSelectedVersion(): ReferenceVersion | null {
351
359
  const versions = this._referenceSetConfig?.versions || [];
352
360
  const selectedVersion = versions.find(
353
361
  (v: ReferenceVersion) => v.selected
354
362
  );
355
363
  // return a selected version if there is one, else return the first one.
356
- return selectedVersion || (versions.length && versions[0]);
364
+ return selectedVersion || (versions.length && versions[0]) || null;
357
365
  }
358
366
 
359
367
  private updateAmfConfigInView(): void {
@@ -367,9 +375,11 @@ export default class AmfReference extends LightningElement {
367
375
  }
368
376
  }
369
377
 
370
- private async fetchAmf(amfConfig): Promise<AmfModel | AmfModel[]> {
378
+ private async fetchAmf(
379
+ amfConfig: AmfConfig
380
+ ): Promise<AmfModel | AmfModel[]> {
371
381
  const { amf } = amfConfig;
372
- const response = await fetch(amf, {
382
+ const response = await fetch(amf!, {
373
383
  headers: {
374
384
  "Cache-Control": `max-age=86400`
375
385
  }
@@ -388,7 +398,7 @@ export default class AmfReference extends LightningElement {
388
398
  /**
389
399
  * Returns whether given url is parent reference path like ../example-project/references/reference-id
390
400
  */
391
- private isParentReferencePath(urlPath: string): boolean {
401
+ private isParentReferencePath(urlPath?: string | null): boolean {
392
402
  if (!urlPath) {
393
403
  return false;
394
404
  }
@@ -419,9 +429,9 @@ export default class AmfReference extends LightningElement {
419
429
  * Populates reference Items from amfConfigList and assigns it to navigation for sidebar
420
430
  */
421
431
  private populateReferenceItems(): void {
422
- const navAmfOrder = [];
432
+ const navAmfOrder = [] as NavigationItem[];
423
433
  for (const [index, amfConfig] of this._amfConfigList.entries()) {
424
- let navItemChildren = [];
434
+ let navItemChildren = [] as ParsedMarkdownTopic[];
425
435
  let isChildrenLoading = false;
426
436
  if (amfConfig.referenceType !== REFERENCE_TYPES.markdown) {
427
437
  if (amfConfig.isSelected) {
@@ -441,10 +451,10 @@ export default class AmfReference extends LightningElement {
441
451
  // check whether we should expand all the child nodes, this is required for Coveo to crawl.
442
452
  if (isExpandChildrenEnabled) {
443
453
  this.expandChildrenForMarkdownReferences(
444
- amfConfig.topic.children
454
+ amfConfig.topic!.children
445
455
  );
446
456
  }
447
- navItemChildren = amfConfig.topic.children;
457
+ navItemChildren = amfConfig.topic!.children;
448
458
  }
449
459
  // store nav items for each spec in order
450
460
  navAmfOrder[index] = {
@@ -465,7 +475,9 @@ export default class AmfReference extends LightningElement {
465
475
  * Returns a boolean indicating whether the children should be expanded or not.
466
476
  */
467
477
  private isExpandChildrenEnabled(referenceId: string): boolean {
468
- return this.expandChildren && this._currentReferenceId === referenceId;
478
+ return (
479
+ !!this.expandChildren && this._currentReferenceId === referenceId
480
+ );
469
481
  }
470
482
 
471
483
  /**
@@ -509,12 +521,12 @@ export default class AmfReference extends LightningElement {
509
521
  referenceId: string,
510
522
  items: ParsedTopicModel[]
511
523
  ): NavItem[] {
512
- const methodList = [];
524
+ const methodList = [] as NavItem[];
513
525
 
514
526
  items.forEach((item) => {
515
527
  item.methods?.forEach((method) => {
516
528
  const title =
517
- this.getTitleForLabel(method.label) || method.method;
529
+ this.getTitleForLabel(method.label!) || method.method;
518
530
  const meta = this.addToMetadata(
519
531
  parentReferencePath,
520
532
  referenceId,
@@ -562,7 +574,7 @@ export default class AmfReference extends LightningElement {
562
574
  const parentReferencePath = amfConfig.href;
563
575
  const model = this.amfMap[referenceId].parser.parsedModel;
564
576
 
565
- const children = [];
577
+ const children: any[] = [];
566
578
  const expandChildren = this.isExpandChildrenEnabled(referenceId);
567
579
 
568
580
  NAVIGATION_ITEMS.forEach(
@@ -589,8 +601,8 @@ export default class AmfReference extends LightningElement {
589
601
  }
590
602
  case "endpoint":
591
603
  if (
592
- model[childrenPropertyName] &&
593
- model[childrenPropertyName].length
604
+ model[childrenPropertyName!] &&
605
+ model[childrenPropertyName!].length
594
606
  ) {
595
607
  const amfTopicId = this.getFormattedIdentifier(
596
608
  referenceId,
@@ -599,7 +611,7 @@ export default class AmfReference extends LightningElement {
599
611
  const childTopics = this.assignEndpointNavItems(
600
612
  parentReferencePath,
601
613
  referenceId,
602
- model[childrenPropertyName]
614
+ model[childrenPropertyName!]
603
615
  );
604
616
  children.push({
605
617
  label,
@@ -614,23 +626,25 @@ export default class AmfReference extends LightningElement {
614
626
  break;
615
627
  case "security":
616
628
  case "type":
617
- if (model[childrenPropertyName]?.length) {
629
+ if (model[childrenPropertyName!]?.length) {
618
630
  // Sorting the types alphabetically
619
- model[childrenPropertyName].sort((typeA, typeB) => {
620
- const typeALbl = typeA.label.toLowerCase();
621
- const typeBLbl = typeB.label.toLowerCase();
622
- return typeALbl < typeBLbl
623
- ? -1
624
- : typeALbl > typeBLbl
625
- ? 1
626
- : 0;
627
- });
631
+ model[childrenPropertyName!].sort(
632
+ (typeA: any, typeB: any) => {
633
+ const typeALbl = typeA.label.toLowerCase();
634
+ const typeBLbl = typeB.label.toLowerCase();
635
+ return typeALbl < typeBLbl
636
+ ? -1
637
+ : typeALbl > typeBLbl
638
+ ? 1
639
+ : 0;
640
+ }
641
+ );
628
642
  }
629
643
  // eslint-disable-next-line no-fallthrough
630
644
  default:
631
645
  if (
632
- model[childrenPropertyName] &&
633
- model[childrenPropertyName].length
646
+ model[childrenPropertyName!] &&
647
+ model[childrenPropertyName!].length
634
648
  ) {
635
649
  const amfTopicId = this.getFormattedIdentifier(
636
650
  referenceId,
@@ -643,8 +657,8 @@ export default class AmfReference extends LightningElement {
643
657
  this.metadata[amfTopicId]?.meta
644
658
  ),
645
659
  isExpanded: expandChildren,
646
- children: model[childrenPropertyName].map(
647
- (topic) => {
660
+ children: model[childrenPropertyName!].map(
661
+ (topic: any) => {
648
662
  const meta = this.addToMetadata(
649
663
  parentReferencePath,
650
664
  referenceId,
@@ -681,12 +695,18 @@ export default class AmfReference extends LightningElement {
681
695
  type: string,
682
696
  topic: { id: string; domId: string },
683
697
  navTitle: string
684
- ): string | undefined {
685
- const { urlIdentifer, prefix } = URL_CONFIG[type];
698
+ ): string {
699
+ const config = URL_CONFIG[type as keyof typeof URL_CONFIG];
700
+ const urlIdentifer = config.urlIdentifer;
701
+ let prefix = null;
702
+ if ("prefix" in config) {
703
+ prefix = config.prefix;
704
+ }
686
705
 
687
706
  // encodeURI to avoid special characters in the URL meta.
688
707
  const identifier =
689
- topic[urlIdentifer] && this.encodeIdentifier(topic[urlIdentifer]);
708
+ urlIdentifer in topic &&
709
+ this.encodeIdentifier(topic[urlIdentifer as keyof typeof topic]);
690
710
  let meta;
691
711
  // Assuming that there will be an identifier always
692
712
  if (identifier) {
@@ -702,7 +722,7 @@ export default class AmfReference extends LightningElement {
702
722
  navTitle
703
723
  };
704
724
  }
705
- return meta;
725
+ return meta!;
706
726
  }
707
727
 
708
728
  /**
@@ -713,7 +733,7 @@ export default class AmfReference extends LightningElement {
713
733
  (metadata: AmfMetadataTopic) => {
714
734
  return routeMeta.meta === metadata.meta;
715
735
  }
716
- );
736
+ )!;
717
737
  }
718
738
 
719
739
  /**
@@ -727,7 +747,7 @@ export default class AmfReference extends LightningElement {
727
747
  return Object.values(this.metadata).find(
728
748
  (metadata: AmfMetadataTopic) =>
729
749
  referenceId === metadata.referenceId && amfId === metadata.amfId
730
- );
750
+ )!;
731
751
  }
732
752
 
733
753
  /**
@@ -742,7 +762,7 @@ export default class AmfReference extends LightningElement {
742
762
  (metadata: AmfMetadataTopic) =>
743
763
  referenceId === metadata.referenceId &&
744
764
  identifier === metadata.identifier
745
- );
765
+ )!;
746
766
  }
747
767
 
748
768
  /**
@@ -756,7 +776,7 @@ export default class AmfReference extends LightningElement {
756
776
  return Object.values(this.metadata).find(
757
777
  (metadata: AmfMetadataTopic) =>
758
778
  referenceId === metadata.referenceId && type === metadata.type
759
- );
779
+ )!;
760
780
  }
761
781
 
762
782
  /**
@@ -833,9 +853,8 @@ export default class AmfReference extends LightningElement {
833
853
  this._currentReferenceId
834
854
  );
835
855
  if (specBasedReference) {
836
- const currentMeta: RouteMeta | null = this.getReferenceMetaInfo(
837
- window.location.href
838
- );
856
+ const currentMeta: RouteMeta | undefined =
857
+ this.getReferenceMetaInfo(window.location.href);
839
858
  const metadata =
840
859
  currentMeta && this.getMetadataByUrlQuery(currentMeta);
841
860
  if (metadata) {
@@ -871,7 +890,7 @@ export default class AmfReference extends LightningElement {
871
890
  this._currentReferenceId
872
891
  );
873
892
  if (specBasedReference) {
874
- const { meta } = this.selectedTopic;
893
+ const { meta } = this.selectedTopic!;
875
894
  const metadata = this.metadata[meta];
876
895
  if (metadata) {
877
896
  const {
@@ -988,7 +1007,7 @@ export default class AmfReference extends LightningElement {
988
1007
  * 1. If the url is encoded already
989
1008
  * 2. If the url is decoded
990
1009
  */
991
- getUrlEncoded(url: string) {
1010
+ getUrlEncoded(url: string): string {
992
1011
  // if url matches, then return the encoded url.
993
1012
  if (decodeURIComponent(url) === url) {
994
1013
  return encodeURIComponent(url);
@@ -1004,7 +1023,7 @@ export default class AmfReference extends LightningElement {
1004
1023
  * For spec based references gets meta parm from url and then topicId & type from meta
1005
1024
  * For markdown based references gets topicId as last html path in the name, meta & type will be empty
1006
1025
  */
1007
- getReferenceMetaInfo(referenceUrl: string): RouteMeta | undefined {
1026
+ getReferenceMetaInfo(referenceUrl: string | null): RouteMeta | undefined {
1008
1027
  let metaReferenceInfo;
1009
1028
  if (referenceUrl) {
1010
1029
  const referenceId = this.getReferenceIdFromUrl(referenceUrl);
@@ -1046,10 +1065,10 @@ export default class AmfReference extends LightningElement {
1046
1065
  let topicTitle = "";
1047
1066
  for (let i = 0; i < topics.length; i++) {
1048
1067
  const topic = topics[i];
1049
- const meta = this.getMarkdownReferenceMeta(topic.link.href);
1068
+ const meta = this.getMarkdownReferenceMeta(topic.link!.href);
1050
1069
  const childTopics = topic.children;
1051
1070
  if (meta === topicMeta) {
1052
- referenceUrl = topic.link.href;
1071
+ referenceUrl = topic.link!.href;
1053
1072
  topicTitle = topic.label;
1054
1073
  } else if (childTopics && childTopics.length) {
1055
1074
  const referenceDetails = this.getReferenceDetailsInGivenTopics(
@@ -1160,7 +1179,7 @@ export default class AmfReference extends LightningElement {
1160
1179
  }
1161
1180
  });
1162
1181
  } else {
1163
- let invalidTopicReferenceUrl = "";
1182
+ let invalidTopicReferenceUrl: string | null = "";
1164
1183
  if (topicId) {
1165
1184
  const referenceDetails = this.getRefDetailsForGivenTopicMeta(
1166
1185
  referenceId,
@@ -1196,7 +1215,7 @@ export default class AmfReference extends LightningElement {
1196
1215
  * set selected sidebar value as a pathname
1197
1216
  */
1198
1217
 
1199
- private loadMarkdownBasedReference(referenceUrl?: string): void {
1218
+ private loadMarkdownBasedReference(referenceUrl?: string | null): void {
1200
1219
  let referenceId = "";
1201
1220
  const currentUrl = window.location.href;
1202
1221
  if (this.isProjectRootPath()) {
@@ -1210,7 +1229,7 @@ export default class AmfReference extends LightningElement {
1210
1229
  * CASE2: This case is to navigate to respective reference when the user clicked on root item
1211
1230
  * Ex: .../references/markdown-ref should navigate to first topic.
1212
1231
  */
1213
- referenceId = this.getReferenceIdFromUrl(referenceUrl);
1232
+ referenceId = this.getReferenceIdFromUrl(referenceUrl!);
1214
1233
  } else if (this.isParentReferencePath(currentUrl)) {
1215
1234
  /**
1216
1235
  * CASE3: This case is to navigate to respective reference when the user entered url with reference id
@@ -1239,9 +1258,9 @@ export default class AmfReference extends LightningElement {
1239
1258
  const amfConfig = this.getAmfConfigWithId(referenceId);
1240
1259
  let redirectReferenceUrl = "";
1241
1260
  if (amfConfig) {
1242
- const childrenItems = amfConfig.topic.children;
1261
+ const childrenItems = amfConfig.topic!.children;
1243
1262
  if (childrenItems.length > 0) {
1244
- redirectReferenceUrl = childrenItems[0].link.href;
1263
+ redirectReferenceUrl = childrenItems[0].link!.href;
1245
1264
  }
1246
1265
  }
1247
1266
  if (redirectReferenceUrl) {
@@ -1375,7 +1394,7 @@ export default class AmfReference extends LightningElement {
1375
1394
 
1376
1395
  handleSelectedItem(): void {
1377
1396
  // update topic view
1378
- const { referenceId, amfId, type } = this.selectedTopic;
1397
+ const { referenceId, amfId, type } = this.selectedTopic!;
1379
1398
 
1380
1399
  // This updates the component in the content section.
1381
1400
  this.topicModel = {
@@ -8,14 +8,15 @@ import {
8
8
  createTypeElement
9
9
  } from "./utils";
10
10
  import type { TopicModel } from "./types";
11
+ import { Json } from "typings/custom";
11
12
 
12
13
  export default class AmfTopic extends LightningElement {
13
- private _model;
14
- private amf;
15
- private type;
14
+ private _model: TopicModel | undefined;
15
+ private amf: Json;
16
+ private type: string | undefined;
16
17
 
17
18
  @api
18
- get model(): TopicModel {
19
+ get model(): TopicModel | undefined {
19
20
  return this._model;
20
21
  }
21
22
 
@@ -41,7 +42,11 @@ export default class AmfTopic extends LightningElement {
41
42
  }
42
43
 
43
44
  update(): void {
44
- const container = this.template.querySelector("div.topic-container");
45
+ if (!this.model) {
46
+ throw new Error("Amf TopicModel undefined when trying to update");
47
+ }
48
+
49
+ const container = this.template.querySelector("div.topic-container")!;
45
50
  const { id } = this.model;
46
51
  const type = this.type;
47
52
  const amf = this.amf;
@@ -79,7 +84,7 @@ export default class AmfTopic extends LightningElement {
79
84
  if (container.firstChild) {
80
85
  container.firstChild.remove();
81
86
  }
82
- container.appendChild(element);
87
+ container.appendChild(element as Node);
83
88
  }
84
89
  }
85
90
 
@@ -89,6 +94,6 @@ export default class AmfTopic extends LightningElement {
89
94
  * @param value JSON Serializable object to clone.
90
95
  * @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
91
96
  */
92
- function clone(value): object {
97
+ function clone(value: any): any {
93
98
  return JSON.parse(JSON.stringify(value));
94
99
  }
@@ -1,4 +1,11 @@
1
1
  import { Json } from "typings/custom";
2
+ import { AmfModelParser } from "doc/amfModelParser";
3
+ import {
4
+ DomainElement,
5
+ EndPoint,
6
+ Operation,
7
+ Shape
8
+ } from "@api-components/amf-helper-mixin";
2
9
 
3
10
  export type ApiSummaryElement = HTMLElement & {
4
11
  amf: Json;
@@ -11,44 +18,39 @@ export type ApiEndpointElement = HTMLElement & {
11
18
  inlineMethods: boolean;
12
19
  noNavigation: boolean;
13
20
  selected: string;
14
- endpoint: Json;
21
+ endpoint: EndPoint;
15
22
  noTryIt: boolean;
16
23
  };
17
24
 
18
25
  export type ApiMethodElement = HTMLElement & {
19
26
  amf: Json;
20
27
  noNavigation: boolean;
21
- endpoint: Json;
22
- method: Json;
28
+ endpoint: EndPoint | undefined;
29
+ method: Operation | undefined;
23
30
  noTryIt: boolean;
24
31
  };
25
32
 
26
33
  export type ApiSecurityElement = HTMLElement & {
27
34
  amf: Json;
28
- security: Json;
35
+ security: DomainElement | undefined;
29
36
  };
30
37
 
31
38
  export type ApiTypeElement = HTMLElement & {
32
39
  amf: Json;
33
- type: Json;
40
+ type?: Shape;
34
41
  mediaTypes: Json;
35
42
  };
36
43
 
37
44
  export type ApiDocElement = HTMLElement & {
38
45
  amf: Json;
39
- shape: Json;
46
+ shape: DomainElement | undefined;
40
47
  };
41
48
 
42
49
  export type AmfModel = Json;
43
50
 
44
- export interface AmfParser {
45
- parse(): void;
46
- parsedModel: any;
47
- }
48
-
49
51
  export interface TopicModel {
50
52
  id: string;
51
53
  type: string;
52
54
  amf: AmfModel;
53
- parser: AmfParser;
55
+ parser: AmfModelParser;
54
56
  }
@@ -1,3 +1,9 @@
1
+ import {
2
+ DomainElement,
3
+ EndPoint,
4
+ Operation,
5
+ Shape
6
+ } from "@api-components/amf-helper-mixin";
1
7
  import type {
2
8
  ApiDocElement,
3
9
  ApiEndpointElement,
@@ -37,7 +43,7 @@ export function createSummaryElement(amf: Json): HTMLElement {
37
43
  */
38
44
  export function createEndpointElement(
39
45
  amf: Json,
40
- endpointModel: Json,
46
+ endpointModel: EndPoint,
41
47
  selected: string
42
48
  ): HTMLElement {
43
49
  const el: ApiEndpointElement = document.createElement(
@@ -57,8 +63,8 @@ export function createEndpointElement(
57
63
  */
58
64
  export function createMethodElement(
59
65
  amf: Json,
60
- endpointMethodModel: Json,
61
- methodModel: Json
66
+ endpointMethodModel: EndPoint | undefined,
67
+ methodModel: Operation | undefined
62
68
  ): HTMLElement {
63
69
  const el: ApiMethodElement = document.createElement(
64
70
  "api-method-documentation"
@@ -79,7 +85,7 @@ export function createMethodElement(
79
85
  */
80
86
  export function createSecurityElement(
81
87
  amf: Json,
82
- securityModel: Json
88
+ securityModel: DomainElement | undefined
83
89
  ): HTMLElement {
84
90
  const el: ApiSecurityElement = document.createElement(
85
91
  "api-security-documentation"
@@ -98,7 +104,7 @@ export function createSecurityElement(
98
104
  */
99
105
  export function createTypeElement(
100
106
  amf: Json,
101
- typeModel: Json,
107
+ typeModel: Shape | undefined,
102
108
  mediaTypes: Json
103
109
  ): HTMLElement {
104
110
  const el: ApiTypeElement = document.createElement(
@@ -119,7 +125,7 @@ export function createTypeElement(
119
125
  */
120
126
  export function createDocumentationElement(
121
127
  amf: Json,
122
- docsModel: Json
128
+ docsModel: DomainElement | undefined
123
129
  ): HTMLElement {
124
130
  const el: ApiDocElement = document.createElement(
125
131
  "api-documentation-document"
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @lwc/lwc/no-inner-html */
2
2
  import { createElement, LightningElement, api, track } from "lwc";
3
3
  import { DocContent, PageReference } from "typings/custom";
4
- import ContentCallout from "doc/contentCallout";
5
4
  import CodeBlock from "dx/codeBlock";
6
- import ContentMedia from "doc/contentMedia";
7
5
  import Button from "dx/button";
8
6
  import { highlightTerms } from "dxUtils/highlight";
7
+ import ContentCallout from "doc/contentCallout";
8
+ import ContentMedia from "doc/contentMedia";
9
9
 
10
10
  const HIGHLIGHTABLE_SELECTOR = [
11
11
  "p",
@@ -86,7 +86,7 @@ export default class Content extends LightningElement {
86
86
  }
87
87
 
88
88
  renderPaginationButton(anchorEl: HTMLElement) {
89
- const isNext = anchorEl.textContent.includes("Next →");
89
+ const isNext = anchorEl.textContent!.includes("Next →");
90
90
  anchorEl.innerHTML = "";
91
91
  const buttonEl = createElement("dx-button", { is: Button });
92
92
  const params = isNext
@@ -116,7 +116,7 @@ export default class Content extends LightningElement {
116
116
  const codeBlockEls = divEl.querySelectorAll(".codeSection");
117
117
  codeBlockEls.forEach((codeBlockEl) => {
118
118
  codeBlockEl.setAttribute("lwc:dom", "manual");
119
- const classList = codeBlockEl.firstChild.classList;
119
+ const classList = (codeBlockEl.firstChild as any).classList;
120
120
  let language = "";
121
121
  for (const key in classList) {
122
122
  if (typeof classList[key] === "string") {
@@ -160,7 +160,7 @@ export default class Content extends LightningElement {
160
160
 
161
161
  let flag = 1;
162
162
  for (let i: number = 0; i < detailEls.length; i++) {
163
- flag &= detailEls[i].innerHTML.trim() === "";
163
+ flag &= (detailEls[i].innerHTML.trim() === "") as any; // Dark Magic TM
164
164
  }
165
165
 
166
166
  if (flag) {
@@ -170,7 +170,7 @@ export default class Content extends LightningElement {
170
170
  });
171
171
  }
172
172
 
173
- const type = calloutEl.querySelector("h4").textContent;
173
+ const type = calloutEl.querySelector("h4")!.textContent!;
174
174
  const typeLower = type.toLowerCase();
175
175
  Object.assign(calloutCompEl, {
176
176
  title: type,
@@ -184,10 +184,10 @@ export default class Content extends LightningElement {
184
184
  // Modify links to work with any domain, links that start with "#" are excluded
185
185
  const anchorEls = divEl.querySelectorAll("a:not([href^='#'])");
186
186
 
187
- anchorEls.forEach((anchorEl) => {
187
+ anchorEls.forEach((anchorEl: any) => {
188
188
  if (
189
- anchorEl.textContent.includes("Next →") ||
190
- anchorEl.textContent.includes("← Previous")
189
+ anchorEl.textContent!.includes("Next →") ||
190
+ anchorEl.textContent!.includes("← Previous")
191
191
  ) {
192
192
  if (this.showPaginationButtons) {
193
193
  this.renderPaginationButton(anchorEl);
@@ -326,8 +326,7 @@ export default class Content extends LightningElement {
326
326
 
327
327
  handleNavClick(event: InputEvent) {
328
328
  event.preventDefault();
329
- // eslint-disable-next-line no-use-before-define
330
- const target = event.currentTarget.dataset.id;
329
+ const target = (event.currentTarget! as any).dataset.id;
331
330
  const [page, docId, deliverable, tempContentDocumentId] =
332
331
  target.split("/");
333
332
  const [contentDocumentId, hash] = tempContentDocumentId.split("#");
@@ -3,7 +3,7 @@ import { LightningElement, api, track } from "lwc";
3
3
  import { closest } from "kagekiri";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
  import { highlightTerms } from "dxUtils/highlight";
6
- import { SearchSyncer } from "docUtils/SearchSyncer";
6
+ import { SearchSyncer } from "docUtils/searchSyncer";
7
7
 
8
8
  type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
9
9
 
@@ -26,9 +26,9 @@ const HIGHLIGHTABLE_SELECTOR = [
26
26
  export const OBSERVER_ATTACH_WAIT_TIME = 500;
27
27
 
28
28
  export default class ContentLayout extends LightningElement {
29
- @api sidebarValue: string;
30
- @api sidebarHeader: string;
31
- @api tocTitle: string;
29
+ @api sidebarValue!: string;
30
+ @api sidebarHeader!: string;
31
+ @api tocTitle!: string;
32
32
  @api enableSlotChange = false;
33
33
  @api coveoOrganizationId!: string;
34
34
  @api coveoPublicAccessToken!: string;
@@ -41,7 +41,7 @@ export default class ContentLayout extends LightningElement {
41
41
  return this._breadcrumbs;
42
42
  }
43
43
 
44
- set breadcrumbs(value): [] {
44
+ set breadcrumbs(value) {
45
45
  if (value) {
46
46
  this._breadcrumbs = toJson(value);
47
47
  }
@@ -52,7 +52,7 @@ export default class ContentLayout extends LightningElement {
52
52
  return this._sidebarContent;
53
53
  }
54
54
 
55
- set sidebarContent(value) {
55
+ set sidebarContent(value: any) {
56
56
  this._sidebarContent = toJson(value);
57
57
  }
58
58
 
@@ -67,7 +67,9 @@ export default class ContentLayout extends LightningElement {
67
67
 
68
68
  @api
69
69
  setSidebarInputValue(searchTerm: string): void {
70
- this.template.querySelector("dx-sidebar")?.setInputValue(searchTerm);
70
+ (this.template.querySelector("dx-sidebar") as any)?.setInputValue(
71
+ searchTerm
72
+ );
71
73
  }
72
74
 
73
75
  @track
@@ -76,11 +78,11 @@ export default class ContentLayout extends LightningElement {
76
78
  private _breadcrumbs = null;
77
79
 
78
80
  @track
79
- private _tocOptions: Array<unknown>;
81
+ private _tocOptions!: Array<unknown>;
80
82
 
81
83
  private tocOptionIdsSet = new Set();
82
84
  private anchoredElements: AnchorMap = {};
83
- private lastScrollPosition: number;
85
+ private lastScrollPosition!: number;
84
86
  private observer?: IntersectionObserver;
85
87
  private hasRendered: boolean = false;
86
88
  private contentLoaded: boolean = false;
@@ -105,7 +107,8 @@ export default class ContentLayout extends LightningElement {
105
107
  target: window
106
108
  });
107
109
  private tocValue?: string = undefined;
108
- private observerTimerId = null;
110
+ // eslint-disable-next-line no-undef
111
+ private observerTimerId?: NodeJS.Timeout;
109
112
  private didScrollToSelectedHash = false;
110
113
  private _scrollInterval = 0;
111
114
 
@@ -203,9 +206,9 @@ export default class ContentLayout extends LightningElement {
203
206
  ".sticky-doc-header"
204
207
  ) as HTMLElement;
205
208
 
206
- const docPhaseEl = this.template
207
- .querySelector("[name=doc-phase]")!
208
- .assignedElements()[0] as HTMLSlotElement;
209
+ const docPhaseEl = (
210
+ this.template.querySelector("[name=doc-phase]")! as any
211
+ ).assignedElements()[0] as HTMLSlotElement;
209
212
 
210
213
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
211
214
  console.warn("One or more required elements are missing.");
@@ -247,7 +250,7 @@ export default class ContentLayout extends LightningElement {
247
250
  document.querySelectorAll("doc-heading")
248
251
  );
249
252
  docHeadingEls.forEach((docHeadingEl) => {
250
- docHeadingEl.style.scrollMarginTop = `${
253
+ (docHeadingEl as any).style.scrollMarginTop = `${
251
254
  globalNavHeight +
252
255
  docHeaderHeight +
253
256
  docPhaseEl.getBoundingClientRect().height
@@ -255,9 +258,8 @@ export default class ContentLayout extends LightningElement {
255
258
  });
256
259
 
257
260
  // Adjust right nav bar position when doc phase is present
258
- const rightNavBarEl = this.template.querySelector(
259
- ".right-nav-bar"
260
- );
261
+ const rightNavBarEl =
262
+ this.template.querySelector(".right-nav-bar");
261
263
 
262
264
  if (rightNavBarEl) {
263
265
  rightNavBarEl.style.top = `${
@@ -291,7 +293,7 @@ export default class ContentLayout extends LightningElement {
291
293
  entries.forEach(
292
294
  (entry) =>
293
295
  (this.anchoredElements[
294
- entry.target.getAttribute("id")
296
+ entry.target.getAttribute("id")!
295
297
  ].intersect = entry.isIntersecting)
296
298
  );
297
299
  this.calculateActualSection();
@@ -303,10 +305,9 @@ export default class ContentLayout extends LightningElement {
303
305
 
304
306
  // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
305
307
  const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
306
-
307
- for (const headingElement of headingElements) {
308
+ for (const headingElement of headingElements as any) {
308
309
  // Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
309
- const id = headingElement.getAttribute("id");
310
+ const id = headingElement.getAttribute("id")!;
310
311
  this.anchoredElements[id] = {
311
312
  id,
312
313
  intersect: false
@@ -320,23 +321,26 @@ export default class ContentLayout extends LightningElement {
320
321
  };
321
322
 
322
323
  onSlotChange(event: Event): void {
323
- const slotElements = (event.target as HTMLSlotElement).assignedElements();
324
+ const slotElements = (
325
+ event.target as HTMLSlotElement
326
+ ).assignedElements();
324
327
 
325
328
  if (slotElements.length) {
326
329
  this.contentLoaded = true;
327
330
  const slotContentElement = slotElements[0];
328
- const headingElements = slotContentElement.ownerDocument?.getElementsByTagName(
329
- TOC_HEADER_TAG
330
- );
331
+ const headingElements =
332
+ slotContentElement.ownerDocument?.getElementsByTagName(
333
+ TOC_HEADER_TAG
334
+ );
331
335
 
332
- for (const headingElement of headingElements) {
336
+ for (const headingElement of headingElements as any) {
333
337
  // Sometimes elements hash is not being set when slot content is wrapped with div
334
338
  headingElement.hash = headingElement.attributes.hash?.nodeValue;
335
339
  }
336
340
 
337
341
  const tocOptions = [];
338
342
 
339
- for (const headingElement of headingElements) {
343
+ for (const headingElement of headingElements as any) {
340
344
  headingElement.id = headingElement.hash;
341
345
 
342
346
  // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
@@ -362,7 +366,7 @@ export default class ContentLayout extends LightningElement {
362
366
  private disconnectObserver(): void {
363
367
  if (this.observer) {
364
368
  this.observer.disconnect();
365
- this.observer = null;
369
+ this.observer = undefined;
366
370
  }
367
371
  }
368
372
 
@@ -387,15 +391,15 @@ export default class ContentLayout extends LightningElement {
387
391
  globalNavEl.offsetHeight +
388
392
  contextNavEl.offsetHeight;
389
393
 
390
- const docPhaseEl = this.template
391
- .querySelector("[name=doc-phase]")!
392
- .assignedElements()[0] as HTMLSlotElement;
394
+ const docPhaseEl = (
395
+ this.template.querySelector("[name=doc-phase]")! as any
396
+ ).assignedElements()[0] as HTMLSlotElement;
393
397
 
394
398
  const offset = docPhaseEl
395
399
  ? headerHeight + docPhaseEl.offsetHeight
396
400
  : headerHeight;
397
401
 
398
- for (const headingElement of headingElements) {
402
+ for (const headingElement of headingElements as any) {
399
403
  if (headingElement.getAttribute("id") === hash) {
400
404
  this.scrollIntoViewWithOffset(headingElement, offset);
401
405
  break;
@@ -432,14 +436,14 @@ export default class ContentLayout extends LightningElement {
432
436
  this.lastScrollPosition = currentScrollPosition;
433
437
  }
434
438
 
435
- private calculatePreviousElementId(): string {
439
+ private calculatePreviousElementId(): string | undefined {
436
440
  const keys = Object.keys(this.anchoredElements);
437
441
  const currentIndex = keys.findIndex((id) => this.tocValue === id);
438
442
 
439
443
  return currentIndex > 0 ? keys[currentIndex - 1] : undefined;
440
444
  }
441
445
 
442
- private assignElementId(id: string): void {
446
+ private assignElementId(id: string | undefined): void {
443
447
  // Change toc(RNB) highlight only for H2
444
448
  if (this.tocOptionIdsSet.has(id)) {
445
449
  this.tocValue = id;
@@ -11,12 +11,14 @@ export const ariaLevels = Object.keys(ariaDisplayLevels);
11
11
 
12
12
  export const displayLevels = Object.values(ariaDisplayLevels);
13
13
 
14
+ // @ts-ignore: Really Dark Magic (TM) to do with ariaLevel needing explicit getter/setters
14
15
  export default class Heading extends LightningElement {
15
16
  @api title: string = "";
16
17
  @api hash: string | null = null;
17
18
 
18
19
  @api
19
20
  private get ariaLevel(): string {
21
+ // Really Dark Magic (TM)
20
22
  return this._ariaLevel || "2";
21
23
  }
22
24
  private set ariaLevel(value: string | null) {
@@ -11,7 +11,7 @@ export default class Toc extends LightningElement {
11
11
  const newPageReference = { ...this.pageReference };
12
12
  // When moving to the new navigation component
13
13
  //const target = event.detail.name.split('-')
14
- const target = event.currentTarget.dataset.id.split("-");
14
+ const target = (event.currentTarget as any).dataset.id.split("-");
15
15
  newPageReference.contentDocumentId = target[0] + ".htm";
16
16
  newPageReference.hash = target[1];
17
17
  this.dispatchEvent(
@@ -64,7 +64,7 @@ export interface Header extends Element {
64
64
  bailHref: string;
65
65
  bailLabel: string;
66
66
  languages: Array<DocLanguage>;
67
- language: string;
67
+ language?: string;
68
68
  headerHref: string;
69
69
  }
70
70
 
@@ -12,15 +12,15 @@ import {
12
12
  PageReference,
13
13
  TocMap
14
14
  } from "./types";
15
- import { SearchSyncer } from "docUtils/SearchSyncer";
16
15
  import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
17
16
  import { oldVersionDocInfo } from "docUtils/utils";
18
17
  import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
19
18
  import { track as trackGTM } from "dxUtils/analytics";
20
19
  import { CoveoAnalyticsClient } from "coveo.analytics";
20
+ import { SearchSyncer } from "docUtils/searchSyncer";
21
21
 
22
22
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
23
- const handleContentError = (error): void => console.log(error);
23
+ const handleContentError = (error: any): void => console.log(error);
24
24
 
25
25
  const PIXEL_PER_CHARACTER_MAP: { [key: string]: number } = {
26
26
  default: 7.7,
@@ -31,6 +31,7 @@ export default class DocXmlContent extends LightningElementWithState<{
31
31
  isFetchingDocument: boolean;
32
32
  isFetchingContent: boolean;
33
33
  lastHighlightedSearch: string;
34
+ internalLinkClicked: boolean;
34
35
  }> {
35
36
  @api apiDomain = "https://developer.salesforce.com";
36
37
  @api coveoOrganizationId!: string;
@@ -60,14 +61,14 @@ export default class DocXmlContent extends LightningElementWithState<{
60
61
 
61
62
  private availableLanguages: Array<DocLanguage> = [];
62
63
  private availableVersions: Array<DocVersion> = [];
63
- private contentProvider: FetchContent;
64
+ private contentProvider?: FetchContent;
64
65
  private docContent = "";
65
- private language: DocLanguage = null;
66
+ private language?: DocLanguage | null = null;
66
67
  private loaded = false;
67
68
  private pdfUrl = "";
68
69
  private tocMap: TocMap = {};
69
- private sidebarContent: Array<TreeNode> = null;
70
- private version: DocVersion = null;
70
+ private sidebarContent: Array<TreeNode> | null = null;
71
+ private version: DocVersion | null = null;
71
72
  private docTitle = "";
72
73
  private _pathName = "";
73
74
  private _pageHeader?: Header;
@@ -174,8 +175,8 @@ export default class DocXmlContent extends LightningElementWithState<{
174
175
  renderedCallback(): void {
175
176
  this.setState({ internalLinkClicked: true });
176
177
  const urlSectionLink =
177
- this.pageReference?.hash?.split("#").length > 1
178
- ? this.pageReference.hash.split("#")[1]
178
+ this.pageReference?.hash?.split("#").length! > 1
179
+ ? this.pageReference.hash!.split("#")[1]
179
180
  : this.pageReference?.hash;
180
181
 
181
182
  const contentEl = this.template.querySelector("doc-content");
@@ -223,15 +224,15 @@ export default class DocXmlContent extends LightningElementWithState<{
223
224
  }
224
225
  }
225
226
 
226
- private get languageId(): string {
227
- return this.language.id.replace("-", "_");
227
+ private get languageId(): string | undefined {
228
+ return this.language?.id.replace("-", "_");
228
229
  }
229
230
 
230
- private get releaseVersionId(): string {
231
- return this.version.id;
231
+ private get releaseVersionId(): string | undefined {
232
+ return this.version?.id;
232
233
  }
233
234
 
234
- private get deliverable(): string {
235
+ private get deliverable(): string | undefined {
235
236
  return this.pageReference.deliverable;
236
237
  }
237
238
 
@@ -252,10 +253,11 @@ export default class DocXmlContent extends LightningElementWithState<{
252
253
  }
253
254
 
254
255
  private get coveoAdvancedQueryConfig(): CoveoAdvancedQueryXMLConfig {
255
- const config: { locale: string; topicid: string; version?: string } = {
256
- locale: this.languageId,
257
- topicid: this.deliverable
258
- };
256
+ const config: { locale?: string; topicid?: string; version?: string } =
257
+ {
258
+ locale: this.languageId,
259
+ topicid: this.deliverable
260
+ };
259
261
 
260
262
  if (this.releaseVersionId && this.releaseVersionId !== "noversion") {
261
263
  config.version = this.releaseVersionId;
@@ -266,7 +268,7 @@ export default class DocXmlContent extends LightningElementWithState<{
266
268
 
267
269
  private get pageHeader(): Header {
268
270
  if (!this._pageHeader) {
269
- this._pageHeader = document.querySelector("doc-header");
271
+ this._pageHeader = document.querySelector("doc-header")!;
270
272
  }
271
273
 
272
274
  return this._pageHeader;
@@ -309,7 +311,7 @@ export default class DocXmlContent extends LightningElementWithState<{
309
311
 
310
312
  private get breadcrumbPixelPerCharacter() {
311
313
  return (
312
- PIXEL_PER_CHARACTER_MAP[this.language.id] ||
314
+ PIXEL_PER_CHARACTER_MAP[this.language!.id] ||
313
315
  PIXEL_PER_CHARACTER_MAP.default
314
316
  );
315
317
  }
@@ -358,7 +360,7 @@ export default class DocXmlContent extends LightningElementWithState<{
358
360
  this.updateUrl();
359
361
  }
360
362
 
361
- handleLanguageChange = (event: CustomEvent<string>): Promise<void> => {
363
+ handleLanguageChange = (event: any) => {
362
364
  if (this.language && this.language.id === event.detail) {
363
365
  return;
364
366
  }
@@ -366,7 +368,7 @@ export default class DocXmlContent extends LightningElementWithState<{
366
368
  this.language = this.availableLanguages.find(
367
369
  ({ id }) => id === event.detail
368
370
  );
369
- this.pageReference.docId = this.language.url;
371
+ this.pageReference.docId = this.language!.url;
370
372
 
371
373
  trackGTM(event.target!, "custEv_ctaLinkClick", {
372
374
  click_text: event.detail,
@@ -453,8 +455,8 @@ export default class DocXmlContent extends LightningElementWithState<{
453
455
  this.setState({
454
456
  isFetchingDocument: true
455
457
  });
456
- const data = await this.contentProvider.fetchDocumentData(
457
- this.pageReference.docId
458
+ const data = await this.contentProvider!.fetchDocumentData(
459
+ this.pageReference.docId!
458
460
  );
459
461
 
460
462
  // This could be a 404 scenario.
@@ -517,12 +519,12 @@ export default class DocXmlContent extends LightningElementWithState<{
517
519
  this.setState({
518
520
  isFetchingContent: true
519
521
  });
520
- const data = await this.contentProvider.fetchContent(
521
- this.pageReference.deliverable,
522
- this.pageReference.contentDocumentId,
522
+ const data = await this.contentProvider!.fetchContent(
523
+ this.pageReference.deliverable!,
524
+ this.pageReference.contentDocumentId!,
523
525
  {
524
- language: this.language.id,
525
- version: this.version.id
526
+ language: this.language!.id,
527
+ version: this.version!.id
526
528
  }
527
529
  );
528
530
 
@@ -586,23 +588,26 @@ export default class DocXmlContent extends LightningElementWithState<{
586
588
  }
587
589
 
588
590
  private updateSearchInput(searchParam: string): void {
589
- this.template
590
- .querySelector("doc-content-layout")
591
- ?.setSidebarInputValue(searchParam);
591
+ (
592
+ this.template.querySelector("doc-content-layout") as any
593
+ )?.setSidebarInputValue(searchParam);
592
594
  }
593
595
 
594
596
  private pageReferenceToString(reference: PageReference): string {
595
597
  const { page, docId, deliverable, contentDocumentId, hash, search } =
596
598
  reference;
597
599
  return `/${page}/${docId}/${deliverable}/${contentDocumentId}${this.normalizeSearch(
598
- search
600
+ search!
599
601
  )}${this.normalizeHash(hash)}`;
600
602
  }
601
603
 
602
- private normalizeUrlPart(part: string, sentinel: string): string {
604
+ private normalizeUrlPart(
605
+ part: string | undefined,
606
+ sentinel: string
607
+ ): string {
603
608
  return (
604
609
  (part &&
605
- (part.startsWith(sentinel) ? part : `${sentinel}${part}`)) ||
610
+ (part.startsWith(sentinel!) ? part : `${sentinel}${part}`)) ||
606
611
  ""
607
612
  );
608
613
  }
@@ -611,16 +616,16 @@ export default class DocXmlContent extends LightningElementWithState<{
611
616
  return this.normalizeUrlPart(search, "?");
612
617
  }
613
618
 
614
- private normalizeHash(hash: string): string {
619
+ private normalizeHash(hash?: string): string {
615
620
  return this.normalizeUrlPart(hash, "#");
616
621
  }
617
622
 
618
623
  private getComposedTitle(
619
- topicTitle: string | undefined,
624
+ topicTitle: string | null | undefined,
620
625
  docTitle: string | undefined
621
626
  ): string {
622
627
  // map to avoid duplicates
623
- const titleMap = {};
628
+ const titleMap: { [key: string]: any } = {};
624
629
  if (topicTitle) {
625
630
  // sometimes the h1 tag text (which is docSubTitle) contains text with new line character. For e.g, "Bulk API 2.0 Older\n Documentation",
626
631
  // here it contains \n in the text context which needs to be removed
@@ -757,7 +762,7 @@ export default class DocXmlContent extends LightningElementWithState<{
757
762
  const headTag = document.getElementsByTagName("head");
758
763
  // this checks if the selected version is not the latest version,
759
764
  // then it adds the noindex, follow meta tag to the older version pages.
760
- const versionId = this.version.id;
765
+ const versionId = this.version!.id;
761
766
  const docId = this.pageReference.docId;
762
767
 
763
768
  // SEO fix:
@@ -47,6 +47,7 @@ export class SearchSyncer {
47
47
  this.handleSearchChange
48
48
  );
49
49
  this.target.removeEventListener("popstate", this.handlePopState);
50
+ // @ts-ignore
50
51
  this.target = undefined;
51
52
  this.callbacks.onSearchChange = undefined;
52
53
  this.callbacks.onUrlChange = undefined;