@scalar/workspace-store 0.15.6 → 0.15.8
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/CHANGELOG.md +29 -0
- package/dist/client.d.ts +1 -38
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -8
- package/dist/client.js.map +2 -2
- package/dist/navigation/get-navigation-options.d.ts +9 -0
- package/dist/navigation/get-navigation-options.d.ts.map +1 -0
- package/dist/navigation/get-navigation-options.js +77 -0
- package/dist/navigation/get-navigation-options.js.map +7 -0
- package/dist/navigation/helpers/get-x-keys.d.ts +10 -0
- package/dist/navigation/helpers/get-x-keys.d.ts.map +1 -0
- package/dist/navigation/helpers/get-x-keys.js +10 -0
- package/dist/navigation/helpers/get-x-keys.js.map +7 -0
- package/dist/navigation/helpers/traverse-description.d.ts +3 -5
- package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-description.js +4 -5
- package/dist/navigation/helpers/traverse-description.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts +121 -28
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js +16 -21
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts +4 -5
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js +15 -8
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts +3 -6
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js +7 -7
- package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts +2 -5
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js +16 -13
- package/dist/navigation/helpers/traverse-tags.js.map +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts +3 -6
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js +27 -7
- package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/index.js.map +2 -2
- package/dist/navigation/types.d.ts +3 -4
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.d.ts +162 -102
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/navigation.d.ts +60 -128
- package/dist/schemas/navigation.d.ts.map +1 -1
- package/dist/schemas/navigation.js +40 -44
- package/dist/schemas/navigation.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +81 -51
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +81 -51
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +9980 -1429
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +31 -4
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts +8 -0
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/ref-definitions.js +12 -1
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +2 -44
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +113 -51
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/config.js.map +2 -2
- package/dist/schemas/workspace-specification/index.d.ts +81 -51
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +567 -357
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/server.d.ts +3 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +2 -2
- package/package.json +11 -6
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import { getXKeysFromObject } from "../../navigation/helpers/get-x-keys.js";
|
|
1
2
|
import { getTag } from "./get-tag.js";
|
|
2
|
-
const createTagEntry = (tag,
|
|
3
|
+
const createTagEntry = (tag, getTagId, children, isGroup = false) => {
|
|
3
4
|
const id = getTagId(tag);
|
|
4
5
|
const title = tag["x-displayName"] ?? tag.name ?? "Untitled Tag";
|
|
5
|
-
|
|
6
|
-
return {
|
|
6
|
+
const entry = {
|
|
7
7
|
id,
|
|
8
8
|
title,
|
|
9
9
|
name: tag.name || title,
|
|
10
|
+
description: tag.description,
|
|
10
11
|
children,
|
|
11
12
|
isGroup,
|
|
12
|
-
type: "tag"
|
|
13
|
+
type: "tag",
|
|
14
|
+
xKeys: getXKeysFromObject(tag)
|
|
13
15
|
};
|
|
16
|
+
return entry;
|
|
14
17
|
};
|
|
15
|
-
const getSortedTagEntries = (_keys, tagsMap,
|
|
18
|
+
const getSortedTagEntries = (_keys, tagsMap, { getTagId, tagsSorter, operationsSorter }) => {
|
|
16
19
|
const hasDefault = _keys.includes("default");
|
|
17
20
|
const keys = hasDefault ? _keys.filter((key) => key !== "default") : _keys;
|
|
18
21
|
if (tagsSorter === "alpha") {
|
|
@@ -33,12 +36,12 @@ const getSortedTagEntries = (_keys, tagsMap, titlesMap, { getTagId, tagsSorter,
|
|
|
33
36
|
return [];
|
|
34
37
|
}
|
|
35
38
|
if (operationsSorter === "alpha") {
|
|
36
|
-
entries.sort((a, b) => "
|
|
39
|
+
entries.sort((a, b) => a.type === "operation" && b.type === "operation" ? a.title.localeCompare(b.title) : 0);
|
|
37
40
|
} else if (operationsSorter === "method") {
|
|
38
|
-
entries.sort((a, b) => "
|
|
41
|
+
entries.sort((a, b) => a.type === "operation" && b.type === "operation" ? a.method.localeCompare(b.method) : 0);
|
|
39
42
|
} else if (typeof operationsSorter === "function") {
|
|
40
43
|
entries.sort((a, b) => {
|
|
41
|
-
if (a.type
|
|
44
|
+
if (!(a.type === "operation" || a.type === "webhook") || !(b.type === "operation" || b.type === "webhook")) {
|
|
42
45
|
return 0;
|
|
43
46
|
}
|
|
44
47
|
const pathA = a.type === "operation" ? a.path : a.name;
|
|
@@ -49,23 +52,23 @@ const getSortedTagEntries = (_keys, tagsMap, titlesMap, { getTagId, tagsSorter,
|
|
|
49
52
|
);
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
|
-
return entries.length ? createTagEntry(tag,
|
|
55
|
+
return entries.length ? createTagEntry(tag, getTagId, entries) : [];
|
|
53
56
|
});
|
|
54
57
|
};
|
|
55
|
-
const traverseTags = (content, tagsMap,
|
|
58
|
+
const traverseTags = (content, tagsMap, { getTagId, tagsSorter, operationsSorter }) => {
|
|
56
59
|
if (content["x-tagGroups"]) {
|
|
57
60
|
const tagGroups = content["x-tagGroups"];
|
|
58
61
|
return tagGroups.flatMap((tagGroup) => {
|
|
59
|
-
const entries = getSortedTagEntries(tagGroup.tags ?? [], tagsMap,
|
|
62
|
+
const entries = getSortedTagEntries(tagGroup.tags ?? [], tagsMap, {
|
|
60
63
|
getTagId,
|
|
61
64
|
tagsSorter,
|
|
62
65
|
operationsSorter
|
|
63
66
|
});
|
|
64
|
-
return entries.length ? createTagEntry(tagGroup,
|
|
67
|
+
return entries.length ? createTagEntry(tagGroup, getTagId, entries, true) : [];
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
const keys = Array.from(tagsMap.keys());
|
|
68
|
-
const tags = getSortedTagEntries(keys, tagsMap,
|
|
71
|
+
const tags = getSortedTagEntries(keys, tagsMap, { getTagId, tagsSorter, operationsSorter });
|
|
69
72
|
if (tags.length === 1 && tags[0]?.title === "default") {
|
|
70
73
|
return tags[0]?.children ?? [];
|
|
71
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/helpers/traverse-tags.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { getXKeysFromObject } from '@/navigation/helpers/get-x-keys'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { OpenApiDocument, TagObject, TraversedEntry, TraversedTag } from '@/schemas/v3.1/strict/openapi-document'\n\nimport { getTag } from './get-tag'\n\ntype Options = Pick<TraverseSpecOptions, 'getTagId' | 'tagsSorter' | 'operationsSorter'>\n\n/** Creates a traversed tag entry from an OpenAPI tag object.\n *\n * @param tag - The OpenAPI tag object\n * @param entriesMap - Map to store tag IDs and titles for mobile header navigation\n * @param getTagId - Function to generate unique IDs for tags\n * @param children - Array of child entries (operations, webhooks, etc.)\n * @param isGroup - Whether this tag represents a group of tags\n * @returns A traversed tag entry with ID, title, name and children\n */\nconst createTagEntry = (\n tag: TagObject,\n getTagId: TraverseSpecOptions['getTagId'],\n children: TraversedEntry[],\n isGroup = false,\n): TraversedTag => {\n const id = getTagId(tag)\n const title = tag['x-displayName'] ?? tag.name ?? 'Untitled Tag'\n\n const entry = {\n id,\n title,\n name: tag.name || title,\n description: tag.description,\n children,\n isGroup,\n type: 'tag',\n xKeys: getXKeysFromObject(tag),\n } satisfies TraversedTag\n\n return entry\n}\n\n/** Sorts and processes tags to create a hierarchical structure of tag entries.\n *\n * This function handles:\n * - Sorting tags alphabetically or using a custom sort function\n * - Ensuring the default tag appears last\n * - Sorting operations within tags by title, method, or custom function\n * - Filtering out internal and ignored tags\n * - Creating tag entries with their associated operations\n *\n * @param _keys - Array of tag keys to process\n * @param tagsMap - Map of tags and their entries\n * @param tagsDict - Dictionary of OpenAPI tags by name\n * @param titlesMap - Map of titles for the mobile header\n * @param options - Sorting and ID generation options\n * @returns Array of processed and sorted tag entries\n */\n/** Sorts tags and returns entries */\nconst getSortedTagEntries = (\n _keys: string[],\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n { getTagId, tagsSorter, operationsSorter }: Options,\n) => {\n // Ensure that default is last if it exists\n const hasDefault = _keys.includes('default')\n const keys = hasDefault ? _keys.filter((key) => key !== 'default') : _keys\n\n // Alpha sort\n if (tagsSorter === 'alpha') {\n keys.sort((a, b) => {\n const nameA = getTag(tagsMap, a).tag['x-displayName'] || a || 'Untitled Tag'\n const nameB = getTag(tagsMap, b).tag['x-displayName'] || b || 'Untitled Tag'\n return nameA.localeCompare(nameB)\n })\n }\n // Custom sort\n else if (typeof tagsSorter === 'function') {\n keys.sort((a, b) => tagsSorter(getTag(tagsMap, a).tag, getTag(tagsMap, b).tag))\n }\n\n if (hasDefault) {\n keys.push('default')\n }\n\n /**\n * Process each tag and its entries:\n * - Skip internal and ignored tags\n * - Sort operations within tags\n * - Create tag entries with sorted operations\n */\n return keys.flatMap((key) => {\n const { tag, entries } = getTag(tagsMap, key)\n\n // Skip if the tag is internal or scalar-ignore\n if (tag['x-internal'] || tag['x-scalar-ignore']) {\n return []\n }\n\n // Alpha sort\n if (operationsSorter === 'alpha') {\n entries.sort((a, b) => (a.type === 'operation' && b.type === 'operation' ? a.title.localeCompare(b.title) : 0))\n }\n // Method sort\n else if (operationsSorter === 'method') {\n entries.sort((a, b) => (a.type === 'operation' && b.type === 'operation' ? a.method.localeCompare(b.method) : 0))\n }\n // Custom sort\n else if (typeof operationsSorter === 'function') {\n entries.sort((a, b) => {\n // Guard against tags\n if (!(a.type === 'operation' || a.type === 'webhook') || !(b.type === 'operation' || b.type === 'webhook')) {\n return 0\n }\n\n // Handle webhooks as well as operations\n const pathA = a.type === 'operation' ? a.path : a.name\n const pathB = b.type === 'operation' ? b.path : b.name\n\n return operationsSorter(\n { method: a.method, path: pathA, ref: a.ref, httpVerb: a.method },\n { method: b.method, path: pathB, ref: b.ref, httpVerb: b.method },\n )\n })\n }\n\n return entries.length ? createTagEntry(tag, getTagId, entries) : []\n })\n}\n\n/**\n * Traverses the tags map to create navigation entries, handling both grouped and ungrouped tags.\n *\n * This function processes the OpenAPI document's tags to:\n * - Handle tag groups if specified via x-tagGroups\n * - Sort tags and their operations according to provided sorters\n * - Create navigation entries for each tag or tag group\n * - Flatten default tag entries if it's the only tag present\n */\nexport const traverseTags = (\n content: OpenApiDocument,\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n { getTagId, tagsSorter, operationsSorter }: Options,\n): TraversedEntry[] => {\n // x-tagGroups\n if (content['x-tagGroups']) {\n const tagGroups = content['x-tagGroups']\n\n return tagGroups.flatMap((tagGroup) => {\n const entries = getSortedTagEntries(tagGroup.tags ?? [], tagsMap, {\n getTagId,\n tagsSorter,\n operationsSorter,\n })\n return entries.length ? createTagEntry(tagGroup, getTagId, entries, true) : []\n })\n }\n\n // Ungrouped regular tags\n const keys = Array.from(tagsMap.keys())\n const tags = getSortedTagEntries(keys, tagsMap, { getTagId, tagsSorter, operationsSorter })\n\n // Flatten if we only have default tag\n if (tags.length === 1 && tags[0]?.title === 'default') {\n return tags[0]?.children ?? []\n }\n\n return tags\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { TagsMap, TraverseSpecOptions } from '../../navigation/types.js';
|
|
2
|
-
import type { TraversedWebhook } from '../../schemas/
|
|
3
|
-
import type { OpenApiDocument } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
2
|
+
import type { OpenApiDocument, TraversedWebhook } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
4
3
|
/** Traverses the webhooks in an OpenAPI document to build an array of webhook entries.
|
|
5
4
|
*
|
|
6
5
|
* This function processes each webhook in the document to:
|
|
@@ -12,13 +11,11 @@ import type { OpenApiDocument } from '../../schemas/v3.1/strict/openapi-document
|
|
|
12
11
|
* @param content - The OpenAPI document to traverse
|
|
13
12
|
* @param tagsMap - Map of tag names to arrays of traversed entries from operations
|
|
14
13
|
* @param tagsDict - Dictionary mapping tag names to their OpenAPI tag objects
|
|
15
|
-
* @param
|
|
14
|
+
* @param entitiesMap - Map to store webhook IDs and titles for mobile header navigation
|
|
16
15
|
* @param getWebhookId - Function to generate unique IDs for webhooks
|
|
17
16
|
* @returns Array of untagged webhook entries
|
|
18
17
|
*/
|
|
19
18
|
export declare const traverseWebhooks: (content: OpenApiDocument,
|
|
20
19
|
/** The tag map from from traversing paths */
|
|
21
|
-
tagsMap: TagsMap,
|
|
22
|
-
/** Map of titles for the mobile title */
|
|
23
|
-
titlesMap: Map<string, string>, getWebhookId: TraverseSpecOptions["getWebhookId"]) => TraversedWebhook[];
|
|
20
|
+
tagsMap: TagsMap, getWebhookId: TraverseSpecOptions["getWebhookId"]) => TraversedWebhook[];
|
|
24
21
|
//# sourceMappingURL=traverse-webhooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAa,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAuC1G;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,eAAe;AACxB,6CAA6C;AAC7C,SAAS,OAAO,EAChB,cAAc,mBAAmB,CAAC,cAAc,CAAC,KAChD,gBAAgB,EAyDlB,CAAA"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
|
|
2
2
|
import { objectKeys } from "@scalar/helpers/object/object-keys";
|
|
3
3
|
import { getResolvedRef } from "../../helpers/get-resolved-ref.js";
|
|
4
|
+
import { isDeprecatedOperation } from "../../navigation/helpers/traverse-paths.js";
|
|
4
5
|
import { getTag } from "./get-tag.js";
|
|
5
|
-
const createWebhookEntry = (ref, method, name = "Unknown", title = "Unknown",
|
|
6
|
+
const createWebhookEntry = (ref, method, name = "Unknown", title = "Unknown", getWebhookId, tag, isDeprecated) => {
|
|
6
7
|
const id = getWebhookId({ name, method }, tag);
|
|
7
|
-
|
|
8
|
-
return {
|
|
8
|
+
const entry = {
|
|
9
9
|
id,
|
|
10
10
|
title,
|
|
11
11
|
name,
|
|
12
12
|
ref,
|
|
13
13
|
method,
|
|
14
|
-
type: "webhook"
|
|
14
|
+
type: "webhook",
|
|
15
|
+
isDeprecated: isDeprecated ? isDeprecated : void 0
|
|
15
16
|
};
|
|
17
|
+
return entry;
|
|
16
18
|
};
|
|
17
|
-
const traverseWebhooks = (content, tagsMap,
|
|
19
|
+
const traverseWebhooks = (content, tagsMap, getWebhookId) => {
|
|
18
20
|
const untagged = [];
|
|
19
21
|
Object.entries(content.webhooks ?? {}).forEach(([name, pathItemObject]) => {
|
|
20
22
|
const pathKeys = objectKeys(pathItemObject ?? {}).filter((key) => isHttpMethod(key));
|
|
@@ -32,11 +34,29 @@ const traverseWebhooks = (content, tagsMap, titlesMap, getWebhookId) => {
|
|
|
32
34
|
operation.tags.forEach((tagName) => {
|
|
33
35
|
const { tag } = getTag(tagsMap, tagName);
|
|
34
36
|
tagsMap.get(tagName)?.entries.push(
|
|
35
|
-
createWebhookEntry(
|
|
37
|
+
createWebhookEntry(
|
|
38
|
+
ref,
|
|
39
|
+
method,
|
|
40
|
+
name,
|
|
41
|
+
operation.summary ?? name,
|
|
42
|
+
getWebhookId,
|
|
43
|
+
tag,
|
|
44
|
+
isDeprecatedOperation(operation)
|
|
45
|
+
)
|
|
36
46
|
);
|
|
37
47
|
});
|
|
38
48
|
} else {
|
|
39
|
-
untagged.push(
|
|
49
|
+
untagged.push(
|
|
50
|
+
createWebhookEntry(
|
|
51
|
+
ref,
|
|
52
|
+
method,
|
|
53
|
+
name,
|
|
54
|
+
operation.summary ?? name,
|
|
55
|
+
getWebhookId,
|
|
56
|
+
void 0,
|
|
57
|
+
isDeprecatedOperation(operation)
|
|
58
|
+
)
|
|
59
|
+
);
|
|
40
60
|
}
|
|
41
61
|
});
|
|
42
62
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/helpers/traverse-webhooks.ts"],
|
|
4
|
-
"sourcesContent": ["import { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\n\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\n\nimport { getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { isDeprecatedOperation } from '@/navigation/helpers/traverse-paths'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { OpenApiDocument, TagObject, TraversedWebhook } from '@/schemas/v3.1/strict/openapi-document'\n\nimport { getTag } from './get-tag'\n\n/** Creates a traversed webhook entry from an OpenAPI webhook object.\n *\n * @param ref - JSON pointer reference to the webhook in the OpenAPI document\n * @param method - HTTP method of the webhook\n * @param name - Name of the webhook, defaults to 'Unknown'\n * @param title - Title of the webhook, defaults to 'Unknown'\n * @param entitiesMap - Map to store webhook IDs and titles for mobile header navigation\n * @param getWebhookId - Function to generate unique IDs for webhooks\n * @param tag - Optional tag object associated with the webhook\n * @returns A traversed webhook entry with ID, title, name, method and reference\n */\nconst createWebhookEntry = (\n ref: string,\n method: HttpMethod,\n name = 'Unknown',\n title = 'Unknown',\n getWebhookId: TraverseSpecOptions['getWebhookId'],\n tag?: TagObject,\n isDeprecated?: boolean,\n): TraversedWebhook => {\n const id = getWebhookId({ name, method }, tag)\n\n const entry = {\n id,\n title,\n name,\n ref,\n method: method,\n type: 'webhook',\n isDeprecated: isDeprecated ? isDeprecated : undefined,\n } satisfies TraversedWebhook\n\n return entry\n}\n\n/** Traverses the webhooks in an OpenAPI document to build an array of webhook entries.\n *\n * This function processes each webhook in the document to:\n * - Filter out internal webhooks (marked with x-internal) and webhooks to ignore (marked with x-scalar-ignore)\n * - Group webhooks by their tags\n * - Create webhook entries with unique references and IDs\n * - Store webhook IDs and titles for mobile header navigation\n *\n * @param content - The OpenAPI document to traverse\n * @param tagsMap - Map of tag names to arrays of traversed entries from operations\n * @param tagsDict - Dictionary mapping tag names to their OpenAPI tag objects\n * @param entitiesMap - Map to store webhook IDs and titles for mobile header navigation\n * @param getWebhookId - Function to generate unique IDs for webhooks\n * @returns Array of untagged webhook entries\n */\nexport const traverseWebhooks = (\n content: OpenApiDocument,\n /** The tag map from from traversing paths */\n tagsMap: TagsMap,\n getWebhookId: TraverseSpecOptions['getWebhookId'],\n): TraversedWebhook[] => {\n const untagged: TraversedWebhook[] = []\n\n // Traverse webhooks\n Object.entries(content.webhooks ?? {}).forEach(([name, pathItemObject]) => {\n const pathKeys = objectKeys(pathItemObject ?? {}).filter((key) => isHttpMethod(key))\n\n pathKeys.forEach((method) => {\n const _operation = pathItemObject?.[method]\n const operation = getResolvedRef(_operation)\n if (!operation) {\n return\n }\n\n // Skip if the operation is internal or scalar-ignore\n if (operation['x-internal'] || operation['x-scalar-ignore']) {\n return\n }\n\n const ref = `#/webhooks/${name}/${method}`\n\n if (operation.tags?.length) {\n operation.tags.forEach((tagName: string) => {\n const { tag } = getTag(tagsMap, tagName)\n tagsMap\n .get(tagName)\n ?.entries.push(\n createWebhookEntry(\n ref,\n method,\n name,\n operation.summary ?? name,\n getWebhookId,\n tag,\n isDeprecatedOperation(operation),\n ),\n )\n })\n }\n // Add to untagged\n else {\n untagged.push(\n createWebhookEntry(\n ref,\n method,\n name,\n operation.summary ?? name,\n getWebhookId,\n undefined,\n isDeprecatedOperation(operation),\n ),\n )\n }\n })\n })\n\n return untagged\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAE3B,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAItC,SAAS,cAAc;AAavB,MAAM,qBAAqB,CACzB,KACA,QACA,OAAO,WACP,QAAQ,WACR,cACA,KACA,iBACqB;AACrB,QAAM,KAAK,aAAa,EAAE,MAAM,OAAO,GAAG,GAAG;AAE7C,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,cAAc,eAAe,eAAe;AAAA,EAC9C;AAEA,SAAO;AACT;AAiBO,MAAM,mBAAmB,CAC9B,SAEA,SACA,iBACuB;AACvB,QAAM,WAA+B,CAAC;AAGtC,SAAO,QAAQ,QAAQ,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,cAAc,MAAM;AACzE,UAAM,WAAW,WAAW,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,aAAa,GAAG,CAAC;AAEnF,aAAS,QAAQ,CAAC,WAAW;AAC3B,YAAM,aAAa,iBAAiB,MAAM;AAC1C,YAAM,YAAY,eAAe,UAAU;AAC3C,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AAGA,UAAI,UAAU,YAAY,KAAK,UAAU,iBAAiB,GAAG;AAC3D;AAAA,MACF;AAEA,YAAM,MAAM,cAAc,IAAI,IAAI,MAAM;AAExC,UAAI,UAAU,MAAM,QAAQ;AAC1B,kBAAU,KAAK,QAAQ,CAAC,YAAoB;AAC1C,gBAAM,EAAE,IAAI,IAAI,OAAO,SAAS,OAAO;AACvC,kBACG,IAAI,OAAO,GACV,QAAQ;AAAA,YACR;AAAA,cACE;AAAA,cACA;AAAA,cACA;AAAA,cACA,UAAU,WAAW;AAAA,cACrB;AAAA,cACA;AAAA,cACA,sBAAsB,SAAS;AAAA,YACjC;AAAA,UACF;AAAA,QACJ,CAAC;AAAA,MACH,OAEK;AACH,iBAAS;AAAA,UACP;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAU,WAAW;AAAA,YACrB;AAAA,YACA;AAAA,YACA,sBAAsB,SAAS;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { DEFAULT_INTRODUCTION_SLUG } from './helpers/traverse-description.js';
|
|
1
2
|
export { traverseDocument as createNavigation } from './helpers/traverse-document.js';
|
|
2
3
|
export type { TraverseSpecOptions as createNavigationOptions } from './types.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAClF,YAAY,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAClF,YAAY,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/navigation/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation/index.ts"],
|
|
4
|
-
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /navigation\nexport { traverseDocument as createNavigation } from './helpers/traverse-document'\nexport type { TraverseSpecOptions as createNavigationOptions } from './types'\n"],
|
|
5
|
-
"mappings": "AACA,SAA6B,wBAAwB;",
|
|
4
|
+
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /navigation\nexport { DEFAULT_INTRODUCTION_SLUG } from './helpers/traverse-description'\nexport { traverseDocument as createNavigation } from './helpers/traverse-document'\nexport type { TraverseSpecOptions as createNavigationOptions } from './types'\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,iCAAiC;AAC1C,SAA6B,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { TraversedEntry } from '../schemas/
|
|
2
|
-
import type { OperationObject, TagObject } from '../schemas/v3.1/strict/openapi-document.js';
|
|
1
|
+
import type { OperationObject, TagObject, TraversedEntry } from '../schemas/v3.1/strict/openapi-document.js';
|
|
3
2
|
/** Map of tagNames and their entries */
|
|
4
3
|
export type TagsMap = Map<string, {
|
|
5
4
|
tag: TagObject;
|
|
@@ -21,9 +20,9 @@ type OperationSortValue = {
|
|
|
21
20
|
*/
|
|
22
21
|
export type TraverseSpecOptions = {
|
|
23
22
|
/** Controls how tags are sorted - either alphabetically or using a custom sort function */
|
|
24
|
-
tagsSorter
|
|
23
|
+
tagsSorter?: 'alpha' | ((a: TagObject, b: TagObject) => number);
|
|
25
24
|
/** Controls how operations are sorted - alphabetically, by method, or using a custom sort function */
|
|
26
|
-
operationsSorter
|
|
25
|
+
operationsSorter?: 'alpha' | 'method' | ((a: OperationSortValue, b: OperationSortValue) => number);
|
|
27
26
|
/** Whether to hide model schemas from the navigation */
|
|
28
27
|
hideModels: boolean;
|
|
29
28
|
/** Function to generate unique IDs for markdown headings */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/navigation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AACxG,wCAAwC;AACxC,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CAAA;AAEhF,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,2FAA2F;IAC3F,UAAU,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,KAAK,MAAM,CAAC,CAAA;IAE/D,sGAAsG;IACtG,gBAAgB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,KAAK,MAAM,CAAC,CAAA;IAElG,wDAAwD;IACxD,UAAU,EAAE,OAAO,CAAA;IAEnB,4DAA4D;IAC5D,YAAY,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAA;IAElF,qDAAqD;IACrD,cAAc,EAAE,CACd,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,GAAG,eAAe,EACnB,SAAS,EAAE,SAAS,KACjB,MAAM,CAAA;IAEX,mDAAmD;IACnD,YAAY,EAAE,CACZ,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,EACD,SAAS,CAAC,EAAE,SAAS,KAClB,MAAM,CAAA;IAEX,yDAAyD;IACzD,UAAU,EAAE,CACV,KAAK,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,EACD,SAAS,CAAC,EAAE,SAAS,KAClB,MAAM,CAAA;IAEX,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|