@redocly/redoc-revel 0.129.0-next.0 → 0.129.0-next.2
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 +45 -0
- package/dist/client/app/Sidebar/useBreadcrumbs.js +1 -1
- package/dist/client/app/hooks/codeHighlight/json-seq.d.ts +43 -0
- package/dist/client/app/hooks/codeHighlight/json-seq.js +1 -0
- package/dist/client/app/hooks/codeHighlight/map-lang.js +1 -1
- package/dist/client/app/hooks/codeHighlight/multipart-mixed.d.ts +40 -0
- package/dist/client/app/hooks/codeHighlight/multipart-mixed.js +1 -0
- package/dist/client/app/hooks/codeHighlight/useCodeHighlight.js +1 -1
- package/dist/client/app/hooks/useBanner.d.ts +4 -0
- package/dist/client/app/hooks/useBanner.js +1 -1
- package/dist/client/app/utils/loadAndNavigate.js +1 -1
- package/dist/client/types/post-message.d.ts +2 -1
- package/dist/server/persistence/kv/helpers/decode-cursor.d.ts +2 -0
- package/dist/server/persistence/kv/helpers/decode-cursor.js +1 -0
- package/dist/server/persistence/kv/helpers/encode-cursor.d.ts +2 -0
- package/dist/server/persistence/kv/helpers/encode-cursor.js +1 -0
- package/dist/server/persistence/kv/mappers/create-kv-list-entry.d.ts +5 -0
- package/dist/server/persistence/kv/mappers/create-kv-list-entry.js +1 -0
- package/dist/server/persistence/kv/mappers/create-kv-value.d.ts +4 -0
- package/dist/server/persistence/kv/mappers/create-kv-value.js +1 -0
- package/dist/server/persistence/kv/repositories/kv-remote-repository.d.ts +5 -5
- package/dist/server/persistence/kv/repositories/kv-remote-repository.js +1 -1
- package/dist/server/persistence/kv/schemas/kv-schemas.d.ts +10 -0
- package/dist/server/persistence/kv/schemas/kv-schemas.js +1 -0
- package/dist/server/persistence/kv/services/kv-service.d.ts +6 -6
- package/dist/server/persistence/kv/services/kv-service.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/dereference-json-schema-refs.d.ts +14 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/dereference-json-schema-refs.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/generate-sample-from-schema.d.ts +62 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/generate-sample-from-schema.js +2 -0
- package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-schema-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-sample-from-json-schema.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-sample-from-json-schema.js +1 -0
- package/dist/server/plugins/markdown/markdoc/attributes/index.d.ts +2 -0
- package/dist/server/plugins/markdown/markdoc/attributes/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/attributes/json-example-ref.d.ts +6 -0
- package/dist/server/plugins/markdown/markdoc/attributes/json-example-ref.js +1 -0
- package/dist/server/plugins/markdown/markdoc/attributes/sample-from-json-schema.d.ts +6 -0
- package/dist/server/plugins/markdown/markdoc/attributes/sample-from-json-schema.js +1 -0
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/index.d.ts +1 -0
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/json-example.d.ts +8 -0
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/json-example.js +7 -0
- package/dist/server/plugins/markdown/markdoc/tags/index.d.ts +4 -0
- package/dist/server/plugins/markdown/markdoc/tags/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/tags/json-example.d.ts +3 -0
- package/dist/server/plugins/markdown/markdoc/tags/json-example.js +1 -0
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +11 -0
- package/dist/server/plugins/scorecard-classic/loaders/scorecard.js +1 -1
- package/dist/server/plugins/search/documents/search-documents.js +1 -1
- package/dist/server/providers/database/copy-migrations.js +1 -1
- package/dist/server/providers/database/databases/main-sqlite/schemas/scorecards-config-table.d.ts +65 -14
- package/dist/server/providers/database/databases/main-sqlite/schemas/scorecards-config-table.js +1 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/{scorecard-result-states-table.d.ts → scorecards-evaluation-runs-table.d.ts} +61 -65
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-evaluation-runs-table.js +1 -0
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/{scorecard-result-levels-table.d.ts → scorecards-level-results-table.d.ts} +28 -60
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-level-results-table.js +1 -0
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-levels-rules-results-table.d.ts +67 -0
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-levels-rules-results-table.js +1 -0
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/{scorecard-results-table.d.ts → scorecards-results-table.d.ts} +80 -46
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-results-table.js +1 -0
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/{scorecard-evaluations-table.d.ts → scorecards-rule-results-table.d.ts} +29 -31
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecards-rule-results-table.js +1 -0
- package/dist/server/providers/database/pagination/utils/decode-cursor.js +1 -1
- package/dist/server/ssr/index.js +1 -1
- package/dist/server/ssr/render.js +1 -1
- package/dist/server/ssr/template.d.ts +1 -1
- package/dist/server/ssr/template.js +13 -13
- package/dist/server/ssr/utils.js +27 -13
- package/dist/server/utils/envs/get-api-route-allowed-env-variables.js +1 -1
- package/dist/server/utils/safe-parse.d.ts +6 -0
- package/dist/server/utils/safe-parse.js +1 -0
- package/dist/types/ssr.d.ts +3 -1
- package/package.json +10 -9
- package/dist/server/persistence/kv/mappers/create-kv-read-record.d.ts +0 -4
- package/dist/server/persistence/kv/mappers/create-kv-read-record.js +0 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-evaluations-table.js +0 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-result-level-states-table.d.ts +0 -48
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-result-level-states-table.js +0 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-result-levels-table.js +0 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-result-states-table.js +0 -1
- package/dist/server/providers/database/databases/sqld-sqlite/schemas/scorecard-results-table.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @redocly/redoc-revel
|
|
2
2
|
|
|
3
|
+
## 0.129.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8fdaab071f: Added `useColorSwitcher` React hook to receive color mode updates in components.
|
|
8
|
+
- dd42fb73d2: Added support for the `json-example` Markdoc tag to embed JSON snippets in documentation.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 8d09c7d474: Updated `@redocly/openapi-core` to version `2.13.0`.
|
|
13
|
+
- 49ddba9c14: Fixed dismissed banner briefly appearing after page refresh.
|
|
14
|
+
- b28161bbc8: Added product-specific CSS class to the root element for targeted styling by product name.
|
|
15
|
+
- 49ddba9c14: Fixed Y-axis scroll position when deep linking to pages with banners.
|
|
16
|
+
- Updated dependencies [8d09c7d474]
|
|
17
|
+
- Updated dependencies [49ddba9c14]
|
|
18
|
+
- Updated dependencies [8fdaab071f]
|
|
19
|
+
- Updated dependencies [b28161bbc8]
|
|
20
|
+
- Updated dependencies [49ddba9c14]
|
|
21
|
+
- @redocly/openapi-docs@3.17.0-next.2
|
|
22
|
+
- @redocly/theme@0.61.0-next.2
|
|
23
|
+
- @redocly/asyncapi-docs@1.6.0-next.2
|
|
24
|
+
- @redocly/portal-plugin-mock-server@0.14.0-next.2
|
|
25
|
+
- @redocly/graphql-docs@1.6.0-next.0
|
|
26
|
+
|
|
27
|
+
## 0.129.0-next.1
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- eb3abbb06e: Added support for OpenAPI 3.2 Sequential and Streaming Data.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- edb34c5f33: Fixed an issue where breadcrumbs appeared on non-nested pages in projects with a path prefix.
|
|
36
|
+
- 743e6e5736: Fixed an issue where the product picker was not properly aligned in the navbar.
|
|
37
|
+
- Updated dependencies [edb34c5f33]
|
|
38
|
+
- Updated dependencies [eb3abbb06e]
|
|
39
|
+
- Updated dependencies [de9da5f2778]
|
|
40
|
+
- Updated dependencies [743e6e5736]
|
|
41
|
+
- @redocly/theme@0.61.0-next.1
|
|
42
|
+
- @redocly/portal-plugin-mock-server@0.14.0-next.1
|
|
43
|
+
- @redocly/openapi-docs@3.17.0-next.1
|
|
44
|
+
- @redocly/realm-asyncapi-sdk@0.7.0-next.1
|
|
45
|
+
- @redocly/asyncapi-docs@1.6.0-next.1
|
|
46
|
+
- @redocly/graphql-docs@1.6.0-next.0
|
|
47
|
+
|
|
3
48
|
## 0.129.0-next.0
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as k}from"react";import{useLocation as T}from"react-router-dom";import{useThemeConfig as y}from"@redocly/theme/core/hooks";import{usePageVersions as
|
|
1
|
+
import{useMemo as k}from"react";import{useLocation as T}from"react-router-dom";import{useThemeConfig as y}from"@redocly/theme/core/hooks";import{withoutPathPrefix as K}from"@redocly/theme/core/utils";import{usePageVersions as g,useTranslate as v,usePageSharedData as d}from"../hooks";import{useSidebarItems as x}from"./useSidebarItems";function D(){const a=d("sidebar")?.relatedNavbarItem,n=d("current-catalog-info"),r=y(),{translate:l}=v(),{versions:e=[]}=g()||{},c=e.find(m=>m?.active),{allSidebarItems:i}=x(c),t=T().pathname,o=n?.item,s=n?.catalog,b=r.breadcrumbs?.prefixItems,f=r.breadcrumbs?.hide;return k(()=>{const m=B({allSidebarItems:i,pathname:K(t),catalogItemInfo:o,relatedNavbarItem:a,catalogInfo:s,prefixItems:b,hide:f,translate:l}),p=S(i,m);return{breadcrumbs:m,currentItemSiblings:p}},[t,a,i,o,s,b,f,l])}const B=({allSidebarItems:a=[],pathname:n,catalogItemInfo:r,relatedNavbarItem:l,catalogInfo:e,prefixItems:c,hide:i,translate:u})=>{if(i===!0)return[];const t=h(a);if(t.length===0)return[];if(r){const o=t[t.length-1];o&&o.label!==r.label&&t.unshift({label:r.label,link:r.link})}if(l&&l.label!==t[0].label&&t.unshift(l),e&&t.unshift({label:u(e.labelTranslationKey,e.label),labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon}),c?.length){const o=c.map(s=>({label:u(s.labelTranslationKey,s.label),labelTranslationKey:s.labelTranslationKey,link:s.link,icon:s.icon}));t.unshift(...o)}return t.length===1&&(!t[0]?.link||t[0]?.link===n)?[]:t},S=(a,n)=>{if(n.length===0)return[];const r=(e,c)=>{for(const i of e){if(i.active)return{item:i,parent:c};if(i.items?.length){const u=r(i.items,i);if(u)return u}}},l=r(a);return l?.parent?l.parent.items?.filter(e=>!!(e.link&&e.link!==l.item.link&&e.label)).map(e=>({label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon}))||[]:[]},h=a=>{const n=a.find(({active:l,hasActiveSubItem:e})=>l||e);if(!n?.label)return[];const r={label:n.label,labelTranslationKey:n.labelTranslationKey,link:n.link,icon:n.icon};return n.type==="group"&&n.selectFirstItemOnExpand&&n.items?.[0]?.link&&(r.link=n.items[0].link),n.items?.length||(r.link=void 0),[r,...h(n.items||[])]};export{B as generateBreadcrumbs,S as generateSiblings,D as useBreadcrumbs};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const _default: (import("shiki").LanguageRegistration | {
|
|
2
|
+
displayName: string;
|
|
3
|
+
name: string;
|
|
4
|
+
scopeName: string;
|
|
5
|
+
patterns: {
|
|
6
|
+
include: string;
|
|
7
|
+
}[];
|
|
8
|
+
repository: {
|
|
9
|
+
'json-seq-record': {
|
|
10
|
+
comment: string;
|
|
11
|
+
begin: string;
|
|
12
|
+
end: string;
|
|
13
|
+
beginCaptures: {
|
|
14
|
+
'1': {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
endCaptures: {
|
|
19
|
+
'1': {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
patterns: {
|
|
24
|
+
comment: string;
|
|
25
|
+
begin: string;
|
|
26
|
+
end: string;
|
|
27
|
+
patterns: {
|
|
28
|
+
include: string;
|
|
29
|
+
}[];
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
'record-separator': {
|
|
33
|
+
match: string;
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
'line-feed': {
|
|
37
|
+
match: string;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
})[];
|
|
42
|
+
export default _default;
|
|
43
|
+
//# sourceMappingURL=json-seq.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"shiki/langs/json.mjs";const o={displayName:"JSON Sequence",name:"json-seq",scopeName:"source.json-seq",patterns:[{include:"#json-seq-record"}],repository:{"json-seq-record":{comment:"Match a complete json-seq record: 0x1E{...}0x0A",begin:"(0x1E)",end:"(0x0A)",beginCaptures:{1:{name:"keyword.control.record-separator.json-seq"}},endCaptures:{1:{name:"keyword.control.line-feed.json-seq"}},patterns:[{comment:"Highlight JSON content between separators",begin:"(?<=0x1E)(?=[\\[\\{])",end:"(?=0x0A)",patterns:[{include:"source.json"}]}]},"record-separator":{match:"0x1E",name:"keyword.control.record-separator.json-seq"},"line-feed":{match:"0x0A",name:"keyword.control.line-feed.json-seq"}}};var r=[...e,o];export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(s){return{"c++":"c",cpp:"c",jsx:"tsx","c#":"csharp","c#+newtonsoft":"csharp","java8+apache":"java",objectivec:"objective-c",shell:"bash",viml:"vim",curl:"bash","node.js":"js","multipart/mixed":"multipart-mixed","application/json-seq":"json-seq","json-seq":"json-seq"}[s]||s}export{c as mapLang};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const _default: (import("shiki").LanguageRegistration | {
|
|
2
|
+
displayName: string;
|
|
3
|
+
name: string;
|
|
4
|
+
scopeName: string;
|
|
5
|
+
patterns: {
|
|
6
|
+
include: string;
|
|
7
|
+
}[];
|
|
8
|
+
repository: {
|
|
9
|
+
boundary: {
|
|
10
|
+
match: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
headers: {
|
|
14
|
+
match: string;
|
|
15
|
+
captures: {
|
|
16
|
+
'1': {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
'2': {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
'json-body': {
|
|
25
|
+
comment: string;
|
|
26
|
+
begin: string;
|
|
27
|
+
end: string;
|
|
28
|
+
patterns: {
|
|
29
|
+
include: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
'binary-body': {
|
|
33
|
+
comment: string;
|
|
34
|
+
match: string;
|
|
35
|
+
name: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
})[];
|
|
39
|
+
export default _default;
|
|
40
|
+
//# sourceMappingURL=multipart-mixed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"shiki/langs/css.mjs";import r from"shiki/langs/graphql.mjs";import a from"shiki/langs/html.mjs";import e from"shiki/langs/javascript.mjs";import o from"shiki/langs/json.mjs";import m from"shiki/langs/sql.mjs";import i from"shiki/langs/xml.mjs";import n from"shiki/langs/yaml.mjs";const s={displayName:"Multipart Mixed",name:"multipart-mixed",scopeName:"source.multipart",patterns:[{include:"#boundary"},{include:"#headers"},{include:"#json-body"},{include:"#binary-body"}],repository:{boundary:{match:"^--[a-zA-Z0-9_\\-\\.]+(?:--)?$",name:"keyword.control.boundary.multipart"},headers:{match:"^([a-zA-Z0-9\\-]+):\\s*(.*)$",captures:{1:{name:"variable.other.header.name.multipart"},2:{name:"string.unquoted.header.value.multipart"}}},"json-body":{comment:"Detects if a block starts with { or [ and highlights it as JSON until the next boundary",begin:"^\\s*(?=[{\\[])",end:"(?=^--)",patterns:[{include:"source.json"}]},"binary-body":{comment:"Catch-all for content that isn't headers or JSON",match:".+",name:"text.plain"}}};var f=[...o,...a,...i,...e,...t,...n,...r,...m,s];export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import u from"shiki/langs/bash.mjs";import w from"shiki/langs/c.mjs";import N from"shiki/langs/coffee.mjs";import b from"shiki/langs/csharp.mjs";import y from"shiki/langs/css.mjs";import H from"shiki/langs/go.mjs";import v from"shiki/langs/graphql.mjs";import
|
|
1
|
+
import u from"shiki/langs/bash.mjs";import w from"shiki/langs/c.mjs";import N from"shiki/langs/coffee.mjs";import b from"shiki/langs/csharp.mjs";import y from"shiki/langs/css.mjs";import H from"shiki/langs/go.mjs";import v from"shiki/langs/graphql.mjs";import x from"shiki/langs/html.mjs";import L from"shiki/langs/http.mjs";import _ from"shiki/langs/java.mjs";import j from"shiki/langs/javascript.mjs";import T from"shiki/langs/kotlin.mjs";import E from"shiki/langs/lua.mjs";import r from"shiki/langs/markdown.mjs";import M from"shiki/langs/objective-c.mjs";import q from"shiki/langs/perl.mjs";import S from"shiki/langs/php.mjs";import A from"shiki/langs/python.mjs";import D from"shiki/langs/scala.mjs";import F from"shiki/langs/sql.mjs";import a from"shiki/langs/swift.mjs";import R from"shiki/langs/tsx.mjs";import W from"shiki/langs/typescript.mjs";import C from"shiki/langs/vim.mjs";import G from"shiki/langs/xml.mjs";import J from"shiki/langs/yaml.mjs";import U from"shiki/langs/jsx.mjs";import V from"shiki/langs/jsonl.mjs";import{transformerNotationDiff as $,transformerNotationHighlight as z,transformerNotationWordHighlight as B,transformerNotationFocus as I,transformerNotationErrorLevel as K,transformerMetaHighlight as O,transformerMetaWordHighlight as P,transformerRemoveNotationEscape as Q}from"@shikijs/transformers";import{createHighlighterCoreSync as s}from"shiki/core";import{createJavaScriptRegexEngine as n}from"shiki/engine/javascript";import X from"./ruby";import Y from"./multipart-mixed";import Z from"./json-seq";import f from"./theme";import rr from"./treeview-transformer";import or from"./node-transformer";import tr from"./line-numbers-transformer";import{mapLang as mr}from"./map-lang";const er=[{...r[0],displayName:"Markdoc",name:"markdoc",scopeName:"source.markdoc",aliases:[],repository:{...r[0].repository,fenced_code_block:{patterns:[...r[0].repository.fenced_code_block.patterns||[],{name:"markdoc",begin:".*{%",end:"%}",patterns:[{match:"(?<={%)\\s*(/\\w+(-\\w+)?|\\w+(-\\w+)?)",name:"markdoc.tag"},{match:"\\$\\w+",name:"markdoc.variable"},{match:'".*?"',name:"markdoc.string"},{match:"\\b\\w+(?=\\()",name:"markdoc.function"},{match:"\\s+\\w+(?==|\\s)",name:"markdoc.keyword"},{match:"(?<==)false|true(?=\\s)",name:"markdoc.boolean"}]}]}}}],p="text",c=s({themes:[f],langs:[u,w,N,b,y,H,v,x,L,_,j,T,E,r,M,q,S,A,X,D,F,a,R,W,G,C,J,er,U,V,Y,Z],engine:n()}),ir=[$(),z(),B(),I(),K(),O(),P(),Q(),or()],ar=(o,m,h)=>{const{withLineNumbers:l,startLineNumber:g,highlight:d,customTransformer:e}=h||{},i=mr(m?.toLowerCase()||p),t={lang:i,theme:"theme",meta:{__raw:d},transformers:[...i==="treeview"?[rr()]:[],...ir,...l?[tr(g)]:[],...e?[e]:[]]};try{return m==="swift"?s({themes:[f],langs:[a],engine:n({forgiving:!0})}).codeToHtml(o,t):c.codeToHtml(o,t)}catch{return c.codeToHtml(o,{...t,lang:p})}};function Ir(){return{highlight:ar}}export{ar as highlight,Ir as useCodeHighlight};
|
|
@@ -3,6 +3,10 @@ type BannerResult = {
|
|
|
3
3
|
banner: BannerConfig | undefined;
|
|
4
4
|
dismissBanner: (content: string) => void;
|
|
5
5
|
};
|
|
6
|
+
export declare const STORAGE_KEY = "redocly-dismissed-banners";
|
|
7
|
+
export declare const STORAGE_KEY_PER_SLUG = "redocly-dismissed-banners-per-slug";
|
|
8
|
+
export declare function getDismissedBannersFromStorage(): Set<string>;
|
|
9
|
+
export declare function getDismissedSlugsFromStorage(): Set<string>;
|
|
6
10
|
export declare function useBanner(): BannerResult;
|
|
7
11
|
export {};
|
|
8
12
|
//# sourceMappingURL=useBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as p,useState as f}from"react";import{useLocation as l}from"react-router-dom";import{useThemeConfig as y}from"@redocly/theme/core/hooks";import{usePageData as w}from"../../providers/page-data/hooks";import{getBannerForSlug as A}from"./utils/match-banner-target.js";const u="redocly-dismissed-banners",m="redocly-dismissed-banners-per-slug";function B(){if(typeof window>"u")return new Set;const e=localStorage.getItem(u);if(e){const r=JSON.parse(e);if(Array.isArray(r))return new Set(r)}return new Set}function D(){if(typeof window>"u")return new Set;const e=localStorage.getItem(m);if(e){const r=JSON.parse(e);if(Array.isArray(r))return new Set(r)}return new Set}function N(){const{banner:e}=y()||{},n=w()?.props?.frontmatter?.banner,c=l(),[s,S]=f(B()),[o,g]=f(D()),t=c.pathname;return{banner:p(()=>{if(n&&Array.isArray(n)&&n.length){if(o.has(t))return;for(const a of n)if(!s.has(a.content))return a;return}if(!(!e||!Array.isArray(e)||e.length===0)&&!o.has(t))return A(e,t,s)},[e,n,t,s,o]),dismissBanner:a=>{const i=new Set(s);i.add(a),S(i);const d=new Set(o);d.add(t),g(d),localStorage.setItem(u,JSON.stringify(Array.from(i))),localStorage.setItem(m,JSON.stringify(Array.from(d)))}}}export{u as STORAGE_KEY,m as STORAGE_KEY_PER_SLUG,B as getDismissedBannersFromStorage,D as getDismissedSlugsFromStorage,N as useBanner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withPathPrefix as
|
|
1
|
+
import{withPathPrefix as p,getNavbarElement as g}from"@redocly/theme/core/utils";import{isLocalLink as b}from"../../../utils/path/is-local-link.js";import{withLoadProgress as T}from"./withLoadProgress";let d;async function v({navigate:i,to:o,origin:r="browser",options:a}){o===""&&(o="/"),d=o;const{pathname:n,hash:w,search:s}=new URL(o,window.location.origin+window.location.pathname),e=decodeURIComponent(w),h=decodeURIComponent(window.location.hash),m=window.__LOADER,t=await T(m.tryLoad(n));if(t?.redirectTo){if(!b(t.redirectTo)){window.location.href=t.redirectTo;return}return v({navigate:i,to:t.redirectTo,origin:r,options:a})}if(o.startsWith(p("/_auth/"))){window.location.href=o;return}if(t&&d===o){if((n!==window.location.pathname||s!==window.location.search||e!==h)&&i({pathname:n,search:s,hash:e},{...a,state:{origin:r},unstable_flushSync:!0}),t.props?.disableAutoScroll)return;requestAnimationFrame(()=>{if(e){const c=e.slice(1),l=document.getElementById(c)||document.getElementsByName(c)[0];if(l){const f=g()?.offsetHeight??0,u=l.getBoundingClientRect().top+window.scrollY-f;window.scrollTo({top:u,behavior:"smooth"})}}else window.scrollTo(0,0)})}}export{v as loadAndNavigate};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HistoryOrigin } from '@redocly/theme/core/utils';
|
|
2
|
+
import type { ColorMode } from '@redocly/theme/core/types';
|
|
2
3
|
export type RouteUpdateIncomingMessage = {
|
|
3
4
|
type: 'route-update';
|
|
4
5
|
path: string;
|
|
@@ -26,7 +27,7 @@ export type EditorScrollUpdateIncomingMessage = {
|
|
|
26
27
|
};
|
|
27
28
|
export type ColorSchemaUpdateIncomingMessage = {
|
|
28
29
|
type: 'color-schema-update';
|
|
29
|
-
colorSchema:
|
|
30
|
+
colorSchema: ColorMode;
|
|
30
31
|
};
|
|
31
32
|
export type IncomingMessage = RouteUpdateIncomingMessage | InitializeIncomingMessage | LocationUpdateIncomingMessage | ScrollUpdateIncomingMessage | EditorScrollUpdateIncomingMessage | ColorSchemaUpdateIncomingMessage;
|
|
32
33
|
export type OutgoingMessage = InitializedOutgoingMessage | RouteUpdatedOutgoingMessage | AddReviewCommentOutgoingMessage | ReviewHoverLinesOutgoingMessage | ScrollOutgoingMessage | EditorScrollOutgoingMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(r){return Buffer.from(r,"base64url").toString()}export{e as decodeCursor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(r){return Buffer.from(r).toString("base64url")}export{e as encodeCursor};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KvKey, KvListEntry, KvValue } from '@redocly/config';
|
|
2
|
+
import type { DatabaseKvDbSchema } from '../../../providers/database/databases/sqld-sqlite/schemas/kv-table.js';
|
|
3
|
+
export declare function createKvListEntry<T extends KvValue>(kvDbEntry: Pick<DatabaseKvDbSchema, 'encodedKey' | 'value'>): KvListEntry<T>;
|
|
4
|
+
export declare function decodeKvKey(encodedKey: string): KvKey;
|
|
5
|
+
//# sourceMappingURL=create-kv-list-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{KV_KEY_SEPARATOR as r}from"./create-kv-db-record.js";import{createKvValue as o}from"./create-kv-value.js";function u(e){const t=o(e);return{key:n(e.encodedKey),value:t}}function n(e){return e.split(r).map(String)}export{u as createKvListEntry,n as decodeKvKey};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { KvValue } from '@redocly/config';
|
|
2
|
+
import type { DatabaseKvDbSchema } from '../../../providers/database/databases/sqld-sqlite/schemas/kv-table.js';
|
|
3
|
+
export declare function createKvValue<T extends KvValue>(kvDbEntry: Pick<DatabaseKvDbSchema, 'encodedKey' | 'value'>): T | null;
|
|
4
|
+
//# sourceMappingURL=create-kv-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{safeParse as a}from"../../../utils/safe-parse.js";function n(r){const e=a(r.value);return"error"in e?null:e.value}export{n as createKvValue};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KvKey,
|
|
1
|
+
import type { KvKey, KvListEntry, KvSetOptions, KvValue, KvListSelector, KvListOptions, KvListResponse, KvTransaction } from '@redocly/config';
|
|
2
2
|
import type { DatabaseConnection, RepositoryInstanceOptions } from '../../../providers/database/types.js';
|
|
3
3
|
import { BaseRepository } from '../../../providers/database/base-repository.js';
|
|
4
4
|
export declare const KV_KEY_END_BOUNDARY = "\u0002";
|
|
@@ -6,11 +6,11 @@ export declare class KvRemoteRepository extends BaseRepository {
|
|
|
6
6
|
#private;
|
|
7
7
|
constructor(dbConnection: DatabaseConnection);
|
|
8
8
|
static getInstance(options: RepositoryInstanceOptions): Promise<KvRemoteRepository | null>;
|
|
9
|
-
get<T extends KvValue = KvValue>(key: KvKey): Promise<
|
|
10
|
-
getMany<T extends KvValue = KvValue>(keys: KvKey[]): Promise<(
|
|
9
|
+
get<T extends KvValue = KvValue>(key: KvKey): Promise<T | null>;
|
|
10
|
+
getMany<T extends KvValue = KvValue>(keys: KvKey[]): Promise<(KvListEntry<T> | null)[]>;
|
|
11
11
|
list<T extends KvValue = KvValue>(selector: KvListSelector, options?: KvListOptions): Promise<KvListResponse<T>>;
|
|
12
|
-
set<T extends KvValue = KvValue>(key: KvKey, value: T, options?: KvSetOptions): Promise<
|
|
13
|
-
delete(key: KvKey): Promise<
|
|
12
|
+
set<T extends KvValue = KvValue>(key: KvKey, value: T, options?: KvSetOptions): Promise<KvListEntry<T> | null>;
|
|
13
|
+
delete(key: KvKey): Promise<void>;
|
|
14
14
|
clearExpired(): Promise<void>;
|
|
15
15
|
transaction<T>(operation: (tx: KvTransaction) => Promise<T>): Promise<T>;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{eq as
|
|
1
|
+
import{eq as E,and as g,gte as m,gt as M,lt as f,asc as B,desc as D,or as K,isNull as C,sql as c,inArray as q,count as $}from"drizzle-orm";import{logger as l}from"../../../tools/notifiers/logger.js";import{kvTable as t}from"../../../providers/database/databases/sqld-sqlite/schemas/kv-table.js";import{BaseRepository as I}from"../../../providers/database/base-repository.js";import{DatabaseConnectionFactory as N}from"../../../providers/database/database-connection-factory.js";import{createKvValue as S}from"../mappers/create-kv-value.js";import{createKvDbRecord as Q,encodeKvKey as d}from"../mappers/create-kv-db-record.js";import{decodeCursor as U}from"../helpers/decode-cursor.js";import{encodeCursor as V}from"../helpers/encode-cursor.js";import{createKvListEntry as b}from"../mappers/create-kv-list-entry.js";const Y="";class u extends I{static#e;constructor(e){super(e)}static async getInstance(e){if(!u.#e)try{const r=await N.create("sqld-remote",e);if(!r)return u.#e=null,null;u.#e=new u(r)}catch(r){return l.error("Error creating kv remote repository",r),u.#e=null,null}return u.#e}async get(e){try{const r=d(e),n=await this.databaseClient.client.select().from(t).where(g(E(t.encodedKey,r),K(C(t.expiresAt),m(c`datetime(${t.expiresAt})`,c`datetime('now')`)))).get();return n?S(n):null}catch(r){return l.error("Error getting kv entry by key",r),null}}async getMany(e){try{if(e.length===0)return[];const r=e.map(i=>d(i)),n=K(C(t.expiresAt),m(c`datetime(${t.expiresAt})`,c`datetime('now')`)),s=await this.databaseClient.client.select().from(t).where(g(q(t.encodedKey,r),n)).all(),o=new Map(s.map(i=>[i.encodedKey,i]));return e.map((i,x)=>{const p=r[x],w=o.get(p);return w?b(w):null})}catch(r){return l.error("Error getting multiple kv entries",r),[]}}async list(e,r){try{const n=r?.limit??100,s=r?.reverse??!1,o=[],v=K(C(t.expiresAt),m(c`datetime(${t.expiresAt})`,c`datetime('now')`));if(o.push(v),"prefix"in e){const a=d(e.prefix),y="start"in e?d(e.start):a,k="end"in e?d(e.end):a+Y;o.push(m(t.encodedKey,y)),o.push(f(t.encodedKey,k))}else if("start"in e&&"end"in e){const a=d(e.start),y=d(e.end);o.push(m(t.encodedKey,a)),o.push(f(t.encodedKey,y))}if(r?.cursor){const a=U(r.cursor),y=s?f(t.encodedKey,a):M(t.encodedKey,a);o.push(y)}const i=this.databaseClient.client.select().from(t),x=o.length>0?i.where(g(...o)):i,p=this.databaseClient.client.select({count:$()}).from(t),A=(await(o.length>0?p.where(g(...o)):p).get())?.count??0,h=await x.orderBy(s?D(t.encodedKey):B(t.encodedKey)).limit(n).all();return{items:h.map(a=>b(a)),total:A,cursor:A>h.length?V(h[h.length-1]?.encodedKey):null}}catch(n){return l.error("Error listing kv entries",n),{items:[],total:0,cursor:null}}}async set(e,r,n){try{const s=Q({key:e,value:r,ttlInSeconds:n?.ttlInSeconds});return await this.databaseClient.client.insert(t).values(s).onConflictDoUpdate({target:[t.encodedKey],set:{value:s.value,expiresAt:s.expiresAt,updatedAt:s.updatedAt}}),b(s)}catch(s){return l.error("Error saving kv entry",s),null}}async delete(e){try{const r=d(e);await this.databaseClient.client.delete(t).where(E(t.encodedKey,r))}catch(r){l.error("Error deleting kv entry by key",r)}}async clearExpired(){try{await this.databaseClient.client.delete(t).where(f(c`datetime(${t.expiresAt})`,c`datetime('now')`))}catch(e){l.error("Error clearing expired kv entries",e)}}async transaction(e){return this.databaseClient.transactionsManager.transaction(async()=>e({get:async n=>this.get(n),getMany:async n=>this.getMany(n),set:async(n,s,o)=>this.set(n,s,o),delete:async n=>this.delete(n)}))}}export{Y as KV_KEY_END_BOUNDARY,u as KvRemoteRepository};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KvKey, KvListOptions, KvListSelector, KvSetOptions } from '@redocly/config';
|
|
2
|
+
type Validator<T> = {
|
|
3
|
+
parse: (data: unknown) => T;
|
|
4
|
+
};
|
|
5
|
+
export declare const kvKeyValidator: Validator<KvKey>;
|
|
6
|
+
export declare const kvListOptionsValidator: Validator<KvListOptions>;
|
|
7
|
+
export declare const kvListSelectorValidator: Validator<KvListSelector>;
|
|
8
|
+
export declare const kvSetOptionsValidator: Validator<KvSetOptions>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=kv-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"@redocly/ajv";const a=new s({coerceTypes:!1,removeAdditional:!0,strictSchema:!1,allowUnionTypes:!0,useDefaults:!0,allErrors:!0,strictTypes:!1}),n=t=>t?.map(e=>`${e.instancePath} ${e.message}`.trim())||["Validation failed"],r={title:"KV key",type:"array",items:{anyOf:[{type:"string"},{type:"number"},{type:"boolean"}]},minItems:1},l={title:"KV list options",type:"object",properties:{limit:{type:"number",minimum:1,maximum:1e3},reverse:{type:"boolean"},cursor:{type:"string"}},additionalProperties:!1,required:[]},p={title:"KV list selector",type:"object",properties:{prefix:r,start:r,end:r},anyOf:[{required:["prefix"]},{required:["start","end"]}],additionalProperties:!1},c={title:"KV set arguments",type:"object",properties:{ttlInSeconds:{type:"number",minimum:1}},additionalProperties:!1,required:[]};function i(t){const e=a.compile(t);return{parse:o=>{if(!e(o))throw new Error(`Invalid ${t.title}: ${n(e.errors).join(", ")}`);return o}}}const u=i(r),y=i(l),f=i(p),v=i(c);export{u as kvKeyValidator,y as kvListOptionsValidator,f as kvListSelectorValidator,v as kvSetOptionsValidator};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { KvValue, KvKey, KvListEntry, KvSetOptions, KvListOptions, KvListResponse, KvListSelector, KvTransaction } from '@redocly/config';
|
|
1
2
|
import type { ServiceInstanceOptions } from '../../../providers/database/types.js';
|
|
2
|
-
import type { KvValue, KvKey, KvReadSchema, KvSetOptions, KvListOptions, KvListResponse, KvListSelector, KvTransaction } from '@redocly/config';
|
|
3
3
|
import { KvRemoteRepository } from '../repositories/kv-remote-repository.js';
|
|
4
4
|
export declare class KvService {
|
|
5
5
|
#private;
|
|
@@ -8,23 +8,23 @@ export declare class KvService {
|
|
|
8
8
|
/**
|
|
9
9
|
* Get a kv entry by key
|
|
10
10
|
*/
|
|
11
|
-
get<T extends KvValue = KvValue>(
|
|
11
|
+
get<T extends KvValue = KvValue>(rawKey: KvKey): Promise<T | null>;
|
|
12
12
|
/**
|
|
13
13
|
* Get multiple kv entries by keys
|
|
14
14
|
*/
|
|
15
|
-
getMany<T extends KvValue = KvValue>(
|
|
15
|
+
getMany<T extends KvValue = KvValue>(rawKeys: KvKey[]): Promise<(KvListEntry<T> | null)[]>;
|
|
16
16
|
/**
|
|
17
17
|
* List kv entries by prefix
|
|
18
18
|
*/
|
|
19
|
-
list<T extends KvValue = KvValue>(
|
|
19
|
+
list<T extends KvValue = KvValue>(rawSelector: KvListSelector, rawOptions?: KvListOptions): Promise<KvListResponse<T>>;
|
|
20
20
|
/**
|
|
21
21
|
* Set a kv entry with optional TTL
|
|
22
22
|
*/
|
|
23
|
-
set(
|
|
23
|
+
set<T extends KvValue = KvValue>(rawKey: KvKey, value: T, rawOptions?: KvSetOptions): Promise<KvListEntry<T> | null>;
|
|
24
24
|
/**
|
|
25
25
|
* Delete a specific kv entry by key
|
|
26
26
|
*/
|
|
27
|
-
delete(
|
|
27
|
+
delete(rawKey: KvKey): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Clear all expired kv entries
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{KvRemoteRepository as l}from"../repositories/kv-remote-repository.js";import{kvKeyValidator as a,kvListOptionsValidator as h,kvListSelectorValidator as u,kvSetOptionsValidator as c}from"../schemas/kv-schemas.js";class i{static#s;#t;constructor(t){this.#t=t}static async#r(t){const s=await l.getInstance(t),n=new i(s);i.#s=n}static async getInstance(t){return i.#s||await i.#r(t),i.#s}async get(t){const s=a.parse(t);return await this.#t?.sync(),await this.#t?.get(s)??null}async getMany(t){if(t.length===0)return[];const s=t.map(n=>a.parse(n));return await this.#t?.sync(),await this.#t?.getMany(s)??[]}async list(t,s){const n=u.parse(t),e=h.parse(s??{});return await this.#t?.sync(),await this.#t?.list(n,e)??{items:[],total:0,cursor:null}}async set(t,s,n){const e=a.parse(t),r=c.parse(n??{});return this.#e(s),this.#n(s),await this.#t?.set(e,s,r)??null}async delete(t){const s=a.parse(t);return this.#t?.delete(s)}async clearExpired(){return await this.#t?.clearExpired()}async transaction(t){if(!this.#t)throw new Error("Remote repository not available for transactions");return await this.#t.sync(),this.#t.transaction(async s=>t({get:async e=>{const r=a.parse(e);return s.get(r)},getMany:async e=>{const r=e.map(o=>a.parse(o));return s.getMany(r)},set:async(e,r,o)=>{const y=a.parse(e),p=c.parse(o);return this.#e(r),this.#n(r),s.set(y,r,p)},delete:async e=>{const r=a.parse(e);return s.delete(r)}}))}#e(t){try{JSON.stringify(t)}catch(s){const n=s instanceof Error?s.message:"Unknown error";throw new Error(`Value is not JSON serializable: ${n}`)}}#n(t){const n=JSON.stringify(t),e=Buffer.byteLength(n,"utf8");if(e>1048576){const r=(e/1024).toFixed(2);throw new Error(`Value size (${r} KB) exceeds the maximum allowed size of 1 MB (1024 KB)`)}}}export{i as KvService};
|
package/dist/server/plugins/markdown/attribute-resolvers/helpers/dereference-json-schema-refs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type NormalizedProblem } from '@redocly/openapi-core';
|
|
2
|
+
import type { ContentFs } from '../../../../fs/content-fs.js';
|
|
3
|
+
type Opts = {
|
|
4
|
+
schemaOrRef: unknown;
|
|
5
|
+
fs: ContentFs;
|
|
6
|
+
filePath: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function dereferenceJsonSchemaRefs({ schemaOrRef, filePath, fs }: Opts): Promise<{
|
|
9
|
+
schema: unknown;
|
|
10
|
+
oas: unknown;
|
|
11
|
+
problems: NormalizedProblem[];
|
|
12
|
+
} | undefined>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=dereference-json-schema-refs.d.ts.map
|
package/dist/server/plugins/markdown/attribute-resolvers/helpers/dereference-json-schema-refs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"node:path";import{bundle as m,createConfig as d,Source as l}from"@redocly/openapi-core";import{ExternalResolver as u}from"../../../../fs/utils/external-ref-resolver.js";async function h({schemaOrRef:e,filePath:n,fs:c}){if(typeof e!="object"||!e)return;const a={config:await d({}),base:f.dirname(n),doc:{source:new l(n,""),parsed:JSON.parse(JSON.stringify({openapi:"3.1.0",components:{schemas:{__root:e}}}))},externalRefResolver:new u(c)},{bundle:{parsed:p},problems:i}=await m(a),s=p,o=s?.components?.schemas,r=o?.__root?.$ref,t=typeof r=="string"?r.split("/").at(-1):void 0;return{schema:t?o?.[t]:o?.__root,problems:i,oas:s}}export{h as dereferenceJsonSchemaRefs};
|
package/dist/server/plugins/markdown/attribute-resolvers/helpers/generate-sample-from-schema.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
type GenerateSampleOptions = Partial<{
|
|
2
|
+
mode: 'read' | 'write';
|
|
3
|
+
spec: object;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Generates a sample JSON value from a JSON Schema using openapi-sampler.
|
|
7
|
+
*
|
|
8
|
+
* @param schema - A JSON Schema object to generate a sample from.
|
|
9
|
+
* Must be a plain JavaScript object (not null, array, or primitive).
|
|
10
|
+
*
|
|
11
|
+
* @param options - Optional configuration for sample generation.
|
|
12
|
+
* - `mode`: Filter properties by read/write semantics (`'read'` | `'write'`).
|
|
13
|
+
* - `spec`: Full OpenAPI specification, required if schema contains `$ref` references.
|
|
14
|
+
*
|
|
15
|
+
* @returns An object containing either the generated value or an error message.
|
|
16
|
+
* - `value`: The generated sample (object or array), or `null` if generation failed.
|
|
17
|
+
* - `error`: A descriptive error message if generation failed, or `null` on success.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Basic object schema
|
|
21
|
+
* generateSampleFromSchema({
|
|
22
|
+
* type: 'object',
|
|
23
|
+
* properties: { name: { type: 'string' } }
|
|
24
|
+
* });
|
|
25
|
+
* // Returns: { value: { name: 'string' }, error: null }
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Using read mode to exclude writeOnly properties
|
|
29
|
+
* generateSampleFromSchema(
|
|
30
|
+
* {
|
|
31
|
+
* type: 'object',
|
|
32
|
+
* properties: {
|
|
33
|
+
* id: { type: 'integer', readOnly: true },
|
|
34
|
+
* password: { type: 'string', writeOnly: true }
|
|
35
|
+
* }
|
|
36
|
+
* },
|
|
37
|
+
* { mode: 'read' }
|
|
38
|
+
* );
|
|
39
|
+
* // Returns: { value: { id: 0 }, error: null }
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Schema with $ref requires spec
|
|
43
|
+
* generateSampleFromSchema(
|
|
44
|
+
* { $ref: '#/components/schemas/User' },
|
|
45
|
+
* { spec: openApiDocument }
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Empty schema returns error
|
|
50
|
+
* generateSampleFromSchema({ type: 'object' });
|
|
51
|
+
* // Returns: { value: null, error: 'Invalid JSON Schema: schema must include properties, items, allOf/anyOf/oneOf, or example/enum/const/default' }
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* - Primitive schemas (`type: 'string'`, `type: 'integer'`, etc.) are not supported.
|
|
55
|
+
* - See `../__tests__/generate-sample-from-schema.test.ts` for comprehensive usage examples.
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateSampleFromSchema(schema: unknown, options?: GenerateSampleOptions): {
|
|
58
|
+
value: unknown;
|
|
59
|
+
error: string | null;
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=generate-sample-from-schema.d.ts.map
|
package/dist/server/plugins/markdown/attribute-resolvers/helpers/generate-sample-from-schema.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import i from"@redocly/ajv";import*as s from"openapi-sampler";import{isObject as t}from"../../../../../utils/guards/is-object.js";function p(a,o){if(!t(a))return{value:null,error:"Invalid JSON Schema: schema must be a plain object."};const{mode:l,spec:u}=o??{};let e;try{e=s.sample(a,{...l==="read"?{skipWriteOnly:!0}:void 0,...l==="write"?{skipReadOnly:!0}:void 0},u)}catch(r){return{value:null,error:`Failed to generate sample from schema. Spec is required for schemas with $ref: ${r?.message||""}`}}if(e==null||t(e)&&Object.keys(e).length===0||Array.isArray(e)&&e.length===1&&e[0]===null){const r=new i({}),n=r.validateSchema(a);return typeof n!="boolean"?{value:null,error:"Invalid JSON Schema: Async schemas are not supported."}:!n&&r.errors?.length?{value:null,error:`Invalid JSON Schema: ${r.errorsText(r.errors,{separator:`
|
|
2
|
+
`})}`}:{value:e,error:null}}return{value:e,error:null}}export{p as generateSampleFromSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveOpenApiRef as e}from"./resolve-open-api-ref.js";import{resolveJsonSchemaRef as
|
|
1
|
+
import{resolveOpenApiRef as e}from"./resolve-open-api-ref.js";import{resolveJsonSchemaRef as o}from"./resolve-json-schema-ref.js";import{resolveParsedYaml as r}from"./resolve-parsed-yaml.js";import{resolveRawContent as m}from"./resolve-raw-content.js";import{resolveSvgContent as t}from"./resolve-svg-content.js";import{resolveRelativePath as i}from"./resolve-relative-path.js";import{resolveLink as l}from"./resolve-link.js";import{resolveNativeMdLink as s}from"./resolve-native-md-link.js";import{resolveCodeSnippetFromFile as a}from"./resolve-code-snippet-from-file.js";import{resolveHtmlSourceAttribute as p}from"./resolve-html-source-attribute.js";import{resolveHtmlHref as n}from"./resolve-html-href.js";import{resolveImageSrc as v}from"./resolve-image-src.js";import{resolveImageSrcSet as f}from"./resolve-image-src-set.js";import{resolveNavLinks as S}from"./resolve-nav-links.js";import{resolveRelativeOrCdnIcon as c}from"./resolve-relative-or-cdn-icon.js";import{resolveCodeWalkthroughFilesets as h}from"./code-walkthrough/filesets-resolver.js";import{resolveJsonExampleRef as d}from"./resolve-json-example-ref.js";import{resolveSampleFromJsonSchema as R}from"./resolve-sample-from-json-schema.js";const N={openapiRef:e,jsonSchemaRef:o,parsedYaml:r,rawContent:m,svgContent:t,relativePath:i,link:l,nativeMdLink:s,codeSnippetFile:a,htmlSourceAttribute:p,htmlHref:n,imageSrc:v,imageSrcSet:f,navLinks:S,relativeOrCdnIcon:c,codeWalkthroughFilesets:h,jsonExampleRef:d,sampleFromJsonSchema:R};export{N as attributeResolvers};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Node } from '@markdoc/markdoc';
|
|
2
|
+
import type { MarkdocResolveContext } from '../../../types';
|
|
3
|
+
export declare function resolveJsonExampleRef(node: Node, attrName: string, relativePath: string, { context, actions }: MarkdocResolveContext): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=resolve-json-example-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{JsonPointer as w}from"@redocly/openapi-docs";import{isObject as d}from"../../../../utils/guards/is-object.js";import{getNodeAttribute as u}from"../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as s}from"../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as p}from"./md-resolve-error.js";import{resolvePathInMarkdown as $}from"../resolve-path-in-markdown.js";async function b(e,o,m,{context:n,actions:h}){const r=u(e,o);try{if(!d(r)||typeof r.$ref!="string"){try{JSON.stringify(r)}catch(i){throw new Error(`Invalid JSON value: ${i.message}`)}s(e,o+"Resolved",r);return}const[t,f]=r.$ref.split("#");if(!t)throw new Error(`Invalid $ref. Path to file is required: ${r.$ref}`);const l=$(t,m,h.contentDir),c=await n.fs.getFileInfo(l);if(!c)throw new Error(`Invalid $ref. No such file: ${l}`);let a;try{a=(await n.cache.load(c.realRelativePath,"yaml")).data}catch(i){throw new Error(`Invalid file format. File must be valid json or yaml: ${l} ${i?.message||""}`)}if(!f){s(e,o+"Resolved",a);return}const v=w.get(a,f);s(e,o+"Resolved",v)}catch(t){throw s(e,o+"ResolvedErrors",[t.message]),new p(t.message,{rawLink:""})}}export{b as resolveJsonExampleRef};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import a from"node:path";import{
|
|
1
|
+
import a from"node:path";import{getNodeAttribute as u}from"../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as f}from"../markdoc/helpers/set-node-attribute-value.js";import{formatBundleFromMarkdocError as b}from"../errors.js";import{MdResolveError as d}from"./md-resolve-error.js";import{dereferenceJsonSchemaRefs as h}from"./helpers/dereference-json-schema-refs.js";async function k(o,r,e,{context:c,actions:i}){const l=u(o,r),t=i.contentDir,p=a.resolve(t,e),s=await h({schemaOrRef:l,filePath:p,fs:c.fs});f(o,r+"Resolved",s?.oas);const n=s?.problems[0];if(!n)return{};const m=b(n,e,t);throw f(o,r+"ResolvedErrors",[m]),new d(m,{rawLink:""})}export{k as resolveJsonSchemaRef};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Node } from '@markdoc/markdoc';
|
|
2
|
+
import type { MarkdocResolveContext } from '../../../types';
|
|
3
|
+
export declare function resolveSampleFromJsonSchema(node: Node, attrName: string, relativePath: string, { context, actions }: MarkdocResolveContext): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=resolve-sample-from-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import S from"node:path";import{getNodeAttribute as f}from"../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as i}from"../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as a}from"./md-resolve-error.js";import{generateSampleFromSchema as g}from"./helpers/generate-sample-from-schema.js";import{formatBundleFromMarkdocError as k}from"../errors.js";import{dereferenceJsonSchemaRefs as E}from"./helpers/dereference-json-schema-refs.js";async function y(o,e,r,{context:p,actions:l}){const h=f(o,e),t=l.contentDir,d=S.resolve(t,r),s=await E({schemaOrRef:h,filePath:d,fs:p.fs});if(!s)return;const{schema:u,problems:w,oas:b}=s,m=w[0];if(m){const c=k(m,r,t);throw i(o,e+"ResolvedErrors",[c]),new a(c,{rawLink:""})}const R=f(o,"mode"),{value:v,error:n}=g(u,{mode:R,spec:b});if(i(o,e+"Resolved",v),n)throw new a(n,{rawLink:""})}export{y as resolveSampleFromJsonSchema};
|
|
@@ -2,4 +2,6 @@ export * from './definition-path.js';
|
|
|
2
2
|
export * from './parsed-yaml.js';
|
|
3
3
|
export * from './raw-content.js';
|
|
4
4
|
export * from './json-schema-ref.js';
|
|
5
|
+
export * from './json-example-ref.js';
|
|
6
|
+
export * from './sample-from-json-schema.js';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./definition-path.js";export*from"./parsed-yaml.js";export*from"./raw-content.js";export*from"./json-schema-ref.js";
|
|
1
|
+
export*from"./definition-path.js";export*from"./parsed-yaml.js";export*from"./raw-content.js";export*from"./json-schema-ref.js";export*from"./json-example-ref.js";export*from"./sample-from-json-schema.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomAttributeTypeInterface, ValidationError } from '@markdoc/markdoc';
|
|
2
|
+
export declare class JsonExampleRef implements CustomAttributeTypeInterface {
|
|
3
|
+
validate(_value: string): ValidationError[];
|
|
4
|
+
static resolver: string;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=json-example-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class l{validate(a){return[]}static resolver="jsonExampleRef"}export{l as JsonExampleRef};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomAttributeTypeInterface, ValidationError } from '@markdoc/markdoc';
|
|
2
|
+
export declare class SampleFromJsonSchema implements CustomAttributeTypeInterface {
|
|
3
|
+
validate(_value: string): ValidationError[];
|
|
4
|
+
static resolver: string;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=sample-from-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class r{validate(a){return[]}static resolver="sampleFromJsonSchema"}export{r as SampleFromJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./json-schema.js";export*from"./explain-step.js";export*from"./openapi-code-sample.js";export*from"./openapi-example.js";export*from"./step-by-step-wrapper.js";export*from"./replay-openapi.js";export*from"./openapi-response-sample.js";
|
|
1
|
+
export*from"./json-schema.js";export*from"./explain-step.js";export*from"./openapi-code-sample.js";export*from"./openapi-example.js";export*from"./step-by-step-wrapper.js";export*from"./replay-openapi.js";export*from"./openapi-response-sample.js";export*from"./json-example.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import r from"react";import l from"styled-components";import{JsonViewer as n}from"@redocly/theme/components/JsonViewer/JsonViewer";import{ClipboardService as a}from"@redocly/theme/core/utils";function E(c){const{json:e,title:t,errors:o}=c;return o.length?r.createElement(i,null,r.createElement(p,null,"error"),r.createElement(n,{data:o,expandLevel:3,onCopyClick:()=>{a.copyCustom(JSON.stringify(o))},title:t})):r.createElement(n,{data:e,expandLevel:3,onCopyClick:()=>{a.copyCustom(JSON.stringify(e))},title:t})}const i=l.div`
|
|
2
|
+
background-color: var(--code-block-bg-color);
|
|
3
|
+
border: 2px solid var(--color-error-border);
|
|
4
|
+
`,p=l.p`
|
|
5
|
+
color: var(--color-error-text);
|
|
6
|
+
padding-left: var(--spacing-xs);
|
|
7
|
+
`;export{E as JsonExample};
|