@ng-doc/keywords-loaders 18.0.9 → 18.1.1

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.
@@ -1,5 +1,4 @@
1
- import { NgResponse } from '../interfaces';
2
- import { NgVersion } from '../types';
1
+ import { NgResponse, NgVersion } from '../types';
3
2
  /**
4
3
  *
5
4
  * @param version
@@ -1,3 +1,2 @@
1
1
  export * from './ng-keyword-loader-options';
2
2
  export * from './ng-page';
3
- export * from './ng-response';
@@ -1,2 +1,3 @@
1
1
  export * from './ng-api-page-type';
2
+ export * from './ng-response';
2
3
  export * from './ng-version';
@@ -0,0 +1,5 @@
1
+ import { NgPage } from '../interfaces';
2
+ export type NgResponse = Array<{
3
+ moduleName: string;
4
+ entries: NgPage[];
5
+ }>;
package/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var fetch = require('node-fetch');
3
+ var fetch$1 = require('node-fetch');
4
4
 
5
5
  /**
6
6
  *
@@ -15,9 +15,9 @@ function getNgHost(version) {
15
15
  *
16
16
  * @param version
17
17
  */
18
- async function fetchDocs(version) {
18
+ async function fetchDocs$1(version) {
19
19
  const manifestUrl = `${getNgHost(version)}/assets/api/manifest.json`;
20
- return fetch(manifestUrl).then(response => response.json());
20
+ return fetch$1(manifestUrl).then(response => response.json());
21
21
  }
22
22
 
23
23
  /**
@@ -26,7 +26,7 @@ async function fetchDocs(version) {
26
26
  * @param pageName
27
27
  * @param version
28
28
  */
29
- function getApiUrl(packageName, pageName, version) {
29
+ function getApiUrl$1(packageName, pageName, version) {
30
30
  const packageNameWithoutPrefix = packageName.replace('@angular/', '');
31
31
  return `${getNgHost(version)}/api/${packageNameWithoutPrefix}/${pageName}`;
32
32
  }
@@ -38,7 +38,7 @@ function getApiUrl(packageName, pageName, version) {
38
38
  * @param version
39
39
  */
40
40
  function ngPageToKeyword(packageName, page, version) {
41
- const url = getApiUrl(packageName, page.name, version);
41
+ const url = getApiUrl$1(packageName, page.name, version);
42
42
  const description = `External link the Angular documentation.`;
43
43
  const keywords = [[page.name, {
44
44
  title: page.name,
@@ -65,8 +65,11 @@ function ngPageToKeyword(packageName, page, version) {
65
65
  function ngKeywordsLoader(options) {
66
66
  return async () => {
67
67
  try {
68
- const packages = await fetchDocs(options?.version);
69
- const keywords = Object.entries(packages).flatMap(([packageName, pages]) => pages.flatMap(page => ngPageToKeyword(packageName, page, options?.version)));
68
+ const packages = await fetchDocs$1(options?.version);
69
+ const keywords = packages.flatMap(({
70
+ moduleName,
71
+ entries
72
+ }) => entries.flatMap(page => ngPageToKeyword(moduleName, page, options?.version)));
70
73
  return Object.fromEntries(keywords);
71
74
  } catch (error) {
72
75
  console.error(`Failed to load Angular keywords: ${error}`);
@@ -80,7 +83,7 @@ function ngKeywordsLoader(options) {
80
83
  * @param endpoint
81
84
  */
82
85
  async function fetchKeywords(endpoint) {
83
- return await fetch(`${endpoint}/keywords.json`).then(response => response.json());
86
+ return await fetch$1(`${endpoint}/keywords.json`).then(response => response.json());
84
87
  }
85
88
 
86
89
  /**
@@ -124,5 +127,58 @@ function ngDocKeywordsLoader(options) {
124
127
  };
125
128
  }
126
129
 
130
+ /**
131
+ * @param version rxjs version
132
+ */
133
+ function getRxjsHost(version) {
134
+ return `https://${version ? `${version}.` : ''}rxjs.dev`;
135
+ }
136
+
137
+ /**
138
+ * @param path type api path from rxjs api manifest
139
+ * @param version version of rxjs
140
+ */
141
+ function getApiUrl(path, version) {
142
+ return `${getRxjsHost(version)}/${path}`;
143
+ }
144
+
145
+ /**
146
+ * @param version rxjs version
147
+ */
148
+ async function fetchDocs(version) {
149
+ const manifestUrl = getApiUrl('generated/docs/api/api-list.json', version);
150
+ return fetch(manifestUrl).then(response => response.json());
151
+ }
152
+
153
+ /**
154
+ *
155
+ * @param page
156
+ * @param version
157
+ */
158
+ function rxjsPageToKeyword(page, version) {
159
+ return [page.title, {
160
+ title: page.title,
161
+ url: getApiUrl(page.path, version),
162
+ description: `External link the RxJS documentation.`
163
+ }];
164
+ }
165
+
166
+ /**
167
+ * @param version rxjs version
168
+ */
169
+ function rxjsKeywordsLoader(version) {
170
+ return async () => {
171
+ try {
172
+ const apiReference = await fetchDocs(version);
173
+ const keywords = apiReference.flatMap(ref => ref.items.map(item => rxjsPageToKeyword(item, version)));
174
+ return Object.fromEntries(keywords);
175
+ } catch (error) {
176
+ console.error(`Failed to load RxJS keywords:`, error);
177
+ return {};
178
+ }
179
+ };
180
+ }
181
+
127
182
  exports.ngDocKeywordsLoader = ngDocKeywordsLoader;
128
183
  exports.ngKeywordsLoader = ngKeywordsLoader;
184
+ exports.rxjsKeywordsLoader = rxjsKeywordsLoader;
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './angular';
2
2
  export * from './ng-doc';
3
+ export * from './rxjs';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@ng-doc/keywords-loaders",
3
- "version": "18.0.9",
3
+ "version": "18.1.1",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
- "@ng-doc/core": "18.0.9",
6
+ "@ng-doc/core": "18.1.1",
7
7
  "node-fetch": "2.6.11"
8
8
  },
9
9
  "publishConfig": {
@@ -0,0 +1,5 @@
1
+ import { RxjsResponse } from '../types';
2
+ /**
3
+ * @param version rxjs version
4
+ */
5
+ export declare function fetchDocs(version?: string): Promise<RxjsResponse>;
@@ -0,0 +1,6 @@
1
+ import { RxjsVersion } from '../types';
2
+ /**
3
+ * @param path type api path from rxjs api manifest
4
+ * @param version version of rxjs
5
+ */
6
+ export declare function getApiUrl(path: string, version?: RxjsVersion): string;
@@ -0,0 +1,5 @@
1
+ import { RxjsVersion } from '../types';
2
+ /**
3
+ * @param version rxjs version
4
+ */
5
+ export declare function getRxjsHost(version?: RxjsVersion): string;
@@ -0,0 +1,2 @@
1
+ export * from './fetch-docs';
2
+ export * from './rxjs-to-keyword';
@@ -0,0 +1,9 @@
1
+ import { NgDocGlobalKeyword } from '@ng-doc/core';
2
+ import { RxjsPage } from '../interfaces';
3
+ import { RxjsVersion } from '../types';
4
+ /**
5
+ *
6
+ * @param page
7
+ * @param version
8
+ */
9
+ export declare function rxjsPageToKeyword(page: RxjsPage, version?: RxjsVersion): [string, NgDocGlobalKeyword];
@@ -0,0 +1,2 @@
1
+ export * from './rxjs-keywords-loader';
2
+ export { RxjsVersion } from './types/rxjs-version';
@@ -0,0 +1 @@
1
+ export * from './rxjs-page';
@@ -0,0 +1,4 @@
1
+ export interface RxjsPage {
2
+ title: string;
3
+ path: `api/${string}/${string}`;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { NgDocKeywordsLoader } from '@ng-doc/core';
2
+ import { RxjsVersion } from './types';
3
+ /**
4
+ * @param version rxjs version
5
+ */
6
+ export declare function rxjsKeywordsLoader(version?: RxjsVersion): NgDocKeywordsLoader;
@@ -0,0 +1,2 @@
1
+ export * from './rxjs-response';
2
+ export * from './rxjs-version';
@@ -0,0 +1,6 @@
1
+ import { RxjsPage } from '../interfaces';
2
+ export type RxjsResponse = Array<{
3
+ name: string;
4
+ title: string;
5
+ items: RxjsPage[];
6
+ }>;
@@ -0,0 +1 @@
1
+ export type RxjsVersion = string;
@@ -1,4 +0,0 @@
1
- import { NgPage } from './ng-page';
2
- export interface NgResponse {
3
- [packageName: string]: NgPage[];
4
- }