@alauda/doom 1.16.2 → 1.16.4

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.
@@ -21,6 +21,7 @@ export interface OpenAPIRefProps {
21
21
  */
22
22
  collectRefs?: boolean;
23
23
  }
24
+ export declare const get$Ref: (obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject) => string | undefined;
24
25
  export declare const OpenAPIProperty: ({ name, property, openapi, }: {
25
26
  name?: string;
26
27
  property: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject;
@@ -8,38 +8,62 @@ import { HeadingTitle } from './_HeadingTitle.js';
8
8
  import { RefLink } from './_RefLink.js';
9
9
  import { X } from './_X.js';
10
10
  import { UidProvider, useUid } from './_context.js';
11
+ export const get$Ref = (obj) => {
12
+ if ('$ref' in obj && obj.$ref) {
13
+ return obj.$ref;
14
+ }
15
+ if ('allOf' in obj && Array.isArray(obj.allOf)) {
16
+ for (const item of obj.allOf) {
17
+ if ('$ref' in item && item.$ref) {
18
+ return item.$ref;
19
+ }
20
+ }
21
+ }
22
+ };
11
23
  export const OpenAPIProperty = ({ name, property, openapi, }) => {
12
- const propObj = '$ref' in property ? resolveRef(openapi, property.$ref) : property;
24
+ const prop$Ref = get$Ref(property);
25
+ const propObj = prop$Ref
26
+ ? resolveRef(openapi, prop$Ref)
27
+ : property;
13
28
  const type = propObj.type;
14
29
  let typeNode;
15
30
  let extraNode;
16
31
  if (type === 'array') {
17
32
  const { items } = propObj;
18
- const itemsObj = '$ref' in items ? resolveRef(openapi, items.$ref) : items;
33
+ const items$Ref = get$Ref(items);
34
+ const itemsObj = items$Ref
35
+ ? resolveRef(openapi, items$Ref)
36
+ : items;
19
37
  const itemsType = itemsObj.type;
20
- typeNode = (_jsxs("code", { children: ["[]", '$ref' in items ? _jsx(RefLink, { "$ref": items.$ref }) : itemsType] }));
38
+ typeNode = (_jsxs("code", { children: ["[]", items$Ref ? _jsx(RefLink, { "$ref": items$Ref }) : itemsType] }));
21
39
  }
22
40
  else if (type === 'object') {
23
- if ('properties' in property && property.properties) {
24
- extraNode = (_jsxs("div", { className: "my-4", children: [_jsx("em", { children: "Properties:" }), _jsx(OpenAPIProperties, { properties: property.properties, openapi: openapi })] }));
41
+ if (prop$Ref) {
42
+ typeNode = _jsx(RefLink, { "$ref": prop$Ref });
25
43
  }
26
44
  if (typeof propObj.additionalProperties === 'object') {
27
45
  const props = propObj.additionalProperties;
28
- const propsObj = '$ref' in props ? resolveRef(openapi, props.$ref) : props;
46
+ const props$Ref = get$Ref(props);
47
+ const propsObj = props$Ref
48
+ ? resolveRef(openapi, props$Ref)
49
+ : props;
29
50
  const propsType = propsObj.type;
30
- typeNode = (_jsxs("code", { children: ["map[string]", typeof propsType === 'string'
31
- ? propsType
32
- : '$ref' in props && _jsx(RefLink, { "$ref": props.$ref })] }));
51
+ typeNode = (_jsxs(_Fragment, { children: [typeNode, _jsxs("code", { children: ["map[string]", typeof propsType === 'string'
52
+ ? propsType
53
+ : props$Ref && _jsx(RefLink, { "$ref": props$Ref })] })] }));
54
+ if ('properties' in property && property.properties) {
55
+ extraNode = (_jsxs("div", { className: "my-4", children: [_jsx("em", { children: "Properties:" }), _jsx(OpenAPIProperties, { properties: property.properties, openapi: openapi })] }));
56
+ }
33
57
  }
34
- else {
58
+ else if (!prop$Ref) {
35
59
  typeNode = _jsx("code", { children: type });
36
60
  }
37
61
  }
38
62
  else if (typeof type === 'string') {
39
63
  typeNode = _jsx("code", { children: type });
40
64
  }
41
- else if ('$ref' in property) {
42
- typeNode = _jsx(RefLink, { "$ref": property.$ref });
65
+ else if (prop$Ref) {
66
+ typeNode = _jsx(RefLink, { "$ref": prop$Ref });
43
67
  }
44
68
  return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description }), extraNode] }));
45
69
  };
@@ -12,10 +12,10 @@ export const resolveRef = (openapi, ref) => {
12
12
  return get(openapi, ref.slice(2).split('/'));
13
13
  };
14
14
  const DEFAULT_COMMON_REFS = {
15
- 'v1alpha1.ListMeta': 'common-definitions/list-meta/#ListMeta',
16
- 'v1.ObjectMeta': 'common-definitions/object-meta/#ObjectMeta',
15
+ 'v1alpha1.ListMeta': 'list-meta/',
16
+ 'v1.ObjectMeta': 'object-meta/',
17
17
  };
18
- const K8S_DOC_PREFIX = 'https://kubernetes.io/docs/reference/kubernetes-api/';
18
+ const K8S_DOC_PREFIX = 'https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/';
19
19
  export const COMMON_REFS = {
20
20
  ...Object.fromEntries(Object.entries(DEFAULT_COMMON_REFS).map(([key, value]) => [
21
21
  key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -56,6 +56,7 @@
56
56
  "@rspress/shared": "2.0.0-beta.34",
57
57
  "@shikijs/transformers": "^3.14.0",
58
58
  "@total-typescript/ts-reset": "^0.6.1",
59
+ "@types/react": "^19.2.2",
59
60
  "ab64": "^0.1.6",
60
61
  "chokidar": "^4.0.3",
61
62
  "clsx": "^2.1.1",