@salesforcedevs/docs-components 1.3.205 → 1.3.209-alpha1
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/lwc.config.json +2 -0
- package/package.json +4 -2
- package/src/modules/doc/atlasContent/atlasContent.css +52 -0
- package/src/modules/doc/atlasContent/atlasContent.html +48 -0
- package/src/modules/doc/atlasContent/atlasContent.ts +116 -0
- package/src/modules/doc/contentCallout/contentCallout.css +5 -0
- package/src/modules/doc/xmlContent/baseContentElement.ts +787 -0
- package/src/modules/doc/xmlContent/types.ts +110 -0
- package/src/modules/doc/xmlContent/utils.ts +1 -1
- package/src/modules/doc/zoominContent/mockResponses.ts +5223 -0
- package/src/modules/doc/zoominContent/zoominContent.css +52 -0
- package/src/modules/doc/zoominContent/zoominContent.html +48 -0
- package/src/modules/doc/zoominContent/zoominContent.ts +476 -0
- package/src/modules/doc/zoominContent/zoominUtils.ts +88 -0
- package/LICENSE +0 -12
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--button-primary-color: var(--dx-g-blue-vibrant-50);
|
|
3
|
+
--button-primary-color-hover: var(--dx-g-blue-vibrant-40);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
doc-content-layout {
|
|
7
|
+
--dx-c-content-sidebar-sticky-top: calc(
|
|
8
|
+
var(--dx-g-global-header-height) +
|
|
9
|
+
var(--dx-g-doc-header-main-nav-height)
|
|
10
|
+
);
|
|
11
|
+
--dx-c-sidebar-height: calc(
|
|
12
|
+
100vh -
|
|
13
|
+
calc(
|
|
14
|
+
var(--dx-g-global-header-height) +
|
|
15
|
+
var(--dx-g-doc-header-main-nav-height)
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
doc-breadcrumbs {
|
|
21
|
+
--dx-c-popover-z-index: 5;
|
|
22
|
+
|
|
23
|
+
display: block;
|
|
24
|
+
margin-bottom: var(--dx-g-spacing-md);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
dx-dropdown {
|
|
28
|
+
--dx-c-dropdown-option-font-size: var(--dx-g-text-sm);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dx-dropdown > dx-button {
|
|
32
|
+
--dx-c-button-primary-color: var(--button-primary-color);
|
|
33
|
+
--dx-c-button-primary-color-hover: var(--button-primary-color-hover);
|
|
34
|
+
--border-color: var(--button-primary-color);
|
|
35
|
+
|
|
36
|
+
border-bottom: 1px dashed var(--border-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dx-dropdown > dx-button:hover {
|
|
40
|
+
--border-color: var(--button-primary-color-hover);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.document-pickers {
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
margin-right: var(--dx-g-spacing-sm);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
doc-phase {
|
|
49
|
+
--doc-c-phase-top: calc(
|
|
50
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<doc-content-layout
|
|
3
|
+
if:true={loaded}
|
|
4
|
+
coveo-organization-id={coveoOrganizationId}
|
|
5
|
+
coveo-public-access-token={coveoPublicAccessToken}
|
|
6
|
+
coveo-analytics-token={coveoAnalyticsToken}
|
|
7
|
+
coveo-search-hub={coveoSearchHub}
|
|
8
|
+
coveo-advanced-query-config={coveoAdvancedQueryConfig}
|
|
9
|
+
sidebar-header="Pages"
|
|
10
|
+
sidebar-content={sidebarContent}
|
|
11
|
+
sidebar-value={sidebarValue}
|
|
12
|
+
onselect={handleSelect}
|
|
13
|
+
use-old-sidebar={useOldSidebar}
|
|
14
|
+
>
|
|
15
|
+
<doc-phase
|
|
16
|
+
slot="version-banner"
|
|
17
|
+
if:true={showVersionBanner}
|
|
18
|
+
doc-phase-info={oldVersionInfo}
|
|
19
|
+
icon-name="warning"
|
|
20
|
+
dismissible="true"
|
|
21
|
+
ondismissphase={handleDismissVersionBanner}
|
|
22
|
+
></doc-phase>
|
|
23
|
+
<div slot="sidebar-header" class="document-pickers">
|
|
24
|
+
<dx-dropdown
|
|
25
|
+
data-type="version"
|
|
26
|
+
analytics-event="custEv_ctaLinkClick"
|
|
27
|
+
analytics-payload={ANALYTICS_PAYLOAD}
|
|
28
|
+
options={versionOptions}
|
|
29
|
+
value={version.id}
|
|
30
|
+
width="290px"
|
|
31
|
+
>
|
|
32
|
+
<dx-button variant="inline" disabled={disableVersion}>
|
|
33
|
+
{version.releaseVersion}
|
|
34
|
+
</dx-button>
|
|
35
|
+
</dx-dropdown>
|
|
36
|
+
</div>
|
|
37
|
+
<doc-breadcrumbs
|
|
38
|
+
if:true={showBreadcrumbs}
|
|
39
|
+
breadcrumbs={breadcrumbs}
|
|
40
|
+
pixel-per-character={breadcrumbPixelPerCharacter}
|
|
41
|
+
></doc-breadcrumbs>
|
|
42
|
+
<doc-content
|
|
43
|
+
docs-data={docContent}
|
|
44
|
+
page-reference={pageReference}
|
|
45
|
+
onnavclick={handleNavClick}
|
|
46
|
+
></doc-content>
|
|
47
|
+
</doc-content-layout>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import {BaseContentElement} from "../xmlContent/baseContentElement";
|
|
2
|
+
import { ApiDocLanguage, ApiDocVersion, ApiNavItem, DocLanguage, DocVersion, DocumentData, HistoryState, PageReference, TocMap, TreeNode, ZoominApiNavItem, ZoominDocContent } from "../xmlContent/types";
|
|
3
|
+
import { Language } from "typings/custom";
|
|
4
|
+
import mockResponses from "./mockResponses";
|
|
5
|
+
import { ZoominFetchContent } from "./zoominUtils";
|
|
6
|
+
|
|
7
|
+
export default class xmlContentElement extends BaseContentElement{
|
|
8
|
+
connectedCallback(){
|
|
9
|
+
this.contentProvider = new ZoominFetchContent(
|
|
10
|
+
this.apiDomain,
|
|
11
|
+
this.allLanguages
|
|
12
|
+
);
|
|
13
|
+
this.fetchDocument().then(() => (this.loaded = true));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getReferenceFromUrl(): PageReference {
|
|
17
|
+
//console.log(`get Reference from URL ${window.location.pathname}`);
|
|
18
|
+
|
|
19
|
+
// const [
|
|
20
|
+
// page,
|
|
21
|
+
// docId,
|
|
22
|
+
// deliverable,
|
|
23
|
+
// contentDocumentId
|
|
24
|
+
// ] = window.location.pathname.substr(1).split("/");
|
|
25
|
+
|
|
26
|
+
// const { origin: domain, hash, search } = window.location;
|
|
27
|
+
|
|
28
|
+
const [
|
|
29
|
+
page,
|
|
30
|
+
docId,
|
|
31
|
+
deliverable,
|
|
32
|
+
contentDocumentId
|
|
33
|
+
] = "/docs/atlas.en-us.bi_dev_guide_ext_data.meta/bi_dev_guide_ext_data/bi_ext_data_overview.htm".substr(1).split("/");
|
|
34
|
+
|
|
35
|
+
const domain = "localhost:3000"
|
|
36
|
+
const hash = ""
|
|
37
|
+
const search = ""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
contentDocumentId,
|
|
42
|
+
deliverable,
|
|
43
|
+
docId,
|
|
44
|
+
domain,
|
|
45
|
+
hash,
|
|
46
|
+
page,
|
|
47
|
+
search
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// async fetchDocument(): Promise<void> {
|
|
52
|
+
// this.setState({
|
|
53
|
+
// isFetchingDocument: true
|
|
54
|
+
// });
|
|
55
|
+
// console.log(`Fetching doc --> ${this.pageReference.docId}`)
|
|
56
|
+
// // const data = await this.contentProvider!.fetchDocumentData(
|
|
57
|
+
// // this.pageReference.docId!
|
|
58
|
+
// // );
|
|
59
|
+
// // const {
|
|
60
|
+
// // available_languages,
|
|
61
|
+
// // available_versions,
|
|
62
|
+
// // toc,
|
|
63
|
+
// // content,
|
|
64
|
+
// // version,
|
|
65
|
+
// // language,
|
|
66
|
+
// // content_document_id,
|
|
67
|
+
// // title,
|
|
68
|
+
// // doc_title,
|
|
69
|
+
// // pdf_url,
|
|
70
|
+
// // deliverable
|
|
71
|
+
// // } = zoominResponse;
|
|
72
|
+
|
|
73
|
+
// const toc = zoominToc;
|
|
74
|
+
// this.docTitle = toc.title || "";
|
|
75
|
+
// this.tocMap = data.tocMap;
|
|
76
|
+
// this.sidebarContent = data.toc;
|
|
77
|
+
// this.version = data.version;
|
|
78
|
+
// this.language = data.language;
|
|
79
|
+
// this.availableLanguages = data.availableLanguages;
|
|
80
|
+
// this.availableVersions = data.availableVersions;
|
|
81
|
+
// this.pdfUrl = data.pdfUrl;
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// const { normalizedToc, tocMap } = this.normalizeToc(toc);
|
|
87
|
+
|
|
88
|
+
// const data = {
|
|
89
|
+
// availableLanguages:
|
|
90
|
+
// available_languages &&
|
|
91
|
+
// available_languages.map(this.normalizeLanguage.bind(this)),
|
|
92
|
+
// availableVersions:
|
|
93
|
+
// available_versions &&
|
|
94
|
+
// available_versions.map(this.normalizeVersion.bind(this)),
|
|
95
|
+
// content,
|
|
96
|
+
// version: this.normalizeVersion(version),
|
|
97
|
+
// id: content_document_id,
|
|
98
|
+
// language: this.normalizeLanguage(language),
|
|
99
|
+
// title,
|
|
100
|
+
// toc: normalizedToc,
|
|
101
|
+
// tocMap,
|
|
102
|
+
// docTitle: doc_title,
|
|
103
|
+
// pdfUrl: pdf_url,
|
|
104
|
+
// deliverable
|
|
105
|
+
// };
|
|
106
|
+
|
|
107
|
+
// //const data = zoominResponse;
|
|
108
|
+
|
|
109
|
+
// // This could be a 404 scenario.
|
|
110
|
+
// if (!data) {
|
|
111
|
+
// this.setState({
|
|
112
|
+
// isFetchingDocument: false
|
|
113
|
+
// });
|
|
114
|
+
// return;
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// this.docTitle = data.docTitle;
|
|
118
|
+
// this.tocMap = data.tocMap;
|
|
119
|
+
// this.sidebarContent = data.toc;
|
|
120
|
+
// this.version = data.version;
|
|
121
|
+
// this.language = data.language;
|
|
122
|
+
// this.availableLanguages = data.availableLanguages;
|
|
123
|
+
// this.availableVersions = data.availableVersions;
|
|
124
|
+
// this.pdfUrl = data.pdfUrl;
|
|
125
|
+
|
|
126
|
+
// this.updateHeader();
|
|
127
|
+
|
|
128
|
+
// this.buildBreadcrumbs();
|
|
129
|
+
|
|
130
|
+
// if (this.pageReference.deliverable !== data.deliverable) {
|
|
131
|
+
// this.pageReference.deliverable = data.deliverable;
|
|
132
|
+
// this.updateUrl(HistoryState.REPLACE_STATE);
|
|
133
|
+
// }
|
|
134
|
+
|
|
135
|
+
// if (this.oldVersionInfo) {
|
|
136
|
+
// this.showVersionBanner = true;
|
|
137
|
+
// }
|
|
138
|
+
|
|
139
|
+
// if (
|
|
140
|
+
// this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
|
|
141
|
+
// data.id
|
|
142
|
+
// ) {
|
|
143
|
+
// try {
|
|
144
|
+
// await this.fetchContent();
|
|
145
|
+
// this.setState({
|
|
146
|
+
// isFetchingDocument: false
|
|
147
|
+
// });
|
|
148
|
+
// return;
|
|
149
|
+
// } catch (error) {
|
|
150
|
+
// this.pageReference.contentDocumentId = `${data.id}.htm`;
|
|
151
|
+
// this.pageReference.hash = "";
|
|
152
|
+
// this.pageReference.search = "";
|
|
153
|
+
// this.updateUrl(HistoryState.REPLACE_STATE);
|
|
154
|
+
// }
|
|
155
|
+
// }
|
|
156
|
+
|
|
157
|
+
// this.docContent = data.content;
|
|
158
|
+
// this.addMetatags();
|
|
159
|
+
// this.setState({
|
|
160
|
+
// isFetchingDocument: false
|
|
161
|
+
// });
|
|
162
|
+
// }
|
|
163
|
+
|
|
164
|
+
async fetchDocument(): Promise<void> {
|
|
165
|
+
this.setState({
|
|
166
|
+
isFetchingDocument: true
|
|
167
|
+
});
|
|
168
|
+
// const data = await this.contentProvider!.fetchDocumentData(
|
|
169
|
+
// this.pageReference.docId!
|
|
170
|
+
// );
|
|
171
|
+
|
|
172
|
+
console.log("Get this doc ID now ---> " +this.pageReference.docId);
|
|
173
|
+
|
|
174
|
+
const data = await this.mockedFetchDocumentData(this.pageReference.docId!)
|
|
175
|
+
|
|
176
|
+
//const data = zoominResponse;
|
|
177
|
+
|
|
178
|
+
// This could be a 404 scenario.
|
|
179
|
+
if (!data) {
|
|
180
|
+
this.setState({
|
|
181
|
+
isFetchingDocument: false
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.docTitle = data.docTitle;
|
|
187
|
+
this.tocMap = data.tocMap;
|
|
188
|
+
this.sidebarContent = data.toc;
|
|
189
|
+
this.version = data.version;
|
|
190
|
+
this.language = data.language;
|
|
191
|
+
this.availableLanguages = data.availableLanguages;
|
|
192
|
+
this.availableVersions = data.availableVersions;
|
|
193
|
+
this.pdfUrl = data.pdfUrl;
|
|
194
|
+
|
|
195
|
+
this.updateHeader();
|
|
196
|
+
|
|
197
|
+
this.buildBreadcrumbs();
|
|
198
|
+
|
|
199
|
+
if (this.pageReference.deliverable !== data.deliverable) {
|
|
200
|
+
this.pageReference.deliverable = data.deliverable;
|
|
201
|
+
// we need the below line - commented for testing only
|
|
202
|
+
//this.updateUrl(HistoryState.REPLACE_STATE);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (this.oldVersionInfo) {
|
|
206
|
+
this.showVersionBanner = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (
|
|
210
|
+
this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
|
|
211
|
+
data.id
|
|
212
|
+
) {
|
|
213
|
+
try {
|
|
214
|
+
await this.fetchContent();
|
|
215
|
+
this.setState({
|
|
216
|
+
isFetchingDocument: false
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
this.pageReference.contentDocumentId = `${data.id}.htm`;
|
|
221
|
+
this.pageReference.hash = "";
|
|
222
|
+
this.pageReference.search = "";
|
|
223
|
+
this.updateUrl(HistoryState.REPLACE_STATE);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
this.docContent = data.content;
|
|
228
|
+
this.addMetatags();
|
|
229
|
+
this.setState({
|
|
230
|
+
isFetchingDocument: false
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async fetchContent(): Promise<void> {
|
|
235
|
+
this.setState({
|
|
236
|
+
isFetchingContent: true
|
|
237
|
+
});
|
|
238
|
+
// const data = await this.contentProvider!.fetchContent(
|
|
239
|
+
// this.pageReference.deliverable!,
|
|
240
|
+
// this.pageReference.contentDocumentId!,
|
|
241
|
+
// {
|
|
242
|
+
// language: this.language!.id,
|
|
243
|
+
// version: this.version!.id
|
|
244
|
+
// }
|
|
245
|
+
// );
|
|
246
|
+
// Working
|
|
247
|
+
//const data = mockResponses.zoominFetchDocContent;
|
|
248
|
+
|
|
249
|
+
const data: ZoominDocContent = await this.contentProvider!.fetchContent(
|
|
250
|
+
this.pageReference.deliverable!,
|
|
251
|
+
this.pageReference.contentDocumentId!,
|
|
252
|
+
{
|
|
253
|
+
language: this.language!.id,
|
|
254
|
+
version: this.version!.id
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
// const data = await this.contentProvider!.zoominFetchContent(
|
|
261
|
+
// this.pageReference.deliverable!,
|
|
262
|
+
// this.pageReference.contentDocumentId!,
|
|
263
|
+
// {
|
|
264
|
+
// language: this.language!.id,
|
|
265
|
+
// version: this.version!.id
|
|
266
|
+
// }
|
|
267
|
+
// )
|
|
268
|
+
|
|
269
|
+
if (data) {
|
|
270
|
+
this.docContent = data.topic_html;
|
|
271
|
+
this.addMetatags();
|
|
272
|
+
|
|
273
|
+
if (!this.pageReference.hash) {
|
|
274
|
+
document.body.scrollIntoView();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
this.setState({
|
|
278
|
+
isFetchingContent: false
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async mockedFetchDocumentData(docId: string): Promise<DocumentData | null> {
|
|
283
|
+
try {
|
|
284
|
+
console.log(`Doc requested ${docId} `)
|
|
285
|
+
//const zoominToc: Array<ZoominApiNavItem> = mockResponses.zoominToc;
|
|
286
|
+
const zoominToc: Array<ZoominApiNavItem> = await this.contentProvider!.fetchDocumentData(this.pageReference.docId!)
|
|
287
|
+
|
|
288
|
+
const atlastToc = this.transformZoominTocToAtlasToc(zoominToc)
|
|
289
|
+
const { normalizedToc, tocMap } = this.normalizeToc(atlastToc);
|
|
290
|
+
|
|
291
|
+
const zoominDocData = mockResponses.zoominFetchDocContent;
|
|
292
|
+
|
|
293
|
+
// const {
|
|
294
|
+
// available_languages,
|
|
295
|
+
// available_versions=[],
|
|
296
|
+
// content,
|
|
297
|
+
// version,
|
|
298
|
+
// language,
|
|
299
|
+
// content_document_id,
|
|
300
|
+
// title,
|
|
301
|
+
// doc_title,
|
|
302
|
+
// pdf_url,
|
|
303
|
+
// deliverable
|
|
304
|
+
// } = zoominDocData;
|
|
305
|
+
|
|
306
|
+
//const available_languages = zoominDocData.available_languages;
|
|
307
|
+
//const available_versions: ApiDocVersion[] = [];
|
|
308
|
+
const pdf_url = zoominDocData.preprocessed_PDF || "";
|
|
309
|
+
const deliverable = zoominDocData.page_id;
|
|
310
|
+
const docContent = zoominDocData.labels_text;
|
|
311
|
+
const docTitle = zoominDocData.title;
|
|
312
|
+
const version = "atlas.en-us.apexcode.meta";
|
|
313
|
+
const language = "en-us";
|
|
314
|
+
const content_document_id = zoominDocData.bundle_id;
|
|
315
|
+
const title = zoominDocData.title;
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
const mock_available_versions= [
|
|
319
|
+
{
|
|
320
|
+
version_text: "Winter '24 (API version 59.0)",
|
|
321
|
+
release_version: "59.0",
|
|
322
|
+
doc_version: "246.0",
|
|
323
|
+
version_url: "atlas.en-us.apexcode.meta"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
version_text: "Summer '23 (API version 58.0)",
|
|
327
|
+
release_version: "58.0",
|
|
328
|
+
doc_version: "244.0",
|
|
329
|
+
version_url: "atlas.en-us.244.0.apexcode.meta"
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
const mock_available_languages= [
|
|
333
|
+
{
|
|
334
|
+
label: "ENGLISH",
|
|
335
|
+
code: "EN",
|
|
336
|
+
locale: "en-us",
|
|
337
|
+
url: "atlas.en-us.246.0.apexcode.meta"
|
|
338
|
+
}
|
|
339
|
+
,
|
|
340
|
+
{
|
|
341
|
+
label: "JAPANESE",
|
|
342
|
+
code: "JA",
|
|
343
|
+
locale: "ja-jp",
|
|
344
|
+
url: "atlas.ja-jp.246.0.apexcode.meta"
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
availableLanguages:
|
|
352
|
+
mock_available_languages &&
|
|
353
|
+
mock_available_languages.map(this.normalizeLanguage.bind(this)),
|
|
354
|
+
availableVersions:
|
|
355
|
+
mock_available_versions &&
|
|
356
|
+
mock_available_versions.map(this.normalizeVersion.bind(this)),
|
|
357
|
+
content: docContent,
|
|
358
|
+
version: this.normalizeVersion(version),
|
|
359
|
+
id: content_document_id,
|
|
360
|
+
language: this.normalizeLanguage(language),
|
|
361
|
+
title,
|
|
362
|
+
toc: normalizedToc,
|
|
363
|
+
tocMap,
|
|
364
|
+
docTitle,
|
|
365
|
+
pdfUrl: pdf_url,
|
|
366
|
+
deliverable
|
|
367
|
+
};
|
|
368
|
+
} catch (error) {
|
|
369
|
+
console.log(error);
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
transformZoominTocToAtlasToc(zoominToc: ZoominApiNavItem[]): Array<ApiNavItem>
|
|
375
|
+
{
|
|
376
|
+
if (!zoominToc) {
|
|
377
|
+
return [];
|
|
378
|
+
}
|
|
379
|
+
console.log(`transformZoominTocToAtlasToc ${zoominToc}`);
|
|
380
|
+
|
|
381
|
+
return zoominToc.map(zoominTocItem => ({
|
|
382
|
+
text: zoominTocItem.title,
|
|
383
|
+
id: zoominTocItem.bundle_id,
|
|
384
|
+
children: zoominTocItem.childEntries
|
|
385
|
+
? this.transformZoominTocToAtlasToc(zoominTocItem.childEntries)
|
|
386
|
+
: []
|
|
387
|
+
}))
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
private normalizeToc(
|
|
391
|
+
apiToc: Array<ApiNavItem>
|
|
392
|
+
): {
|
|
393
|
+
tocMap: { [key: string]: TreeNode };
|
|
394
|
+
normalizedToc: Array<TreeNode>;
|
|
395
|
+
} {
|
|
396
|
+
const tocMap = {};
|
|
397
|
+
const normalizedToc =
|
|
398
|
+
apiToc &&
|
|
399
|
+
apiToc.map((navItem) => this.normalizeNavItem(navItem, tocMap));
|
|
400
|
+
|
|
401
|
+
return { normalizedToc, tocMap };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private normalizeNavItem(
|
|
405
|
+
navItem: ApiNavItem,
|
|
406
|
+
tocMap: TocMap,
|
|
407
|
+
parentNavItem?: TreeNode
|
|
408
|
+
): TreeNode {
|
|
409
|
+
const name = this.calculateNavItemName(navItem, tocMap);
|
|
410
|
+
const node: TreeNode = {
|
|
411
|
+
label: navItem.text,
|
|
412
|
+
name,
|
|
413
|
+
parent: parentNavItem
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
if (name) {
|
|
417
|
+
tocMap[name] = node;
|
|
418
|
+
}
|
|
419
|
+
node.children = navItem.children?.map((child) =>
|
|
420
|
+
this.normalizeNavItem(child, tocMap, node)
|
|
421
|
+
);
|
|
422
|
+
return node;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private calculateNavItemName(navItem: ApiNavItem, tocMap: TocMap): string {
|
|
426
|
+
let href = navItem.a_attr?.href || "";
|
|
427
|
+
if (href.includes("#")) {
|
|
428
|
+
const [pathUrl] = href.split("#");
|
|
429
|
+
href = pathUrl in tocMap ? href : pathUrl;
|
|
430
|
+
}
|
|
431
|
+
return href || navItem.id;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
private normalizeVersion(version: ApiDocVersion): DocVersion {
|
|
435
|
+
return (
|
|
436
|
+
version && {
|
|
437
|
+
label: version.version_text,
|
|
438
|
+
releaseVersion:
|
|
439
|
+
version.release_version &&
|
|
440
|
+
!version.release_version.startsWith("v")
|
|
441
|
+
? `v${version.release_version}`
|
|
442
|
+
: version.release_version,
|
|
443
|
+
id: version.doc_version,
|
|
444
|
+
url: version.version_url
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
private normalizeLanguage(language: ApiDocLanguage): DocLanguage {
|
|
450
|
+
return (
|
|
451
|
+
language && {
|
|
452
|
+
// label:
|
|
453
|
+
// this.getLanguageDisplayTextById(
|
|
454
|
+
// this.languages,
|
|
455
|
+
// language.locale
|
|
456
|
+
// ) || language.label,
|
|
457
|
+
label: 'English',
|
|
458
|
+
id: 'en-us',
|
|
459
|
+
code: 'EN',
|
|
460
|
+
url: 'atlas.en-us.246.0.apexcode.meta'
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
private getLanguageDisplayTextById (
|
|
466
|
+
languages: Language[],
|
|
467
|
+
languageId: string
|
|
468
|
+
): string
|
|
469
|
+
{
|
|
470
|
+
const language = languages.find(
|
|
471
|
+
(languageItem) => languageItem.id === languageId
|
|
472
|
+
);
|
|
473
|
+
return language ? language.displayText : "";
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Language } from "typings/custom";
|
|
2
|
+
import { ContentApiOptions, ZoominApiNavItem, ZoominDocContent } from "../xmlContent/types";
|
|
3
|
+
import jsonwebtoken from 'jsonwebtoken'
|
|
4
|
+
import mockResponses from "./mockResponses";
|
|
5
|
+
|
|
6
|
+
export class ZoominFetchContent {
|
|
7
|
+
private apiDomain: string;
|
|
8
|
+
private languages: Array<Language> = [];
|
|
9
|
+
|
|
10
|
+
constructor(apiDomain: string, languages: Array<Language>) {
|
|
11
|
+
this.apiDomain = apiDomain;
|
|
12
|
+
this.languages = languages;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async fetchDocumentData(docId: string): Promise<Array<ZoominApiNavItem>> {
|
|
16
|
+
try {
|
|
17
|
+
// const token = this.fetchZoomInToken();
|
|
18
|
+
// console.log(`Doc Id ${docId}`)
|
|
19
|
+
// const data = await this.fetchResource<DocumentData>(
|
|
20
|
+
// `https://salesforce-be-dev.zoominsoftware.io/api/bundle/pardot-guides/toc?jwt=${token}`
|
|
21
|
+
// );
|
|
22
|
+
// return data;
|
|
23
|
+
console.log(`Doc Id ${docId} `)
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
// Simulating an asynchronous operation, such as fetching data from a server
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
return resolve(mockResponses.zoominToc); // Resolve the promise with the string value
|
|
28
|
+
}, 50); // Simulating a delay of 1 second
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.log(error);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fetchContent(
|
|
38
|
+
deliverable: string,
|
|
39
|
+
contentId: string,
|
|
40
|
+
options: ContentApiOptions
|
|
41
|
+
): Promise<ZoominDocContent> {
|
|
42
|
+
// console.log(`ZoominContent ${deliverable} ${contentId} ${options}`)
|
|
43
|
+
// const token = this.fetchZoomInToken();
|
|
44
|
+
// const data = this.fetchResource<ContentData>(
|
|
45
|
+
// `https://salesforce-be-dev.zoominsoftware.io/api/bundle/sample_md/page/b2c-developer-sandboxes.html?jwt=${token}`
|
|
46
|
+
// );
|
|
47
|
+
// return data;
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
// Simulating an asynchronous operation, such as fetching data from a server
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
return resolve(mockResponses.zoominFetchDocContent); // Resolve the promise with the string value
|
|
52
|
+
}, 50); // Simulating a delay of 1 second
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private async fetchResource<T>(url: string): Promise<T> {
|
|
57
|
+
const response = await fetch(url);
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw new Error(response.statusText);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const json = await response.json();
|
|
63
|
+
|
|
64
|
+
return json;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fetchZoomInToken(){
|
|
68
|
+
const payload = {
|
|
69
|
+
aud: 'https://salesforce-be-dev.zoominsoftware.io',
|
|
70
|
+
iss: 'https://salesforce.com',
|
|
71
|
+
iat: Math.floor(Date.now() / 1000),
|
|
72
|
+
exp: Math.floor(Date.now() / 1000) + 360,
|
|
73
|
+
sub: 'lnemalipuri@salesforce.com',
|
|
74
|
+
data: {
|
|
75
|
+
ZoominRole: 'admin',
|
|
76
|
+
fullName: 'kishore',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// Need to update the token while running
|
|
80
|
+
//const token = jsonwebtoken.sign(payload, 'fcrvBbXi1Aimu6sIiZMlcvIP9CqjYjVd');
|
|
81
|
+
//console.log(token);
|
|
82
|
+
// return token;
|
|
83
|
+
|
|
84
|
+
return `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL3NhbGVzZm9yY2UtYmUtZGV2Lnpvb21pbnNvZnR3YXJlLmlvIiwiaXNzIjoiaHR0cHM6Ly9zYWxlc2ZvcmNlLmNvbSIsImlhdCI6MTcwODQxOTkxMCwiZXhwIjoxNzA4Nzc5OTEwLCJzdWIiOiJsbmVtYWxpcHVyaUBzYWxlc2ZvcmNlLmNvbSIsImRhdGEiOnsiWm9vbWluUm9sZSI6ImFkbWluIiwiZnVsbE5hbWUiOiJraXNob3JlIn19.1ekF_78Mq5136do4TdpQaPTy-CUroom0N1DdczcirSk`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|