@redocly/redoc 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 +185 -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{and as u,count as
|
|
1
|
+
import{and as u,count as A,eq as E,isNotNull as q,notExists as h,or as J,sql as e}from"drizzle-orm";import{unionAll as T}from"drizzle-orm/sqlite-core";import{logger as g}from"../../../../../tools/notifiers/logger.js";import{VERSION_NOT_SPECIFIED as L}from"@redocly/theme/core/constants";import{applyPagination as v}from"../../../../../providers/database/pagination/index.js";import{applyFilter as P}from"../../../../../providers/database/pagination/filter.js";import{createEntityFieldsForSelect as p,FIELDS_TO_SELECT_FOR_ENTITY as N,FIELDS_TO_SELECT_FOR_ENTITY_RELATION as d}from"../utils.js";import{createEntityReadModel as $}from"../../mappers/create-entity-read-model.js";import{entitiesTable as i}from"../../../../../providers/database/databases/catalog-sqlite/schemas/entities-table.js";import{entitiesRelationsTable as y}from"../../../../../providers/database/databases/catalog-sqlite/schemas/entities-relations-table.js";import{entitiesAttributesTable as _}from"../../../../../providers/database/databases/catalog-sqlite/schemas/entities-attributes-table.js";import{CatalogEntitiesRelationsRepository as D}from"./catalog-entities-relations-repository.js";import{CatalogEntitiesBffRepository as M}from"./catalog-entities-bff-repository.js";import{createMergedEntityFieldsForSelect as j}from"../utils/create-merged-entity-fields-for-select.js";import{buildSemanticVersionSortExpr as B}from"../utils/semantic-version-sort.js";import{normalizeRevisionFlags as x}from"../utils/normalize-revision-flags.js";import{buildEntitiesExclusionFilter as R}from"../utils/build-entities-exclusion-filter.js";import{buildRbacFilter as S,buildRbacFilterRaw as Y}from"../utils/build-rbac-filter.js";import{createEntityRelationReadModel as U}from"../../mappers/create-entity-relation-read-model.js";class ye{#e;#t=void 0;#i;#s;constructor(t){this.#e=t,this.#i=new D(this.#e,this.#t||""),this.#s=new M(this.#e,this.#t||"")}async attachDatabase(t){this.#t!==t&&(this.#t=t,await this.#e.client.run(e`ATTACH DATABASE ${t} AS remote`),this.#i=new D(this.#e,t),this.#s=new M(this.#e,t))}async getEntities({paginationParams:t,rbacTeams:s,excludedTypes:n,excludedEntities:r}){const o=R(n,r,"remote.entities"),l=R(n,r,"entities"),a=R(n,r,"r"),c=this.#t?T(this.#e.client.select(p("remote.entities")).from(e`remote.entities`).leftJoin(e`remote.entities_attributes`,E(i.key,_.entityKey)).where(u(S(s,"remote.entities_attributes"),o,h(this.#e.client.select({id:N.id}).from(i).where(u(e`${i.key} = remote.entities.key`,e`${i.version} = remote.entities.version`,e`${i.revision} = remote.entities.revision`))))),this.#e.client.select(p("entities")).from(i).leftJoin(_,E(i.key,_.entityKey)).where(u(S(s,"entities_attributes"),l,h(this.#e.client.select({id:e.raw("id")}).from(e`remote.entities as r`).where(u(e`r.key = ${i.key}`,e`r.version = ${i.version}`,e`r.revision = ${i.revision}`))))),this.#e.client.select(j("r","l")).from(e`remote.entities as r`).innerJoin(e`entities as l`,e`l.key = r.key AND l.version = r.version AND l.revision = r.revision`).leftJoin(e`entities_attributes as ea`,e`l.key = ea.entity_key`).where(u(S(s,"ea"),a))):this.#e.client.select(p("entities")).from(i).leftJoin(_,E(i.key,_.entityKey)).where(u(S(s,"entities_attributes"),l)),m=this.#e.client.select(N).from(c.as("combined_entities")),f=this.#e.client.select(N).from(c.as("combined_entities")).$dynamic(),k=v(f,{...t,limit:void 0,skip:void 0,after:void 0,before:void 0}),O=this.#e.client.$count(k),w=m.$dynamic(),C=t.limit||10,W=v(w,{...t,limit:C+1}),[H,V]=await Promise.all([W.run(),O]),F=H.rows,X=F.length>C;return{items:F.slice(0,C).map(I=>$(I)).filter(I=>I!==null),hasMore:X,total:V}}async getEntityKeysAndVersionsBySourceFile(t){const s=this.#t?T(this.#e.client.select({keyVersion:e`key || ':' || COALESCE(version, ${L})`.as("keyVersion")}).from(e`remote.entities`).where(u(e`source_file = ${t}`,e`source = 'file'`,e`key IS NOT NULL`)),this.#e.client.select({keyVersion:e`${i.key} || ':' || COALESCE(${i.version}, ${L})`.as("keyVersion")}).from(i).where(u(E(i.sourceFile,t),E(i.source,"file"),e`${i.key} IS NOT NULL`,h(this.#e.client.select({key:e.raw("key")}).from(e`remote.entities as remote`).where(e`remote.key = ${i.key}`))))):this.#e.client.select({keyVersion:e`${i.key} || ':' || COALESCE(${i.version}, ${L})`.as("keyVersion")}).from(i).where(u(E(i.sourceFile,t),E(i.source,"file"),q(i.key))),n=await this.#e.client.selectDistinct({keyVersion:e`combined_keys_versions.keyVersion`}).from(s.as("combined_keys_versions")).run();return new Set(n.rows.map(r=>r.keyVersion))}async listEntityRevisions(t,s){const n=[E(i.key,t),E(i.isDeleted,!1),...s?[E(i.version,s)]:[]],r={version:e.raw("version"),revision:e.raw("revision"),isCurrent:e.raw("is_current"),createdAt:e.raw("created_at"),updatedAt:e.raw("updated_at"),isDefaultVersion:e.raw("is_default_version")},o=this.#t?T(this.#e.client.select(r).from(e`remote.entities`).where(u(e`key = ${t}`,e`is_deleted = 0`,s?e`version = ${s}`:void 0,h(this.#e.client.select({id:e.raw("id")}).from(i).where(u(e`${i.key} = remote.entities.key`,e`${i.version} = remote.entities.version`,e`${i.revision} = remote.entities.revision`))))),this.#e.client.select({version:i.version,revision:i.revision,isCurrent:i.isCurrent,createdAt:i.createdAt,updatedAt:i.updatedAt,isDefaultVersion:i.isDefaultVersion}).from(i).where(u(...n,h(this.#e.client.select({id:e.raw("id")}).from(e`remote.entities as r`).where(u(e`r.key = ${i.key}`,e`r.version = ${i.version}`,e`r.revision = ${i.revision}`))))),this.#e.client.select({version:e.raw("r.version AS version"),revision:e.raw("r.revision AS revision"),isCurrent:e.raw("MAX(r.is_current, l.is_current) AS is_current"),createdAt:e.raw("MIN(r.created_at, l.created_at) AS created_at"),updatedAt:e.raw("MAX(r.updated_at, l.updated_at) AS updated_at"),isDefaultVersion:e.raw("MAX(r.is_default_version, l.is_default_version) AS is_default_version")}).from(e`remote.entities as r`).innerJoin(e`entities as l`,e`l.key = r.key AND l.version = r.version AND l.revision = r.revision`).where(u(e`r.key = ${t}`,e`r.is_deleted = 0`,e`l.is_deleted = 0`,s?e`r.version = ${s}`:void 0))):this.#e.client.select({version:i.version,revision:i.revision,isCurrent:i.isCurrent,createdAt:i.createdAt,updatedAt:i.updatedAt,isDefaultVersion:i.isDefaultVersion}).from(i).where(u(...n)),a=(await this.#e.client.select({version:e.raw("version"),revision:e.raw("revision"),isCurrent:e.raw("is_current"),createdAt:e.raw("created_at"),updatedAt:e.raw("updated_at"),isDefaultVersion:e.raw("is_default_version")}).from(o.as("combined_revisions")).orderBy(e`${B("version")} DESC`,e.raw("revision DESC")).run()).rows.map(c=>({version:c.version,revision:c.revision??"",isCurrent:c.is_current!==null?!!c.is_current:!1,createdAt:c.created_at,updatedAt:c.updated_at,isDefaultVersion:c.is_default_version!==null?!!c.is_default_version:!1}));return x(a),a}async getEntitiesCountByTypes(){if(this.#t){const t=e`
|
|
2
2
|
SELECT key, type, version,
|
|
3
3
|
ROW_NUMBER() OVER (
|
|
4
4
|
PARTITION BY key
|
|
@@ -9,7 +9,7 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
9
9
|
UNION ALL
|
|
10
10
|
SELECT key, type, version FROM entities WHERE is_current = 1 AND is_deleted = 0
|
|
11
11
|
)
|
|
12
|
-
`;return this.#e.client.select({type:e`type`,count:
|
|
12
|
+
`;return this.#e.client.select({type:e`type`,count:A()}).from(e`(SELECT * FROM (${t}) WHERE rn = 1) as highest_version_entities`).groupBy(e`type`)}return this.#e.client.select({type:i.type,count:A()}).from(i).where(u(E(i.isCurrent,!0),E(i.isDeleted,!1))).groupBy(i.type)}async getEntityById(t,s){const{rbacTeams:n,excludedTypes:r,excludedEntities:o}=s||{},l=R(r,o,"remote.entities"),a=R(r,o,"entities"),f=(await(this.#t?T(this.#e.client.select(p("remote.entities")).from(e`remote.entities`).leftJoin(e`remote.entities_attributes`,E(i.key,_.entityKey)).where(u(e`remote.entities.id = ${t}`,S(n,"remote.entities_attributes"),l)),this.#e.client.select(p("entities")).from(i).leftJoin(_,E(i.key,_.entityKey)).where(u(E(i.id,t),S(n,"entities_attributes"),a))):this.#e.client.select(p("entities")).from(i).leftJoin(_,E(i.key,_.entityKey)).where(u(E(i.id,t),S(n,"entities_attributes"),a))).run()).rows[0];return f?$(f):null}async getOutdatedEntities(t){const s=this.#t?T(this.#e.client.select(N).from(e`remote.entities`),this.#e.client.select(N).from(i).where(h(this.#e.client.select({id:N.id}).from(e`remote.entities as remote`).where(e`remote.key = ${i.key}`)))):this.#e.client.select(N).from(i),n=this.#e.client.select(N).from(s.as("combined_entities")).$dynamic(),{whereCondition:r}=P(n,t),o=J(e`combined_entities.scorecards_status = 'OUTDATED'`,e`combined_entities.scorecards_status IS NULL`),l=r?u(r,o):o;return(await n.where(l).run()).rows.map(c=>$(c)).filter(c=>c!==null)}async getEntitiesRelations(t={}){const s=this.#t?T(this.#e.client.select(d).from(e`remote.entities_relations`),this.#e.client.select(d).from(y).where(h(this.#e.client.select({id:d.id}).from(e`remote.entities_relations as remote`).where(e`remote.source_key = ${y.sourceKey}`)))):this.#e.client.select(d).from(y),n=this.#e.client.select(d).from(s.as("combined_entities_relations")).$dynamic(),r=this.#e.client.select(d).from(s.as("combined_entities_relations")).$dynamic(),o=v(r,{...t,limit:void 0,skip:void 0,after:void 0,before:void 0}),l=this.#e.client.$count(o),a=t.limit||10,c=v(n,{...t,limit:a+1}),[m,f]=await Promise.all([c.run(),l]),k=m.rows,O=k.length>a;return{items:k.slice(0,a).map(w=>U(w)).filter(w=>w!==null),hasMore:O,total:f}}async getEntityRelationById(t){const r=(await(this.#t?T(this.#e.client.select(d).from(e`remote.entities_relations`).where(E(y.id,t)),this.#e.client.select(d).from(y).where(u(E(y.id,t),h(this.#e.client.select({id:d.id}).from(e`remote.entities_relations as remote`).where(e`remote.id = ${y.id}`))))):this.#e.client.select(d).from(y).where(E(y.id,t))).run()).rows[0];return r?U(r):null}async getEntitiesWithRelations({paginationParams:t,rbacTeams:s,excludedEntities:n,excludedTypes:r}){return this.#s.getEntitiesWithRelations({paginationParams:t,rbacTeams:s,excludedEntities:n,excludedTypes:r})}async getEntityWithRelationsByKey({entityKey:t,filter:s,rbacTeams:n,excludedTypes:r,excludedEntities:o}){return this.#s.getEntityWithRelationsByKey({entityKey:t,filter:s,rbacTeams:n,excludedTypes:r,excludedEntities:o})}async getRelationsForEntity(t,s,n){return this.#i.getRelationsForEntity(t,s,n)}async getRelatedEntities({key:t,paginationParams:s,rbacTeams:n,excludedTypes:r,excludedEntities:o}){return this.#i.getRelatedEntities({key:t,paginationParams:s,rbacTeams:n,excludedTypes:r,excludedEntities:o})}async getCatalogFilters({entitiesTypes:t=[],emptyFilters:s=[],rbacTeams:n,excludedTypes:r,excludedEntities:o}){if(!s.length)return{};try{return await this.#n({entitiesTypes:t,rbacTeams:n,excludedTypes:r,excludedEntities:o}),(s.includes("domains")||s.includes("owners"))&&await this.#o(),await this.#a(s)}catch(l){return console.error("Error fetching catalog filters:",l),{}}finally{await this.#u()}}async#n({entitiesTypes:t,rbacTeams:s,excludedTypes:n,excludedEntities:r}){const o=Y(s,"ea"),l=this.#r(n,r);if(this.#t){const a=["e.is_current = 1","e.is_deleted = 0"];o&&a.push(o),l&&a.push(l.replace(/ENTITY_ALIAS/g,"e"));const c=["r.key IS NULL","e.is_current = 1","e.is_deleted = 0"];o&&c.push(o),l&&c.push(l.replace(/ENTITY_ALIAS/g,"e")),await this.#e.client.run(e.raw(`
|
|
13
13
|
CREATE TEMP TABLE IF NOT EXISTS temp_combined_entities AS
|
|
14
14
|
SELECT
|
|
15
15
|
e.key,
|
|
@@ -28,8 +28,8 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
28
28
|
FROM entities e
|
|
29
29
|
LEFT JOIN remote.entities r ON r.key = e.key AND r.is_current = 1
|
|
30
30
|
LEFT JOIN entities_attributes ea ON ea.entity_key = e.key
|
|
31
|
-
WHERE ${
|
|
32
|
-
`))}else{const a=["e.is_current = 1","e.is_deleted = 0"];o&&a.push(o),
|
|
31
|
+
WHERE ${c.join(" AND ")}
|
|
32
|
+
`))}else{const a=["e.is_current = 1","e.is_deleted = 0"];o&&a.push(o),l&&a.push(l.replace(/ENTITY_ALIAS/g,"e")),await this.#e.client.run(e.raw(`
|
|
33
33
|
CREATE TEMP TABLE IF NOT EXISTS temp_combined_entities AS
|
|
34
34
|
SELECT
|
|
35
35
|
e.key,
|
|
@@ -39,7 +39,7 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
39
39
|
FROM entities e
|
|
40
40
|
LEFT JOIN entities_attributes ea ON ea.entity_key = e.key
|
|
41
41
|
WHERE ${a.join(" AND ")}
|
|
42
|
-
`))}if(
|
|
42
|
+
`))}if(t.length){const a=t.map(c=>`'${c.replace(/'/g,"''")}'`).join(",");await this.#e.client.run(e.raw(`
|
|
43
43
|
CREATE TEMP TABLE IF NOT EXISTS temp_filtered_entities AS
|
|
44
44
|
SELECT * FROM temp_combined_entities
|
|
45
45
|
WHERE type IN (${a})
|
|
@@ -48,7 +48,7 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
48
48
|
SELECT * FROM temp_combined_entities
|
|
49
49
|
`);await this.#e.client.run(e`
|
|
50
50
|
CREATE INDEX IF NOT EXISTS idx_temp_filtered_type ON temp_filtered_entities(type)
|
|
51
|
-
`)}#
|
|
51
|
+
`)}#r(t,s){const n=[];if(t&&t.length>0){const r=t.map(o=>`'${o.replace(/'/g,"''")}'`).join(", ");n.push(`ENTITY_ALIAS.type NOT IN (${r})`)}if(s&&s.length>0){const r=s.map(o=>`'${o.replace(/'/g,"''")}'`).join(", ");n.push(`ENTITY_ALIAS.key NOT IN (${r})`)}return n.length>0?`(${n.join(" AND ")})`:null}async#o(){this.#t?await this.#e.client.run(e`
|
|
52
52
|
CREATE TEMP TABLE IF NOT EXISTS temp_combined_relations AS
|
|
53
53
|
SELECT
|
|
54
54
|
source_key,
|
|
@@ -78,12 +78,12 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
78
78
|
CREATE INDEX IF NOT EXISTS idx_temp_rel_target ON temp_combined_relations(target_key)
|
|
79
79
|
`),await this.#e.client.run(e`
|
|
80
80
|
CREATE INDEX IF NOT EXISTS idx_temp_rel_relation ON temp_combined_relations(source_to_target_relation)
|
|
81
|
-
`)}async#a(
|
|
81
|
+
`)}async#a(t){const s={},n=[],r=t.filter(a=>a.startsWith("metadata."));t.includes("type")&&n.push(`
|
|
82
82
|
SELECT 'type' as filter_name, type as value, COUNT(*) as count
|
|
83
83
|
FROM temp_filtered_entities
|
|
84
84
|
WHERE type IS NOT NULL
|
|
85
85
|
GROUP BY type
|
|
86
|
-
`),
|
|
86
|
+
`),t.includes("tags")&&n.push(`
|
|
87
87
|
SELECT 'tags' as filter_name, tag.value as value, COUNT(DISTINCT tfe.key) as count
|
|
88
88
|
FROM temp_filtered_entities tfe,
|
|
89
89
|
json_each(COALESCE(tfe.tags, json_array())) as tag
|
|
@@ -92,7 +92,7 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
92
92
|
AND tag.value IS NOT NULL
|
|
93
93
|
AND tag.value != ''
|
|
94
94
|
GROUP BY tag.value
|
|
95
|
-
`),
|
|
95
|
+
`),t.includes("domains")&&n.push(`
|
|
96
96
|
SELECT 'domains' as filter_name, tcr.source_key as value, COUNT(DISTINCT tfe.key) as count
|
|
97
97
|
FROM temp_combined_relations tcr
|
|
98
98
|
INNER JOIN temp_filtered_entities tfe ON tfe.key = tcr.target_key
|
|
@@ -100,7 +100,7 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
100
100
|
WHERE tce.type = 'domain'
|
|
101
101
|
AND tcr.source_to_target_relation = 'hasParts'
|
|
102
102
|
GROUP BY tcr.source_key
|
|
103
|
-
`),
|
|
103
|
+
`),t.includes("owners")&&n.push(`
|
|
104
104
|
SELECT 'owners' as filter_name, owner_key as value, COUNT(DISTINCT entity_key) as count
|
|
105
105
|
FROM (
|
|
106
106
|
SELECT
|
|
@@ -120,12 +120,26 @@ import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as
|
|
|
120
120
|
INNER JOIN temp_combined_entities tce ON tce.key = owner_key
|
|
121
121
|
WHERE owner_key IS NOT NULL
|
|
122
122
|
GROUP BY owner_key
|
|
123
|
-
`);for(const a of
|
|
124
|
-
SELECT json_extract(metadata, '${
|
|
123
|
+
`);for(const a of r)await this.#l(a,s);if(n.length===0)return s;const o=n.join(" UNION ALL "),l=await this.#e.client.run(e.raw(o));if(l?.rows)for(const a of l.rows){const c=a.filter_name,m=a.value,f=Number(a.count)||0;s[c]||(s[c]=[]),m&&s[c].push({value:m,count:f})}return s}async#l(t,s){const n=t.substring(9),r=`$.${K(n)}`,o=await this.#e.client.run(e.raw(`
|
|
124
|
+
SELECT json_extract(metadata, '${r}') as value, COUNT(*) as count
|
|
125
125
|
FROM temp_filtered_entities
|
|
126
126
|
WHERE metadata IS NOT NULL
|
|
127
127
|
AND metadata != ''
|
|
128
|
-
AND json_extract(metadata, '${
|
|
129
|
-
AND json_extract(metadata, '${
|
|
128
|
+
AND json_extract(metadata, '${r}') IS NOT NULL
|
|
129
|
+
AND json_extract(metadata, '${r}') != ''
|
|
130
130
|
GROUP BY value
|
|
131
|
-
`));o?.rows&&(s[
|
|
131
|
+
`));o?.rows&&(s[t]=o.rows.map(l=>({value:l.value,count:Number(l.count)||0})).filter(l=>l.value))}async getEntitiesCount(t,s,n){let r;try{if(this.#t){const o=e`
|
|
132
|
+
SELECT key, version, revision FROM entities WHERE source = ${t}
|
|
133
|
+
UNION
|
|
134
|
+
SELECT key, version, revision FROM remote.entities WHERE source = ${t}
|
|
135
|
+
`,l=await this.#e.client.select({count:A()}).from(e`(${o}) AS combined`);r=Number(l[0]?.count??0)}else{const o=await this.#e.client.select({count:A()}).from(i).where(E(i.source,t));r=Number(o[0]?.count??0)}if(s?.length){const o=await this.#c(t,s);r+=s.length-o}return n!==void 0&&(r-=n),{total:r}}catch(o){throw g.error("Error getting entities count:",o),new Error(`Error getting entities count: ${o?.message}`)}}async#c(t,s){const n=e.join(s.map(a=>e`(${a.key}, ${a.version}, ${a.revision})`),e`, `),r=this.#t?e`SELECT count(*) AS count FROM (
|
|
136
|
+
SELECT key, version, revision FROM entities WHERE source = ${t}
|
|
137
|
+
UNION
|
|
138
|
+
SELECT key, version, revision FROM remote.entities WHERE source = ${t}
|
|
139
|
+
) AS combined WHERE (key, version, revision) IN (VALUES ${n})`:e`SELECT count(*) AS count FROM entities WHERE source = ${t} AND (key, version, revision) IN (VALUES ${n})`,l=(await this.#e.client.run(r)).rows?.[0];return Number(l?.count??0)}async getDuplicatedEntitiesCount(t,s){if(!this.#t)return{total:0};try{const n=a=>`${a.key}|${a.version}|${a.revision}`,r=await this.#e.client.run(e`
|
|
140
|
+
SELECT key, version, revision FROM entities
|
|
141
|
+
INTERSECT
|
|
142
|
+
SELECT key, version, revision FROM remote.entities
|
|
143
|
+
`),o=new Set((r.rows??[]).map(a=>n(a)));if(t?.length){const a=e.join(t.map(m=>e`(${m.key}, ${m.version}, ${m.revision})`),e`, `),c=await this.#e.client.run(e`SELECT key, version, revision FROM entities WHERE (key, version, revision) IN (VALUES ${a})
|
|
144
|
+
UNION
|
|
145
|
+
SELECT key, version, revision FROM remote.entities WHERE (key, version, revision) IN (VALUES ${a})`);for(const m of c.rows??[])o.add(n(m))}let l=0;if(s?.length){const a=new Set;for(const c of s){const m=n(c);o.has(m)&&a.add(m)}l=a.size}return{total:o.size-l}}catch(n){throw g.error("Error getting duplicated entities count:",n),new Error(`Error getting duplicated entities count: ${n?.message}`)}}async#u(){try{await this.#e.client.run(e`DROP TABLE IF EXISTS temp_combined_entities`),await this.#e.client.run(e`DROP TABLE IF EXISTS temp_filtered_entities`),await this.#e.client.run(e`DROP TABLE IF EXISTS temp_combined_relations`)}catch(t){g.error("Error cleaning up temp tables:",t)}}}function K(b){return b.replace(/[^a-zA-Z0-9._-]/g,"")}export{ye as CatalogEntitiesLocalReadRepository};
|
|
@@ -90,5 +90,11 @@ export declare class CatalogEntitiesLocalRepository extends BaseRepository {
|
|
|
90
90
|
updateEntityScorecardsStatusIfCalculating(entityId: string, status: Extract<ScorecardsStatus, 'UP_TO_DATE' | 'OUTDATED'>): Promise<boolean>;
|
|
91
91
|
getOutdatedEntities(filter?: Filter): Promise<EntityReadModelSchema[]>;
|
|
92
92
|
setEntitiesAsOutdated(filter: Filter): Promise<void>;
|
|
93
|
+
getEntitiesCount(source: 'file' | 'remote', addedEntities?: EntityReadModelSchema[], entitiesRemovedCount?: number): Promise<{
|
|
94
|
+
total: number;
|
|
95
|
+
}>;
|
|
96
|
+
getDuplicatedEntitiesCount(addedEntities?: EntityReadModelSchema[], removedEntities?: EntityReadModelSchema[]): Promise<{
|
|
97
|
+
total: number;
|
|
98
|
+
}>;
|
|
93
99
|
}
|
|
94
100
|
//# sourceMappingURL=catalog-entities-local-repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{promiseMapLimit as l}from"../../../../../utils/async/promise-map-limit.js";import{logger as R}from"../../../../../tools/notifiers/logger.js";import{DatabaseConnectionFactory as p}from"../../../../../providers/database/database-connection-factory.js";import{BaseRepository as f}from"../../../../../providers/database/base-repository.js";import{CatalogEntitiesLocalReadRepository as m}from"./catalog-entities-local-read-repository.js";import{CatalogEntitiesLocalWriteRepository as w}from"./catalog-entities-local-write-repository.js";import{createEntityRelationDbRecordFromDto as
|
|
1
|
+
import{promiseMapLimit as l}from"../../../../../utils/async/promise-map-limit.js";import{logger as R}from"../../../../../tools/notifiers/logger.js";import{DatabaseConnectionFactory as p}from"../../../../../providers/database/database-connection-factory.js";import{BaseRepository as f}from"../../../../../providers/database/base-repository.js";import{CatalogEntitiesLocalReadRepository as m}from"./catalog-entities-local-read-repository.js";import{CatalogEntitiesLocalWriteRepository as w}from"./catalog-entities-local-write-repository.js";import{createEntityRelationDbRecordFromDto as h}from"../../mappers/create-entity-relation-db-record-from-dto.js";import{hasOptionsChanged as C}from"../../../utils/has-options-changed.js";const c=50;class r extends f{static#i;static#n;#t;#e;#s={};constructor(t){super(t),this.#t=new m(this.databaseClient),this.#e=new w(this.databaseClient,this.organizationId,this.projectId)}get transactionsManager(){return this.databaseClient.transactionsManager}getEntitySources(){return this.#s}static async getInstance(t){const e=C(r.#n,t);if(!r.#i||e){const i=await p.create("catalog-local",t);if(!i)throw new Error("Failed to create db connection for catalog entities local repository");r.#i=new r(i),r.#n=t}return r.#i}async attachDatabase(t){await this.#t.attachDatabase(t)}getEntities({paginationParams:t,rbacTeams:e,excludedTypes:i,excludedEntities:s}){return this.#t.getEntities({paginationParams:t,rbacTeams:e,excludedTypes:i,excludedEntities:s})}getEntityById(t,e){return this.#t.getEntityById(t,e)}getEntityKeysAndVersionsBySourceFile(t){return this.#t.getEntityKeysAndVersionsBySourceFile(t)}getEntitiesCountByTypes(){return this.#t.getEntitiesCountByTypes()}getEntitiesRelations(t={}){return this.#t.getEntitiesRelations(t)}getEntityRelationById(t){return this.#t.getEntityRelationById(t)}getEntitiesWithRelations({paginationParams:t,rbacTeams:e,excludedTypes:i,excludedEntities:s}){return this.#t.getEntitiesWithRelations({paginationParams:t,rbacTeams:e,excludedTypes:i,excludedEntities:s})}getEntityWithRelationsByKey({entityKey:t,filter:e,rbacTeams:i,excludedTypes:s,excludedEntities:n}){return this.#t.getEntityWithRelationsByKey({entityKey:t,filter:e,rbacTeams:i,excludedTypes:s,excludedEntities:n})}getRelatedEntities({key:t,paginationParams:e,rbacTeams:i,excludedTypes:s,excludedEntities:n}){return this.#t.getRelatedEntities({key:t,paginationParams:e,rbacTeams:i,excludedTypes:s,excludedEntities:n})}createEntity(t){return t.isRootEntity&&(this.#s[t.sourceFile]={key:t.entity.key,version:t.entity.version??void 0}),this.#e.createEntity(t)}async createEntities(t){await l(t,c,async e=>this.createEntity(e))}createEntityRelation(t){const e=h(t,this.organizationId,this.projectId);return this.#e.upsertEntityRelation(e)}async createEntityRelations(t){await l(t,c,async e=>this.createEntityRelation(e))}deleteEntity(t){return this.#e.deleteEntity(t)}async softDeleteEntities({filter:t,revision:e,fileHash:i}){const s=await this.getEntities({paginationParams:{filter:t}}),n=await this.#e.softDeleteEntities(s.items,e,i);await this.softDeleteEntitiesRelations(n,e)}async softDeleteEntitiesRelations(t,e){try{const i=t.filter(n=>n.result==="created");if(i.length===0)return!0;const s=await l(i,c,async n=>(await this.#t.getRelationsForEntity(n.entityKey,n.entityVersion,e)).map(a=>{if(!a)return null;const u=a.direction,o=a.sourceToTargetRelation,y=a.targetKey,d=u==="outgoing"?n.entityKey:y,E=u==="outgoing"?y:n.entityKey,g=u==="outgoing"?o:o.startsWith("reverse:")?o.slice(8):o;return!g||!d||!E?null:h({type:g,sourceKey:d,targetKey:E,sourceVersion:n.entityVersion,targetVersion:n.entityVersion,sourceRevision:e,targetRevision:e,isDeleted:!0},this.organizationId,this.projectId)}).filter(a=>a!==null));return await l(s.flat(),c,async n=>this.#e.upsertEntityRelation(n)),!0}catch(i){return R.error("Error soft deleting entity relations",i),!1}}deleteEntities(t){return this.#e.deleteEntities(t)}deleteEntityRelation(t){return this.#e.deleteEntityRelation(t)}deleteEntityRelations(t){return this.#e.deleteEntityRelations(t)}getCatalogFilters(t){return this.#t.getCatalogFilters(t)}listEntityRevisions(t,e){return this.#t.listEntityRevisions(t,e)}updateEntityScorecardsStatus(t,e){return this.#e.updateEntityScorecardsStatus(t,e)}updateEntityScorecardsStatusIfCalculating(t,e){return this.#e.updateEntityScorecardsStatusIfCalculating(t,e)}getOutdatedEntities(t){return this.#t.getOutdatedEntities(t)}async setEntitiesAsOutdated(t){await this.#e.setEntitiesAsOutdated(t)}getEntitiesCount(t,e,i){return this.#t.getEntitiesCount(t,e,i)}getDuplicatedEntitiesCount(t,e){return this.#t.getDuplicatedEntitiesCount(t,e)}}export{r as CatalogEntitiesLocalRepository};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sha1 as
|
|
1
|
+
import{sha1 as I}from"../../utils/crypto/sha1.js";import{isValidSanitizedString as D}from"../../utils/validate-and-sanitize-string";import{CatalogEntitiesService as F}from"./database/catalog-entities-service.js";import{createPaginationParamsValidator as E}from"../../providers/database/pagination/schemas";import{parseSearch as R}from"../../providers/database/pagination/search";import{OPERATORS as w}from"../../providers/database/pagination/constants.js";import{CacheService as P}from"../../persistence/cache/services/cache-service.js";import{CATALOG_FILTERS_CACHE_NAMESPACE as A,CATALOG_FILTERS_CACHE_TTL_IN_SECONDS as N}from"../../constants/plugins/catalog-entities.js";import{isValidIsoDate as V}from"../../utils/is-valid-iso-date.js";import{expandTeamsForRead as _}from"../../utils";import{getNotAccessibleCatalogResources as L}from"./utils/get-not-accessible-catalog-resources.js";const st={all:"all",domains:"domain",services:"service",teams:"team",users:"user","api-descriptions":"api-description","data-schemas":"data-schema"},O={team:{field:"type",operator:"equal",value:"user"},"api-description":{field:"type",operator:"equal",value:"api-operation"}},M=async({entitiesTypes:e,serverOutDir:i,catalogConfig:s,queries:t={},rbacTeams:o,excludedTypes:p,excludedEntities:c})=>{const u=await F.getInstance({baseDbDir:i}),f=T.concat("domains","owners"),l=E(f).parse(t),n=s.excludes?.map(a=>a.key)??[],g=e.filter(a=>a!=="all"),m=j(g,n);return l.filter?l.filter={op:w.AND,conditions:[l.filter,m]}:l.filter=m,await u.getEntitiesWithRelations({paginationParams:{sort:[{field:"type",order:"ASC"},{field:"title",order:"ASC"}],limit:10,...l},rbacTeams:o,excludedTypes:p,excludedEntities:c})},k=async({entityKey:e,serverOutDir:i,queries:s,rbacTeams:t,excludedTypes:o,excludedEntities:p})=>{const c=await F.getInstance({baseDbDir:i});let u=null;const f=s?.revision;f&&V(f)&&(u=f);const l=s?.version;if(!D(l,{pattern:/^[a-zA-Z0-9._-]+$/,maxLength:100,allowEmpty:!0}))return null;const n=await c.getEntityWithRelationsByKey({entityKey:e,filter:{revision:u,version:l},rbacTeams:t,excludedTypes:o,excludedEntities:p});if(!n)return null;const g=n.type==="data-schema"?await c.getRelatedEntities({entityKey:e,paginationParams:{limit:1,filter:{field:"type",operator:"equal",value:"api-description"}}}).then(b=>b.items?.[0]??null):null,m=O[n.type]??void 0,d=B(m,l,u),y=E(T).parse(s),h=await c.getRelatedEntities({entityKey:e,paginationParams:{limit:10,sort:y.sort?.length?y.sort:[{field:"title",order:"ASC"}],filter:d,search:s?.search?R(s?.search,["key","type","title","summary"]):void 0},rbacTeams:t,excludedTypes:o,excludedEntities:p});return{status:"success",entity:n,relatedEntity:g,relations:h}},q=e=>{const i=JSON.stringify({entitiesTypes:e.entitiesTypes.sort(),filtersConfig:e.filtersConfig,rbacTeams:e.rbacTeams,excludedTypes:e.excludedTypes,excludedEntities:e.excludedEntities});return I(i)},x=async({serverOutDir:e,entitiesTypes:i,filtersConfig:s,rbacTeams:t,excludedTypes:o,excludedEntities:p})=>{if(!s||s.length===0)return{};const c=q({entitiesTypes:i,filtersConfig:s,rbacTeams:t,excludedTypes:o,excludedEntities:p}),u=await P.getInstance({baseDbDir:e}),f=await u.get({key:c,namespace:A});if(f)return f;const l=await F.getInstance({baseDbDir:e}),n=[],g=new Map;for(const a of s)!a.options||a.options.length===0?n.push(a.property):g.set(a.property,a.options);const m=await l.getCatalogFilters({entitiesTypes:i,emptyFilters:n,rbacTeams:t,excludedTypes:o,excludedEntities:p}),d={};for(const a of s){const y=g.get(a.property);if(!y){const r=m[a.property];d[a.property]=r&&r.length>0?r:[];continue}const b=(await l.getCatalogFilters({entitiesTypes:i,emptyFilters:[a.property],rbacTeams:t,excludedTypes:o,excludedEntities:p}))[a.property];if(!b){d[a.property]=[];continue}const S=new Map;for(const r of b){const C=r.value.toLowerCase().trim();S.set(C,{originalValue:r.value,count:r.count})}d[a.property]=y.map(r=>{const C=r.toLowerCase().trim(),v=S.get(C);return{value:v?.originalValue??r,count:v?.count??0}}).filter(r=>r.count>0).sort((r,C)=>r.value.localeCompare(C.value))}return await u.set({key:c,value:d,namespace:A,ttlInSeconds:N}),d},K=async(e,{props:i},{variables:s},{serverOutDir:t,getRouteSharedDataByFsPath:o,getConfig:p})=>{const c=i?.catalogConfig||{};if(!e.params||!i?.catalogConfig)return{status:"notFound"};const[u,f,l]=e.params;if(!u)return{status:"notFound"};const n=z(c,u),g=n?.includes?.map(C=>C.type)??[];if(!n||n.hide)return{status:"notFound"};const m=_(p().rbac||{},s?.rbac.teams||[]),{catalogs:d,types:a,entities:y}=L({rbacConfig:p().rbac||{},currentRbacTeams:s?.rbac.teams||[]});if(d.includes(u))return{status:"notFound"};if(!l&&f!=="entities"){const C=await x({entitiesTypes:g,serverOutDir:t,filtersConfig:n.filters,rbacTeams:m,excludedTypes:a,excludedEntities:y}),v=e.queries?.viewMode??"table";return{status:"success",catalogSwitcherItems:W(c,n,d),entitiesTypes:g,entities:await M({entitiesTypes:g,serverOutDir:t,catalogConfig:n,queries:e.queries,rbacTeams:m,excludedTypes:a,excludedEntities:y}),catalogConfig:n,filters:C,initialViewMode:v}}const h=await k({entityKey:l,serverOutDir:t,queries:e.queries,rbacTeams:m,excludedTypes:a,excludedEntities:y});if(!h)return{status:"notFound"};const b=h?.entity.sourceFile,S=h?.entity.type==="api-description",r=b&&S&&o(b)||{};return{status:"success",entity:h.entity,relatedEntity:h.relatedEntity,relations:h.relations,entitiesCatalogConfig:c,catalogConfig:n,sharedDataIds:r}},z=(e,i)=>Object.values(e.catalogs??{}).find(s=>s&&typeof s=="object"&&"slug"in s&&s.slug===i),W=(e,i,s)=>Object.values(e.catalogs??{}).filter(t=>!t?.hide&&!s.includes(t?.slug??"")).map(t=>({labelTranslationKey:t?.catalogSwitcherLabelTranslationKey??t?.slug??"",slug:t?.slug??"",selected:t?.slug===i.slug})).sort((t,o)=>t.slug.localeCompare(o.slug)),j=(e,i)=>({op:"AND",conditions:[...e.length?[{field:"type",operator:"in",value:e}]:[],...i.length?[{field:"key",operator:"in",value:i,modifier:"not"}]:[]]}),B=(e,i,s)=>{let t=e;if(i!==void 0){const o={field:"version",operator:"equal",value:i};t=t?{op:w.AND,conditions:[t,o]}:o}if(s){const o={field:"revision",operator:"equal",value:s};t=t?{op:w.AND,conditions:[t,o]}:o}return t},T=["type","key","title","summary","tags","metadata","metadata.*","git","contact","links","id","source","sourceFile","createdAt","updatedAt"];var it=K;export{it as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as S}from"node:fs";import b from"path";import{PAGE_COUNT_OUTPUT_FILE_NAME as O}from"../../constants/common.js";import{envConfig as C}from"../../config/env-config.js";import{logger as o}from"../../tools/notifiers/logger.js";import{isReactPage as R}from"../../utils/content/is-react-page.js";import{EntitlementsProvider as $}from"../../entitlements/entitlements-provider.js";import{getBilledPagesCount as E,isPathIgnored as M}from"../../utils/index.js";import{isGraphqlDoc as k}from"../graphql-docs/is-graphql-doc.js";import{isMarkdownPage as D}from"../markdown/is-markdown-page.js";import{isOpenapiDoc as _}from"../openapi-docs/is-openapi-doc.js";import{PRODUCT_NAME as p}from"../../../config/product-gates.js";import{isAsyncapiDoc as I}from"../asyncapi-docs/is-asyncapi-doc.js";import{telemetryTraceStep as j}from"../../../cli/telemetry/helpers/trace-step.js";import{getBilledCatalogBuildPagesCount as q}from"./utils/get-billed-catalog-build-pages-count.js";async function Z(){return{id:"entitlements",async afterRoutesCreated(g,u){await j("build.plugin.entitlements",async t=>{const i=$.instance(),s=[],n=[],r=[],a=[],l=[];for(const{relativePath:e}of u.fs.scan())M(e)||(D(e)?s.push(e):k(e)?r.push(e):R(e)?a.push(e):await _(e,u)?n.push(e):await I(e,u)&&l.push(e));const c=i.canAccessFeature("markdown");t?.setAttribute("totalMarkdownFiles",s.length.toString()),t?.setAttribute("isMarkdownSupported",(!!c).toString()),s.length>0&&!c&&o.warn(`The product you are using ("${p}") does not support Markdown pages. The following Markdown files were detected but will be ignored: ${s.map(()=>"%rp").join(", ")}`,...s);const d=i.canAccessFeature("openapi");t?.setAttribute("totalOpenApiFiles",n.length.toString()),t?.setAttribute("isOpenApiSupported",(!!d).toString()),n.length>0&&!d&&o.warn(`The product you are using ("${p}") does not support OpenAPI documents. The following files are ignored: ${n.map(()=>"%rp").join(", ")}`,...n);const f=i.canAccessFeature("asyncapi");t?.setAttribute("totalAsyncApiFiles",l.length.toString()),t?.setAttribute("isAsyncApiSupported",(!!f).toString()),l.length>0&&!f&&o.warn(`The product you are using ("${p}") does not support AsyncAPI documents. The following files are ignored: ${l.map(()=>"%rp").join(", ")}`,...l);const m=i.canAccessFeature("graphql");t?.setAttribute("totalGraphqlFiles",r.length.toString()),t?.setAttribute("isGraphqlSupported",(!!m).toString()),r.length>0&&!m&&o.warn(`The product you are using ("${p}") does not support GraphQL documents. The following files are ignored: ${r.map(()=>"%rp").join(", ")}`,...r);const A=i.canAccessFeature("reactPages");t?.setAttribute("totalReactFiles",a.length.toString()),t?.setAttribute("isReactPagesSupported",(!!A).toString()),a.length>0&&!A&&o.warn(`The product you are using ("${p}") does not support React pages. The following files are ignored: ${a.map(()=>"%rp").join(", ")}`,...a);const w=(await u.getConfig()).entitiesCatalog,T=E(g.getAllRoutes()),{total:y,duplicatedEntitiesPages:F}=await q(g.serverOutDir,w),h=T+y;t?.setAttribute("totalBilledPages",h.toString());const P=C.REDOCLY_METADATA_OUTPUT_FOLDER;P&&(o.info("Save total pages..."),S(b.join(P,O),JSON.stringify({totalPages:h,duplicatedEntitiesPages:F},null)))})}}}export{Z as entitlementsPlugin};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RedoclyConfig } from '@redocly/config';
|
|
2
|
+
export declare function getBilledCatalogBuildPagesCount(serverOutDir: string, catalogConfig: RedoclyConfig['entitiesCatalog']): Promise<{
|
|
3
|
+
total: number;
|
|
4
|
+
duplicatedEntitiesPages: number;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=get-billed-catalog-build-pages-count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{envConfig as c}from"../../../config/env-config.js";import{PRODUCT_NAME as s}from"../../../../config/product-gates.js";import{CatalogEntitiesService as g}from"../../catalog-entities/database/catalog-entities-service.js";async function E(t,a){const i=s.toLowerCase().includes("realm")||s.toLowerCase().includes("reef"),e=c.NEW_CATALOG_ENABLED==="true";if(!i||!e)return{total:0,duplicatedEntitiesPages:0};const o=await g.getInstance({baseDbDir:t}),{total:n}=await o.getEntitiesCount("file"),{total:l}=await o.getDuplicatedEntitiesCount(),r=u(a);return{total:n+r,duplicatedEntitiesPages:l}}function u(t){return t?.show?Object.entries(t.catalogs??{}).filter(([i,e])=>!e?.hide).length:0}export{E as getBilledCatalogBuildPagesCount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as v}from"node:fs";import C from"node:path";import{REDOCLY_TEAMS_RBAC as $}from"@redocly/config";import{combineUrls as I}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_TEMPLATE_ID as O,GRAPHQL_SPEC_SLUG as Q,PUBLIC_RBAC_SCOPE_ITEM as H}from"../../../constants/common.js";import{removeTrailingSlash as _}from"../../../utils/url/remove-trailing-slash.js";import{getTemplatePath as N}from"./get-template-path.js";import{searchResolver as F}from"./search/search-resolver.js";import{graphqlDocLoader as M}from"./graphql-doc-loader.js";import{getAiDocumentsStore as A}from"./search/ai/get-ai-search-document.js";import{fromCurrentDir as U}from"../../utils/paths.js";import{ensureDir as k}from"../../utils/fs.js";import{telemetryTraceStep as x}from"../../../cli/telemetry/helpers/trace-step.js";const B="graphql-docs-",R="graphql-spec-download";async function nt(){return{id:"graphql",requiredEntitlements:["graphql"],loaders:{"graphql-doc":M},processContent:async(t,{fs:n,cache:l,isPathIgnored:i,withPathPrefix:p})=>{await x("build.plugin.graphql_docs",async()=>{t.createRequestHandler(R,U(import.meta.url,"./spec-download.api.js")),t.addApiRoute({slug:Q+"/*",requestHandlerId:R,httpMethod:"all",[$]:H,getStaticData:async()=>({props:{}})});const m=t.createTemplate(O,N("./template/GraphQLDocs.js"));for(const{relativePath:o}of n.scan(/(\.gql|\.graphql)$/)){if(await i(o))continue;const h=await l.load(o,"graphql-doc");if(!h.data)continue;j(h.data.content,t.outdir,o);const{menu:q,content:G,settings:u,metadata:T,store:c}=h.data,L=`${B}${o}`;await t.createSharedData(L,G);const d=[{key:"graphQlSettings",id:L}],b=q.getGroups(),y=q.getSidebarItems(),g={type:"graphql",title:b[0].name,...T},s=[{slugSuffix:"",fsPath:o,templateId:m,getStaticData:S(void 0,u,p),sharedData:d,getAiDocumentsStore:A({label:u.info?.title??"GraphQL Overview",groupName:"overview",metadata:g,actions:t,store:c,includeInLLMsTxt:!0})}];for(const r of b){const f=`${r.id}`;s.push({slugSuffix:f,fsPath:o,templateId:m,getStaticData:S(r,u,p),sharedData:d});for(const e of r.typeGroups){const a=`${e.id}`;s.push({slugSuffix:a,fsPath:o,templateId:m,getStaticData:S(e,u,p),sharedData:d,getAiDocumentsStore:A({label:e.name,groupName:e.name,metadata:g,actions:t,store:c,isTypeGroup:!0,items:new Set(e.items)})});for(const E of e.items){const P=`${e.id}/${E}`;s.push({slugSuffix:P,fsPath:o,templateId:m,getStaticData:S(e,u,p),sharedData:d,getAiDocumentsStore:A({label:E,groupName:e.name,metadata:g,actions:t,store:c})})}}}if(!s.length)return;const D=s[s.length-1];D.metadata=g,D.getSidebar=r=>{function f(e){return e.map(a=>({...a,slug:a.slug&&_(I(r.baseSlug,a.slug)),routeSlug:a.routeSlug&&_(I(r.baseSlug,a.routeSlug)),link:a.link&&_(I(r.baseSlug,a.link)),items:a.items&&f(a.items)}))}return f(y)},D.getSearchDocuments=F(t,c);for(const r of s)t.addRoute(r)}})}}}function S(t,n,l){return async function(i){return{props:{seo:{title:t?.name??n.info?.title??"GraphQL Overview"},settings:{...n,location:{section:t?.id},sidebar:{hide:!0},baseUrlPath:l(i.baseSlug)},disableAutoScroll:!0}}}}function j(t,n,l){const i=w.slice(1);v(k(C.resolve(n,`${i}/${l}`)),t,"utf8")}export{nt as graphqlDocsPlugin,j as storeGqlSchema};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RbacScopeItems } from '@redocly/config';
|
|
2
2
|
import type { FrontmatterKeywords } from '../../../types/index.js';
|
|
3
3
|
import type { AstToSearchNodeTransformer } from './walk-sections.js';
|
|
4
4
|
import { MdSearchDocument } from './md-search-document.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SEARCH_DOCUMENT_METADATA_KEY as
|
|
2
|
-
`," "],
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as $}from"@redocly/config";import{SEARCH_DOCUMENT_METADATA_KEY as g}from"../../../constants/plugins/search.js";import{slugger as x}from"../../../../utils/slugger.js";import{TagNode as M}from"./nodes/tag-node.js";import{TextNode as U}from"./nodes/text-node.js";import{MdSearchDocument as D}from"./md-search-document.js";import{HeadingNode as N}from"./nodes/heading-node.js";const C=Symbol();function H(r,e){if(!r)return e;if(!e)return r;const d=[" ",`
|
|
2
|
+
`," "],u=d.some(o=>r.endsWith(o)),s=d.some(o=>e.startsWith(o));return r+(!u&&!s?" ":"")+e}function Y(r,e,d,u,s,a={},o){const h=new Map(Array.from({length:6},(t,c)=>[c,""])),i=new Map;let S=null,_=0;u=u??{},x.reset();for(const t of r.transform()){const c=t.getUrl(e),f={...u};for(const n of t.rbacTeams??[])f[n.toLowerCase()]="read";if(t instanceof U){const n=t.parentNode?.id,m=n?`${c}#${n}`:C,A=i.get(m),l=A??new D(d,e,[],a,f,s),E=Object.keys(l[$]??{});if(A&&t.rbacTeams&&t.rbacTeams.length>0&&(E.length===0||!E.every(p=>(t.rbacTeams||[]).includes(p)))){const p=new D(A?.title??d,c,t.getPath(h),a,f,s);p.text=t.content,i.set(`${c}#rbac-text-${_++}`,p)}else l.text=H(l.text,t.content),l.facets=a,i.set(m,l);continue}if(t instanceof M){const n=`${c}#${t.id}`,m=new D(t.content,t.getUrl(e),t.getPath(h),a,f,s);i.set(n,m);continue}if(t instanceof N){h.set(t.attributes.level,t.content);const n=new D(t.content,t.getUrl(e),t.getPath(h),a,f,s),m=`${c}#${t.id}`;i.set(m,n),S===null&&(S=n)}}const T=Array.from(i.values()),b=S??T[0];if(b&&o?.includes&&(b[g].curated=!0,b[g].includes=o.includes),o?.excludes)for(const t of T)t[g].curated=!0,t[g].excludes=o.excludes;return T}export{Y as getSearchDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SectionNode as
|
|
1
|
+
import{SectionNode as o,WithSlugId as r}from"./section-node.js";class s extends r(o){constructor(e){super({...e,parentNode:null})}getUrl(e){const t=this.node.attributes.id??this.id;return`${e}#${t}`}getPath(e){return[...e.values()].slice(0,this.node.attributes.level+1).filter(Boolean)}}export{s as HeadingNode};
|
|
@@ -4,7 +4,7 @@ export type SectionNodeParams = {
|
|
|
4
4
|
node: Node;
|
|
5
5
|
content: string;
|
|
6
6
|
parentNode: SearchParentNode;
|
|
7
|
-
|
|
7
|
+
rbacTeams?: string[];
|
|
8
8
|
};
|
|
9
9
|
export declare class SectionNode {
|
|
10
10
|
#private;
|
|
@@ -14,7 +14,7 @@ export declare class SectionNode {
|
|
|
14
14
|
get node(): Node;
|
|
15
15
|
get id(): string | number;
|
|
16
16
|
get parentNode(): SearchParentNode;
|
|
17
|
-
get
|
|
17
|
+
get rbacTeams(): string[] | undefined;
|
|
18
18
|
}
|
|
19
19
|
type Constructor<T = any> = new (...args: any[]) => T;
|
|
20
20
|
export declare function WithCounterId<TBase extends Constructor>(Base: TBase): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getInnerText as o}from"../../../../../markdoc/helpers/get-inner-text.js";import{slugger as c}from"../../../../../utils/slugger.js";class a{#t;#e;#r;#n;constructor(t){const{node:r,content:n,
|
|
1
|
+
import{getInnerText as o}from"../../../../../markdoc/helpers/get-inner-text.js";import{slugger as c}from"../../../../../utils/slugger.js";class a{#t;#e;#r;#n;constructor(t){const{node:r,content:n,rbacTeams:s,parentNode:i}=t;this.#t=r,this.#e=n,this.#r=i,this.#n=s}get attributes(){return this.#t.attributes}get content(){return this.#e}get node(){return this.#t}get id(){throw new Error("SectionNode needs an id mixin applied")}get parentNode(){return this.#r}get rbacTeams(){return this.#n}}function h(e){let t=0;return class extends e{#t=++t;get id(){return this.#t}}}function g(e){return class extends e{#t;constructor(...t){super(...t);const r=this;this.#t=c.slug(o(r.node.children),{replaceDots:!0,replaceSlashes:!0})}get id(){return this.#t}}}export{a as SectionNode,h as WithCounterId,g as WithSlugId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as a}from"../../../tools/notifiers/logger.js";import{isNode as f}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as u}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as y}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as N}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as e}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as T,TagNode as n}from"./nodes/tag-node.js";import{HeadingNode as p}from"./nodes/heading-node.js";class C{#t;#o;#i;#s;constructor({ast:i,partials:t,skipConditionals:r=!1,getInnerContent:s}){if(this.#t=i,this.#o=t,this.#i=r,this.#s=s,!this.#t||!f(this.#t))throw new Error("ast is not a valid Markdoc Node.")}*transform(){yield*this.#
|
|
1
|
+
import{logger as a}from"../../../tools/notifiers/logger.js";import{isNode as f}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as u}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as y}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as N}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as e}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as T,TagNode as n}from"./nodes/tag-node.js";import{HeadingNode as p}from"./nodes/heading-node.js";class C{#t;#o;#i;#s;constructor({ast:i,partials:t,skipConditionals:r=!1,getInnerContent:s}){if(this.#t=i,this.#o=t,this.#i=r,this.#s=s,!this.#t||!f(this.#t))throw new Error("ast is not a valid Markdoc Node.")}*transform(){yield*this.#c(this.#t,{parentNode:null})}*#c(i,t,r=this.#s){if(!(!i||!f(i))){if(u(i)){if(this.#i)return;const s=N(i);s&&s.length>0&&(yield*this.#r(i,{...t,rbacTeams:s},r));return}if(y(i)){yield new e({node:i,content:r([i],{skipConditionals:this.#i}),...t});return}if(i.type==="heading"){yield new p({node:i,content:r([i],{skipConditionals:this.#i}),rbacTeams:t?.rbacTeams});return}if(i.type==="tag"){yield*this.#l(i,t,r);return}yield*this.#r(i,t,r)}}*#l(i,t,r=this.#s){switch(i.tag){case"partial":{const s=i.attributes.file,o=i.attributes.variables??{};if(s&&this.#o[s]){yield*this.#c(this.#o[s],t,(c,l)=>r(c,{...l,variables:o}));return}a.warn(`Could not create search indexes for partial \u201C${s}\u201D: file not found`);return}case"cards":case"tabs":case"code-walkthrough":{yield*this.#r(i,t,r);return}case"markdoc-example":{const s=r([i],{skipConditionals:this.#i});yield new e({node:i,content:s,...t});return}case"code-snippet":{const s=h(i,"title"),o=r([i],{skipConditionals:this.#i});if(s){const c=new n({node:i,content:s,...t});t={...t,parentNode:c},yield c}o&&(yield new e({node:i,content:o,...t}));return}default:{const s=T.find(l=>l in i.attributes),o=(s&&h(i,s))??"",c=typeof o=="string"?o:r([o]);if(c){const l=new n({node:i,content:c,...t});t={...t,parentNode:l},yield l}yield*this.#r(i,t,r);return}}}*#r(i,t,r=this.#s){for(const s of[...Object.values(i.slots),...i.children])for(const o of this.#c(s,t,r))o instanceof p&&(t={...t,parentNode:o}),yield o}}export{C as AstToSearchNodeTransformer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as
|
|
2
|
-
`;for(const[T,w]of $?.publiclyAccessibleTaggedSearchDocuments?.entries()||[]){if(!w.length)return;const U=
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as F,join as L}from"node:path";import{toMarkdown as _}from"../../../plugins/markdown/search/to-markdown.js";import{canDownloadApiDefinition as G,isResourcePubliclyAccessible as J}from"../../../utils/rbac.js";import{PUBLIC_API_DEFINITIONS_FOLDER as q}from"../../../constants/common.js";import{DEFAULT_ANONYMOUS_VISITOR_TEAM as z}from"../../../../constants/common.js";import{SearchIndexer as V}from"../search-indexer.js";import{getLocaleFromRelativePath as B}from"../../../fs/utils/get-locale-from-relative-path.js";import{extractDocumentSearchFacets as C}from"./search-facets.js";import{formatDocumentMetadata as Y}from"../../search/utils.js";import{getLLMsTxtMdSlug as H,llmsTxtLink as E}from"../../search/llmstxt/index.js";import{replaceFileExtension as K}from"../store-definition-bundles.js";const x=new Map,he=({parser:s,options:c,info:t,tagOperations:i,relativePath:n,openapiContentItem:e,metadata:r,getSearchFacets:o,includeInLLMsTxt:a,excludeFromSearch:m})=>async(u,f,l)=>{if(m)return;const D=await u.getNavText?.()||F(u.fsPath),A=new V(s,c,u.baseSlug||u.slug),p=A.addItem(e);if(!p)return;const O=await l.getConfig(),S=Array.isArray(p.title)?p.title.join(" "):p.title;let g,d,$=x.get(n);if((e.type==="tag"||e.type==="section"&&e.infoDefinition)&&!$){const{all:b,publiclyAccessible:y}=ne(i.tagged,A,O),{all:T,publiclyAccessible:w}=te(i.untagged,A,O);x.set(n,{taggedSearchDocuments:new Map(b),untaggedSearchDocuments:T,publiclyAccessibleTaggedSearchDocuments:new Map(y),publiclyAccessibleUntaggedSearchDocuments:w})}$=x.get(n);const h="#";switch(e.type){case"operation":const b=A.getOperation(e);g=d=Z({title:S,security:s.definition.security,document:p,version:p.version||t.version,headingLevel:h,operation:b});break;case"section":if(e.infoDefinition){$=x.get(n),d=await M({parser:s,info:t,staticData:f,relativePath:n,headingLevel:h,pageName:D,config:O}),d+=`
|
|
2
|
+
`;for(const[T,w]of $?.publiclyAccessibleTaggedSearchDocuments?.entries()||[]){if(!w.length)return;const U=s.definition.tags?.find(N=>N.name===T);d+=j({title:U?.["x-displayName"]||T,description:U?.description,operationSearchDocuments:w,headingLevel:`${h}#`})}const y=$?.publiclyAccessibleUntaggedSearchDocuments||[];y.length&&(d+=j({title:"Other",description:void 0,operationSearchDocuments:y,headingLevel:`${h}#`})),g=await M({parser:s,info:t,staticData:f,relativePath:n,headingLevel:h,pageName:D,config:O})}else e.ast&&(d=g=_(e.ast));break;case"tag":d=j({title:S,description:e.description,operationSearchDocuments:$?.publiclyAccessibleTaggedSearchDocuments.get(e.name)||[],headingLevel:h}),g=j({title:S,description:e.description,operationSearchDocuments:[],headingLevel:h});break;case"rsrc":case"prompt":case"tool":d=I({title:S,description:e.description,name:e.name,xMcpConfig:s.definition["x-mcp"],headingLevel:h}),g=d;break}return{async getLLMsTxts(){return[{title:e.name,description:e.type==="tag"?e.description:void 0,content:d||"",slug:u.slug,fsPath:u.fsPath,includeInLLMsTxt:a}]},async getSearchDocuments(){if(e.type==="operation"||e.type==="section"&&(e.infoDefinition||e.ast)||e.type==="tag"){const b=B(u.fsPath),y=C({...p,...r},t,o);return[{title:S,description:Array.isArray(p.text)?p.text.join(" "):p.text,content:g||"",url:p.url??u.slug,fsPath:u.fsPath,locale:b,product:u.product?.name,rbacTeams:p.rbacTeams,facets:y}]}return[]}}};async function M({parser:s,info:c,staticData:t,relativePath:i,pageName:n,headingLevel:e,config:r}){const o=Y(c["x-metadata"]);let a=c.title?`${e} ${c.title}
|
|
3
3
|
|
|
4
4
|
`:`${e} ${n}
|
|
5
5
|
|
|
@@ -12,30 +12,30 @@ import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as R,join a
|
|
|
12
12
|
`:"",e=`${e}#`,a+=o.length?`Metadata:
|
|
13
13
|
${o}
|
|
14
14
|
`:"",a+=`
|
|
15
|
-
`,a+=
|
|
15
|
+
`,a+=Q({parser:s,headingLevel:e}),a+=X({parser:s,headingLevel:e}),a+=await W({info:c,staticData:t,relativePath:i,pageName:n,headingLevel:e,config:r}),a}function j({title:s="",description:c,operationSearchDocuments:t,headingLevel:i}){let n=`${i} ${s}
|
|
16
16
|
|
|
17
17
|
`;return c&&(n+=`${c}
|
|
18
18
|
|
|
19
|
-
`),t.length&&t.forEach(e=>{const r=Array.isArray(e.title)?e.title.join(" "):e.title;n+=`${
|
|
19
|
+
`),t.length&&t.forEach(e=>{const r=Array.isArray(e.title)?e.title.join(" "):e.title;n+=`${i}# ${r}${e.deprecated?" (deprecated)":""}
|
|
20
20
|
|
|
21
|
-
`,n+=` - ${
|
|
22
|
-
`}),n}function
|
|
21
|
+
`,n+=` - ${E({title:`${e.httpMethod?.toUpperCase()} ${e.httpPath}`,description:Array.isArray(e.text)?e.text.join(" "):e.text,slug:H(e.url)})}`,n+=`
|
|
22
|
+
`}),n}function Q({parser:s,headingLevel:c}){const{servers:t}=s.definition;if(t&&t.length){let i=`${c} Servers
|
|
23
23
|
|
|
24
|
-
`;return t.forEach(n=>{
|
|
25
|
-
`:"",
|
|
24
|
+
`;return t.forEach(n=>{i+=n.description?`${n.description}
|
|
25
|
+
`:"",i+=`\`\`\`
|
|
26
26
|
${n.url}
|
|
27
27
|
\`\`\`
|
|
28
28
|
|
|
29
|
-
`,n.variables&&(
|
|
30
|
-
`,Object.entries(n.variables).forEach(([e,r])=>{
|
|
31
|
-
`,
|
|
32
|
-
`:"",
|
|
33
|
-
`:""}),
|
|
34
|
-
`)}),
|
|
29
|
+
`,n.variables&&(i+=`Variables:
|
|
30
|
+
`,Object.entries(n.variables).forEach(([e,r])=>{i+=`- \`${e}\`${r.description?`: ${r.description}`:""}
|
|
31
|
+
`,i+=r.default?`Default: ${JSON.stringify(r.default)}
|
|
32
|
+
`:"",i+=r.enum?`Enum: ${r.enum.map(o=>JSON.stringify(o)).join(", ")}
|
|
33
|
+
`:""}),i+=`
|
|
34
|
+
`)}),i}return""}async function W({info:s,staticData:c,relativePath:t,pageName:i,headingLevel:n,config:e}){const r=L(c.props?.outdir||"",q,K(t,".yaml"));if(G(r,e.rbac||{},e.requiresLogin||!1,{isAuthenticated:!1,teams:[z]})){let o=`${n} Download OpenAPI description
|
|
35
35
|
|
|
36
|
-
`;return o+=
|
|
36
|
+
`;return o+=E({title:s.title||i||"OpenAPI definition",description:void 0,slug:r}),o}return""}function X({parser:s,headingLevel:c}){if(!s.definition.components?.securitySchemes)return"";let t=`${c} Security
|
|
37
37
|
|
|
38
|
-
`;const{securitySchemes:
|
|
38
|
+
`;const{securitySchemes:i}=s.definition.components;return Object.keys(i).forEach(n=>{const e=i[n];e&&(t+=`${c}# ${n}
|
|
39
39
|
|
|
40
40
|
`,t+=e.description?`${e.description}
|
|
41
41
|
|
|
@@ -52,41 +52,41 @@ ${n.url}
|
|
|
52
52
|
`),e.flows?.password?.scopes&&(t+=`Scopes:
|
|
53
53
|
`,Object.entries(e.flows?.password?.scopes||{}).forEach(([r,o])=>{t+=`- \`${r}\`: ${o}
|
|
54
54
|
`})),t+=`
|
|
55
|
-
`)}),t}function
|
|
55
|
+
`)}),t}function Z({title:s,security:c,document:t,version:i,headingLevel:n,operation:e}){const{text:r,httpMethod:o,httpPath:a,deprecated:m}=t,u=ee(t.parameters||[],`${n}#`),f=v(`${n}#`,t.parameters,e);let l=s?`${n} ${s}${m?" (deprecated)":""}
|
|
56
56
|
|
|
57
57
|
`:"";return l+=r?`${r}
|
|
58
58
|
|
|
59
59
|
`:"",l+=`Endpoint: ${o?.toUpperCase()} ${a}
|
|
60
|
-
`,l+=
|
|
60
|
+
`,l+=i?`Version: ${i}
|
|
61
61
|
`:"",l+=t.security?.length?`Security: ${t.security.join(", ")}
|
|
62
62
|
`:c?.length?`Security: ${c.map(D=>D.id).join(", ")}
|
|
63
63
|
`:"",l+=`
|
|
64
64
|
`,l+=u?`${u}
|
|
65
65
|
`:"",l+=`
|
|
66
66
|
`,l+=`${f.join(`
|
|
67
|
-
`)}`,l}function
|
|
67
|
+
`)}`,l}function I({title:s,name:c,xMcpConfig:t,headingLevel:i}){const n=t?.tools.find(r=>r.name===c);if(!n)return"";let e=`${i} ${s}
|
|
68
68
|
|
|
69
69
|
`;return e+=n.description?`${n.description}
|
|
70
70
|
|
|
71
|
-
`:"",e+=`${
|
|
71
|
+
`:"",e+=`${i}# Input schema:
|
|
72
72
|
|
|
73
73
|
`,e+=`\`\`\`json
|
|
74
74
|
${JSON.stringify(n.inputSchema,null,2)}
|
|
75
75
|
\`\`\`
|
|
76
76
|
|
|
77
|
-
`,n.outputSchema&&(e+=`${
|
|
77
|
+
`,n.outputSchema&&(e+=`${i}# Output schema:
|
|
78
78
|
|
|
79
79
|
`,e+=`\`\`\`json
|
|
80
80
|
${JSON.stringify(n.outputSchema,null,2)}
|
|
81
81
|
\`\`\`
|
|
82
82
|
|
|
83
|
-
`),e}function
|
|
84
|
-
`)}function
|
|
83
|
+
`),e}function v(s,c,t){return!c&&!t||!t?.responses?[]:t?.responses.filter(n=>!n.content?.mediaTypes[0]?.schema).map(n=>`${s} ${P(`response ${n.code} fields`)}
|
|
84
|
+
`)}function ee(s,c){const t={};for(const n of s){const e=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;t[e]=[...t[e]||[],n]}return Object.entries(t).map(([n,e])=>{const r=e.map(o=>{const a=" ",m=[...o.path||[],o.name],u=Array.isArray(o.description)?o.description.join(" "):o.description;let f=` - \`${m.join(".")}\` (${o.type}${o.required?", required":""})
|
|
85
85
|
`;return f+=u?`${a}${u.trim()}
|
|
86
86
|
`:"",o.enum?f+=`${a}Enum: ${o.enum.map(l=>JSON.stringify(l)).join(", ")}
|
|
87
87
|
`:o.example&&(f+=`${a}Example: ${o.example}
|
|
88
|
-
`),f});return`${c} ${
|
|
88
|
+
`),f});return`${c} ${P(n)}:
|
|
89
89
|
|
|
90
90
|
${r.join(`
|
|
91
91
|
`)}`}).join(`
|
|
92
|
-
`)}function
|
|
92
|
+
`)}function ne(s,c,t){const i=[],n=[];return s.forEach((e,r)=>{const o=[],a=[];e.forEach(m=>{const u=c.addItem(m);u&&(o.push(u),R({[k]:m[k],slug:u.url},t)&&a.push(u))}),i.push([r,o]),n.push([r,a])}),{all:i,publiclyAccessible:n}}function te(s,c,t){const i=[],n=[];return s.forEach(e=>{const r=c.addItem(e);r&&(i.push(r),R({[k]:e[k],slug:r.url},t)&&n.push(r))}),{all:i,publiclyAccessible:n}}function P(s){return s.charAt(0).toUpperCase()+s.slice(1)}function R(s,c){return c.requiresLogin?!0:J(s,c)}export{he as getAiDocumentsStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as y from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{combineUrls as u}from"@redocly/theme/core/utils";import{SEARCH_DOCUMENT_METADATA_KEY as x}from"../../constants/plugins/search.js";import{removeMarkdownLinks as c,stripFormatting as a}from"./utils.js";import{normalizeFrontmatterKeywords as k}from"../helpers/normalize-frontmatter-keywords.js";const h=y.default||y;class q{#n=[];#r;#s;#e;#i;constructor(e,t,n){this.#r=e,this.#s=t,this.#e=n}addItem(e){const{result:t}=k(e.keywords||e.operationDefinition?.keywords);t?.excludes&&e.type==="section"&&e.id===""&&(this.#i=t.excludes);try{let n;switch(e.type){case"tag":n=this.#c(e);break;case"operation":const o=this.getOperation(e);n=this.#d(o,e[d]);break;case"section":n=this.#p(e);break;case"rsrc":case"prompt":case"tool":n=this.#o(e);break}if(!n)return;const s=[...new Set([...t?.excludes?t.excludes:[],...this.#i?this.#i:[]])];return(t||s.length)&&(n[x]={curated:!0,...t,excludes:s}),this.#n.push(n),n}catch(n){console.error("Cannot add item to search indexer",n.message)}}addInfo(e,t){const n=this.#e,s={id:n,url:n,text:a(c(e.description||"")),title:a(`${e.title} (${e.version})`),metadata:t};return this.#n.push(s),s}#o(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:e.name}}getResult(){return this.#n}getOperation(e){return h.getOperation(this.#r,e.operationDefinition,e.parent,{...this.#s,internal_skipSamples:!0},e.href)}#a(e){return[...e.path||[],e.name.toString()].join(".")+e.description+e.place}#d(e,t){if(e.type!=="operation")return;let n={};for(let i of e.parameters){if(i[d])continue;const r=i.schema?.example||i.example,p={name:i.name,description:a(c(i.description)),place:i.in+" parameters",mediaType:void 0,type:i.schema?.type.toString()||"unknown",deepLink:h.generateDeepLink(i),[d]:i[d],required:i.required,example:r?JSON.stringify(r):void 0,enum:i.schema?.enum?.length?i.schema.enum:void 0};n[this.#a(p)]=p}const s=new Set;this.#t(n,e.requestBody?.content?.mediaTypes[0]?.schema,e.requestBody?.content?.mediaTypes[0]?.name,"request fields",!1,[],s);for(let i of e.responses){const r=`response ${i.code} fields`;this.#t(n,i.content?.mediaTypes[0]?.schema,i.content?.mediaTypes[0]?.name,r,!0,[],s)}let o=u(this.#e,e.href);return{id:o,url:o,title:a(e.name),text:a(c(e.description||"")),httpMethod:e.httpVerb,httpPath:e.path,deprecated:e.deprecated,isAdditionalOperation:e.isAdditionalOperation,security:e.security.map(i=>i.schemes.map(r=>r.id)).flat().filter(Boolean),parameters:Object.values(n),badges:e.badges.length?e.badges:void 0,[d]:t}}#t(e,t,n,s,o,l=[],i=new Set){if(!(!t||t.isCircular)){if(t.pointer){if(i.has(t.pointer))return;i.add(t.pointer)}if(t?.fields)for(let r of t.fields){if(t[d]||r.kind==="additionalProperties"||r.schema?.readOnly&&!o||r.schema?.writeOnly&&o)continue;const p=r.schema?.example||r.example,m=r.schema?.enum,f={name:r.name,description:a(r.description),place:s,mediaType:n,path:l,deepLink:h.generateDeepLink(r),type:r.schema?.type.toString()||"unknown",required:r.required||t.schema.required?.includes(r.name)||!1,example:p?JSON.stringify(p):void 0,enum:m?.length?m:void 0},g=this.#a(f);e[g]==null&&(e[g]=f,this.#t(e,r.schema,n,s,o,l.concat([r.name]),i))}t?.items&&this.#t(e,t.items,n,s,o,l,i)}}#c(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}#p(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}}export{q as SearchIndexer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import u
|
|
1
|
+
import{pathToFileURL as u}from"node:url";import{slash as d}from"../../../../utils/path/slash.js";import{logger as o}from"../../../tools/notifiers/logger.js";import{reporter as n}from"../../../tools/notifiers/reporter.js";import{getServerProps as p}from"../../../ssr/server-side-props/get-server-props.js";import{telemetry as f}from"../../../../cli/telemetry/index.js";async function x(r,i){try{n.clearPageRenderProblems();const e=r.getAllRoutes().filter(t=>t.fsPath.match(/\.page\.tsx?$/));if(!e.length)return;const l=o.startTiming();o.info("Validating react pages");const g=await P(r.serverOutDir);for(const t of e){const c=await r.resolveRouteStaticData(t,i),m=await p(t,null,c,r);let a;try{a=(await g(t,m,null,r,f,!0)).error}catch(s){a=s}a&&n.reportPageRenderError({message:a.name==="PageMissingDefaultExportError"?a.message:`Runtime error: ${a.message}`,sourceFileRelativePath:t.fsPath})}o.infoTime(l,`Validated ${e.length} React pages`)}catch(e){await n.panicOnBuild(`Failed to validate react pages: ${e.message}`)}}async function P(r){const e=await import(u(`${d(r)}/index.mjs`)+"?only-exports=true");if(!e.renderPage)throw new Error("renderPage function not found in bundle");return e.renderPage}export{x as validateReactPages};
|