@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.
Files changed (112) hide show
  1. package/CHANGELOG.md +201 -1
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/{prepare → build}/index.d.ts +2 -2
  4. package/dist/cli/{prepare → build}/index.js +1 -1
  5. package/dist/cli/develop.js +1 -1
  6. package/dist/cli/stats/collectors/{openapi.d.ts → openapi/index.d.ts} +2 -2
  7. package/dist/cli/stats/collectors/openapi/index.js +1 -0
  8. package/dist/cli/stats/collectors/openapi/oas32.d.ts +15 -0
  9. package/dist/cli/stats/collectors/openapi/oas32.js +1 -0
  10. package/dist/cli/stats/index.js +1 -1
  11. package/dist/cli/utils/listen-stdin.d.ts +10 -0
  12. package/dist/cli/utils/listen-stdin.js +2 -0
  13. package/dist/client/TestProvider.js +1 -1
  14. package/dist/client/app/hooks/index.d.ts +1 -0
  15. package/dist/client/app/hooks/index.js +1 -1
  16. package/dist/client/app/hooks/useAnchorPositioning.d.ts +6 -0
  17. package/dist/client/app/hooks/useAnchorPositioning.js +1 -0
  18. package/dist/client/app/l10n/index.js +1 -1
  19. package/dist/client/app/search/useAiSearch.js +1 -1
  20. package/dist/client/app/search/useSearch.js +1 -1
  21. package/dist/client/app/seo/SeoTags.js +1 -1
  22. package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
  23. package/dist/client/templates/asyncapi-docs/template.js +1 -3
  24. package/dist/client/templates/openapi-docs/template.js +2 -6
  25. package/dist/client/types/ai-search.d.ts +1 -0
  26. package/dist/constants/l10n/langs/ar.js +1 -1
  27. package/dist/constants/l10n/langs/de.js +1 -1
  28. package/dist/constants/l10n/langs/en.js +1 -1
  29. package/dist/constants/l10n/langs/es.js +1 -1
  30. package/dist/constants/l10n/langs/fr.js +1 -1
  31. package/dist/constants/l10n/langs/hi.js +1 -1
  32. package/dist/constants/l10n/langs/it.js +1 -1
  33. package/dist/constants/l10n/langs/ja.js +1 -1
  34. package/dist/constants/l10n/langs/ko.js +1 -1
  35. package/dist/constants/l10n/langs/pl.js +1 -1
  36. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  37. package/dist/constants/l10n/langs/pt.js +1 -1
  38. package/dist/constants/l10n/langs/ru.js +1 -1
  39. package/dist/constants/l10n/langs/uk.js +1 -1
  40. package/dist/constants/l10n/langs/zh.js +1 -1
  41. package/dist/server/api-routes/execute-api-route.js +1 -1
  42. package/dist/server/config/env-schema.d.ts +3 -3
  43. package/dist/server/config/env-schemas/search.d.ts +2 -2
  44. package/dist/server/config/env-schemas/search.js +1 -1
  45. package/dist/server/constants/plugins/search.d.ts +0 -4
  46. package/dist/server/constants/plugins/search.js +1 -1
  47. package/dist/server/node-bundle-entry.js +1 -1
  48. package/dist/server/plugins/analytics/segment/browser-hooks.js +1 -1
  49. package/dist/server/plugins/analytics/segment/build-script.js +5 -2
  50. package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.js +37 -37
  51. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +7 -0
  52. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
  53. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +22 -0
  54. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +29 -15
  55. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +6 -0
  56. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
  57. package/dist/server/plugins/entitlements/index.js +1 -1
  58. package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.d.ts +6 -0
  59. package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.js +1 -0
  60. package/dist/server/plugins/graphql-docs/index.js +1 -1
  61. package/dist/server/plugins/markdown/search/nodes/heading-node.js +1 -1
  62. package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +25 -25
  63. package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
  64. package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +1 -1
  65. package/dist/server/plugins/search/documents/search-documents.js +1 -1
  66. package/dist/server/plugins/search/engines/typesense/index.js +1 -1
  67. package/dist/server/plugins/search/utils.js +1 -1
  68. package/dist/server/plugins/sidebars/index.d.ts +0 -1
  69. package/dist/server/plugins/sidebars/index.js +2 -2
  70. package/dist/server/ssr/template.js +3 -3
  71. package/dist/server/tools/notifiers/logger.d.ts +2 -2
  72. package/dist/server/tools/notifiers/logger.js +2 -2
  73. package/dist/server/tools/notifiers/reporter.d.ts +0 -1
  74. package/dist/server/tools/notifiers/reporter.js +6 -7
  75. package/dist/server/tools/notifiers/terminal-manager.d.ts +1 -1
  76. package/dist/server/tools/notifiers/terminal-manager.js +5 -4
  77. package/dist/server/utils/lifecycle-hooks.d.ts +2 -2
  78. package/dist/server/utils/rbac.js +1 -1
  79. package/dist/server/web-server/routes/catalog/catalog.js +1 -1
  80. package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.d.ts +12 -0
  81. package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.js +1 -0
  82. package/dist/server/web-server/routes/cors-proxy.js +2 -2
  83. package/package.json +13 -13
  84. package/dist/cli/stats/collectors/openapi.js +0 -1
  85. /package/dist/cli/{prepare → build}/analytics/collect-analytics.d.ts +0 -0
  86. /package/dist/cli/{prepare → build}/analytics/collect-analytics.js +0 -0
  87. /package/dist/cli/{prepare → build}/analytics/collectors/get-api-functions-usage.d.ts +0 -0
  88. /package/dist/cli/{prepare → build}/analytics/collectors/get-api-functions-usage.js +0 -0
  89. /package/dist/cli/{prepare → build}/analytics/collectors/get-async-api-usage.d.ts +0 -0
  90. /package/dist/cli/{prepare → build}/analytics/collectors/get-async-api-usage.js +0 -0
  91. /package/dist/cli/{prepare → build}/analytics/collectors/get-config-stats-usage.d.ts +0 -0
  92. /package/dist/cli/{prepare → build}/analytics/collectors/get-config-stats-usage.js +0 -0
  93. /package/dist/cli/{prepare → build}/analytics/collectors/get-file-extensions-usage.d.ts +0 -0
  94. /package/dist/cli/{prepare → build}/analytics/collectors/get-file-extensions-usage.js +0 -0
  95. /package/dist/cli/{prepare → build}/analytics/collectors/get-frontmatter-usage.d.ts +0 -0
  96. /package/dist/cli/{prepare → build}/analytics/collectors/get-frontmatter-usage.js +0 -0
  97. /package/dist/cli/{prepare → build}/analytics/collectors/get-markdoc-usage.d.ts +0 -0
  98. /package/dist/cli/{prepare → build}/analytics/collectors/get-markdoc-usage.js +0 -0
  99. /package/dist/cli/{prepare → build}/analytics/collectors/get-nested-configs-usage.d.ts +0 -0
  100. /package/dist/cli/{prepare → build}/analytics/collectors/get-nested-configs-usage.js +0 -0
  101. /package/dist/cli/{prepare → build}/analytics/collectors/get-processed-config-stats-usage.d.ts +0 -0
  102. /package/dist/cli/{prepare → build}/analytics/collectors/get-processed-config-stats-usage.js +0 -0
  103. /package/dist/cli/{prepare → build}/analytics/collectors/get-refs-usage.d.ts +0 -0
  104. /package/dist/cli/{prepare → build}/analytics/collectors/get-refs-usage.js +0 -0
  105. /package/dist/cli/{prepare → build}/analytics/collectors/get-theme-folder-usage.d.ts +0 -0
  106. /package/dist/cli/{prepare → build}/analytics/collectors/get-theme-folder-usage.js +0 -0
  107. /package/dist/cli/{prepare → build}/copy-env-files.d.ts +0 -0
  108. /package/dist/cli/{prepare → build}/copy-env-files.js +0 -0
  109. /package/dist/cli/{prepare → build}/libsql/copy-prebuilt-binary.d.ts +0 -0
  110. /package/dist/cli/{prepare → build}/libsql/copy-prebuilt-binary.js +0 -0
  111. /package/dist/cli/{prepare → build}/libsql/get-current-platform.d.ts +0 -0
  112. /package/dist/cli/{prepare → build}/libsql/get-current-platform.js +0 -0
@@ -1,4 +1,4 @@
1
- import{and as u,count as F,eq as _,isNotNull as X,notExists as f,or as J,sql as e}from"drizzle-orm";import{unionAll as p}from"drizzle-orm/sqlite-core";import{logger as q}from"../../../../../tools/notifiers/logger.js";import{VERSION_NOT_SPECIFIED as v}from"@redocly/theme/core/constants";import{applyPagination as R}from"../../../../../providers/database/pagination/index.js";import{applyFilter as P}from"../../../../../providers/database/pagination/filter.js";import{createEntityFieldsForSelect as S,FIELDS_TO_SELECT_FOR_ENTITY as h,FIELDS_TO_SELECT_FOR_ENTITY_RELATION as m}from"../utils.js";import{createEntityReadModel as g}from"../../mappers/create-entity-read-model.js";import{entitiesTable as t}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 d}from"../../../../../providers/database/databases/catalog-sqlite/schemas/entities-attributes-table.js";import{CatalogEntitiesRelationsRepository as b}from"./catalog-entities-relations-repository.js";import{CatalogEntitiesBffRepository as $}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 A}from"../utils/build-entities-exclusion-filter.js";import{buildRbacFilter as T,buildRbacFilterRaw as Y}from"../utils/build-rbac-filter.js";import{createEntityRelationReadModel as M}from"../../mappers/create-entity-relation-read-model.js";class Ee{#e;#t=void 0;#i;#s;constructor(i){this.#e=i,this.#i=new b(this.#e,this.#t||""),this.#s=new $(this.#e,this.#t||"")}async attachDatabase(i){this.#t!==i&&(this.#t=i,await this.#e.client.run(e`ATTACH DATABASE ${i} AS remote`),this.#i=new b(this.#e,i),this.#s=new $(this.#e,i))}async getEntities({paginationParams:i,rbacTeams:s,excludedTypes:r,excludedEntities:n}){const o=A(r,n,"remote.entities"),c=A(r,n,"entities"),a=A(r,n,"r"),l=this.#t?p(this.#e.client.select(S("remote.entities")).from(e`remote.entities`).leftJoin(e`remote.entities_attributes`,_(t.key,d.entityKey)).where(u(T(s,"remote.entities_attributes"),o,f(this.#e.client.select({id:h.id}).from(t).where(u(e`${t.key} = remote.entities.key`,e`${t.version} = remote.entities.version`,e`${t.revision} = remote.entities.revision`))))),this.#e.client.select(S("entities")).from(t).leftJoin(d,_(t.key,d.entityKey)).where(u(T(s,"entities_attributes"),c,f(this.#e.client.select({id:e.raw("id")}).from(e`remote.entities as r`).where(u(e`r.key = ${t.key}`,e`r.version = ${t.version}`,e`r.revision = ${t.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(T(s,"ea"),a))):this.#e.client.select(S("entities")).from(t).leftJoin(d,_(t.key,d.entityKey)).where(u(T(s,"entities_attributes"),c)),N=this.#e.client.select(h).from(l.as("combined_entities")),E=this.#e.client.select(h).from(l.as("combined_entities")).$dynamic(),k=R(E,{...i,limit:void 0,skip:void 0,after:void 0,before:void 0}),O=this.#e.client.$count(k),w=N.$dynamic(),I=i.limit||10,U=R(w,{...i,limit:I+1}),[W,V]=await Promise.all([U.run(),O]),D=W.rows,H=D.length>I;return{items:D.slice(0,I).map(C=>g(C)).filter(C=>C!==null),hasMore:H,total:V}}async getEntityKeysAndVersionsBySourceFile(i){const s=this.#t?p(this.#e.client.select({keyVersion:e`key || ':' || COALESCE(version, ${v})`.as("keyVersion")}).from(e`remote.entities`).where(u(e`source_file = ${i}`,e`source = 'file'`,e`key IS NOT NULL`)),this.#e.client.select({keyVersion:e`${t.key} || ':' || COALESCE(${t.version}, ${v})`.as("keyVersion")}).from(t).where(u(_(t.sourceFile,i),_(t.source,"file"),e`${t.key} IS NOT NULL`,f(this.#e.client.select({key:e.raw("key")}).from(e`remote.entities as remote`).where(e`remote.key = ${t.key}`))))):this.#e.client.select({keyVersion:e`${t.key} || ':' || COALESCE(${t.version}, ${v})`.as("keyVersion")}).from(t).where(u(_(t.sourceFile,i),_(t.source,"file"),X(t.key))),r=await this.#e.client.selectDistinct({keyVersion:e`combined_keys_versions.keyVersion`}).from(s.as("combined_keys_versions")).run();return new Set(r.rows.map(n=>n.keyVersion))}async listEntityRevisions(i,s){const r=[_(t.key,i),_(t.isDeleted,!1),...s?[_(t.version,s)]:[]],n={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?p(this.#e.client.select(n).from(e`remote.entities`).where(u(e`key = ${i}`,e`is_deleted = 0`,s?e`version = ${s}`:void 0,f(this.#e.client.select({id:e.raw("id")}).from(t).where(u(e`${t.key} = remote.entities.key`,e`${t.version} = remote.entities.version`,e`${t.revision} = remote.entities.revision`))))),this.#e.client.select({version:t.version,revision:t.revision,isCurrent:t.isCurrent,createdAt:t.createdAt,updatedAt:t.updatedAt,isDefaultVersion:t.isDefaultVersion}).from(t).where(u(...r,f(this.#e.client.select({id:e.raw("id")}).from(e`remote.entities as r`).where(u(e`r.key = ${t.key}`,e`r.version = ${t.version}`,e`r.revision = ${t.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 = ${i}`,e`r.is_deleted = 0`,e`l.is_deleted = 0`,s?e`r.version = ${s}`:void 0))):this.#e.client.select({version:t.version,revision:t.revision,isCurrent:t.isCurrent,createdAt:t.createdAt,updatedAt:t.updatedAt,isDefaultVersion:t.isDefaultVersion}).from(t).where(u(...r)),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(l=>({version:l.version,revision:l.revision??"",isCurrent:l.is_current!==null?!!l.is_current:!1,createdAt:l.created_at,updatedAt:l.updated_at,isDefaultVersion:l.is_default_version!==null?!!l.is_default_version:!1}));return x(a),a}async getEntitiesCountByTypes(){if(this.#t){const i=e`
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:F()}).from(e`(SELECT * FROM (${i}) WHERE rn = 1) as highest_version_entities`).groupBy(e`type`)}return this.#e.client.select({type:t.type,count:F()}).from(t).where(u(_(t.isCurrent,!0),_(t.isDeleted,!1))).groupBy(t.type)}async getEntityById(i,s){const{rbacTeams:r,excludedTypes:n,excludedEntities:o}=s||{},c=A(n,o,"remote.entities"),a=A(n,o,"entities"),E=(await(this.#t?p(this.#e.client.select(S("remote.entities")).from(e`remote.entities`).leftJoin(e`remote.entities_attributes`,_(t.key,d.entityKey)).where(u(e`remote.entities.id = ${i}`,T(r,"remote.entities_attributes"),c)),this.#e.client.select(S("entities")).from(t).leftJoin(d,_(t.key,d.entityKey)).where(u(_(t.id,i),T(r,"entities_attributes"),a))):this.#e.client.select(S("entities")).from(t).leftJoin(d,_(t.key,d.entityKey)).where(u(_(t.id,i),T(r,"entities_attributes"),a))).run()).rows[0];return E?g(E):null}async getOutdatedEntities(i){const s=this.#t?p(this.#e.client.select(h).from(e`remote.entities`),this.#e.client.select(h).from(t).where(f(this.#e.client.select({id:h.id}).from(e`remote.entities as remote`).where(e`remote.key = ${t.key}`)))):this.#e.client.select(h).from(t),r=this.#e.client.select(h).from(s.as("combined_entities")).$dynamic(),{whereCondition:n}=P(r,i),o=J(e`combined_entities.scorecards_status = 'OUTDATED'`,e`combined_entities.scorecards_status IS NULL`),c=n?u(n,o):o;return(await r.where(c).run()).rows.map(l=>g(l)).filter(l=>l!==null)}async getEntitiesRelations(i={}){const s=this.#t?p(this.#e.client.select(m).from(e`remote.entities_relations`),this.#e.client.select(m).from(y).where(f(this.#e.client.select({id:m.id}).from(e`remote.entities_relations as remote`).where(e`remote.source_key = ${y.sourceKey}`)))):this.#e.client.select(m).from(y),r=this.#e.client.select(m).from(s.as("combined_entities_relations")).$dynamic(),n=this.#e.client.select(m).from(s.as("combined_entities_relations")).$dynamic(),o=R(n,{...i,limit:void 0,skip:void 0,after:void 0,before:void 0}),c=this.#e.client.$count(o),a=i.limit||10,l=R(r,{...i,limit:a+1}),[N,E]=await Promise.all([l.run(),c]),k=N.rows,O=k.length>a;return{items:k.slice(0,a).map(w=>M(w)).filter(w=>w!==null),hasMore:O,total:E}}async getEntityRelationById(i){const n=(await(this.#t?p(this.#e.client.select(m).from(e`remote.entities_relations`).where(_(y.id,i)),this.#e.client.select(m).from(y).where(u(_(y.id,i),f(this.#e.client.select({id:m.id}).from(e`remote.entities_relations as remote`).where(e`remote.id = ${y.id}`))))):this.#e.client.select(m).from(y).where(_(y.id,i))).run()).rows[0];return n?M(n):null}async getEntitiesWithRelations({paginationParams:i,rbacTeams:s,excludedEntities:r,excludedTypes:n}){return this.#s.getEntitiesWithRelations({paginationParams:i,rbacTeams:s,excludedEntities:r,excludedTypes:n})}async getEntityWithRelationsByKey({entityKey:i,filter:s,rbacTeams:r,excludedTypes:n,excludedEntities:o}){return this.#s.getEntityWithRelationsByKey({entityKey:i,filter:s,rbacTeams:r,excludedTypes:n,excludedEntities:o})}async getRelationsForEntity(i,s,r){return this.#i.getRelationsForEntity(i,s,r)}async getRelatedEntities({key:i,paginationParams:s,rbacTeams:r,excludedTypes:n,excludedEntities:o}){return this.#i.getRelatedEntities({key:i,paginationParams:s,rbacTeams:r,excludedTypes:n,excludedEntities:o})}async getCatalogFilters({entitiesTypes:i=[],emptyFilters:s=[],rbacTeams:r,excludedTypes:n,excludedEntities:o}){if(!s.length)return{};try{return await this.#r({entitiesTypes:i,rbacTeams:r,excludedTypes:n,excludedEntities:o}),(s.includes("domains")||s.includes("owners"))&&await this.#o(),await this.#a(s)}catch(c){return console.error("Error fetching catalog filters:",c),{}}finally{await this.#c()}}async#r({entitiesTypes:i,rbacTeams:s,excludedTypes:r,excludedEntities:n}){const o=Y(s,"ea"),c=this.#n(r,n);if(this.#t){const a=["e.is_current = 1","e.is_deleted = 0"];o&&a.push(o),c&&a.push(c.replace(/ENTITY_ALIAS/g,"e"));const l=["r.key IS NULL","e.is_current = 1","e.is_deleted = 0"];o&&l.push(o),c&&l.push(c.replace(/ENTITY_ALIAS/g,"e")),await this.#e.client.run(e.raw(`
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 ${l.join(" AND ")}
32
- `))}else{const a=["e.is_current = 1","e.is_deleted = 0"];o&&a.push(o),c&&a.push(c.replace(/ENTITY_ALIAS/g,"e")),await this.#e.client.run(e.raw(`
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(i.length){const a=i.map(l=>`'${l.replace(/'/g,"''")}'`).join(",");await this.#e.client.run(e.raw(`
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
- `)}#n(i,s){const r=[];if(i&&i.length>0){const n=i.map(o=>`'${o.replace(/'/g,"''")}'`).join(", ");r.push(`ENTITY_ALIAS.type NOT IN (${n})`)}if(s&&s.length>0){const n=s.map(o=>`'${o.replace(/'/g,"''")}'`).join(", ");r.push(`ENTITY_ALIAS.key NOT IN (${n})`)}return r.length>0?`(${r.join(" AND ")})`:null}async#o(){this.#t?await this.#e.client.run(e`
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(i){const s={},r=[],n=i.filter(a=>a.startsWith("metadata."));i.includes("type")&&r.push(`
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
- `),i.includes("tags")&&r.push(`
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
- `),i.includes("domains")&&r.push(`
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
- `),i.includes("owners")&&r.push(`
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 n)await this.#l(a,s);if(r.length===0)return s;const o=r.join(" UNION ALL "),c=await this.#e.client.run(e.raw(o));if(c?.rows)for(const a of c.rows){const l=a.filter_name,N=a.value,E=Number(a.count)||0;s[l]||(s[l]=[]),N&&s[l].push({value:N,count:E})}return s}async#l(i,s){const r=i.substring(9),n=`$.${Q(r)}`,o=await this.#e.client.run(e.raw(`
124
- SELECT json_extract(metadata, '${n}') as value, COUNT(*) as count
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, '${n}') IS NOT NULL
129
- AND json_extract(metadata, '${n}') != ''
128
+ AND json_extract(metadata, '${r}') IS NOT NULL
129
+ AND json_extract(metadata, '${r}') != ''
130
130
  GROUP BY value
131
- `));o?.rows&&(s[i]=o.rows.map(c=>({value:c.value,count:Number(c.count)||0})).filter(c=>c.value))}async#c(){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(i){q.error("Error cleaning up temp tables:",i)}}}function Q(L){return L.replace(/[^a-zA-Z0-9._-]/g,"")}export{Ee as CatalogEntitiesLocalReadRepository};
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 g}from"../../mappers/create-entity-relation-db-record-from-dto.js";import{hasOptionsChanged as I}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=I(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=g(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 y=a.direction,o=a.sourceToTargetRelation,u=a.targetKey,d=y==="outgoing"?n.entityKey:u,h=y==="outgoing"?u:n.entityKey,E=y==="outgoing"?o:o.startsWith("reverse:")?o.slice(8):o;return!E||!d||!h?null:g({type:E,sourceKey:d,targetKey:h,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)}}export{r as CatalogEntitiesLocalRepository};
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 P}from"node:fs";import T from"path";import{PAGE_COUNT_OUTPUT_FILE_NAME as y}from"../../constants/common.js";import{envConfig as F}from"../../config/env-config.js";import{logger as o}from"../../tools/notifiers/logger.js";import{isReactPage as S}from"../../utils/content/is-react-page.js";import{EntitlementsProvider as b}from"../../entitlements/entitlements-provider.js";import{getBilledPagesCount as O,isPathIgnored as R}from"../../utils/index.js";import{isGraphqlDoc as $}from"../graphql-docs/is-graphql-doc.js";import{isMarkdownPage as M}from"../markdown/is-markdown-page.js";import{isOpenapiDoc as k}from"../openapi-docs/is-openapi-doc.js";import{PRODUCT_NAME as l}from"../../../config/product-gates.js";import{isAsyncapiDoc as E}from"../asyncapi-docs/is-asyncapi-doc.js";import{telemetryTraceStep as _}from"../../../cli/telemetry/helpers/trace-step.js";async function z(){return{id:"entitlements",async afterRoutesCreated(w,u){await _("build.plugin.entitlements",async t=>{const i=b.instance(),n=[],r=[],s=[],a=[],p=[];for(const{relativePath:e}of u.fs.scan())R(e)||(M(e)?n.push(e):$(e)?s.push(e):S(e)?a.push(e):await k(e,u)?r.push(e):await E(e,u)&&p.push(e));const g=i.canAccessFeature("markdown");t?.setAttribute("totalMarkdownFiles",n.length.toString()),t?.setAttribute("isMarkdownSupported",(!!g).toString()),n.length>0&&!g&&o.warn(`The product you are using ("${l}") does not support Markdown pages. The following Markdown files were detected but will be ignored: ${n.map(()=>"%rp").join(", ")}`,...n);const c=i.canAccessFeature("openapi");t?.setAttribute("totalOpenApiFiles",r.length.toString()),t?.setAttribute("isOpenApiSupported",(!!c).toString()),r.length>0&&!c&&o.warn(`The product you are using ("${l}") does not support OpenAPI documents. The following files are ignored: ${r.map(()=>"%rp").join(", ")}`,...r);const d=i.canAccessFeature("asyncapi");t?.setAttribute("totalAsyncApiFiles",p.length.toString()),t?.setAttribute("isAsyncApiSupported",(!!d).toString()),p.length>0&&!d&&o.warn(`The product you are using ("${l}") does not support AsyncAPI documents. The following files are ignored: ${p.map(()=>"%rp").join(", ")}`,...p);const m=i.canAccessFeature("graphql");t?.setAttribute("totalGraphqlFiles",s.length.toString()),t?.setAttribute("isGraphqlSupported",(!!m).toString()),s.length>0&&!m&&o.warn(`The product you are using ("${l}") does not support GraphQL documents. The following files are ignored: ${s.map(()=>"%rp").join(", ")}`,...s);const f=i.canAccessFeature("reactPages");t?.setAttribute("totalReactFiles",a.length.toString()),t?.setAttribute("isReactPagesSupported",(!!f).toString()),a.length>0&&!f&&o.warn(`The product you are using ("${l}") does not support React pages. The following files are ignored: ${a.map(()=>"%rp").join(", ")}`,...a);const A=O(w.getAllRoutes());t?.setAttribute("totalBilledPages",A.toString());const h=F.REDOCLY_METADATA_OUTPUT_FOLDER;h&&(o.info("Save total pages..."),P(T.join(h,y),JSON.stringify({totalPages:A},null)))})}}}export{z as entitlementsPlugin};
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 C}from"node:fs";import $ from"node:path";import{REDOCLY_TEAMS_RBAC as v}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 H,GRAPHQL_SPEC_SLUG as N,PUBLIC_RBAC_SCOPE_ITEM as O}from"../../../constants/common.js";import{removeTrailingSlash as _}from"../../../utils/url/remove-trailing-slash.js";import{getTemplatePath as Q}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:u,withPathPrefix:p})=>{await x("build.plugin.graphql_docs",async()=>{t.createRequestHandler(R,U(import.meta.url,"./spec-download.api.js")),t.addApiRoute({slug:N+"/*",requestHandlerId:R,httpMethod:"all",[v]:O,getStaticData:async()=>({props:{}})});const m=t.createTemplate(H,Q("./template/GraphQLDocs.js"));for(const{relativePath:o}of n.scan(/(\.gql|\.graphql)$/)){if(await u(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:T,settings:i,metadata:y,store:c}=h.data,b=`${B}${o}`;await t.createSharedData(b,T);const d=[{key:"graphQlSettings",id:b}],E=q.getGroups(),G=q.getSidebarItems(),g={type:"graphql",title:E[0].name,...y},s=[{slugSuffix:"",fsPath:o,templateId:m,getStaticData:S(void 0,i,p),sharedData:d,getAiDocumentsStore:A({label:i.info?.title??"GraphQL Overview",groupName:"overview",metadata:g,actions:t,store:c,includeInLLMsTxt:!0})}];for(const r of E){const f=`${r.id}`;s.push({slugSuffix:f,fsPath:o,templateId:m,getStaticData:S(r,i,p),sharedData:d});for(const e of r.typeGroups){const a=`${e.id}`;s.push({slugSuffix:a,fsPath:o,templateId:m,getStaticData:S(e,i,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 L of e.items){const P=`${e.id}/${L}`;s.push({slugSuffix:P,fsPath:o,templateId:m,getStaticData:S(e,i,p),sharedData:d,getAiDocumentsStore:A({label:L,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(G)},D.getSearchDocuments=F(t,c);for(const r of s)t.addRoute(r)}})}}}function S(t,n,l){return async function(u){return{props:{seo:{title:t?.name},settings:{...n,location:{section:t?.id},sidebar:{hide:!0},baseUrlPath:l(u.baseSlug)},disableAutoScroll:!0}}}}function j(t,n,l){const u=w.slice(1);C(k($.resolve(n,`${u}/${l}`)),t,"utf8")}export{nt as graphqlDocsPlugin,j as storeGqlSchema};
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 t,WithSlugId as r}from"./section-node.js";class i extends r(t){constructor(e){super({...e,parentNode:null})}getUrl(e){return`${e}#${this.id}`}getPath(e){return[...e.values()].slice(0,this.node.attributes.level+1).filter(Boolean)}}export{i as HeadingNode};
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 R,join as _}from"node:path";import{toMarkdown as L}from"../../../plugins/markdown/search/to-markdown.js";import{canDownloadApiDefinition as G,isResourcePubliclyAccessible as E}from"../../../utils/rbac.js";import{PUBLIC_API_DEFINITIONS_FOLDER as J}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 q}from"../../../fs/utils/get-locale-from-relative-path.js";import{extractDocumentSearchFacets as B}from"./search-facets.js";import{formatDocumentMetadata as C}from"../../search/utils.js";import{getLLMsTxtMdSlug as Y,llmsTxtLink as M}from"../../search/llmstxt/index.js";import{replaceFileExtension as H}from"../store-definition-bundles.js";const x=new Map,me=({parser:i,options:c,info:t,tagOperations:s,relativePath:n,openapiContentItem:e,metadata:r,getSearchFacets:o,includeInLLMsTxt:a,excludeFromSearch:m})=>async(u,f,l)=>{if(m)return;const D=await u.getNavText?.()||R(u.fsPath),A=new V(i,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}=ee(s.tagged,A,O),{all:T,publiclyAccessible:w}=ne(s.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=X({title:S,security:i.definition.security,document:p,version:p.version||t.version,headingLevel:h,operation:b});break;case"section":if(e.infoDefinition){$=x.get(n),d=await P({parser:i,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=i.definition.tags?.find(F=>F.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 P({parser:i,info:t,staticData:f,relativePath:n,headingLevel:h,pageName:D,config:O})}else e.ast&&(d=g=L(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=Z({title:S,description:e.description,name:e.name,xMcpConfig:i.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=q(u.fsPath),y=B({...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 P({parser:i,info:c,staticData:t,relativePath:s,pageName:n,headingLevel:e,config:r}){const o=C(c["x-metadata"]);let a=c.title?`${e} ${c.title}
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+=K({parser:i,headingLevel:e}),a+=W({parser:i,headingLevel:e}),a+=await Q({info:c,staticData:t,relativePath:s,pageName:n,headingLevel:e,config:r}),a}function j({title:i="",description:c,operationSearchDocuments:t,headingLevel:s}){let n=`${s} ${i}
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+=`${s}# ${r}${e.deprecated?" (deprecated)":""}
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+=` - ${M({title:`${e.httpMethod?.toUpperCase()} ${e.httpPath}`,description:Array.isArray(e.text)?e.text.join(" "):e.text,slug:Y(e.url)})}`,n+=`
22
- `}),n}function K({parser:i,headingLevel:c}){const{servers:t}=i.definition;if(t&&t.length){let s=`${c} Servers
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=>{s+=n.description?`${n.description}
25
- `:"",s+=`\`\`\`
24
+ `;return t.forEach(n=>{i+=n.description?`${n.description}
25
+ `:"",i+=`\`\`\`
26
26
  ${n.url}
27
27
  \`\`\`
28
28
 
29
- `,n.variables&&(s+=`Variables:
30
- `,Object.entries(n.variables).forEach(([e,r])=>{s+=`- \`${e}\`${r.description?`: ${r.description}`:""}
31
- `,s+=r.default?`Default: ${JSON.stringify(r.default)}
32
- `:"",s+=r.enum?`Enum: ${r.enum.map(o=>JSON.stringify(o)).join(", ")}
33
- `:""}),s+=`
34
- `)}),s}return""}async function Q({info:i,staticData:c,relativePath:t,pageName:s,headingLevel:n,config:e}){const r=_(c.props?.outdir||"",J,H(t,".yaml"));if(G(r,e.rbac||{},e.requiresLogin||!1,{isAuthenticated:!1,teams:[z]})){let o=`${n} Download OpenAPI description
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+=M({title:i.title||s||"OpenAPI definition",description:void 0,slug:r}),o}return""}function W({parser:i,headingLevel:c}){if(!i.definition.components?.securitySchemes)return"";let t=`${c} Security
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:s}=i.definition.components;return Object.keys(s).forEach(n=>{const e=s[n];e&&(t+=`${c}# ${n}
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 X({title:i,security:c,document:t,version:s,headingLevel:n,operation:e}){const{text:r,httpMethod:o,httpPath:a,deprecated:m}=t,u=v(t.parameters||[],`${n}#`),f=I(`${n}#`,t.parameters,e);let l=i?`${n} ${i}${m?" (deprecated)":""}
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+=s?`Version: ${s}
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 Z({title:i,name:c,xMcpConfig:t,headingLevel:s}){const n=t?.tools.find(r=>r.name===c);if(!n)return"";let e=`${s} ${i}
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+=`${s}# Input schema:
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+=`${s}# Output schema:
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 I(i,c,t){return!c&&!t||!t?.responses?[]:t?.responses.filter(n=>!n.content?.mediaTypes[0]?.schema).map(n=>`${i} ${N(`response ${n.code} fields`)}
84
- `)}function v(i,c){const t={};for(const n of i){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":""})
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} ${N(n)}:
88
+ `),f});return`${c} ${P(n)}:
89
89
 
90
90
  ${r.join(`
91
91
  `)}`}).join(`
92
- `)}function ee(i,c,t){const s=[],n=[];return i.forEach((e,r)=>{const o=[],a=[];e.forEach(m=>{const u=c.addItem(m);u&&(o.push(u),E({[k]:m[k],slug:u.url},t)&&a.push(u))}),s.push([r,o]),n.push([r,a])}),{all:s,publiclyAccessible:n}}function ne(i,c,t){const s=[],n=[];return i.forEach(e=>{const r=c.addItem(e);r&&(s.push(r),E({[k]:e[k],slug:r.url},t)&&n.push(r))}),{all:s,publiclyAccessible:n}}function N(i){return i.charAt(0).toUpperCase()+i.slice(1)}export{me as getAiDocumentsStore};
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 from"node:path";import{logger as n}from"../../../tools/notifiers/logger.js";import{reporter as s}from"../../../tools/notifiers/reporter.js";import{getServerProps as d}from"../../../ssr/server-side-props/get-server-props.js";import{telemetry as f}from"../../../../cli/telemetry/index.js";async function b(e,o){s.clearPageRenderProblems();const r=e.getAllRoutes().filter(t=>t.fsPath.match(/\.page\.tsx?$/));if(!r.length)return;const l=n.startTiming();n.info("Validating react pages");const g=await p(e.serverOutDir);for(const t of r){const c=await e.resolveRouteStaticData(t,o),m=await d(t,null,c,e);let a;try{a=(await g(t,m,null,e,f,!0)).error}catch(i){a=i}a&&s.reportPageRenderError({message:a.name==="PageMissingDefaultExportError"?a.message:`Runtime error: ${a.message}`,sourceFileRelativePath:t.fsPath})}n.infoTime(l,`Validated ${r.length} React pages`)}async function p(e){const r=await import(u.join(e,"index.mjs"));if(!r.renderPage)throw new Error("renderPage function not found in bundle");return r.renderPage}export{b as validateReactPages};
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 T,REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{existsSync as M}from"fs";import{rm as O}from"node:fs/promises";import{DEFAULT_LOCALE_PLACEHOLDER as $}from"../../../../constants/common.js";import{SEARCH_DATA_EXPORT_FOLDER as S}from"../../../constants/plugins/search.js";import{envConfig as A}from"../../../config/env-config.js";import{logger as n}from"../../../tools/notifiers/logger.js";import{extractTeamsFromScopeItems as y,getRbacTeamsListForResource as P}from"../../../utils/index.js";import{getSearchDocumentGroup as B}from"../utils.js";import{telemetry as I}from"../../../../cli/telemetry/index.js";import{telemetryTraceStep as R}from"../../../../cli/telemetry/helpers/trace-step.js";async function J(_,t,l){await R("build.plugin.search.prepare_search_documents",async()=>{n.info("Preparing search documents and create indexes..."),A.isBuildMode&&M(`${t.outdir}/${S}`)&&await O(`${t.outdir}/${S}`,{recursive:!0});const b=n.startTiming(),v=t.getConfig().rbac,F=[$,..._.localeFolders.map(a=>a.toLowerCase())];for(const a of F)await R("build.plugin.search.prepare_search_documents.locale",async c=>{const C=t.getAllRoutesForLocale(a);let g=0,D=0;for(const r of C){if(g++,r.excludeFromSearch)continue;const d=new Map,{product:m}=r,L=await r.getStaticData?.(r,{...t,contentDir:t.contentDir,parseMarkdoc:(s,e,u)=>t.parseMarkdoc(s,e,u)})||{},i=await r.getSearchDocuments?.(r,{...L,[p]:r[p],[T]:r[T]},t),o=r.versions?.find(s=>s.active),w=P(r,v??{});if(i){if(i&&i.length){D+=i.length;for(const s in i){let e=i[s];const u=y(e?.[p]),h=u?.length?u:w,x=e.tags||[];e={...e,...o&&{version:o.version,isDefaultVersion:o.default,versionFolderId:o.folderId},...m&&{product:m},rbacTeams:h,tags:[...x,...h,...o?o.default?["v:default"]:[`v:${o.folderId}:${o.version}`]:["v:default"],...m?[`p:${m.name}`]:[]],url:e.url&&(e.path&&e.path.length>1?e.url:e.url.split("#")[0])};const f=B(e.facets);if(f){const E=d.get(f)??[];d.set(f,[...E,e])}}}for(const[s,e]of d)await l.addDocuments(e,{locale:a,group:s,outDir:t.outdir})}}c?.setAttribute("locale",a),c?.setAttribute("totalDocuments",g),c?.setAttribute("totalSearchDocuments",D)});if(l.cleanupFacetValues(t),n.infoTime(b,"Search indexes created"),A.isBuildMode){n.info("Writing out search data...");const a=n.startTiming();await l.export(t.outdir);const c=n.infoTime(a,"Search data written");c&&I.sendTimingPerformedMessage(c)}})}export{J as prepareSearchDocuments};
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 A}from"node:fs/promises";import{existsSync as v}from"node:fs";import m from"node:path";import{Client as R}from"typesense";import{SEARCH_GROUP_FACET_FIELD as D,SEARCH_PRODUCT_FIELD as b,SEARCH_RBAC_FIELD as g,SEARCH_VERSION_FIELD as h}from"../../../../../constants/common.js";import{BASE_SEARCH_DOCUMENT as $,DEFAULT_ORGANIZATION_ID as O,DEFAULT_PROJECT_ID as P,DEFAULT_TYPESENSE_API_KEY as N,DEFAULT_TYPESENSE_API_URL as L,DISABLE_DEEP_LINK_IF_FIELDS_EXIST as C,HIGHLIGHTED_TEXT_MAX_LENGTH as I,SEARCH_DATA_EXPORT_FOLDER as F,SEARCH_DOCUMENT_METADATA_KEY as M,SEARCH_GROUP_LIMIT as w,SEARCH_MAX_FACET_VALUES as S,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as k}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as T}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as u}from"../../../../config/env-config.js";import{logger as j}from"../../../../tools/notifiers/logger.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:b,type:"string",facet:!0,optional:!0},{name:h,type:"object",facet:!0,optional:!0},{name:g,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;#o={ORGANIZATION_ID:u.ORGANIZATION_ID||(u.isDevelopMode?O:""),PROJECT_ID:u.PROJECT_ID||(u.isDevelopMode?P:""),TYPESENSE_API_URL:u.TYPESENSE_API_URL||(u.isDevelopMode?L:""),TYPESENSE_API_KEY:u.TYPESENSE_API_KEY||(u.isDevelopMode?N:"")};constructor(){if(!u.isBuildMode){for(const[e,t]of Object.entries(this.#o))if(!t)throw new Error(`Cannot initialize search index. ${e} is not set`);this.#r=`${this.#o.ORGANIZATION_ID}_${this.#o.PROJECT_ID}_`,this.#e=new R({nodes:[{url:this.#o.TYPESENSE_API_URL}],apiKey:this.#o.TYPESENSE_API_KEY,connectionTimeoutSeconds:5})}}async initIndexSchema(e){this.#d(e),u.isDevelopMode&&await this.#m()}async addDocuments(e,t){e.push($);const{locale:i,outDir:r}=t,o=e.map(n=>{const s={...n},a=n[M];return a&&(a.curated&&(s.metadata_curated=a.curated),a.excludes&&(s.metadata_keywords_excludes=a.excludes),a.includes&&(s.metadata_keywords_includes=a.includes)),s});if(u.isDevelopMode){if(o.length){await this.#p(i);try{const n=o.map(s=>({url:s.url,title:s.title,text:s.text,path:s.path,httpMethod:s.httpMethod,isAdditionalOperation:s.isAdditionalOperation,httpPath:s.httpPath,parameters:s.parameters,[b]:s.product?s.product.name:"",[g]:s.rbacTeams??[],[h]:s.version?{isDefault:s.isDefaultVersion,version:s.version,folderId:s.versionFolderId}:{isDefault:!0},...s.facets}));await this.#e?.collections(i).documents().import(n)}catch(n){if(n.importResults)for(const s of n.importResults)s.success===!1&&j.error(`Error adding document to collection: ${i}: ${s.error}`)}}}else{const n=this.#s.get(i)??[];this.#s.set(i,n.concat(o)),n.length+e.length>=k&&await this.exportDocuments(r)}}async search(e){return await T("search",async t=>{const{query:i,locale:r,filter:o,loadMore:n,auth:s}=e,a=u.isDevelopMode?r:this.#c(r),l={collection:a,q:i||"*",query_by:this.#l(),max_facet_values:S};if(t?.setAttribute("collectionName",a),t?.setAttribute("locale",r),this.#e)if(n){const{groupKey:c,offset:f}=n,p={offset:f,filter_by:this.#i(s,o),facet_by:"*"};return t?.setAttribute("isLoadMore",!0),t?.setAttribute("filter",p.filter_by),this.#u(await this.#e.collections(a).documents().search({...l,...p}),c)}else{const c={group_by:this.#_(),group_limit:w,filter_by:this.#i(s,o)};t?.setAttribute("groups",c.group_by),t?.setAttribute("filter",c.filter_by);const f=[c,...this.#E(s,o)];return this.#f(await this.#e?.multiSearch.perform({searches:f},l),o)}else return{facets:{},documents:{}}})}#u(e,t){const i={facets:{},documents:{[t]:[]}};if(e.hits&&e.hits.length)for(const r of e.hits)i.documents[t].push({document:this.#a(r),highlight:this.#n(r)});return i}#f(e,t){const i={facets:{},documents:{}};for(const r of this.#y(t))i.documents[r]=[];if("results"in e)for(const r of e.results){if(r.facet_counts&&r.facet_counts.length)for(const o of r.facet_counts)i.facets[o.field_name]=o.counts.map(n=>({value:n.value,count:n.count}));if(r.grouped_hits&&r.grouped_hits.length)for(const o of r.grouped_hits){const n=o.group_key[0],s=[];for(const a of o.hits)s.push({document:this.#a(a),highlight:this.#n(a)});i.documents[n]=s}}return i}#a(e){return this.#h(e)}#n(e){const t={},i=[];for(const[r,o]of Object.entries(e.highlight??{}))if(Array.isArray(o)){if(r==="path"){const n=o,s=[];for(const a of n)s.push(a.snippet);t.path=s}else if(r==="parameters"){const n=o;for(const s of n){let a=!1;for(const[l,c]of Object.entries(s))if(l!=="deepLink")if(Array.isArray(c))for(const f of c)f.matched_tokens?.length&&(a=!0);else c.matched_tokens?.length&&(a=!0);if(a){const l={name:s.name?.snippet||"",description:s.description?.snippet||"",place:s.place?.snippet||"",path:s.path?.map(c=>c?.snippet)||[]};t.parameters=[l];break}}}}else t[r]=o.snippet,i.push(r);for(const[r,o]of Object.entries(e.document))!i.includes(r)&&typeof o=="string"&&(t[r]=o.length>I?`${o.substring(0,I)}...`:o);return t.parameters||(t.parameters=[]),t}#h(e){let t;const i=Object.keys(e.highlight);for(const o of C)if(i.some(n=>n===o))return e.document;const r=e.highlight.parameters;if(r){for(const o of r)for(const[n,s]of Object.entries(o))if(n!=="deepLink"){if(Array.isArray(s)){for(const a of s)if(a.matched_tokens?.length){t=o.deepLink.snippet;break}}else if(s.matched_tokens?.length){t=o.deepLink.snippet;break}}}if(t){const o=t.split("#")[1];return{...e.document,url:`${e.document.url}#${o}`}}return e.document}async exportDocuments(e){const t='{"documents":[',i=d(m.join(e,F));for(const[r,o]of this.#s){if(o.length===0)continue;const n=d(m.join(i,`${r}.json`)),s=!v(n),a=JSON.stringify(o).substring(1).slice(0,-1),l=s?t+a:","+a;await A(n,l,{encoding:"utf8"}),this.#s.set(r,[])}}async exportIndexes(e){const t=d(m.join(e,F));for(const i of this.#s.keys()){const r=d(m.join(t,`${i}.json`)),o=`],"schemaFields":${JSON.stringify(this.#t)}}`;await A(r,o,{encoding:"utf8"})}}async import(e){}async countFacets(e,t){return await T("search.facets",async i=>{const{locale:r,query:o,facetQuery:n,filter:s,field:a,auth:l}=e,c=u.isDevelopMode?r:this.#c(r),f={q:o||"*",query_by:this.#l(),facet_by:"*",facet_query:this.#g(n,a),filter_by:this.#i(l,s,a),max_facet_values:S};if(i?.setAttribute("collectionName",c),i?.setAttribute("query",f.q),i?.setAttribute("facetQuery",f.facet_query),i?.setAttribute("filter",f.filter_by),this.#e){const p={},_=await this.#e.collections(c).documents().search(f);if(_.facet_counts&&_.facet_counts.length)for(const y of _.facet_counts)p[y.field_name]=y.counts.map(E=>({value:E.value,count:E.count,isCounterVisible:!!o||(s?.length||0)>0}));return p}else return{}})}#c(e){return`${this.#r}${e}`}async#p(e){const t=await this.#e?.collections().retrieve();t&&t.length&&t.find(i=>i.name===e)||await this.#e?.collections().create({name:e,fields:this.#t,enable_nested_fields:!0})}async#m(){const e=await this.#e?.collections().retrieve();for(const t of e??[])await this.#e?.collections(t.name).delete()}#d(e){for(const[t]of e)this.#t.find(i=>i.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(",")}#_(){return this.#t.filter(e=>e.facet&&e.name===D).map(e=>e.name).join(",")}#i(e,t,i){const r=`${g}:[${e.teams.map(n=>`'${n}'`).join(", ")}]`;let o=`${h}.isDefault:true`;if(t&&t.length){const n=t.filter(a=>a.field!==i&&a.field!==h).map(a=>{const l=a.values.map(c=>`'${c}'`);return l.length?`${a.field}:[${l.join(", ")}]`:""}).join(" && "),s=t.find(a=>a.field===h);if(s&&s.values.length&&s.values.length===2){const a=s.values[0],l=s.values[1],c=`(${h}.folderId:! ${a} && ${h}.isDefault:true)`,f=`(${h}.folderId:${a} && ${h}.version:${l})`;o=`(${c} || ${f})`}return n?`${r} && ${n} && ${o}`:`${r} && ${o}`}else return`${r} && ${o}`}#g(e,t){return e&&t?`${t}:${e}`:""}#y(e){const t=[];if(e&&e.length)for(const i of e)i.field===D&&t.push(...i.values);return t}#E(e,t){const i=[],r=this.#t.filter(o=>o.facet);for(const o of r){const n={facet_by:o.name,filter_by:this.#i(e,t,o.name)};i.push(n)}return i}cleanupFacetValues(e){const t=e.getSearchFacets();t.forEach(i=>{i.values=[]}),e.setSearchFacets(t)}}export{Q as Typesense};
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==="true";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(`
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