@redocly/redoc 0.131.0-next.8 → 0.131.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 +201 -1
- package/dist/bin.js +1 -1
- package/dist/cli/{prepare → build}/index.d.ts +2 -2
- package/dist/cli/{prepare → build}/index.js +1 -1
- package/dist/cli/develop.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/cli/utils/listen-stdin.d.ts +10 -0
- package/dist/cli/utils/listen-stdin.js +2 -0
- package/dist/client/TestProvider.js +1 -1
- package/dist/client/app/hooks/index.d.ts +1 -0
- package/dist/client/app/hooks/index.js +1 -1
- package/dist/client/app/hooks/useAnchorPositioning.d.ts +6 -0
- package/dist/client/app/hooks/useAnchorPositioning.js +1 -0
- package/dist/client/app/l10n/index.js +1 -1
- package/dist/client/app/search/useAiSearch.js +1 -1
- package/dist/client/app/search/useSearch.js +1 -1
- package/dist/client/app/seo/SeoTags.js +1 -1
- package/dist/client/providers/theme/ThemeDataProvider.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/server/api-routes/execute-api-route.js +1 -1
- package/dist/server/config/env-schema.d.ts +3 -3
- package/dist/server/config/env-schemas/search.d.ts +2 -2
- package/dist/server/config/env-schemas/search.js +1 -1
- package/dist/server/constants/plugins/search.d.ts +0 -4
- package/dist/server/constants/plugins/search.js +1 -1
- package/dist/server/node-bundle-entry.js +1 -1
- package/dist/server/plugins/analytics/segment/browser-hooks.js +1 -1
- package/dist/server/plugins/analytics/segment/build-script.js +5 -2
- 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/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/nodes/heading-node.js +1 -1
- package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +25 -25
- package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
- package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +1 -1
- package/dist/server/plugins/search/documents/search-documents.js +1 -1
- package/dist/server/plugins/search/engines/typesense/index.js +1 -1
- package/dist/server/plugins/search/utils.js +1 -1
- package/dist/server/plugins/sidebars/index.d.ts +0 -1
- package/dist/server/plugins/sidebars/index.js +2 -2
- package/dist/server/ssr/template.js +3 -3
- package/dist/server/tools/notifiers/logger.d.ts +2 -2
- package/dist/server/tools/notifiers/logger.js +2 -2
- package/dist/server/tools/notifiers/reporter.d.ts +0 -1
- package/dist/server/tools/notifiers/reporter.js +6 -7
- package/dist/server/tools/notifiers/terminal-manager.d.ts +1 -1
- package/dist/server/tools/notifiers/terminal-manager.js +5 -4
- package/dist/server/utils/lifecycle-hooks.d.ts +2 -2
- package/dist/server/utils/rbac.js +1 -1
- 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/package.json +13 -13
- package/dist/cli/stats/collectors/openapi.js +0 -1
- /package/dist/cli/{prepare → build}/analytics/collect-analytics.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collect-analytics.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-api-functions-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-api-functions-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-async-api-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-async-api-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-config-stats-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-config-stats-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-file-extensions-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-file-extensions-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-frontmatter-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-frontmatter-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-markdoc-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-markdoc-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-nested-configs-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-nested-configs-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-processed-config-stats-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-processed-config-stats-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-refs-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-refs-usage.js +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-theme-folder-usage.d.ts +0 -0
- /package/dist/cli/{prepare → build}/analytics/collectors/get-theme-folder-usage.js +0 -0
- /package/dist/cli/{prepare → build}/copy-env-files.d.ts +0 -0
- /package/dist/cli/{prepare → build}/copy-env-files.js +0 -0
- /package/dist/cli/{prepare → build}/libsql/copy-prebuilt-binary.d.ts +0 -0
- /package/dist/cli/{prepare → build}/libsql/copy-prebuilt-binary.js +0 -0
- /package/dist/cli/{prepare → build}/libsql/get-current-platform.d.ts +0 -0
- /package/dist/cli/{prepare → build}/libsql/get-current-platform.js +0 -0
|
@@ -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{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 +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};
|
|
@@ -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 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};
|
|
@@ -2,6 +2,7 @@ import type { RedoclyConfig } from '@redocly/config';
|
|
|
2
2
|
export declare const getScorecardConfig: (config: Partial<RedoclyConfig>) => {
|
|
3
3
|
ignore?: string[] | undefined;
|
|
4
4
|
levels: {
|
|
5
|
+
extends?: string[] | undefined;
|
|
5
6
|
preprocessors?: {
|
|
6
7
|
[x: string]: unknown;
|
|
7
8
|
} | undefined;
|
|
@@ -112,7 +113,6 @@ export declare const getScorecardConfig: (config: Partial<RedoclyConfig>) => {
|
|
|
112
113
|
[x: string]: unknown;
|
|
113
114
|
};
|
|
114
115
|
} | undefined;
|
|
115
|
-
extends?: string[] | undefined;
|
|
116
116
|
color?: string | undefined;
|
|
117
117
|
name: string;
|
|
118
118
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_ROUTE_RBAC as
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as E,REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{existsSync as B}from"fs";import{rm as M}from"node:fs/promises";import $ from"node:path";import{DEFAULT_LOCALE_PLACEHOLDER as y}from"../../../../constants/common.js";import{SEARCH_DATA_EXPORT_FOLDER as S}from"../../../constants/plugins/search.js";import{envConfig as m}from"../../../config/env-config.js";import{logger as n}from"../../../tools/notifiers/logger.js";import{extractTeamsFromScopeItems as H,getRbacTeamsListForResource as P}from"../../../utils/index.js";import{getSearchDocumentGroup as U}from"../utils.js";import{telemetry as V}from"../../../../cli/telemetry/index.js";import{telemetryTraceStep as A}from"../../../../cli/telemetry/helpers/trace-step.js";async function Q(R,r,d){await A("build.plugin.search.prepare_search_documents",async()=>{n.info("Preparing search documents and create indexes...");const u=m.SEARCH_DEV_DEBUG?$.join(r.contentDir,"..","public","client"):r.outdir;(m.SEARCH_DEV_DEBUG||m.isBuildMode)&&B(`${u}/${S}`)&&await M(`${u}/${S}`,{recursive:!0});const C=n.startTiming(),b=r.getConfig().rbac,v=[y,...R.localeFolders.map(a=>a.toLowerCase())];for(const a of v)await A("build.plugin.search.prepare_search_documents.locale",async c=>{const F=r.getAllRoutesForLocale(a);let h=0,T=0;for(const t of F){if(h++,t.excludeFromSearch)continue;const p=new Map,{product:l}=t,L=await t.getStaticData?.(t,{...r,contentDir:r.contentDir,parseMarkdoc:(s,e,f)=>r.parseMarkdoc(s,e,f)})||{},i=await t.getSearchDocuments?.(t,{...L,[g]:t[g],[E]:t[E]},r),o=t.versions?.find(s=>s.active),w=P(t,b??{});if(i){if(i&&i.length){T+=i.length;for(const s in i){let e=i[s];const f=H(e?.[g]),_=f?.length?f:w,x=e.tags||[];e={...e,...o&&{version:o.version,isDefaultVersion:o.default,versionFolderId:o.folderId},...l&&{product:l},rbacTeams:_,tags:[...x,..._,...o?o.default?["v:default"]:[`v:${o.folderId}:${o.version}`]:["v:default"],...l?[`p:${l.name}`]:[]],url:e.url&&(e.path&&e.path.length>1?e.url:e.url.split("#")[0])};const D=U(e.facets);if(D){const O=p.get(D)??[];p.set(D,[...O,e])}}}for(const[s,e]of p)await d.addDocuments(e,{locale:a,group:s,outDir:u})}}c?.setAttribute("locale",a),c?.setAttribute("totalDocuments",h),c?.setAttribute("totalSearchDocuments",T)});if(d.cleanupFacetValues(r),n.infoTime(C,"Search indexes created"),m.SEARCH_DEV_DEBUG||m.isBuildMode){n.info("Writing out search data...");const a=n.startTiming();await d.export(u);const c=n.infoTime(a,"Search data written");c&&V.sendTimingPerformedMessage(c)}})}export{Q as prepareSearchDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appendFile as
|
|
1
|
+
import{appendFile as E}from"node:fs/promises";import{existsSync as $}from"node:fs";import m from"node:path";import{Client as R}from"typesense";import{SEARCH_GROUP_FACET_FIELD as A,SEARCH_PRODUCT_FIELD as T,SEARCH_RBAC_FIELD as b,SEARCH_VERSION_FIELD as f}from"../../../../../constants/common.js";import{BASE_SEARCH_DOCUMENT as O,DISABLE_DEEP_LINK_IF_FIELDS_EXIST as P,HIGHLIGHTED_TEXT_MAX_LENGTH as F,SEARCH_DATA_EXPORT_FOLDER as S,SEARCH_DOCUMENT_METADATA_KEY as N,SEARCH_GROUP_LIMIT as C,SEARCH_MAX_FACET_VALUES as D,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as v}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as I}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as p}from"../../../../config/env-config.js";import{ensureDir as d}from"../../../../utils/index.js";class q{#e=null;#r="";#t=[{name:"title",type:"string",facet:!1,optional:!0},{name:"text",type:"string",facet:!1,optional:!0},{name:"path",type:"string[]",facet:!1,optional:!0},{name:"isAdditionalOperation",type:"bool",facet:!1,optional:!0},{name:"parameters",type:"object[]",facet:!1,optional:!0},{name:T,type:"string",facet:!0,optional:!0},{name:f,type:"object",facet:!0,optional:!0},{name:b,type:"string[]",facet:!0},{name:"metadata_curated",type:"auto",facet:!1,optional:!0},{name:"metadata_keywords_excludes",type:"auto",facet:!1,optional:!0},{name:"metadata_keywords_includes",type:"auto",facet:!1,optional:!0}];#s=new Map;#n={ORGANIZATION_ID:p.ORGANIZATION_ID??"",PROJECT_ID:p.PROJECT_ID??"",TYPESENSE_API_URL:p.TYPESENSE_API_URL??"",TYPESENSE_API_KEY:p.TYPESENSE_API_KEY??""};constructor(){if(!p.isBuildMode){for(const[e,t]of Object.entries(this.#n))if(!t)throw new Error(`Cannot initialize search index. ${e} is not set`);this.#r=`${this.#n.ORGANIZATION_ID}_${this.#n.PROJECT_ID}_`,this.#e=new R({nodes:[{url:this.#n.TYPESENSE_API_URL}],apiKey:this.#n.TYPESENSE_API_KEY,connectionTimeoutSeconds:5})}}async initIndexSchema(e){this.#p(e)}async addDocuments(e,t){e.push(O);const{locale:o,outDir:n}=t,s=e.map(a=>{const r={...a},c=a[N];return c&&(c.curated&&(r.metadata_curated=c.curated),c.excludes&&(r.metadata_keywords_excludes=c.excludes),c.includes&&(r.metadata_keywords_includes=c.includes)),r}),i=this.#s.get(o)??[];this.#s.set(o,i.concat(s)),i.length+e.length>=v&&await this.exportDocuments(n)}async search(e){return await I("search",async t=>{const{query:o,locale:n,filter:s,loadMore:i,auth:a}=e,r=this.#c(n),c={collection:r,q:o||"*",query_by:this.#l(),max_facet_values:D};if(t?.setAttribute("collectionName",r),t?.setAttribute("locale",n),this.#e)if(i){const{groupKey:l,offset:u}=i,h={offset:u,filter_by:this.#o(a,s),facet_by:"*"};return t?.setAttribute("isLoadMore",!0),t?.setAttribute("filter",h.filter_by),this.#u(await this.#e.collections(r).documents().search({...c,...h}),l)}else{const l={group_by:this.#m(),group_limit:C,filter_by:this.#o(a,s)};t?.setAttribute("groups",l.group_by),t?.setAttribute("filter",l.filter_by);const u=[l,...this.#g(a,s)];return this.#f(await this.#e?.multiSearch.perform({searches:u},c),s)}else return{facets:{},documents:{}}})}#u(e,t){const o={facets:{},documents:{[t]:[]}};if(e.hits&&e.hits.length)for(const n of e.hits)o.documents[t].push({document:this.#a(n),highlight:this.#i(n)});return o}#f(e,t){const o={facets:{},documents:{}};for(const n of this.#_(t))o.documents[n]=[];if("results"in e)for(const n of e.results){if(n.facet_counts&&n.facet_counts.length)for(const s of n.facet_counts)o.facets[s.field_name]=s.counts.map(i=>({value:i.value,count:i.count}));if(n.grouped_hits&&n.grouped_hits.length)for(const s of n.grouped_hits){const i=s.group_key[0],a=[];for(const r of s.hits)a.push({document:this.#a(r),highlight:this.#i(r)});o.documents[i]=a}}return o}#a(e){return this.#h(e)}#i(e){const t={},o=[];for(const[n,s]of Object.entries(e.highlight??{}))if(Array.isArray(s)){if(n==="path"){const i=s,a=[];for(const r of i)a.push(r.snippet);t.path=a}else if(n==="parameters"){const i=s;for(const a of i){let r=!1;for(const[c,l]of Object.entries(a))if(c!=="deepLink")if(Array.isArray(l))for(const u of l)u.matched_tokens?.length&&(r=!0);else l.matched_tokens?.length&&(r=!0);if(r){const c={name:a.name?.snippet||"",description:a.description?.snippet||"",place:a.place?.snippet||"",path:a.path?.map(l=>l?.snippet)||[]};t.parameters=[c];break}}}}else t[n]=s.snippet,o.push(n);for(const[n,s]of Object.entries(e.document))!o.includes(n)&&typeof s=="string"&&(t[n]=s.length>F?`${s.substring(0,F)}...`:s);return t.parameters||(t.parameters=[]),t}#h(e){let t;const o=Object.keys(e.highlight);for(const s of P)if(o.some(i=>i===s))return e.document;const n=e.highlight.parameters;if(n){for(const s of n)for(const[i,a]of Object.entries(s))if(i!=="deepLink"){if(Array.isArray(a)){for(const r of a)if(r.matched_tokens?.length){t=s.deepLink.snippet;break}}else if(a.matched_tokens?.length){t=s.deepLink.snippet;break}}}if(t){const s=t.split("#")[1];return{...e.document,url:`${e.document.url}#${s}`}}return e.document}async exportDocuments(e){const t='{"documents":[',o=d(m.join(e,S));for(const[n,s]of this.#s){if(s.length===0)continue;const i=d(m.join(o,`${n}.json`)),a=!$(i),r=JSON.stringify(s).substring(1).slice(0,-1),c=a?t+r:","+r;await E(i,c,{encoding:"utf8"}),this.#s.set(n,[])}}async exportIndexes(e){const t=d(m.join(e,S));for(const o of this.#s.keys()){const n=d(m.join(t,`${o}.json`)),s=`],"schemaFields":${JSON.stringify(this.#t)}}`;await E(n,s,{encoding:"utf8"})}}async import(e){}async countFacets(e,t){return await I("search.facets",async o=>{const{locale:n,query:s,facetQuery:i,filter:a,field:r,auth:c}=e,l=this.#c(n),u={q:s||"*",query_by:this.#l(),facet_by:"*",facet_query:this.#d(i,r),filter_by:this.#o(c,a,r),max_facet_values:D};if(o?.setAttribute("collectionName",l),o?.setAttribute("query",u.q),o?.setAttribute("facetQuery",u.facet_query),o?.setAttribute("filter",u.filter_by),this.#e){const h={},_=await this.#e.collections(l).documents().search(u);if(_.facet_counts&&_.facet_counts.length)for(const g of _.facet_counts)h[g.field_name]=g.counts.map(y=>({value:y.value,count:y.count,isCounterVisible:!!s||(a?.length||0)>0}));return h}else return{}})}#c(e){return`${this.#r}${e}`}#p(e){for(const[t]of e)this.#t.find(o=>o.name===t)||this.#t.push({name:t,type:"string",facet:!0,optional:!0})}#l(){return this.#t.filter(e=>!e.facet&&!e.name.startsWith("metadata_")&&e.name!=="isAdditionalOperation").map(e=>e.name).join(",")}#m(){return this.#t.filter(e=>e.facet&&e.name===A).map(e=>e.name).join(",")}#o(e,t,o){const n=`${b}:[${e.teams.map(i=>`'${i}'`).join(", ")}]`;let s=`${f}.isDefault:true`;if(t&&t.length){const i=t.filter(r=>r.field!==o&&r.field!==f).map(r=>{const c=r.values.map(l=>`'${l}'`);return c.length?`${r.field}:[${c.join(", ")}]`:""}).join(" && "),a=t.find(r=>r.field===f);if(a&&a.values.length&&a.values.length===2){const r=a.values[0],c=a.values[1],l=`(${f}.folderId:! ${r} && ${f}.isDefault:true)`,u=`(${f}.folderId:${r} && ${f}.version:${c})`;s=`(${l} || ${u})`}return i?`${n} && ${i} && ${s}`:`${n} && ${s}`}else return`${n} && ${s}`}#d(e,t){return e&&t?`${t}:${e}`:""}#_(e){const t=[];if(e&&e.length)for(const o of e)o.field===A&&t.push(...o.values);return t}#g(e,t){const o=[],n=this.#t.filter(s=>s.facet);for(const s of n){const i={facet_by:s.name,filter_by:this.#o(e,t,s.name)};o.push(i)}return o}cleanupFacetValues(e){const t=e.getSearchFacets();t.forEach(o=>{o.values=[]}),e.setSearchFacets(t)}}export{q as Typesense};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SEARCH_GROUP_FACET_FIELD as o}from"../../../constants/common.js";import{DEFAULT_AI_SEARCH_ENABLED as s}from"../../constants/plugins/search.js";import{isPrimitive as c}from"../../../utils/guards/is-primitive.js";import{envConfig as i}from"../../config/env-config.js";import{EntitlementsProvider as n}from"../../entitlements/entitlements-provider.js";function a(e){if(i.isDevelopMode)return i.SEARCH_DEV_DEBUG
|
|
1
|
+
import{SEARCH_GROUP_FACET_FIELD as o}from"../../../constants/common.js";import{DEFAULT_AI_SEARCH_ENABLED as s}from"../../constants/plugins/search.js";import{isPrimitive as c}from"../../../utils/guards/is-primitive.js";import{envConfig as i}from"../../config/env-config.js";import{EntitlementsProvider as n}from"../../entitlements/entitlements-provider.js";function a(e){if(i.isDevelopMode)return i.SEARCH_DEV_DEBUG;if(!n.instance().canAccessFeature("aiSearchLimit"))return!1;const t=e.aiAssistant;return typeof t?.hide=="boolean"?!t?.hide:s}function m(e){return n.instance().canAccessFeature("mcp")?!e.mcp?.hide&&!e.mcp?.docs?.hide:!1}function h(e){const r=a(e),t=m(e);return r||t}function l(e){let r;return e&&Object.keys(e).forEach(t=>{t===o&&(r=e[t])}),r}function S(e){return Object.entries(e||{}).map(([r,t])=>` - ${r}: ${c(t)?t:JSON.stringify(t)}`).join(`
|
|
2
2
|
`)}export{S as formatDocumentMetadata,l as getSearchDocumentGroup,a as isAiSearchEnabled,m as isDocsMcpEnabled,h as shouldGenerateEmbeddings};
|
|
@@ -4,5 +4,4 @@ import type { ContentFs } from '../../fs/content-fs.js';
|
|
|
4
4
|
export declare function sidebarsPlugin({ contentDir, }: PluginOptions): Promise<LifecyclePluginInstance>;
|
|
5
5
|
export declare function removeMarkdownTags(items: ResolvedNavItem[]): ResolvedNavItem[];
|
|
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
|