@mintlify/validation 0.1.496 → 0.1.498

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/dist/index.d.ts CHANGED
@@ -27,3 +27,6 @@ export * from './mint-config/schemas/v2/properties/index.js';
27
27
  export * from './types/index.js';
28
28
  export type { ThemeType } from './mint-config/schemas/v2/index.js';
29
29
  export * from './chat-config/index.js';
30
+ export * from './openapi/v2/types/index.js';
31
+ export * from './openapi/v2/openApiToSchemaGraph.js';
32
+ export * from './openapi/v2/isOpenAPIV3orV31Document.js';
package/dist/index.js CHANGED
@@ -5,9 +5,11 @@ import { colorsSchema } from './mint-config/schemas/v2/properties/colors.js';
5
5
  import { baseLanguageSchema, languageSchema, languagesSchema, pageSchema, } from './mint-config/schemas/v2/properties/index.js';
6
6
  import { anchorsSchema, anchorSchema, baseAnchorSchema, } from './mint-config/schemas/v2/properties/navigation/anchors.js';
7
7
  import { baseDropdownSchema, dropdownSchema, dropdownsSchema, } from './mint-config/schemas/v2/properties/navigation/dropdown.js';
8
- import { baseGroupSchema, groupSchema, groupsSchema, } from './mint-config/schemas/v2/properties/navigation/groups.js';
8
+ import { baseGroupSchema, groupsSchema, } from './mint-config/schemas/v2/properties/navigation/groups.js';
9
9
  import { navigationSchema } from './mint-config/schemas/v2/properties/navigation/index.js';
10
+ import { baseMenuItemSchema, menuItemSchema, menuSchema, } from './mint-config/schemas/v2/properties/navigation/menu.js';
10
11
  import { pagesSchema, pageOrGroupSchema, } from './mint-config/schemas/v2/properties/navigation/pages.js';
12
+ import { baseProductSchema, productSchema, productsSchema, } from './mint-config/schemas/v2/properties/navigation/products.js';
11
13
  import { baseTabSchema, tabSchema, tabsSchema, } from './mint-config/schemas/v2/properties/navigation/tabs.js';
12
14
  import { baseVersionSchema, versionSchema, versionsSchema, } from './mint-config/schemas/v2/properties/navigation/version.js';
13
15
  import { hiddenSchema } from './mint-config/schemas/v2/properties/reusable/hidden.js';
@@ -30,6 +32,8 @@ export const docsConfigJsonSchema = zodToJsonSchema(docsConfigSchema, {
30
32
  anchorsSchema,
31
33
  baseAnchorSchema,
32
34
  baseDropdownSchema,
35
+ baseMenuItemSchema,
36
+ baseProductSchema,
33
37
  baseGroupSchema,
34
38
  baseLanguageSchema,
35
39
  baseTabSchema,
@@ -37,7 +41,10 @@ export const docsConfigJsonSchema = zodToJsonSchema(docsConfigSchema, {
37
41
  colorsSchema,
38
42
  dropdownSchema,
39
43
  dropdownsSchema,
40
- groupSchema,
44
+ menuItemSchema,
45
+ menuSchema,
46
+ productSchema,
47
+ productsSchema,
41
48
  groupsSchema,
42
49
  hiddenSchema,
43
50
  iconSchema,
@@ -57,3 +64,6 @@ export const docsConfigJsonSchema = zodToJsonSchema(docsConfigSchema, {
57
64
  export * from './mint-config/schemas/v2/properties/index.js';
58
65
  export * from './types/index.js';
59
66
  export * from './chat-config/index.js';
67
+ export * from './openapi/v2/types/index.js';
68
+ export * from './openapi/v2/openApiToSchemaGraph.js';
69
+ export * from './openapi/v2/isOpenAPIV3orV31Document.js';
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { nonRecursiveAnchorSchema } from './anchors.js';
3
3
  import { nonRecursiveDropdownSchema } from './dropdown.js';
4
4
  import { nonRecursiveLanguageSchema } from './languages.js';
5
+ import { nonRecursiveProductSchema } from './products.js';
5
6
  import { nonRecursiveTabSchema } from './tabs.js';
6
7
  import { nonRecursiveVersionSchema } from './version.js';
7
8
  export const globalSchema = z
@@ -12,6 +13,7 @@ export const globalSchema = z
12
13
  tabs: z.array(nonRecursiveTabSchema).optional(),
13
14
  dropdowns: z.array(nonRecursiveDropdownSchema).optional(),
14
15
  anchors: z.array(nonRecursiveAnchorSchema).optional(),
16
+ products: z.array(nonRecursiveProductSchema).optional(),
15
17
  })
16
18
  .strict())
17
19
  .describe('Add external links that will appear on all sections and pages irregardless of navigation nesting');
@@ -376,11 +376,11 @@ export declare const navigationSchema: z.ZodUnion<[z.ZodObject<{
376
376
  global?: import("./divisionNav.js").GlobalNavigation | undefined;
377
377
  }>]>;
378
378
  export declare const decoratedNavigationSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
379
- products: z.ZodArray<z.ZodType<import("./divisionNav.js").ProductNavigation<"default">, z.ZodTypeDef, import("./divisionNav.js").ProductNavigation<"default">>, "many">;
379
+ products: z.ZodArray<z.ZodType<import("./divisionNav.js").ProductNavigation<"decorated">, z.ZodTypeDef, import("./divisionNav.js").ProductNavigation<"decorated">>, "many">;
380
380
  }, "strip", z.ZodTypeAny, {
381
- products: import("./divisionNav.js").ProductNavigation<"default">[];
381
+ products: import("./divisionNav.js").ProductNavigation<"decorated">[];
382
382
  }, {
383
- products: import("./divisionNav.js").ProductNavigation<"default">[];
383
+ products: import("./divisionNav.js").ProductNavigation<"decorated">[];
384
384
  }>, z.ZodObject<{
385
385
  languages: z.ZodArray<z.ZodType<import("./divisionNav.js").LanguageNavigation<"decorated">, z.ZodTypeDef, import("./divisionNav.js").LanguageNavigation<"decorated">>, "many">;
386
386
  }, "strip", z.ZodTypeAny, {
@@ -5,7 +5,7 @@ import { globalSchema } from './global.js';
5
5
  import { decoratedGroupsSchema, groupsSchema, } from './groups.js';
6
6
  import { decoratedLanguagesSchema, languagesSchema, } from './languages.js';
7
7
  import { decoratedPagesSchema, pagesSchema } from './pages.js';
8
- import { productsSchema } from './products.js';
8
+ import { decoratedProductsSchema, productsSchema, } from './products.js';
9
9
  import { decoratedTabsSchema, tabsSchema } from './tabs.js';
10
10
  import { decoratedVersionsSchema, versionsSchema, } from './version.js';
11
11
  const baseNavigationSchema = z.object({ global: globalSchema.optional() });
@@ -23,7 +23,7 @@ export const navigationSchema = z
23
23
  .describe('The navigation structure of the content');
24
24
  export const decoratedNavigationSchema = z
25
25
  .union([
26
- z.object({ products: productsSchema }),
26
+ z.object({ products: decoratedProductsSchema }),
27
27
  z.object({ languages: decoratedLanguagesSchema }),
28
28
  z.object({ versions: decoratedVersionsSchema }),
29
29
  z.object({ tabs: decoratedTabsSchema }),
@@ -62,6 +62,66 @@ export declare const decoratedProductSchema: z.ZodType<ProductNavigation<'decora
62
62
  export declare const productsSchema: z.ZodArray<z.ZodType<ProductNavigation<"default">, z.ZodTypeDef, ProductNavigation<"default">>, "many">;
63
63
  export declare const decoratedProductsSchema: z.ZodArray<z.ZodType<ProductNavigation<"decorated">, z.ZodTypeDef, ProductNavigation<"decorated">>, "many">;
64
64
  export type BaseProductSchema = z.infer<typeof baseProductSchema>;
65
+ export declare const nonRecursiveProductSchema: z.ZodObject<{
66
+ name: z.ZodOptional<z.ZodString>;
67
+ icon: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodObject<{
68
+ style: z.ZodOptional<z.ZodEnum<["brands", "duotone", "light", "regular", "sharp-duotone-solid", "sharp-light", "sharp-regular", "sharp-solid", "sharp-thin", "solid", "thin"]>>;
69
+ name: z.ZodEffects<z.ZodString, string, string>;
70
+ library: z.ZodOptional<z.ZodEnum<["fontawesome", "lucide"]>>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ name: string;
73
+ style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
74
+ library?: "fontawesome" | "lucide" | undefined;
75
+ }, {
76
+ name: string;
77
+ style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
78
+ library?: "fontawesome" | "lucide" | undefined;
79
+ }>]>>;
80
+ color: z.ZodOptional<z.ZodObject<{
81
+ light: z.ZodOptional<z.ZodString>;
82
+ dark: z.ZodOptional<z.ZodString>;
83
+ }, "strict", z.ZodTypeAny, {
84
+ light?: string | undefined;
85
+ dark?: string | undefined;
86
+ }, {
87
+ light?: string | undefined;
88
+ dark?: string | undefined;
89
+ }>>;
90
+ description: z.ZodOptional<z.ZodString>;
91
+ hidden: z.ZodOptional<z.ZodBoolean>;
92
+ product: z.ZodString;
93
+ href: z.ZodString;
94
+ }, "strip", z.ZodTypeAny, {
95
+ href: string;
96
+ product: string;
97
+ name?: string | undefined;
98
+ icon?: string | {
99
+ name: string;
100
+ style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
101
+ library?: "fontawesome" | "lucide" | undefined;
102
+ } | undefined;
103
+ color?: {
104
+ light?: string | undefined;
105
+ dark?: string | undefined;
106
+ } | undefined;
107
+ description?: string | undefined;
108
+ hidden?: boolean | undefined;
109
+ }, {
110
+ href: string;
111
+ product: string;
112
+ name?: string | undefined;
113
+ icon?: string | {
114
+ name: string;
115
+ style?: "brands" | "duotone" | "light" | "regular" | "sharp-duotone-solid" | "sharp-light" | "sharp-regular" | "sharp-solid" | "sharp-thin" | "solid" | "thin" | undefined;
116
+ library?: "fontawesome" | "lucide" | undefined;
117
+ } | undefined;
118
+ color?: {
119
+ light?: string | undefined;
120
+ dark?: string | undefined;
121
+ } | undefined;
122
+ description?: string | undefined;
123
+ hidden?: boolean | undefined;
124
+ }>;
65
125
  export type ProductConfig = z.infer<typeof productSchema>;
66
126
  export type ProductsConfig = z.infer<typeof productsSchema>;
67
127
  export type DecoratedProductConfig = z.infer<typeof decoratedProductSchema>;
@@ -91,3 +91,4 @@ export const decoratedProductsSchema = z
91
91
  .array(decoratedProductSchema)
92
92
  .min(1, 'At least one product must be specified')
93
93
  .describe('Organizing by products');
94
+ export const nonRecursiveProductSchema = baseProductSchema.extend({ href: hrefSchema });
@@ -0,0 +1,2 @@
1
+ import { OpenAPIV3, OpenAPIV3_1, OpenAPI } from 'openapi-types';
2
+ export declare const isOpenAPIV3orV31Document: (spec: OpenAPI.Document) => spec is OpenAPIV3.Document | OpenAPIV3_1.Document;
@@ -0,0 +1,3 @@
1
+ export const isOpenAPIV3orV31Document = (spec) => {
2
+ return 'openapi' in spec;
3
+ };
@@ -1,8 +1,10 @@
1
+ import { HttpMethod } from '../types/endpoint.js';
1
2
  import { OperationObject, RefUuidMap, UUIDObjectHashMap, HashedNodeMap, UUID } from './types/index.js';
2
- export declare const mapOperation: ({ operation, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, }: {
3
+ export declare const mapOperation: ({ operation, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, method, }: {
3
4
  operation: OperationObject;
4
5
  refUuidMap: RefUuidMap;
5
6
  uuidObjectHashMap: UUIDObjectHashMap;
6
7
  hashedNodeMap: HashedNodeMap;
7
8
  uuid: UUID;
9
+ method: HttpMethod;
8
10
  }) => void;
@@ -4,7 +4,7 @@ import { mapParameter } from './mapParameter.js';
4
4
  import { mapRequestBody } from './mapRequestBody.js';
5
5
  import { mapResponse } from './mapResponse.js';
6
6
  import { mapSecurityRequirement } from './mapSecurityRequirement.js';
7
- export const mapOperation = ({ operation, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, }) => {
7
+ export const mapOperation = ({ operation, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, method, }) => {
8
8
  var _a;
9
9
  const objectHash = hash(operation);
10
10
  uuidObjectHashMap[uuid] = objectHash;
@@ -68,6 +68,7 @@ export const mapOperation = ({ operation, refUuidMap, uuidObjectHashMap, hashedN
68
68
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
69
  operation.servers = serverUuids;
70
70
  }
71
+ operation.method = method;
71
72
  // add to hashedNodeMap
72
73
  hashedNodeMap[objectHash] = operation;
73
74
  };
@@ -1,8 +1,10 @@
1
1
  import { RefUuidMap, UUIDObjectHashMap, HashedNodeMap, UUID, PathObjectOrRef } from './types/index.js';
2
- export declare const mapPath: ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, }: {
2
+ export declare const mapPath: ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, path, isWebhook, }: {
3
3
  pathItem: PathObjectOrRef;
4
4
  refUuidMap: RefUuidMap;
5
5
  uuidObjectHashMap: UUIDObjectHashMap;
6
6
  hashedNodeMap: HashedNodeMap;
7
7
  uuid: UUID;
8
+ path: string;
9
+ isWebhook?: boolean;
8
10
  }) => void;
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
3
3
  import { httpMethods } from '../types/endpoint.js';
4
4
  import { mapOperation } from './mapOperation.js';
5
5
  import { mapParameter } from './mapParameter.js';
6
- export const mapPath = ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, }) => {
6
+ export const mapPath = ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, path, isWebhook, }) => {
7
7
  var _a;
8
8
  const objectHash = hash(pathItem);
9
9
  uuidObjectHashMap[uuid] = objectHash;
@@ -16,9 +16,15 @@ export const mapPath = ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap
16
16
  if ('parameters' in pathItem) {
17
17
  const parameterUuids = [];
18
18
  (_a = pathItem.parameters) === null || _a === void 0 ? void 0 : _a.forEach((parameter) => {
19
- const uuid = uuidv4();
20
- mapParameter({ parameter, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid });
21
- parameterUuids.push(uuid);
19
+ const parameterUuid = uuidv4();
20
+ mapParameter({
21
+ parameter,
22
+ refUuidMap,
23
+ uuidObjectHashMap,
24
+ hashedNodeMap,
25
+ uuid: parameterUuid,
26
+ });
27
+ parameterUuids.push(parameterUuid);
22
28
  });
23
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
30
  pathItem.parameters = parameterUuids;
@@ -31,12 +37,21 @@ export const mapPath = ({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap
31
37
  const operation = pathItem[method];
32
38
  if (!operation)
33
39
  return;
34
- const uuid = uuidv4();
35
- mapOperation({ operation, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid });
40
+ const operationUuid = uuidv4();
41
+ mapOperation({
42
+ operation,
43
+ refUuidMap,
44
+ uuidObjectHashMap,
45
+ hashedNodeMap,
46
+ uuid: operationUuid,
47
+ method,
48
+ });
36
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- pathItem[method] = uuid;
50
+ pathItem[method] = operationUuid;
51
+ refUuidMap[`${path}/${isWebhook ? 'webhook' : method}`] = uuid;
38
52
  });
39
53
  }
54
+ pathItem.path = path;
40
55
  // store path object
41
56
  hashedNodeMap[objectHash] = pathItem;
42
57
  };
@@ -9,6 +9,6 @@ export const mapPathComponents = ({ spec, refUuidMap, uuidObjectHashMap, hashedN
9
9
  Object.entries(pathComponents).forEach(([name, pathItem]) => {
10
10
  const refId = `#/components/pathItems/${name}`;
11
11
  const uuid = refUuidMap[refId] || uuidv4();
12
- mapPath({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid });
12
+ mapPath({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, path: name });
13
13
  });
14
14
  };
@@ -11,10 +11,10 @@ export const mapPaths = ({ spec, refUuidMap, uuidObjectHashMap, hashedNodeMap, d
11
11
  Object.entries(paths).forEach(([path, pathItem]) => {
12
12
  if (!pathItem)
13
13
  return;
14
- // map to refUuidMap, uuidObjectHashMap, hashedNodeMap
15
14
  const uuid = uuidv4();
16
- refUuidMap[path] = uuid;
17
- mapPath({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid });
15
+ // map to uuidObjectHashMap, hashedNodeMap
16
+ // map path + operation in refUuidMap in mapPath
17
+ mapPath({ pathItem, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid, path });
18
18
  // add path to document
19
19
  document.paths.push(uuid);
20
20
  });
@@ -14,8 +14,18 @@ export const mapWebhooks = ({ spec, refUuidMap, uuidObjectHashMap, hashedNodeMap
14
14
  if (!webhook)
15
15
  return;
16
16
  const uuid = uuidv4();
17
- refUuidMap[webhookPath] = uuid;
18
- mapPath({ pathItem: webhook, refUuidMap, uuidObjectHashMap, hashedNodeMap, uuid });
17
+ // map to uuidObjectHashMap, hashedNodeMap
18
+ // map path + operation in refUuidMap in mapPath
19
+ mapPath({
20
+ pathItem: webhook,
21
+ refUuidMap,
22
+ uuidObjectHashMap,
23
+ hashedNodeMap,
24
+ uuid,
25
+ path: webhookPath,
26
+ isWebhook: true,
27
+ });
28
+ // add webhook to document
19
29
  document.webhooks.push(uuid);
20
30
  });
21
31
  };
@@ -1,14 +1,7 @@
1
1
  import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
2
- import { UUIDObjectHashMap, HashedNodeMap } from './types/index.js';
2
+ import { SchemaGraphData } from './types/index.js';
3
3
  export declare const openApiToSchemaGraph: ({ spec, filename, originalFileLocation, }: {
4
4
  spec: OpenAPIV3.Document | OpenAPIV3_1.Document;
5
5
  filename: string;
6
6
  originalFileLocation?: string;
7
- }) => {
8
- spec: {
9
- uuidObjectHashMap: UUIDObjectHashMap;
10
- hashedNodeMap: HashedNodeMap;
11
- };
12
- filename: string;
13
- originalFileLocation?: string;
14
- };
7
+ }) => SchemaGraphData;
@@ -60,6 +60,7 @@ export const openApiToSchemaGraph = ({ spec, filename, originalFileLocation, })
60
60
  filename,
61
61
  originalFileLocation,
62
62
  spec: {
63
+ refUuidMap,
63
64
  uuidObjectHashMap,
64
65
  hashedNodeMap,
65
66
  },
@@ -1,11 +1,11 @@
1
1
  import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
2
- import { XMcp, XMint } from '../../types/endpoint.js';
2
+ import { XMcp, XMint, HttpMethod } from '../../types/endpoint.js';
3
3
  export type UUID = string;
4
4
  export type HashId = string;
5
5
  export type RefUuidMap = Record<string, UUID>;
6
6
  export type UUIDObjectHashMap = Record<UUID, HashId>;
7
7
  export type HashedNodeMap = Record<HashId, GraphNode>;
8
- export type GraphNode = SchemaOrRef | ResponseOrRef | HeaderOrRef | ParameterOrRef | Media | ExampleOrRef | RequestBodyOrRef | SecuritySchemeOrRef | Server | PathOrRef | Operation | SecurityRequirement | Document;
8
+ export type GraphNode = SchemaOrRef | ResponseOrRef | HeaderOrRef | ParameterOrRef | Media | ExampleOrRef | RequestBodyOrRef | SecuritySchemeOrRef | ServerObject | PathOrRef | Operation | SecurityRequirement | Document;
9
9
  export type SchemaObject = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject;
10
10
  export type RefObject = OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject;
11
11
  export type SchemaOrRefObject = SchemaObject | RefObject;
@@ -131,16 +131,17 @@ export type SecuritySchemeOrRef = (SecuritySchemeObject & {
131
131
  $ref: UUID;
132
132
  });
133
133
  export type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
134
- export type Server = ServerObject;
135
134
  export type PathObject = OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject;
136
135
  export type PathObjectOrRef = PathObject | RefObject;
137
136
  export type PathOrRef = (PathObject & {
137
+ path: string;
138
138
  parameters?: UUID[];
139
139
  } & {
140
140
  [method in OpenAPIV3.HttpMethods]: UUID;
141
141
  } & {
142
142
  $ref?: never;
143
143
  }) | (RefObject & {
144
+ path: string;
144
145
  $ref: UUID;
145
146
  } & {
146
147
  parameters?: never;
@@ -157,6 +158,7 @@ export type OperationExtensions = {
157
158
  'x-code-samples'?: string[];
158
159
  };
159
160
  export type Operation = OperationObject & {
161
+ method: HttpMethod;
160
162
  parameters?: UUID[];
161
163
  requestBody?: UUID;
162
164
  responses?: {
@@ -182,3 +184,12 @@ export type Document = Omit<DocumentObject, 'servers' | 'paths' | 'webhooks' | '
182
184
  webhooks: UUID[];
183
185
  security: UUID[];
184
186
  };
187
+ export type SchemaGraphData = {
188
+ filename: string;
189
+ originalFileLocation?: string;
190
+ spec: {
191
+ uuidObjectHashMap: UUIDObjectHashMap;
192
+ hashedNodeMap: HashedNodeMap;
193
+ refUuidMap: RefUuidMap;
194
+ };
195
+ };