@redocly/reef 0.131.0-next.9 → 0.132.0-next.0
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 +167 -1
- package/dist/bin.js +1 -1
- package/dist/cli/stats/collectors/{openapi.d.ts → openapi/index.d.ts} +2 -2
- package/dist/cli/stats/collectors/openapi/index.js +1 -0
- package/dist/cli/stats/collectors/openapi/oas32.d.ts +15 -0
- package/dist/cli/stats/collectors/openapi/oas32.js +1 -0
- package/dist/cli/stats/index.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogSort.d.ts +1 -1
- package/dist/client/app/hooks/catalog/useCatalogSort.js +1 -1
- package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
- package/dist/client/app/hooks/useAnchorPositioning.js +1 -1
- package/dist/client/app/l10n/index.js +1 -1
- package/dist/client/app/search/useAiSearch.js +1 -1
- package/dist/client/app/seo/SeoTags.js +1 -1
- package/dist/client/templates/asyncapi-docs/template.js +1 -3
- package/dist/client/templates/openapi-docs/template.js +2 -6
- package/dist/client/types/ai-search.d.ts +1 -0
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/markdoc/helpers/extract-rbac-from-condition-node.d.ts +6 -15
- package/dist/markdoc/helpers/extract-rbac-from-condition-node.js +1 -1
- package/dist/markdoc/helpers/guards/is-function.d.ts +1 -0
- package/dist/markdoc/helpers/guards/is-variable.d.ts +3 -3
- package/dist/server/api-routes/execute-api-route.js +1 -1
- package/dist/server/config/env-config.d.ts +1 -0
- package/dist/server/config/env-config.js +1 -1
- package/dist/server/config/env-schema.d.ts +3 -3
- package/dist/server/config/env-schemas/server-config.d.ts +3 -3
- package/dist/server/config/env-schemas/server-config.js +1 -1
- package/dist/server/esbuild/esbuild-logger.js +3 -3
- package/dist/server/node-bundle-entry.js +1 -1
- package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.js +37 -37
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +7 -0
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +22 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +29 -15
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +6 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
- package/dist/server/plugins/entitlements/index.js +1 -1
- package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.d.ts +6 -0
- package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.js +1 -0
- package/dist/server/plugins/graphql-docs/index.js +1 -1
- package/dist/server/plugins/markdown/search/get-search-documents.d.ts +1 -1
- package/dist/server/plugins/markdown/search/get-search-documents.js +2 -2
- package/dist/server/plugins/markdown/search/nodes/heading-node.js +1 -1
- package/dist/server/plugins/markdown/search/nodes/section-node.d.ts +2 -2
- package/dist/server/plugins/markdown/search/nodes/section-node.js +1 -1
- package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
- package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +25 -25
- package/dist/server/plugins/openapi-docs/search-indexer.js +1 -1
- package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
- package/dist/server/plugins/scorecard-classic/compute-scorecard.js +4 -4
- package/dist/server/plugins/sidebars/index.d.ts +1 -2
- package/dist/server/plugins/sidebars/index.js +2 -2
- package/dist/server/providers/database/pagination/after-and-before.js +1 -1
- package/dist/server/providers/database/pagination/utils/create-cursor.d.ts +7 -1
- package/dist/server/providers/database/pagination/utils/create-cursor.js +1 -1
- package/dist/server/ssr/template.js +3 -3
- package/dist/server/tools/notifiers/formatter.js +3 -3
- package/dist/server/tools/notifiers/helpers/colors.js +1 -1
- package/dist/server/tools/notifiers/logger.d.ts +2 -2
- package/dist/server/tools/notifiers/logger.js +2 -2
- package/dist/server/tools/notifiers/terminal-manager.d.ts +1 -1
- package/dist/server/tools/notifiers/terminal-manager.js +4 -4
- package/dist/server/web-server/routes/catalog/catalog.js +1 -1
- package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.d.ts +12 -0
- package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.js +1 -0
- package/dist/server/web-server/routes/cors-proxy.js +2 -2
- package/dist/server/web-server/utils/prepare-list-response.js +1 -1
- package/package.json +13 -13
- package/dist/cli/stats/collectors/openapi.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import w from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as
|
|
2
|
-
- ${
|
|
3
|
-
- `)}`;
|
|
4
|
-
... and ${
|
|
1
|
+
import w from"node:path";import R from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as l}from"../../tools/notifiers/logger.js";import{ScorecardStatus as g}from"./types.js";import{getTarget as L}from"./loaders/scorecard.js";const P=15;async function $({actions:t,context:e,scorecardConfig:a,reuniteConfig:n}){l.info("Computing scorecard...");const i=a.levels||[],o=i[0],m=await t.loadOpenApiDefinitions(e),s=a.ignore||[],d=R(s),f=new Set,h=l.startTiming(),c={},p={};for(const r of m){if(!M(r,d,f))continue;const v=r.customOutputRelativeFile||r.realRelativePath;f.add(v);const u=await T(r,e,a,i,o);c[r.realRelativePath]=u,p[u.relativePath]=u}return l.infoTime(h,"Scorecard processed"),N(c,n,a),p}function M(t,e,a){if(t.isVirtual||!t.definition)return!1;const n=t.customOutputRelativeFile||t.realRelativePath,i=S(t.realRelativePath);return e(i)?(l.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!a.has(n)}function D(t,e,a){return t-1<e?g.BelowMinimum:e<a-1?g.Minimum:g.Highest}async function T(t,e,a,n,i){let o=i.name;if(a.targets?.length){const r=await e.getConfig(w.posix.dirname(t.realRelativePath)),v=t.definition.info?.["x-metadata"]||{},u={title:t.definition.info?.title,version:t.definition.info?.version,...v,...r.metadata};o=await B(a,u)||i.name}const{data:{levels:m,scorecardLevelIdx:s,scorecardLevel:d}}=await e.cache.load(t.realRelativePath,"scorecard"),f=n.findIndex(r=>r.name===o),h=D(s,f,n.length),c=t.customOutputRelativeFile||t.realRelativePath,p=O(c)?.versionName;return{levels:m,status:h,targetLevel:o,scorecardLevel:d,scorecardLevelIdx:s,relativePath:c,title:t.definition.info?.title,version:p}}function N(t,e,a){const n=Object.values(t).filter(s=>s.status===g.BelowMinimum);if(n.length===0)return;const i=n.map(s=>s.relativePath);let o=`Detected OpenAPI definitions with score below minimum level:
|
|
2
|
+
- ${i.slice(0,P).map(()=>"%rp").join(`
|
|
3
|
+
- `)}`;i.length>P&&(o+=`
|
|
4
|
+
... and ${i.length-P} more`),e?.ignoreLint??a.ignoreNonCompliant?l.warn(o,...i):l.error(o,...i)}async function B(t,e){return(await L(t.targets,e))?.minimumLevel}export{$ as computeScorecard};
|
|
@@ -2,7 +2,6 @@ import type { LifecyclePluginInstance, PluginOptions } from '../../types';
|
|
|
2
2
|
import type { ResolvedNavItem } from '@redocly/config';
|
|
3
3
|
import type { ContentFs } from '../../fs/content-fs.js';
|
|
4
4
|
export declare function sidebarsPlugin({ contentDir, }: PluginOptions): Promise<LifecyclePluginInstance>;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function stripMarkdocFromDescriptions(items: ResolvedNavItem[]): void;
|
|
6
6
|
export declare function resolveSidebarId(relativePath: string, sidebarPath: string, fs: ContentFs): Promise<string | null>;
|
|
7
|
-
export declare function isSidebarIgnored(ignore: string[], sidebarPath: string): boolean;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as tt}from"node:fs";import*as
|
|
1
|
+
import{writeFileSync as tt}from"node:fs";import*as d from"path";import{removeMarkdocTags as et}from"../../../markdoc/helpers/remove-markdoc-tags.js";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as v,SIDEBAR_PREFIX as at,CONFIG_FILE_NAME as V}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as rt}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as st}from"../../config/env-config.js";import{isLocalLink as nt}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as B}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{collectItemsLinkedToSidebars as dt,resolveItems as J}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as ut,getSidebarReferences as mt,hasCircularDependency as gt}from"./utils.js";import{getLocaleFromRelativePath as pt}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as ht}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as St}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as yt}from"../../../cli/telemetry/helpers/trace-step.js";import{isPathIgnored as Ft}from"../../utils/paths.js";const It=180,bt=170,Dt=10;async function Jt({contentDir:c}){return{id:"sidebars",async afterRoutesCreated(o,i){await yt("build.plugin.sidebars",async()=>{const{cache:p,fs:f}=i,b=o.getConfig(),D=new Map,C=new Set,x=[v,...f.localeFolders],j=o.getGlobalData()[St]||{},G=new Map;let R=f.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!Ft(t,b.ignore??[])&&t);const $=await mt(i,c,R),Q=it(R.filter(t=>!$.has(t)),t=>ct(t)?.versionFolderPath||t),_=ut(b),Z=await dt(b?.navbar,o,i,{navFile:V,excludedFromLinkCheckerPatterns:_});let P;const T=gt($);T&&Array.isArray(T)&&await k.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
|
|
2
2
|
Circular dependency chain: ${T.reverse().join(" -> ")}
|
|
3
|
-
`);for(const t of
|
|
3
|
+
`);for(const t of Q){const u=(await Promise.all(t.map(async s=>{const e=(await p.load(s,"yaml")).data;if(!Array.isArray(e)){await k.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',s,f,s,typeof e);return}return{items:e,sidebarRelativePath:s,locale:pt(s)}}))).filter(X),r=(await A(u))?.firstLink;P||(P=r)}const H=Object.entries(b?.catalogClassic??{});for(const t of x){for(const[e,l]of H)await z(e,l,t);const u={},r=new Set,s=o.getAllRoutesForLocale(t);for(const e of s)if(W(e)&&e.fsPath&&!r.has(e.fsPath)){r.add(e.fsPath);let n=d.posix.dirname(e.fsPath);const h=d.parse(n).root;do u[n]=(u[n]||0)+1,n=d.dirname(n);while(n&&n!="."&&h!=n)}for(const e of s){if(D.has(e.slug))continue;const l=W(e),n=d.dirname(e.fsPath),h=u[n]===1,m=Et(e.baseSlug||e.slug);l&&h?await A([{items:[{directory:n}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}]):e.getSidebar!==void 0&&await A([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}])}for(const[e,l]of H)await z(e,l,t,!0)}if(R.length===0)for(const t of x){B.verbose("Creating default sidebar");const u=t===v,r=`sidebars.yaml${u?"":"_"+t}`,s=u?"":`${f.localizationFolder}/${t}`,e=(await A([{items:[{directory:`./${s}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:C}]))?.firstLink;P||(P=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const u=o.getAllRoutes().find(s=>!ht(s.slug)),r=P?P.link:u?.baseSlug??null;if(r){const s=ot(r);o.addRedirect("/",{to:s,type:302}),B.info("Creating default redirect for index page => %s",s)}}const U=st.REDOCLY_METADATA_OUTPUT_FOLDER;U&&(B.info("Writing catalog data..."),tt(d.join(U,rt),JSON.stringify(Object.fromEntries(G.entries()))));function W(t){return C.has(t.slug)||j[t.fsPath]}async function A(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:m,locale:I,sidebarRelativePath:g,ignoredRoutes:L})=>{const a=await J(m,d.dirname(d.join(c,g)),o,i,{locale:I,ignoredRoutes:L,navFile:g,excludedFromLinkCheckerPatterns:_});if(!a){await k.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",g);return}return a}))).flat().filter(X),s=N(r,"routeSlug"),e=t[0].sidebarRelativePath,l=q(e),n=new Set;for(const m of s){const I=o.getRouteBySlug(m)?.fsPath??"",g=j[I];g&&(Array.from(n).find(a=>a.key===g.key&&a.version===g.version)||n.add(g)),o.addRouteSharedData(m,"sidebar",l),D.set(Y(m),r)}const h=n.size===1?Array.from(n)[0]:void 0;return await o.createSharedData(l,{relatedNavbarItem:Z?.get(e),items:r,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(r,m=>!!m.link),resolved:r}}async function z(t,u,r,s=!1){const e=structuredClone(u);r&&r!==v&&e.items.forEach(a=>{a.directory=d.posix.join(f.localizationFolder||"",r,a.directory||"")});let l=await J(e.items,c,o,i,{groupCustomSidebars:!0,locale:r,navFile:V,excludedFromLinkCheckerPatterns:_});if(!l){await k.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Pt(l);const n=r===v?"":"/"+r.toLowerCase(),h=r===v?"":`-${r}`,m=Y(d.posix.join(n,e.slug));if(s)for(const a of l){const S=M(a.items||[],F=>!!F.routeSlug);if(!S?.routeSlug)continue;const y=D.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),w="current-catalog-info-"+a.routeSlug+h,E={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:a.metadata?.title,link:a.link,icon:a.icon}};await o.createSharedData(w,E);for(const F of O)o.addRouteSharedData(F,"current-catalog-info",w),C.add(F);const K=M(y,F=>!!F.link&&!F.external&&nt(F.link)&&(!a.version||F.version===a.version));K&&(a.sidebar=[{...K,items:void 0}])}const I={},g=new Set;for(const a of l){if(!(a.routeSlug||a.sidebar?.[0]?.routeSlug)||!a.fsPath||g.has(a.fsPath))continue;g.add(a.fsPath);const y=d.dirname(a.fsPath);I[y]=(I[y]||0)+1}if(s){const a=await o.createSharedData("catalog-"+t+h,l.flatMap(S=>{const y=d.dirname(S.fsPath??""),O=I[y]===1,w=E=>({...E,fsPath:O?y:E.fsPath??""});return S.type==="group"&&S.items?.every(E=>E.type==="group")?(S.items||[]).map(w):w(S)}));o.addRouteSharedData(m,"catalog",a),Ct(r,l,G,I)}const L=N(l,"routeSlug");for(const a of L)C.add(a)}})}}}function Ct(c,o,i,p){if(c===v)for(const f of o){const b=f.routeSlug||f.sidebar?.[0]?.routeSlug;if(!b||!f.fsPath)continue;const D=d.dirname(f.fsPath),C=p[D]===1;i.set(b,{rootFileFsPath:f.fsPath,fsPath:C?D:f.fsPath,metadata:f.metadata||{},title:f.metadata?.title||f.label||"Untitled",version:f.version||"latest"})}}function Pt(c){const o=i=>{typeof i.metadata?.description=="string"&&(i.metadata={...i.metadata,description:et(i.metadata.description)})};for(const i of c)if(i.routeSlug)o(i);else for(const p of i.items||[])o(p)}function q(c){return at+lt(c)}async function qt(c,o,i){const p=d.posix.join(d.dirname(c),o);return await i.exists(p)?q(p):(await k.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",c,i,c,o),null)}function Et(c){const o=c.replaceAll("/","_");if(o.length>It){const i=o.slice(0,bt),p=ft(c).slice(0,Dt).replaceAll("/","_");return i+p}else return o}export{qt as resolveSidebarId,Jt as sidebarsPlugin,Pt as stripMarkdocFromDescriptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{and as
|
|
1
|
+
import{and as g,eq as v,gt as c,lt as a,or as b,sql as p}from"drizzle-orm";import{decodeCursor as q}from"./utils/decode-cursor.js";const G=e=>{if(e===null||typeof e!="object")return!1;const r=e;return typeof r.value=="string"&&typeof r.id=="string"},M=e=>{if(e===null||typeof e!="object")return!1;const r=e;return Array.isArray(r.values)&&r.values.every(f=>typeof f=="string")&&typeof r.id=="string"};function k(e,r,f){if(e.length!==r.length)return p`0`;const h=[];for(let t=0;t<e.length;t++){const C=p.identifier(e[t].field),y=r[t],m=e[t].order==="ASC",d=f==="after"&&m||f==="before"&&!m?c(C,y):a(C,y);if(t===0)h.push(d);else{const o=e.slice(0,t).map((i,S)=>v(p.identifier(i.field),r[S]));h.push(g(g(...o),d))}}return b(...h)}const N=(e,r)=>{const{after:f,before:h}=r;if(!f&&!h)return{sqlBuilder:e,whereCondition:null};const t=q(f),C=q(h),y=t!=null,m=C!=null&&!y,l=r.sort&&r.sort.length>0?r.sort:[{field:"id",order:"ASC"}],d=l[0],o=p.identifier(d.field),i=p.identifier("id");let S=null;function j(B,A){if(!B)return null;try{const n=JSON.parse(B);if(M(n)){const F=l[l.length-1]?.field==="id",I=n.id!=null,w=l.length===n.values.length+1&&F&&I,T=!F&&I&&l.length===n.values.length,x=T?[...l,{field:"id",order:l[0]?.order??"ASC"}]:l,E=w||T?[...n.values,n.id]:n.values;return k(x,E,A)}if(!G(n))return null;const s=String(n.value),u=String(n.id);return d.field==="id"?d.order==="ASC"?A==="after"?c(i,u):a(i,u):A==="after"?a(i,u):c(i,u):d.order==="ASC"?A==="after"?b(c(o,s),g(v(o,s),c(i,u))):b(a(o,s),g(v(o,s),a(i,u))):A==="after"?b(a(o,s),g(v(o,s),a(i,u))):b(c(o,s),g(v(o,s),c(i,u)))}catch{return null}}return y?S=j(t,"after"):m&&(S=j(C,"before")),{sqlBuilder:e,whereCondition:S}};export{N as applyAfterAndBefore};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import type { SortOption } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a cursor from an entity and the full sort definition.
|
|
4
|
+
* Encodes all sort field values so that "after" pagination is correct for multi-column sort
|
|
5
|
+
* (e.g. sort by type, title, id). Single-field sort still uses { value, id } for backward compat.
|
|
6
|
+
*/
|
|
1
7
|
export declare function createCursor<T extends {
|
|
2
8
|
id: string;
|
|
3
|
-
}>(entity: T,
|
|
9
|
+
}>(entity: T, sortOptions: SortOption[], nameTransformationsFromDatabase?: Record<string, string>): string;
|
|
4
10
|
//# sourceMappingURL=create-cursor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{transformToCamelCase as d}from"./transform-to-camel-case.js";function c(r,t){return t?.[r]??d(r)}function S(r,t,u){if(!t.length){const n={value:String(r.id),id:String(r.id)};return Buffer.from(JSON.stringify(n)).toString("base64")}const i=t.map(n=>{const o=c(n.field,u),s=r[o];if(s===void 0&&n.field!=="id")throw new Error(`Cursor field '${n.field}' (key: ${String(o)}) not found in entity`);return String(s??r.id)}),e=r.id;if(e==null)return Buffer.from(JSON.stringify({values:i})).toString("base64");const f=String(e);if(i.length===1){const n={value:i[0],id:f};return Buffer.from(JSON.stringify(n)).toString("base64")}const g={values:i,id:f};return Buffer.from(JSON.stringify(g)).toString("base64")}export{S as createCursor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{withPathPrefix as p}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as y}from"../../constants/common.js";import{RUNTIME_RESOURCES_DIR as E}from"../constants/common.js";import{INIT_BROWSER_HOOKS_SCRIPT as R}from"./init-browser-hooks-script.js";const _="";function w({bodyHtml:r,linkTags:i,title:m,favicon:e,preload:n,headScriptTags:$,postBodyScriptTags:
|
|
1
|
+
import{withPathPrefix as p}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as y}from"../../constants/common.js";import{RUNTIME_RESOURCES_DIR as E}from"../constants/common.js";import{INIT_BROWSER_HOOKS_SCRIPT as R}from"./init-browser-hooks-script.js";const _="";function w({bodyHtml:r,linkTags:i,title:m,favicon:e,preload:n,headScriptTags:$,postBodyScriptTags:l,preBodyScriptTags:s,lang:t,productClass:o,fonts:a=_,runtimeCss:h}){const c=t&&t!=y?` lang="${t}"`:' lang="en"',d=o?` class="${o}"`:"";return`<!doctype html>
|
|
2
2
|
<html${c}${d}>
|
|
3
3
|
<head>
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
@@ -17,9 +17,9 @@ import{withPathPrefix as p}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE
|
|
|
17
17
|
${h||""}
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
20
|
-
${
|
|
20
|
+
${s||""}
|
|
21
21
|
<div id="app_root">${r}</div>
|
|
22
22
|
<script async type="module" src="${p(E)}/browser-entry.js"></script>
|
|
23
|
-
${
|
|
23
|
+
${l||""}
|
|
24
24
|
</body>
|
|
25
25
|
</html>`}export{w as htmlTemplate};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`},
|
|
3
|
-
`},
|
|
1
|
+
import*as O from"node:path";import{envConfig as S}from"../../config/env-config.js";import{maskEmail as E}from"./helpers/privacy/mask-email.js";import{maskSubject as T}from"./helpers/privacy/mask-subject.js";import{removePii as C}from"./helpers/privacy/remove-pii.js";import{removePiiFromUrl as $}from"./helpers/privacy/remove-pii-from-url.js";import{red as x,green as A,bold as j,blue as p,gray as i,yellow as P,cyan as w}from"./helpers/colors.js";var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const b={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function _(e,s){return b[e]>=b[s]}function z(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const F={[n.INFO]:p,[n.SUCCESS]:A,[n.WARN]:P,[n.ERROR]:x,[n.HTTP]:w,[n.VERBOSE]:i},I={"%ap":e=>p(O.resolve(e)),"%rp":e=>p(O.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>p(e)},v={format(e){switch(S.logFormat){case"JSON":return U(e);default:return H(e)}},interpolate(e,...s){const a=Object.keys(I).map(t=>`(${t})`).join("|"),m=new RegExp(a,"g");let o,u=e;for(;(o=m.exec(e))!==null;){o.index===m.lastIndex&&m.lastIndex++;const t=s.shift();if(t===void 0)break;const r=o[0];u=u.replace(r,I[r](t))}return u}};var G=v;const H=e=>{const{level:s,message:a,duration:m,context:o}=e,u=S.isRuntimeMode,t=[F[s](j(`[${s.toLowerCase()}]`))];if(u&&t.push(i(`time="${N()}"`)),o){const{email:r,ipAddress:f,subject:l,method:d,pathname:c,statusCode:R,teams:h,apiFunction:g}=o;g&&t.push(p(`fn="${g}"`)),R&&t.push(y(R)),e.level===n.HTTP&&(d&&t.push(i(`method="${d}"`)),c&&t.push(i(`path="${$(c)}"`))),f&&t.push(i(`ip="${f}"`)),r&&t.push(i(`email="${E(r)}"`)),l&&t.push(i(`sub="${T(l)}"`)),h?.length&&t.push(i(`teams="${h.join(", ")}"`))}if(a){const r=u?`msg="${String(C(a)).replaceAll?.('"','\\"')}"`:String(a);t.push(r)}return e.level===n.HTTP&&o?.userAgent&&t.push(i(`agent="${o.userAgent}"`)),m&&t.push(M(m)),t.join(" ")+`
|
|
2
|
+
`},U=({context:e,message:s,...a})=>{const{method:m,pathname:o,statusCode:u,userAgent:t,subject:r,email:f,teams:l,apiFunction:d}=e||{},c={...a,email:f&&E(f),subject:r&&T(r),teams:l,apiFunction:d,...a.level===n.HTTP?{method:m,pathname:String($(o)),statusCode:u,userAgent:t}:{message:String(C(s))}};return S.isRuntimeMode&&(c.time=N()),JSON.stringify(c,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
|
|
3
|
+
`},y=e=>(e%500<100?x:e%400<100?P:A)(`status="${e}"`),N=()=>{let e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},M=e=>i(`dur="${Math.round(e)}ms"`);export{n as LogLevel,G as default,z as parseLogLevel,_ as shouldLog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createColors as e}from"colorette";import{envConfig as l}from"../../../config/env-config.js";const r=l.
|
|
1
|
+
import{createColors as e}from"colorette";import{envConfig as l}from"../../../config/env-config.js";const r=l.logFormat!=="JSON",{red:s,green:t,bold:c,blue:n,gray:a,yellow:g,cyan:m}=e({useColor:r}),d=o=>typeof o=="string"?o.replace(/\x1B[[(?);]{0,2}(;?\d)*./g,""):o;export{n as blue,c as bold,r as colorsAreEnabled,m as cyan,a as gray,t as green,s as red,d as stripColors,g as yellow};
|
|
@@ -14,12 +14,12 @@ export type LoggerContext = {
|
|
|
14
14
|
};
|
|
15
15
|
type LoggerOptions = {
|
|
16
16
|
context?: LoggerContext;
|
|
17
|
-
|
|
17
|
+
allowInteractive?: boolean;
|
|
18
18
|
minLogLevel?: LogLevel;
|
|
19
19
|
};
|
|
20
20
|
export declare class Logger {
|
|
21
21
|
#private;
|
|
22
|
-
constructor({ context,
|
|
22
|
+
constructor({ context, allowInteractive, minLogLevel }?: LoggerOptions);
|
|
23
23
|
shouldLog(level: LogLevel): boolean;
|
|
24
24
|
info(message: string, ...args: unknown[]): void;
|
|
25
25
|
infoTime(timingId: symbol | string, message: string, ...args: unknown[]): {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{telemetry as c}from"../../telemetry/index.js";import{envConfig as l}from"../../config/env-config.js";import h,{LogLevel as r,shouldLog as m,parseLogLevel as u}from"./formatter.js";import{isVirtualFile as f}from"../../fs/utils/isVirtualFile.js";import{TerminalManager as g}from"./terminal-manager.js";class p{#e;#l;#i;#n;#r=new Map;#o=new Map;constructor({context:t,
|
|
2
|
-
`;this.isInteractive()||this.#i.isFooterChanged(t,o)&&this.#t({level:r.INFO,message:e,args:i}),this.#i.updateFooter(t,o)}successTime(t,e,...i){return this.#s(r.SUCCESS,e,t,...i)}warn(t,...e){this.#t({level:r.WARN,message:t,args:e})}warnProd(t,...e){this.#l?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#t({level:r.ERROR,message:t,args:e})}contentError(t,...e){this.#t({level:r.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){this.#t({level:r.VERBOSE,message:t,args:e})}verboseTime(t,e,...i){return this.#s(r.VERBOSE,e,t,...i)}httpTime(t){return this.#s(r.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const i=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,i),e}updateContext(t){this.#e={...this.#e,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}isInteractive(){return this.#i.isInteractive()}warnForRealFile(t,e,i,...o){f(e,i)||this.warn(t,e,...o)}#s(t,e,i,...o){const n=this.#r.get(i);if(!n)return;const s=Math.round(performance.now()-n);return this.#r.delete(i),this.#t({level:t,message:e,duration:s,args:o}),{message:e,timeMs:s}}#t({level:t,message:e,duration:i,scope:o,args:n}){if(!m(t,this.#n))return;let s=e&&h.interpolate(e,...n);s&&i!=null&&t!==r.VERBOSE&&c.sendTimingPerformedMessage([{object:"timing",timeMs:i,message:s}]);const a={level:t,message:s,duration:i,scope:o,context:this.#e};process.stderr.write(h.format(a))}}const R=new p;export{p as Logger,R as logger};
|
|
1
|
+
import{telemetry as c}from"../../telemetry/index.js";import{envConfig as l}from"../../config/env-config.js";import h,{LogLevel as r,shouldLog as m,parseLogLevel as u}from"./formatter.js";import{isVirtualFile as f}from"../../fs/utils/isVirtualFile.js";import{TerminalManager as g}from"./terminal-manager.js";class p{#e;#l;#i;#n;#r=new Map;#o=new Map;constructor({context:t,allowInteractive:e,minLogLevel:i}={}){this.#e=t,this.#l=l.isProductionEnv,this.#i=new g(e),this.#n=i??u(l.REDOCLY_LOG_LEVEL)??(l.isDevelopMode?r.INFO:r.HTTP)}shouldLog(t){return m(t,this.#n)}info(t,...e){this.#t({level:r.INFO,message:t,args:e})}infoTime(t,e,...i){return this.#s(r.INFO,e,t,...i)}success(t,...e){this.#t({level:r.SUCCESS,message:t,args:e})}logInFooter(t,e,...i){const o=h.interpolate(e,...i)+`
|
|
2
|
+
`;this.isInteractive()||this.#i.isFooterChanged(t,o)&&this.#t({level:r.INFO,message:e,args:i}),this.#i.updateFooter(t,o)}successTime(t,e,...i){return this.#s(r.SUCCESS,e,t,...i)}warn(t,...e){this.#t({level:r.WARN,message:t,args:e})}warnProd(t,...e){this.#l?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#t({level:r.ERROR,message:t,args:e})}contentError(t,...e){this.#t({level:r.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){this.#t({level:r.VERBOSE,message:t,args:e})}verboseTime(t,e,...i){return this.#s(r.VERBOSE,e,t,...i)}httpTime(t){return this.#s(r.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const i=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,i),e}updateContext(t){this.#e={...this.#e,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}isInteractive(){return this.#i.isInteractive()}warnForRealFile(t,e,i,...o){f(e,i)||this.warn(t,e,...o)}#s(t,e,i,...o){const n=this.#r.get(i);if(!n)return;const s=Math.round(performance.now()-n);return this.#r.delete(i),this.#t({level:t,message:e,duration:s,args:o}),{message:e,timeMs:s}}#t({level:t,message:e,duration:i,scope:o,args:n}){if(!m(t,this.#n))return;let s=e&&h.interpolate(e,...n);s&&i!=null&&t!==r.VERBOSE&&c.sendTimingPerformedMessage([{object:"timing",timeMs:i,message:s}]);const a={level:t,message:s,duration:i,scope:o,context:this.#e};process.stderr.write(h.format(a))}}const R=new p({allowInteractive:!0});export{p as Logger,R as logger};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class TerminalManager {
|
|
2
2
|
#private;
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(allowInteractive?: boolean);
|
|
4
4
|
isInteractive(): boolean;
|
|
5
5
|
isFooterChanged(id: string, content: string): boolean;
|
|
6
6
|
updateFooter(id: string, content: string): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{envConfig as p}from"../../config/env-config.js";import{gray as w}from"./helpers/colors.js";const t="\x1B[",
|
|
1
|
+
import{envConfig as p}from"../../config/env-config.js";import{gray as w}from"./helpers/colors.js";const t="\x1B[",l=`${t}6n`,i=`${t}s`,c=`${t}u`,f=`${t}J`,h=n=>`${t}1;${n}r`,d=`${t}r`,u=`${t}?25h`,R=`${t}?25l`,I=()=>`${w("\u2500".repeat(process.stderr.columns||80))}
|
|
2
2
|
|
|
3
|
-
`,g=3;class T{#s=new Map;#t=process.stderr.rows;#o=0;#i=!1;#c=!1;#r;constructor(s=!1){this.#c=s,this.#a(),
|
|
3
|
+
`,g=3;class T{#s=new Map;#t=process.stderr.rows;#o=0;#i=!1;#c=!1;#r;constructor(s=!1){this.#c=s,this.isInteractive()&&(this.#a(),process.stderr.write(l))}isInteractive(){return!!(this.#c&&process.stderr&&process.stderr.isTTY&&p.TERM!=="dumb"&&!("CI"in process.env)&&p.isDevelopMode)}isFooterChanged(s,r){return this.#s.get(s)!==r}updateFooter(s,r){const e=!this.#s.has(s);this.#s.set(s,r),this.isInteractive()&&(e?this.#p():this.#n())}get#e(){if(this.#s.size===0)return 0;let s=g;for(const r of this.#s.values())s+=(r.match(/\n/g)||[]).length;return s}#n(){if(!this.isInteractive()||this.#s.size===0||!this.#r)return;this.#h();const s=this.#e,r=process.stderr.rows;if(!(s>r)){process.stderr.write(i),process.stderr.cursorTo(0,r-s-1),process.stderr.write(f),process.stderr.cursorTo(0,r-s+1),process.stderr.write(I());for(const e of this.#s.values())process.stderr.write(e);process.stderr.write(c)}}#p(s=0){if(!this.isInteractive())return;const r=process.stderr.rows;let e=this.#e;e>r&&(e=0);const o=e-this.#o;this.#o=e,o>0&&(process.stderr.write(i),process.stderr.write(`
|
|
4
4
|
`.repeat(o)),process.stderr.write(c)),process.stderr.write(i),s<0&&process.stderr.write(`
|
|
5
|
-
`.repeat(e)),process.stderr.write(h(r-e)),process.stderr.write(c),this.#n()}#h(){this.#i||!this.#r||(this.#i=!0,this.#d(),process.stderr.write(R),process.on("exit",this.#w),process.stderr.on("resize",this.#
|
|
6
|
-
`.repeat(Math.max(0,r-e))),process.stderr.write(h(o)),process.stderr.write(c),process.stderr.cursorTo(0,0))}#a(){if(!this.isInteractive())return;process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const s=/\[(\d+);(\d+)R/;process.stdin.once("data",r=>{if(s.test(r)){const e=s.exec(r);if(e){const o=parseInt(e[1],10),a=parseInt(e[2],10);this.#r={row:o,col:a}}}process.stdin.setRawMode(!1)})}#w=()=>{this.isInteractive()&&(process.stderr.write(d),process.stderr.write(`${t}${process.stderr.rows};1H`),process.stderr.write(u))};#
|
|
5
|
+
`.repeat(e)),process.stderr.write(h(r-e)),process.stderr.write(c),this.#n()}#h(){this.#i||!this.#r||(this.#i=!0,this.#d(),process.stderr.write(R),process.on("exit",this.#w),process.stderr.on("resize",this.#l))}#d(){if(!this.#r)return;const s=process.stderr.rows,{row:r}=this.#r,e=this.#e,o=s-e;r<o||(process.stderr.write(i),process.stderr.write(d),process.stderr.cursorTo(0,s-1),process.stderr.write(`
|
|
6
|
+
`.repeat(Math.max(0,r-e))),process.stderr.write(h(o)),process.stderr.write(c),process.stderr.cursorTo(0,0))}#a(){if(!this.isInteractive())return;process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const s=/\[(\d+);(\d+)R/;process.stdin.once("data",r=>{if(s.test(r)){const e=s.exec(r);if(e){const o=parseInt(e[1],10),a=parseInt(e[2],10);this.#r={row:o,col:a}}}process.stdin.setRawMode(!1)})}#w=()=>{this.isInteractive()&&(process.stderr.write(d),process.stderr.write(`${t}${process.stderr.rows};1H`),process.stderr.write(u))};#l=()=>{const s=process.stderr.rows-this.#t;this.#t=process.stderr.rows,this.#p(s)}}export{T as TerminalManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCompleteCatalogConfig as
|
|
1
|
+
import{getCompleteCatalogConfig as j}from"../../../plugins/catalog-entities/get-complete-catalog-config.js";import{telemetryTraceStep as m}from"../../../telemetry/helpers/trace-step.js";import{CATALOG_FILTERS_CACHE_NAMESPACE as b,ALLOWED_CATALOG_QUERY_PARAMS as F}from"../../../constants/plugins/catalog-entities.js";import{CATALOG_ENTITY_ID as f}from"../../../../constants/common.js";import{allowlistObject as _}from"../../../../utils/object/allowlist-object.js";import{isValidIsoDate as R}from"../../../utils/is-valid-iso-date.js";import{CatalogEntitiesService as q}from"../../../plugins/catalog-entities/database/catalog-entities-service.js";import{createPaginationParamsValidator as I}from"../../../providers/database/pagination/schemas.js";import{createEntityRelationDtoFromFileSchema as O}from"../../../plugins/catalog-entities/database/mappers/create-entity-relation-dto-from-file-schema.js";import{CacheService as C}from"../../../persistence/cache/services/cache-service.js";import{hasAccessToEntity as w}from"./helpers/has-access-to-entity.js";import{getRbacRestrictionsDataForCatalog as T}from"../helpers/get-rbac-restrictions-data-for-catalog.js";import{mapEntityReadModelSchemaToEntityReadDto as g}from"./mappers/map-entity-read-model-schema-to-entity-read-dto.js";import{parseEntity as D}from"./parsers/entities/parse-entity.js";import{parseEntityUpdateData as P}from"./parsers/entities/parse-entity-update-data.js";import{parseEntities as v}from"./parsers/entities/parse-entities.js";import{upsertPagesStats as h}from"./helpers/upsert-pages-stats.js";const N=["type","key","title","summary","tags","metadata","metadata.*","git","contact","links","id","source","sourceFile","createdAt","updatedAt"],A=async n=>{await(await C.getInstance({baseDbDir:n})).deleteByNamespace(b)},W=async({catalogEntitiesService:n,ctx:e,store:u})=>m("catalog_entities.get_entities",async o=>{const i=e.get("logger");try{const r=e.req.query();o?.setAttribute("queryParams",JSON.stringify(_(r,F)));const{currentRbacTeamsForRead:d,excludedTypes:t,excludedEntities:s}=T({store:u,ctx:e}),c=I(N).parse(r),y=await n.getEntities({paginationParams:c,rbacTeams:d,excludedTypes:t,excludedEntities:s});return o?.setAttribute("entitiesCount",y.items.length),e.json({...y,items:y.items.map(g)})}catch(r){return i.error(r),o?.error(r),e.json({message:"Failed to get entities"},500)}}),k=async({catalogEntitiesService:n,ctx:e,store:u})=>m("catalog_entities.get_entity",async o=>{const i=e.req.param(f);if(!i)return o?.error(new Error("Entity id is required")),e.json({message:"Entity id is required"},400);o?.setAttribute("pathParams",JSON.stringify({entityId:i}));const{currentRbacTeamsForRead:r,excludedTypes:d,excludedEntities:t}=T({store:u,ctx:e}),s=await n.getEntityById(i,{rbacTeams:r,excludedTypes:d,excludedEntities:t});return s?(o?.setAttribute("entity",JSON.stringify(s)),e.json(g(s))):(o?.error(new Error("Entity not found")),e.json({message:"Entity not found"},404))}),L=async({catalogEntitiesService:n,ctx:e,catalogConfig:u,serverOutDir:o,store:i})=>m("catalog_entities.create_entity",async r=>{const d=e.get("logger");try{const t=await e.req.json();r?.setAttribute("requestBody",JSON.stringify(t));const s=D(t,u);if(!w({ctx:e,store:i,accessLevel:"WRITE",entityType:s.type,entityKey:s.key}))return r?.error(new Error("Access denied")),e.json({message:"Access denied"},403);const y=await n.remoteTransaction(async()=>{const a=await n.createEntity(s),l=s.relations?.map(E=>O(s.key,E));return await n.createEntitiesRelations(l??[]),await h({ctx:e,catalogEntitiesService:n,addedEntities:a?[a]:void 0}),a});return y?(A(o),r?.setAttribute("entity",JSON.stringify(y)),e.json(g(y))):(r?.error(new Error("Failed to create entity")),e.json({message:"Failed to create entity"},500))}catch(t){return d.error(t),t instanceof Error&&t.message.includes("validation failed")?(r?.error(new Error(t.message)),e.json({message:t.message},400)):(r?.error(t),e.json({message:"Failed to create entity"},500))}}),J=async({catalogEntitiesService:n,ctx:e,catalogConfig:u,serverOutDir:o,store:i})=>m("catalog_entities.bulk_upsert_entities",async r=>{const d=e.get("logger");try{const t=await e.req.json();r?.setAttribute("requestBody",JSON.stringify(t));const s=v(t,u);for(const a of s)if(!w({ctx:e,store:i,accessLevel:"WRITE",entityType:a.type,entityKey:a.key}))return r?.error(new Error("Access denied")),e.json({message:"Access denied"},403);const c=await n.remoteTransaction(async()=>{const a=await n.createEntities(s),l=a.reduce((E,p)=>(p.status==="ok"&&p.resource!=null&&E.push(p.resource),E),[]);return await h({ctx:e,catalogEntitiesService:n,addedEntities:l}),a});if(!c.length)return r?.error(new Error("Failed to create entities")),e.json({message:"Failed to create entities"},500);A(o);const y=c.filter(a=>a.status==="ok");return r?.setAttribute("totalSuccess",y.length),r?.setAttribute("totalFailed",c.length-y.length),e.json(y.map(a=>({...a,resource:g(a.resource)})),207)}catch(t){return d.error(t),t instanceof Error&&t.message.includes("validation failed")?(r?.error(new Error(t.message)),e.json({message:t.message},400)):(r?.error(t),e.json({message:"Failed to create entities"},500))}}),B=async({catalogEntitiesService:n,ctx:e,catalogConfig:u,serverOutDir:o,store:i})=>m("catalog_entities.update_entity",async r=>{const d=e.get("logger"),t=e.req.param(f);if(!t)return r?.error(new Error("Entity id is required")),e.json({message:"Entity id is required"},400);r?.setAttribute("pathParams",JSON.stringify({entityId:t}));try{const s=await e.req.json();r?.setAttribute("requestBody",JSON.stringify(s));const c=await n.getEntityById(t);if(!c)return r?.error(new Error(`Entity with id: ${t} not found`)),e.json({message:`Entity with id: ${t} not found`},404);if(!w({ctx:e,store:i,accessLevel:"WRITE",entityType:s.type??c.type,entityKey:s.key??c.key}))return r?.error(new Error("Access denied")),e.json({message:"Access denied"},403);const a=P(s,u,s?.type??c.type);if(a.revision&&!R(a.revision))throw new Error("Entity validation failed: 'entity.revision' must be a valid ISO 8601 date-time string");const l=await n.updateEntity(a,c);return l?(A(o),r?.setAttribute("entity",JSON.stringify(l)),e.json(g(l))):(r?.error(new Error("Failed to update entity")),e.json({message:"Failed to update entity"},500))}catch(s){return d.error(s),s instanceof Error&&s.message.includes("validation failed")?(r?.error(new Error(s.message)),e.json({message:s.message},400)):(r?.error(s),e.json({message:s.message},500))}}),U=async({catalogEntitiesService:n,ctx:e,serverOutDir:u,store:o})=>m("catalog_entities.delete_entity",async i=>{const r=e.get("logger"),d=e.req.param(f);if(!d)return i?.error(new Error("Entity id is required")),e.json({message:"Entity id is required"},400);i?.setAttribute("pathParams",JSON.stringify({entityId:d}));try{const t=await n.getEntityById(d);return t?w({ctx:e,store:o,accessLevel:"WRITE",entityType:t.type,entityKey:t.key})?await n.remoteTransaction(async()=>{const y=await n.deleteEntity(t);return y?(await h({ctx:e,catalogEntitiesService:n,removedEntities:t?[t]:void 0}),y):null})?(A(u),new Response(null,{status:204})):(i?.error(new Error("Failed to delete entity")),e.json({message:"Failed to delete entity"},500)):(i?.error(new Error("Access denied")),e.json({message:"Access denied"},403)):new Response(null,{status:204})}catch(t){return r.error(t),i?.error(t),e.json({message:"Failed to delete entity"},500)}}),G={GET:W,POST:L,PUT:J},H={GET:k,DELETE:U,PATCH:B};function oe(n){return async e=>m("catalog_entities",async u=>{const o=await q.getInstance({baseDbDir:n.serverOutDir}),i=e.req.method;u?.setAttribute("method",i);const r=e.req.param(f)?H:G,d=j(n.config.entitiesCatalog),t=r[i];return t?await t({catalogEntitiesService:o,ctx:e,catalogConfig:d,serverOutDir:n.serverOutDir,store:n}):(u?.error(new Error("Method not allowed")),e.json({message:"Method not allowed"},405))})}export{oe as catalogHandler};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { CatalogEntitiesService } from '../../../../plugins/catalog-entities/database/catalog-entities-service';
|
|
3
|
+
import type { EntityReadModelSchema } from '../../../../plugins/catalog-entities/schemas/read-model-schemas';
|
|
4
|
+
type UpsertPagesStatsParams = {
|
|
5
|
+
ctx: Context;
|
|
6
|
+
catalogEntitiesService: CatalogEntitiesService;
|
|
7
|
+
addedEntities?: EntityReadModelSchema[];
|
|
8
|
+
removedEntities?: EntityReadModelSchema[];
|
|
9
|
+
};
|
|
10
|
+
export declare function upsertPagesStats({ ctx, catalogEntitiesService, addedEntities, removedEntities, }: UpsertPagesStatsParams): Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=upsert-pages-stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{envConfig as t}from"../../../../config/env-config.js";async function f({ctx:o,catalogEntitiesService:r,addedEntities:s,removedEntities:n}){if(t.REDOCLY_ENV!=="production"){o.get("logger").info("Skipping pages stats upsert in non-production environment");return}if(!t.BH_API_URL||!t.ORGANIZATION_ID||!t.PROJECT_ID)throw new Error("Pages stats service not configured");const a=o.req.header("apiKey");if(!a)throw new Error("API key is required to upsert pages stats");const{total:i}=await r.getDuplicatedEntitiesCount(s,n),{total:p}=await r.getEntitiesCount("remote",s,n?.length),g={remoteEntityPages:p,duplicatedEntityPages:i,isReported:!1},c=new URL(`/api/orgs/${t.ORGANIZATION_ID}/projects/${t.PROJECT_ID}/project-pages-stats`,t.BH_API_URL).toString();try{const e=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(g)});if(!e.ok)throw new Error(e.statusText)}catch(e){throw new Error(`Failed to upsert project pages stats: ${e?.message}`)}}export{f as upsertPagesStats};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withPathPrefix as
|
|
2
|
-
Usage: ${o}/https://api.example.com/path`);const
|
|
1
|
+
import{withPathPrefix as _}from"@redocly/theme/core/utils";import{ServerRoutes as q}from"../../../constants/common.js";import{getRequestOrigin as C}from"../utils/get-request-origin.js";const P=new Set(["connection","keep-alive","proxy-authenticate","proxy-connection","proxy-authorization","te","trailer","transfer-encoding","upgrade","host"]),$=new Set(["cookie","cookie2","accept-encoding"]),T=new Set(["set-cookie","set-cookie2","content-encoding","content-length"]),g="x-redocly-proxy-streaming",H="x-http-method-override",w="x-redocly-cookie";function z(o=_(q.CORS_PROXY)){return async e=>{const n=new URL(e.req.url).pathname;if(n===o||n===`${o}/`)return e.text(`Realm CORS proxy endpoint.
|
|
2
|
+
Usage: ${o}/https://api.example.com/path`);const r=I(e.req.url,o);if(!r)return e.text("Invalid proxied URL",400);const i=C(e),c=r.origin===i,h=r.pathname===o||r.pathname.startsWith(`${o}/`);if(c&&!h)return new Response("Please use a direct request",{status:308,headers:{Location:r.toString(),Vary:"origin","Cache-Control":"private"}});const s=new Headers,f=S(e.req.raw.headers);for(const[t,E]of e.req.raw.headers)f.has(t.toLowerCase())||$.has(t.toLowerCase())||s.append(t,E);const d=s.get(w);if(d){const t=e.req.raw.headers.get("cookie")||"";s.set("cookie",t?`${t}; ${d}`:d),s.delete(w)}const u=e.req.raw.headers.get("origin")||"";L(u)&&s.delete("origin");let p=e.req.method;const R=s.get(H);R&&(p=R.toUpperCase(),s.delete(H));const m={method:p,headers:s,redirect:"follow"};p!=="GET"&&p!=="HEAD"&&e.req.raw.body&&(m.body=e.req.raw.body,m.duplex="half");let a;try{a=await fetch(r,m)}catch(t){const E=t instanceof Error?t.message:"unknown error",O=t instanceof Error&&t.cause instanceof Error?`: ${t.cause.message}`:"";return e.text(`Failed to proxy request: ${E}${O}`,502)}const l=new Headers(a.headers),y=S(a.headers);for(const t of y)l.delete(t);for(const t of T)l.delete(t);return l.set(g,"1"),new Response(a.body,{status:a.status,statusText:a.statusText,headers:l})}}function k(o){try{return decodeURIComponent(o)}catch{return o}}function D(o){return o.replace(/^(https?):\/(?!\/)/i,"$1://")}function A(o,e){return e?o.includes("?")?e==="?"?o:`${o.endsWith("?")||o.endsWith("&")?o:`${o}&`}${e.slice(1)}`:`${o}${e}`:o}function S(o){const e=new Set(P),n=o.get("connection");if(!n)return e;for(const r of n.split(",")){const i=r.trim().toLowerCase();i&&e.add(i)}return e}function L(o){const e=o.toLowerCase();return e.includes(".redocly.app")||e.includes("localhost")}function I(o,e){const n=new URL(o),r=n.pathname===e,i=n.pathname.startsWith(`${e}/`);if(!r&&!i)return null;const c=n.pathname.slice(e.length).replace(/^\/+/,"");if(!c)return null;const h=[c,k(c)];for(const s of h){const f=D(s),d=A(f,n.search);try{const u=new URL(d);if(u.protocol==="http:"||u.protocol==="https:")return u}catch{continue}}return null}const U=g;export{U as CORS_PROXY_STREAM_HEADER,z as corsProxyHandler,I as resolveCorsProxyTarget};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCursor as l}from"../../providers/database/pagination/utils/create-cursor.js";import{
|
|
1
|
+
import{createCursor as l}from"../../providers/database/pagination/utils/create-cursor.js";import{DEFAULT_LIMIT as o}from"../../providers/database/pagination/limit.js";function c(e){return!!(e.after||e.before)}function g(e,i,r){const n=c(i),t=i.limit??o;if(n){if(i.before)return!0;if(i.after)return e.length===t}return r!==void 0&&i.skip!==void 0?i.skip+t<r:r!==void 0?t<r:e.length===t}function h(e){return!!(e.after||e.before||e.skip!==void 0&&e.skip>0)}function d({data:e,params:i,totalCount:r,nameTransformationsFromDatabase:n={},hasMore:t}){if(!e.length)return{object:"list",items:[],page:{total:0,limit:i.limit??o,hasNextPage:!1,hasPrevPage:!1,startCursor:null,endCursor:null}};const f=i.sort?.length?i.sort:[{field:"id",order:"ASC"}],s=t??g(e,i,r),u=h(i);return{object:"list",items:e,page:{total:r??0,limit:i.limit??o,hasNextPage:s,hasPrevPage:u,startCursor:l(e[0],f,n),endCursor:l(e[e.length-1],f,n)}}}export{d as prepareListResponse};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/reef",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0-next.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@opentelemetry/sdk-trace-web": "2.0.1",
|
|
30
30
|
"@opentelemetry/semantic-conventions": "1.34.0",
|
|
31
31
|
"@redocly/ajv": "8.18.0",
|
|
32
|
-
"@redocly/openapi-core": "2.20.
|
|
32
|
+
"@redocly/openapi-core": "2.20.5",
|
|
33
33
|
"@shikijs/transformers": "3.21.0",
|
|
34
34
|
"@tanstack/react-query": "5.62.3",
|
|
35
35
|
"@tanstack/react-table": "8.21.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"fetch-to-node": "^2.1.0",
|
|
52
52
|
"fflate": "0.7.4",
|
|
53
53
|
"flexsearch": "0.7.43",
|
|
54
|
-
"graphql": "16.
|
|
54
|
+
"graphql": "16.12.0",
|
|
55
55
|
"gray-matter": "4.0.3",
|
|
56
56
|
"hono": "4.11.10",
|
|
57
57
|
"htmlparser2": "8.0.2",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"nanoid": "5.0.9",
|
|
65
65
|
"node-fetch": "3.3.1",
|
|
66
66
|
"nprogress": "0.2.0",
|
|
67
|
-
"openapi-sampler": "1.7.
|
|
67
|
+
"openapi-sampler": "^1.7.2",
|
|
68
68
|
"os-browserify": "0.3.0",
|
|
69
69
|
"path-browserify": "1.0.1",
|
|
70
70
|
"picomatch": "2.3.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"reactjs-popup": "2.0.6",
|
|
78
78
|
"semver": "7.7.3",
|
|
79
79
|
"shiki": "3.21.0",
|
|
80
|
-
"simple-git": "3.
|
|
80
|
+
"simple-git": "3.32.3",
|
|
81
81
|
"sitemap": "7.1.1",
|
|
82
82
|
"stream-http": "3.2.0",
|
|
83
83
|
"styled-components": "5.3.11",
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"xpath": "0.0.34",
|
|
92
92
|
"yaml-ast-parser": "0.0.43",
|
|
93
93
|
"zod": "^3.25.76",
|
|
94
|
-
"@redocly/asyncapi-docs": "1.
|
|
95
|
-
"@redocly/config": "0.44.
|
|
96
|
-
"@redocly/graphql-docs": "1.
|
|
97
|
-
"@redocly/openapi-docs": "3.
|
|
98
|
-
"@redocly/portal-legacy-ui": "0.
|
|
99
|
-
"@redocly/portal-plugin-mock-server": "0.
|
|
100
|
-
"@redocly/realm-asyncapi-sdk": "0.
|
|
101
|
-
"@redocly/theme": "0.
|
|
94
|
+
"@redocly/asyncapi-docs": "1.9.0-next.0",
|
|
95
|
+
"@redocly/config": "0.44.1",
|
|
96
|
+
"@redocly/graphql-docs": "1.9.0-next.0",
|
|
97
|
+
"@redocly/openapi-docs": "3.20.0-next.0",
|
|
98
|
+
"@redocly/portal-legacy-ui": "0.15.0-next.0",
|
|
99
|
+
"@redocly/portal-plugin-mock-server": "0.17.0-next.0",
|
|
100
|
+
"@redocly/realm-asyncapi-sdk": "0.10.0-next.0",
|
|
101
|
+
"@redocly/theme": "0.64.0-next.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{detectSpec as m,getTypes as f,normalizeTypes as d,normalizeVisitors as u,resolveDocument as w,BaseResolver as h,StatsOAS as S,walkDocument as y}from"@redocly/openapi-core";import{logger as l}from"../../../server/tools/notifiers/logger.js";import{envConfig as g}from"../../../server/config/env-config.js";import{telemetryTraceStep as D}from"../../telemetry/helpers/trace-step.js";import{telemetry as I}from"../../telemetry/index.js";const t={refs:{metric:"References",total:0,color:"red",items:new Set},externalDocs:{metric:"External Documents",total:0,color:"magenta"},schemas:{metric:"Schemas",total:0,color:"white"},parameters:{metric:"Parameters",total:0,color:"yellow",items:new Set},links:{metric:"Links",total:0,color:"cyan",items:new Set},pathItems:{metric:"Path Items",total:0,color:"green"},webhooks:{metric:"Webhooks",total:0,color:"green"},operations:{metric:"Operations",total:0,color:"yellow"},tags:{metric:"Tags",total:0,color:"white",items:new Set}};async function T(s,a){await D("stats.openapi",async()=>{l.info("OpenAPI collector: start processing documents...");const e=(await s.cache.load(".","load-oas-docs")).data,o=[];for(const r of e)if(!r.isVirtual){const n=await v(r);o.push(n),I.sendStatsOpenapiCollectedMessage([{...n,projectBuildId:g.PROJECT_BUILD_ID||""}])}a||console.table(o),l.info("OpenAPI collector: openapi docments processing completed.")})}async function v(s){const a=s.definition,e=m(a),o=d(f(e)),r=u([{severity:"warn",ruleId:"openapi_stats",visitor:S(t)}],o),n={problems:[],specVersion:e,visitorsData:{}},c={source:{absoluteRef:""},parsed:a},i=o.Root;if(!i)throw new Error("Root type not found in OpenAPI spec types");const p=await w({rootDocument:c,rootType:i,externalRefResolver:new h});return y({rootType:i,normalizedVisitors:r,resolvedRefMap:p,document:c,ctx:n}),{path:s.relativePath,refs:t.refs.total,externalDocs:t.externalDocs.total,schemas:t.schemas.total,parameters:t.parameters.total,links:t.links.total,pathItems:t.pathItems.total,webhooks:t.webhooks.total,operations:t.operations.total,tags:t.tags.total,version:e}}export{T as collectOpenapiDocumentsStatistics};
|