@redocly/realm 0.130.0-next.1 → 0.130.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +157 -0
- package/dist/bin.js +1 -1
- package/dist/cli/develop.js +1 -1
- package/dist/cli/eject/resolveEjectParams.js +1 -1
- package/dist/cli/prepare/copy-env-files.js +1 -1
- package/dist/cli/stats/collectors/openapi.d.ts +3 -0
- package/dist/cli/stats/collectors/openapi.js +1 -0
- package/dist/cli/stats/index.d.ts +7 -0
- package/dist/cli/stats/index.js +1 -0
- package/dist/cli/stats/options.d.ts +3 -0
- package/dist/cli/stats/options.js +1 -0
- package/dist/cli/telemetry/index.d.ts +2 -2
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/client/ErrorBoundary.js +1 -1
- package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
- package/dist/client/app/Sidebar/Sidebar.js +2 -2
- package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogViewMode.js +1 -1
- package/dist/client/app/hooks/catalog/useSearchTracker.js +1 -1
- package/dist/client/app/hooks/usePageTimeTracker.js +1 -1
- package/dist/client/app/hooks/useRouteChangeTracker.js +1 -1
- package/dist/client/app/hooks/useTelemetry.d.ts +2 -2
- package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
- package/dist/client/app/search/useAiSearch.js +1 -1
- package/dist/client/app/search/useSearch.js +1 -1
- package/dist/client/app/telemetry/index.d.ts +11 -1
- package/dist/client/app/telemetry/index.js +1 -1
- package/dist/client/browser-entry.js +3 -3
- package/dist/constants/common.d.ts +3 -1
- package/dist/constants/common.js +1 -1
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/server/api-routes/execute-api-route.js +1 -1
- package/dist/server/api-routes/run-api-routes-worker.js +1 -1
- package/dist/server/constants/plugins/catalog-entities.d.ts +1 -0
- package/dist/server/constants/plugins/catalog-entities.js +1 -1
- package/dist/server/esbuild/esbuild.js +3 -3
- package/dist/server/fs/cache.js +1 -1
- package/dist/server/node-bundle-entry.js +1 -1
- package/dist/server/persistence/kv/repositories/kv-remote-repository.d.ts +1 -0
- package/dist/server/persistence/kv/repositories/kv-remote-repository.js +2 -1
- package/dist/server/persistence/kv/services/kv-service.js +1 -1
- package/dist/server/plugins/asyncapi-docs/store-definition-bundles.js +1 -1
- package/dist/server/plugins/asyncapi-docs/template/AsyncApiDocs.js +5 -3
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +11 -12
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-attributes-db-record.d.ts +8 -0
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-attributes-db-record.js +1 -0
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-db-record.d.ts +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-read-model.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/map-entity-relation-row.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.d.ts +27 -0
- package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.d.ts +36 -0
- package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-bff-repository.d.ts +2 -2
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-bff-repository.js +34 -27
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +5 -4
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +27 -14
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +10 -8
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.d.ts +3 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-relations-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/remote/catalog-entities-remote-repository.d.ts +2 -5
- package/dist/server/plugins/catalog-entities/database/repositories/remote/catalog-entities-remote-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/utils/create-merged-entity-fields-for-select.d.ts +34 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils/create-merged-entity-fields-for-select.js +13 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.d.ts +23 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils/semantic-version-sort.d.ts +78 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils/semantic-version-sort.js +34 -0
- package/dist/server/plugins/catalog-entities/entities/validate-entity.d.ts +3 -1
- package/dist/server/plugins/catalog-entities/entities/validate-entity.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.d.ts +4 -3
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +2 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.d.ts +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
- package/dist/server/plugins/catalog-entities/plugin.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/database-schemas.d.ts +3 -0
- package/dist/server/plugins/catalog-entities/schemas/database-schemas.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/dto-schemas.d.ts +15 -1
- package/dist/server/plugins/catalog-entities/schemas/dto-schemas.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.d.ts +1 -0
- package/dist/server/plugins/catalog-entities/types/extractors.d.ts +4 -4
- package/dist/server/plugins/catalog-entities/utils/ajv-validator.js +1 -1
- package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/default-theme/index.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/docs-mcp-tool.d.ts +54 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/docs-mcp-tool.js +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.d.ts +9 -8
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.d.ts +9 -8
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.d.ts +9 -8
- package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.d.ts +9 -8
- package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +7 -13
- package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.d.ts +9 -6
- package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/search.d.ts +9 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/search.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/utils.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/utils.js +6 -6
- package/dist/server/plugins/mcp/docs-mcp/tools/whoami.d.ts +9 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/whoami.js +1 -1
- package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
- package/dist/server/plugins/mcp/handlers/errors.js +1 -1
- package/dist/server/plugins/mcp/handlers/handle-mcp-request.d.ts +5 -0
- package/dist/server/plugins/mcp/handlers/handle-mcp-request.js +1 -0
- package/dist/server/plugins/mcp/handlers/mcp-request-handler.d.ts +0 -1
- package/dist/server/plugins/mcp/handlers/mcp-request-handler.js +1 -1
- package/dist/server/plugins/mcp/servers/base-server.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +40 -0
- package/dist/server/plugins/mcp/workers/execute-mcp-tool.d.ts +3 -0
- package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -0
- package/dist/server/plugins/openapi-docs/index.js +1 -1
- package/dist/server/plugins/openapi-docs/template/OpenAPIDocs.js +8 -4
- package/dist/server/plugins/openapi-docs/template/helpers.d.ts +1 -1
- package/dist/server/plugins/openapi-docs/template/helpers.js +3 -3
- package/dist/server/plugins/scorecard-classic/loaders/scorecard-config.js +1 -1
- package/dist/server/plugins/scorecard-classic/types.d.ts +3 -3
- package/dist/server/plugins/scorecard-classic/types.js +1 -1
- package/dist/server/plugins/scorecards/database/repositories/local/scorecards-config-local-repository.d.ts +12 -0
- package/dist/server/plugins/scorecards/database/repositories/local/scorecards-config-local-repository.js +1 -0
- package/dist/server/plugins/scorecards/database/scorecards-config-service.d.ts +11 -0
- package/dist/server/plugins/scorecards/database/scorecards-config-service.js +1 -0
- package/dist/server/plugins/scorecards/workers/run-scorecards-worker.d.ts +2 -1
- package/dist/server/plugins/scorecards/workers/run-scorecards-worker.js +1 -1
- package/dist/server/plugins/scorecards/workers/scorecards.d.ts +1 -12
- package/dist/server/plugins/scorecards/workers/scorecards.js +1 -1
- package/dist/server/plugins/search/ai-indexer/prepare-ai-search-documents.js +1 -1
- package/dist/server/plugins/search/documents/search-documents.js +1 -1
- package/dist/server/plugins/sso/index.js +1 -1
- package/dist/server/providers/database/base-repository.d.ts +1 -0
- package/dist/server/providers/database/base-repository.js +1 -1
- package/dist/server/providers/database/database-connection-factory.js +1 -1
- package/dist/server/providers/database/databases/catalog-sqlite/migrations/0005_catalog-relations-constraint-fix.sql +2 -0
- package/dist/server/providers/database/databases/catalog-sqlite/migrations/0006_add-catalog-entitities-attributes-table.sql +11 -0
- package/dist/server/providers/database/databases/catalog-sqlite/migrations/meta/0005_snapshot.json +393 -0
- package/dist/server/providers/database/databases/catalog-sqlite/migrations/meta/0006_snapshot.json +458 -0
- package/dist/server/providers/database/databases/catalog-sqlite/migrations/meta/_journal.json +14 -0
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-attributes-table.d.ts +143 -0
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-attributes-table.js +1 -0
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-relations-table.js +1 -1
- package/dist/server/providers/database/databases/main-sqlite/migrations/0006_change-scorecards-config-timestamps-field-types.sql +19 -0
- package/dist/server/providers/database/databases/main-sqlite/migrations/meta/0006_snapshot.json +261 -0
- package/dist/server/providers/database/databases/main-sqlite/migrations/meta/_journal.json +7 -0
- package/dist/server/providers/database/databases/main-sqlite/schemas/scorecards-config-table.d.ts +24 -18
- package/dist/server/providers/database/databases/main-sqlite/schemas/scorecards-config-table.js +1 -1
- package/dist/server/providers/database/databases/sqld-sqlite/migrations/0007_catalog-relations-constraint-fix.sql +2 -0
- package/dist/server/providers/database/databases/sqld-sqlite/migrations/0008_add-catalog-entitities-attributes-table.sql +11 -0
- package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/0007_snapshot.json +833 -0
- package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/0008_snapshot.json +898 -0
- package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/_journal.json +14 -0
- package/dist/server/providers/database/pagination/entities-to-filter.d.ts +15 -0
- package/dist/server/providers/database/pagination/entities-to-filter.js +1 -0
- package/dist/server/providers/database/pagination/utils/index.d.ts +4 -0
- package/dist/server/providers/database/pagination/utils/index.js +1 -1
- package/dist/server/providers/database/pagination/utils/is-nested-condition.d.ts +16 -0
- package/dist/server/providers/database/pagination/utils/is-nested-condition.js +1 -0
- package/dist/server/providers/database/pagination/utils/is-simple-condition.d.ts +18 -0
- package/dist/server/providers/database/pagination/utils/is-simple-condition.js +1 -0
- package/dist/server/providers/database/pagination/utils/map-operator.d.ts +10 -0
- package/dist/server/providers/database/pagination/utils/map-operator.js +1 -0
- package/dist/server/providers/database/pagination/utils/transform-condition.d.ts +12 -0
- package/dist/server/providers/database/pagination/utils/transform-condition.js +1 -0
- package/dist/server/ssr/server-side-props/get-server-props-from-user-handler.js +1 -1
- package/dist/server/store.d.ts +3 -1
- package/dist/server/store.js +1 -1
- package/dist/server/tools/notifiers/logger.js +1 -1
- package/dist/server/tools/notifiers/reporter.js +7 -7
- package/dist/server/types/plugins/common.d.ts +3 -1
- package/dist/server/types/plugins/scorecards.d.ts +30 -0
- package/dist/server/types/plugins/scorecards.js +0 -0
- package/dist/server/utils/envs/load-env-variables.d.ts +1 -1
- package/dist/server/utils/envs/load-env-variables.js +1 -1
- package/dist/server/utils/envs/sanitize-branch-name.d.ts +6 -0
- package/dist/server/utils/envs/sanitize-branch-name.js +1 -0
- package/dist/server/utils/lifecycle-hooks.js +1 -1
- package/dist/server/utils/rbac.d.ts +11 -7
- package/dist/server/utils/rbac.js +1 -1
- package/dist/server/utils/time/with-timestamp.d.ts +42 -10
- package/dist/server/utils/time/with-timestamp.js +1 -1
- package/dist/server/web-server/auth.js +2 -2
- package/dist/server/web-server/dev-server.js +1 -1
- package/dist/server/web-server/handle-api-route-request.js +1 -1
- package/dist/server/web-server/middleware/catalogAuthMiddleware.js +1 -1
- package/dist/server/web-server/routes/auth.js +1 -1
- package/dist/server/web-server/routes/catalog/bff-catalog.js +1 -1
- package/dist/server/web-server/routes/catalog/catalog.js +1 -1
- package/dist/server/web-server/routes/dynamic-route.js +1 -1
- package/dist/server/web-server/routes/mcp-oauth.js +1 -1
- package/dist/server/web-server/routes/page-data.js +1 -1
- package/dist/server/workers/mcp-tool-worker-pool.d.ts +4 -0
- package/dist/server/workers/mcp-tool-worker-pool.js +1 -0
- package/dist/server/workers/mcp-tool-worker.d.ts +2 -0
- package/dist/server/workers/mcp-tool-worker.js +1 -0
- package/dist/server/workers/types.d.ts +7 -1
- package/dist/utils/env/is-local-development.js +1 -1
- package/package.json +15 -18
- package/dist/server/plugins/mcp/workers/run-api-routes-worker.d.ts +0 -5
- package/dist/server/plugins/mcp/workers/run-api-routes-worker.js +0 -1
- package/dist/server/workers/mcp-worker-pool.d.ts +0 -4
- package/dist/server/workers/mcp-worker-pool.js +0 -1
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"when": 1766391516611,
|
|
51
51
|
"tag": "0006_catalog-versions-and-revisions-relations",
|
|
52
52
|
"breakpoints": true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"idx": 7,
|
|
56
|
+
"version": "6",
|
|
57
|
+
"when": 1768307646039,
|
|
58
|
+
"tag": "0007_catalog-relations-constraint-fix",
|
|
59
|
+
"breakpoints": true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"idx": 8,
|
|
63
|
+
"version": "6",
|
|
64
|
+
"when": 1768558795586,
|
|
65
|
+
"tag": "0008_add-catalog-entitities-attributes-table",
|
|
66
|
+
"breakpoints": true
|
|
53
67
|
}
|
|
54
68
|
]
|
|
55
69
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScorecardsConfig } from '@redocly/config';
|
|
2
|
+
import type { Filter } from '../../../providers/database/pagination/types.js';
|
|
3
|
+
type ScorecardConfig = ScorecardsConfig[number];
|
|
4
|
+
type EntitiesConfig = ScorecardConfig['entities'];
|
|
5
|
+
/**
|
|
6
|
+
* Transforms scorecards entities config (array or `{ operator, conditions }`) into a {@link Filter}
|
|
7
|
+
* used by the pagination layer. Handles AND/OR, nested conditions, and simple field conditions.
|
|
8
|
+
*
|
|
9
|
+
* @param entities - Entities config: array of conditions (AND) or `{ operator: 'and'|'or', conditions }`
|
|
10
|
+
* @returns A filter tree with `op` and `conditions`
|
|
11
|
+
* @throws Error when config is empty array, invalid structure, or unsupported operator
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformEntitiesToFilter(entities: EntitiesConfig): Filter;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=entities-to-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{OPERATORS as n}from"../../../providers/database/pagination/constants.js";import{isNestedCondition as a}from"../../../providers/database/pagination/utils/is-nested-condition.js";import{isSimpleCondition as f}from"../../../providers/database/pagination/utils/is-simple-condition.js";import{transformCondition as s}from"../../../providers/database/pagination/utils/transform-condition.js";function t(o){if(Array.isArray(o)){if(o.length===0)throw new Error("Entities config cannot be an empty array");if(o.length===1){const r=o[0];if(f(r))return{op:n.AND,conditions:[s(r)]};if(a(r))return{op:n.AND,conditions:[t(r)]};throw new Error("Invalid condition structure")}return{op:n.AND,conditions:o.map(r=>{if(f(r))return s(r);if(a(r))return t(r);throw new Error("Invalid condition structure")})}}const{operator:i,conditions:e}=o;if(!["and","or"].includes(i))throw new Error(`Unsupported operator: ${i}`);const p=Array.isArray(e)?e.map(r=>{if(a(r))return t(r);if(f(r))return s(r);throw new Error("Invalid condition structure")}):[t(e)];return{op:i==="and"?n.AND:n.OR,conditions:p}}export{t as transformEntitiesToFilter};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './create-cursor.js';
|
|
2
2
|
export * from './decode-cursor.js';
|
|
3
3
|
export * from './is-base-64.js';
|
|
4
|
+
export * from './is-nested-condition.js';
|
|
5
|
+
export * from './is-simple-condition.js';
|
|
6
|
+
export * from './map-operator.js';
|
|
7
|
+
export * from './transform-condition.js';
|
|
4
8
|
export * from './transform-to-camel-case.js';
|
|
5
9
|
export * from './transform-to-snake-case.js';
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./create-cursor.js";export*from"./decode-cursor.js";export*from"./is-base-64.js";export*from"./transform-to-camel-case.js";export*from"./transform-to-snake-case.js";
|
|
1
|
+
export*from"./create-cursor.js";export*from"./decode-cursor.js";export*from"./is-base-64.js";export*from"./is-nested-condition.js";export*from"./is-simple-condition.js";export*from"./map-operator.js";export*from"./transform-condition.js";export*from"./transform-to-camel-case.js";export*from"./transform-to-snake-case.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nested condition shape: has `operator` and `conditions`, no `field`.
|
|
3
|
+
*/
|
|
4
|
+
type NestedCondition = {
|
|
5
|
+
operator: string;
|
|
6
|
+
conditions: unknown;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Type guard: checks if the value is a nested condition (operator + conditions, no field).
|
|
10
|
+
*
|
|
11
|
+
* @param condition - Value to check
|
|
12
|
+
* @returns `true` when condition has `operator` and `conditions` and no `field`; otherwise `false`
|
|
13
|
+
*/
|
|
14
|
+
export declare function isNestedCondition(condition: unknown): condition is NestedCondition;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=is-nested-condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(e){return typeof e=="object"&&e!==null&&"operator"in e&&"conditions"in e&&!("field"in e)}export{r as isNestedCondition};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple entity condition from scorecards config: has `field` and `operator`, optional `value`, `match`, `modifier`.
|
|
3
|
+
*/
|
|
4
|
+
export type SimpleEntityCondition = {
|
|
5
|
+
field: string;
|
|
6
|
+
operator: string;
|
|
7
|
+
value?: unknown;
|
|
8
|
+
match?: unknown;
|
|
9
|
+
modifier?: 'not';
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Type guard: checks if the value is a simple entity condition (field + operator shape).
|
|
13
|
+
*
|
|
14
|
+
* @param condition - Value to check
|
|
15
|
+
* @returns `true` when condition has `field` (string) and `operator`; otherwise `false`
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSimpleCondition(condition: unknown): condition is SimpleEntityCondition;
|
|
18
|
+
//# sourceMappingURL=is-simple-condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(e){return typeof e=="object"&&e!==null&&"field"in e&&typeof e.field=="string"&&"operator"in e}export{r as isSimpleCondition};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FilterClause } from '../../../../providers/database/pagination/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Maps a config operator string to the corresponding {@link FilterClause} operator.
|
|
4
|
+
*
|
|
5
|
+
* @param operator - Config operator: `'eq' | 'in' | 'contains' | 'between'`
|
|
6
|
+
* @returns The filter clause operator: `'equal' | 'in' | 'contains' | 'between'`
|
|
7
|
+
* @throws Error when operator is not supported
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapOperator(operator: string): FilterClause['operator'];
|
|
10
|
+
//# sourceMappingURL=map-operator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e){switch(e){case"eq":return"equal";case"in":return"in";case"contains":return"contains";case"between":return"between";default:throw new Error(`Unsupported operator "${e}". Supported operators: eq, in, contains, between`)}}export{n as mapOperator};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FilterClause } from '../../../../providers/database/pagination/types.js';
|
|
2
|
+
import type { SimpleEntityCondition } from './is-simple-condition.js';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a simple entity condition from scorecards config into a {@link FilterClause}.
|
|
5
|
+
* Handles operator mapping, optional `modifier: 'not'`, and rejects unsupported `match` / array operators.
|
|
6
|
+
*
|
|
7
|
+
* @param cond - Simple entity condition (must pass {@link isSimpleCondition})
|
|
8
|
+
* @returns A filter clause ready for the pagination layer
|
|
9
|
+
* @throws Error when `match` is used or when operator is an array operator (some, every, none)
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformCondition(cond: SimpleEntityCondition): FilterClause;
|
|
12
|
+
//# sourceMappingURL=transform-condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mapOperator as n}from"./map-operator.js";function a(e){const r=e;if(r.match)throw["some","every","none"].includes(r.operator)?new Error("Array query operators (some, every, none) are not yet supported in Filter type"):new Error("match property is only supported with array query operators");const t=n(r.operator),o={field:r.field,operator:t,value:r.value};return r.modifier==="not"&&(o.modifier="not"),o}export{a as transformCondition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as
|
|
1
|
+
import{logger as i}from"../../tools/notifiers/logger.js";import{reporter as m}from"../../tools/notifiers/reporter.js";import{enhanceContext as f}from"../../api-routes/helpers/enhance-context.js";import{KvService as l}from"../../persistence/kv/services/kv-service.js";import{enhanceRequest as u}from"../../api-routes/helpers/enhance-request.js";async function S({route:r,ctx:t,staticData:n,serverPropsGetters:a,serverPropsUser:p,actions:s}){try{if(!a[r.fsPath]||!t)return;const e=a[r.fsPath];e||await m.panicOnBuild(`Invalid page props getter id: "${r.fsPath}" for route "${r.slug}"`);const o=async()=>l.getInstance({baseDbDir:s.serverOutDir,sqldRemoteDatabaseUrl:process.env.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:process.env.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),c=f({honoCtx:t,ctx:{user:p,config:s.getConfig()},getKv:o}),g=await u(t);return await(await e()).default(n,g,c)}catch(e){const o=r.fsPath.replace(/\.(page\.tsx?|md)$/,".props.ts");return i.error(`Page prop getter error: ${e.message}`),{pagePropGetterError:{message:`${e.message||"An unknown error occurred"} in ${o}`,name:"ServerPropsGetterError",stack:e.stack}}}}export{S as getServerPropsFromUserHandler};
|
package/dist/server/store.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { SearchFacet } from '@redocly/theme/core/types';
|
|
|
8
8
|
import type { BundledDefinition as OpenApiBundledDefinition } from './plugins/openapi-docs/load-definition.js';
|
|
9
9
|
import type { BundledDefinition as AsyncApiBundledDefinition } from './plugins/asyncapi-docs/asyncapi-doc-loader.js';
|
|
10
10
|
import type { SearchEngine } from './plugins/search/engines/search-engine.js';
|
|
11
|
+
import { KvService } from './persistence/kv/services/kv-service.js';
|
|
11
12
|
export declare const MARKDOC_PARTIALS_DATA_KEY = "markdown/partials";
|
|
12
13
|
export declare const MARKDOC_PARTIALS_DEPS_KEY = "markdown/partials-deps";
|
|
13
14
|
export declare const USER_DEFINED_API_FUNCTIONS_COUNTER_KEY = "userDefinedApiFunctions";
|
|
@@ -91,7 +92,7 @@ export declare class Store {
|
|
|
91
92
|
frontMatterKeysToResolve?: string[] | undefined;
|
|
92
93
|
partialsFolders?: string[] | undefined;
|
|
93
94
|
lastUpdatedBlock?: {
|
|
94
|
-
format?: "
|
|
95
|
+
format?: "timeago" | "iso" | "long" | "short" | undefined;
|
|
95
96
|
hide?: boolean | undefined;
|
|
96
97
|
locale?: string | undefined;
|
|
97
98
|
} | undefined;
|
|
@@ -117,6 +118,7 @@ export declare class Store {
|
|
|
117
118
|
};
|
|
118
119
|
setGlobalData: (data: GlobalData) => void;
|
|
119
120
|
getGlobalData: () => GlobalData;
|
|
121
|
+
getKv: () => Promise<KvService>;
|
|
120
122
|
parseMarkdoc: (input: MarkdownParseInput, context: LifecycleContext, deps?: MarkdocDeps) => Promise<{
|
|
121
123
|
info: {
|
|
122
124
|
sharedDataDeps?: Set<string>;
|
package/dist/server/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import b from"@markdoc/markdoc";import{getPathnameForLocale as C}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as u}from"../constants/common.js";import{DEFAULT_TITLE as A}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as T}from"../utils/guards/is-object.js";import{mapObject as M}from"../utils/object/map-object.js";import{getValueDeep as w}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as O}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as f}from"../utils/path/normalize-route-slug.js";import{isLocalLink as k}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as p}from"./tools/notifiers/logger.js";import{sha1 as L}from"./utils/crypto/sha1.js";import{writeEnvVariable as _}from"./utils/envs/write-env-variable.js";import{readEnvVariable as F}from"./utils/envs/read-env-variable.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as G}from"./ssr/render.js";import{readStaticData as I,writeStaticData as N}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as y}from"./entitlements/entitlements-provider.js";import{isL10nPath as H}from"./fs/utils/is-l10n-path.js";import{resolveMetadataGlobs as J}from"./utils/globs.js";import{replaceEnvVariablesDeep as U}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{addWildcardRedirectToTree as K}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as q}from"../cli/telemetry/helpers/trace-step.js";const R={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map"},g="markdown/partials",Et="markdown/partials-deps",v="PLAN_GATES",$=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORG_ID"],Pt="userDefinedApiFunctions";class E{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},rbac:{},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#e=new Map;constructor({outdir:t,contentDir:e,serverMode:s=!1,serverOutDir:r}){this.#r=e,this.outdir=t,this.serverMode=s,this.serverOutDir=r,this.userCodeReady=new Promise(a=>{this.#a=a})}on(t,e){const s=this.listeners.get(t);s?s.add(e):this.listeners.set(t,new Set([e]))}queueEvent=(t,e,...s)=>{this.#e.set(t+String(e),[t,e,...s])};runListeners=(t,e,...s)=>{for(const r of this.listeners.get(t)||new Set)e?r(e,...s):r(...s)};startPluginsRun(){this.clear(),this.#o=new Promise(t=>{this.#i=t})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const t of this.#e.values())this.runListeners(...t);this.#e.clear()}startEsbuildRun(){this.#n=new Promise(t=>{this.#c=t})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await q("build.reload_markdoc_options",async()=>{const t=y.instance(),e=await j(this.serverOutDir),s=Object.fromEntries(Object.entries(e.tags).filter(([r])=>D[r]!=null?t.canAccessFeature(D[r]):!0));this.#s={...e,tags:s}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(g),themeConfig:this.config.markdown}}setGlobalData=t=>{const e=this.globalData,s={...this.globalData,...t};this.globalData=s,JSON.stringify(s)!==JSON.stringify(e)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;parseMarkdoc=async(t,e,s)=>{const{data:{info:r,ast:a},compoundHash:c}=await V(t,this.markdocOptions,{actions:this,context:e});for(const o of r.sharedDataDeps||[]){for(const i of s?.routeSlugs||[])this.addRouteSharedData(i,o,o);for(const i of s?.sharedDataIds||[]){const n=this.sharedDataDeps.get(i)||new Set;n.add(o),this.sharedDataDeps.set(i,n)}}for(const o of r.dynamicMarkdocComponents||[]){for(const i of s?.routeSlugs||[]){const n=this.routesDynamicComponents.get(i)||new Set;n.add(o),this.routesDynamicComponents.set(i,n)}for(const i of s?.sharedDataIds||[]){const n=this.sharedDataMarkdocComponents.get(i)||new Set;n.add(o),this.sharedDataMarkdocComponents.set(i,n)}}if(s?.routeSlugs&&r.partials?.length)for(const o of s.routeSlugs){const i=this.routesPartials.get(o)||[];for(const n of r.partials)i.includes(n)||i.push(n);this.routesPartials.set(o,i)}return{info:r,ast:a,compoundHash:c}};async loadOpenApiDefinitions(t){return(await t.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(t){return(await t.cache.load(".","asyncapi-docs")).data}setSearchEngine(t){this.searchEngine=t}setSearchFacets=t=>{this.searchFacets=t};setGlobalConfig=t=>{const e=Object.keys(t);for(const c of e)for(const o in this.replacedEnvVars)if(o===c||o.startsWith(`${c}:`)){const i=o.split(":"),{error:n,value:l}=w(t,i);(n||l!==this.replacedEnvVars[o].replaced)&&delete this.replacedEnvVars[o]}const{resolvedObj:s,unsetEnvVars:r,replacedValues:a}=U(t);for(const c of r)this.unsetEnvVars.add(c);Object.assign(this.replacedEnvVars,a),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=t=>this.config[t];getSearchFacets=()=>this.searchFacets;addRedirect=(t,e)=>{if(!y.instance().canAccessFeature("redirects")&&t!=="/")return;this.config.redirects||(this.config.redirects={});const a=f(t).toLowerCase();this.config.redirects[a]=e,a.endsWith("*")&&K(this.config.wildcardRedirectsTree,a)};getRedirect=t=>{const e=f(t).toLowerCase();return x(e,this.config.redirects,this.config.wildcardRedirectsTree)};createSharedData=async(t,e,s)=>{if(s&&this.#t[t]===s)return t;const r=JSON.stringify(e),a=s??L(r);return this.#t[t]===a||(this.#t[t]=a,await B(t,r,this.outdir),this.queueEvent("shared-data-updated",t)),t};addRouteSharedData=(t,e,s)=>{const r=O(t),a=this.routesSharedData.get(r)||{};a[e]=s,this.routesSharedData.set(r,a),p.verbose(`Adding shared data to ${t}, ${e}, ${s}`)};getRouteSharedDataByFsPath=t=>{const e=this.routesByFsPath.get(t);return e?this.routesSharedData.get(e)||{}:{}};getPartialsForRoute=t=>{const e=this.getGlobalConfig(g)||{},s=this.routesPartials.get(t);if(!s||s.length===0)return{};const r={};for(const a of s)e[a]&&(r[a]=e[a]);return r};addRoute=t=>{const s={...J(t.fsPath,this.config.metadataGlobs),...t.metadata||{}};this.newRoutes.push({...t,metadata:s}),p.verbose("Created route %s",t.slug)};addRouteSharedDataToAllLocales=(t,e,s)=>{const r=[u,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const c=C(t,u,a.code,r);this.addRouteSharedData(c,e,s)}};addApiRoute=t=>{this.apiRoutes.push(t),p.verbose("Created API route %s",t.slug)};addMiddleware=t=>{this.middleware.push(t),p.verbose("Created middleware %s",t.id)};getRouteByFsPath=t=>{const e=this.routesByFsPath.get(t);return e?this.getRouteBySlug(e):void 0};getRouteBySlug=(t,e={})=>{const{followRedirect:s=!0}=e,r=this.getRedirect(t);return s&&r?this.routesBySlug.get(f(r.to)):this.routesBySlug.get(t)};slugHasRouteOrRedirect=t=>{if(this.routesBySlug.has(t))return!0;const e=this.getRedirect(t);if(!e)return!1;if(!k(e.to))return!0;const s=f(e.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=t=>this.newRoutes.filter(e=>e.templateId===t);getAllRoutesForLocale=(t=u)=>{const e=Array.from(this.routesBySlug.values()),s=t.toLowerCase();return e.filter(r=>t===u?!H(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=t=>this.templates.get(t);getRequestHandler=t=>this.apiRoutesRequestHandlers.get(t);createTemplate=(t,e)=>(this.templates.set(t,e),t);addBrowserPlugin=t=>{this.browserPlugins.add(t)};createRequestHandler=(t,e)=>(this.apiRoutesRequestHandlers.set(t,e),t);registerServerPropsGetter=(t,e)=>(this.serverPropsGetters.set(t,e),t);registerPagePropsGetter=(t,e)=>{this.pagePropsGetters.set(t,e)};async writeRouteStaticData(t,e){const s=await this.resolveRouteStaticData(t,e,!1);s&&N(t.slug,s,this.outdir)}async resolveRouteStaticData(t,e,s){if(this.serverMode)return I(t.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:(l,d)=>this.parseMarkdoc(l,d,{routeSlugs:[t.slug]})},a=await t.getStaticData?.(t,r)||{},c=new Set(this.routesDynamicComponents.get(t.slug)),o=this.routesSharedData.get(t.slug)||{};for(const l of Object.values(o)){const d=this.sharedDataMarkdocComponents.get(l);d&&d.forEach(h=>c.add(h));const m=this.sharedDataDeps.get(l);m&&m.forEach(h=>this.addRouteSharedData(t.slug,h,h))}const i=this.getGlobalConfig("seo"),n=a?.frontmatter||{};return{...a,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await t.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(c),metadata:{...a?.props?.metadata,...t.metadata},seo:{title:A,...i,...a.props?.seo},compilationErrors:this.compilationErrors},lastModified:s||!t.fsPath?null:await this.lifecycleContext?.fs.getLastModified(t.fsPath)}}addSsrComponents(t,e){if(!t?.length)return;const s=typeof t[0]=="string"?t.join(""):G(t);s&&(e==="head"?this.ssr.headTags.push(s):e==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const t=[];for(const[s,r]of Object.entries(R))switch(r){case"map":const a=Array.from(this[s].entries());t.push([s,a]);break;case"object":s==="config"&&t.push([s,await this.getConfigWithEnvPlaceholders()]),t.push([s,this[s]]);break;default:throw new Error("Invalid format")}const e=Object.fromEntries(t);return e[v]=F("PLAN_GATES"),e}static fromJson(t,e){const s=new E(e);for(const[a,c]of Object.entries(R))switch(c){case"map":s[a]=new Map(t[a]);break;case"object":if(a==="config"){s.setGlobalConfig(t[a]);break}s[a]=t[a];break;default:throw new Error("Invalid format")}s.config[g]=W(s.config[g]||{});const r=t[v];return r&&_("PLAN_GATES",r),s}async getConfigWithEnvPlaceholders(){const t=JSON.parse(JSON.stringify(this.config));for(const e in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[e],r=e.split(":"),a=r.pop(),{error:c,value:o}=w(t,r);if(c||!T(o)&&!Array.isArray(o)){await S.panicOnBuild(`Failed to replace env var with env name for ${e}`);continue}o[a]=s}return t}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const t=Array.from(this.unsetEnvVars).filter(s=>!$.includes(s));if(t.length===0)return;const e=`Failed to resolve config. The following environment variables are not set: ${t.join(", ")}`;await S.panicOnBuildContentError(e)}}function W(P){return M(P,t=>b.Ast.fromJSON(JSON.stringify(t)))}export{g as MARKDOC_PARTIALS_DATA_KEY,Et as MARKDOC_PARTIALS_DEPS_KEY,E as Store,Pt as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
1
|
+
import b from"@markdoc/markdoc";import{getPathnameForLocale as A}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as u}from"../constants/common.js";import{DEFAULT_TITLE as C}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as O}from"../utils/guards/is-object.js";import{mapObject as T}from"../utils/object/map-object.js";import{getValueDeep as S}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as M}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as f}from"../utils/path/normalize-route-slug.js";import{isLocalLink as L}from"../utils/path/is-local-link.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as p}from"./tools/notifiers/logger.js";import{sha1 as k}from"./utils/crypto/sha1.js";import{writeEnvVariable as _}from"./utils/envs/write-env-variable.js";import{readEnvVariable as F}from"./utils/envs/read-env-variable.js";import{KvService as G}from"./persistence/kv/services/kv-service.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as I}from"./ssr/render.js";import{readStaticData as N,writeStaticData as V}from"./utils/static-data.js";import{parseAndResolveMarkdoc as j}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as H}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as y}from"./entitlements/entitlements-provider.js";import{isL10nPath as K}from"./fs/utils/is-l10n-path.js";import{resolveMetadataGlobs as U}from"./utils/globs.js";import{replaceEnvVariablesDeep as J}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{addWildcardRedirectToTree as q}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as $}from"../cli/telemetry/helpers/trace-step.js";const R={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map"},g="markdown/partials",bt="markdown/partials-deps",v="PLAN_GATES",W=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],At="userDefinedApiFunctions";class E{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},rbac:{},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#e=new Map;constructor({outdir:t,contentDir:e,serverMode:s=!1,serverOutDir:r}){this.#r=e,this.outdir=t,this.serverMode=s,this.serverOutDir=r,this.userCodeReady=new Promise(a=>{this.#a=a})}on(t,e){const s=this.listeners.get(t);s?s.add(e):this.listeners.set(t,new Set([e]))}queueEvent=(t,e,...s)=>{this.#e.set(t+String(e),[t,e,...s])};runListeners=(t,e,...s)=>{for(const r of this.listeners.get(t)||new Set)e?r(e,...s):r(...s)};startPluginsRun(){this.clear(),this.#o=new Promise(t=>{this.#i=t})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const t of this.#e.values())this.runListeners(...t);this.#e.clear()}startEsbuildRun(){this.#n=new Promise(t=>{this.#c=t})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await $("build.reload_markdoc_options",async()=>{const t=y.instance(),e=await H(this.serverOutDir),s=Object.fromEntries(Object.entries(e.tags).filter(([r])=>D[r]!=null?t.canAccessFeature(D[r]):!0));this.#s={...e,tags:s}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(g),themeConfig:this.config.markdown}}setGlobalData=t=>{const e=this.globalData,s={...this.globalData,...t};this.globalData=s,JSON.stringify(s)!==JSON.stringify(e)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;getKv=async()=>G.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async(t,e,s)=>{const{data:{info:r,ast:a},compoundHash:c}=await j(t,this.markdocOptions,{actions:this,context:e});for(const o of r.sharedDataDeps||[]){for(const i of s?.routeSlugs||[])this.addRouteSharedData(i,o,o);for(const i of s?.sharedDataIds||[]){const n=this.sharedDataDeps.get(i)||new Set;n.add(o),this.sharedDataDeps.set(i,n)}}for(const o of r.dynamicMarkdocComponents||[]){for(const i of s?.routeSlugs||[]){const n=this.routesDynamicComponents.get(i)||new Set;n.add(o),this.routesDynamicComponents.set(i,n)}for(const i of s?.sharedDataIds||[]){const n=this.sharedDataMarkdocComponents.get(i)||new Set;n.add(o),this.sharedDataMarkdocComponents.set(i,n)}}if(s?.routeSlugs&&r.partials?.length)for(const o of s.routeSlugs){const i=this.routesPartials.get(o)||[];for(const n of r.partials)i.includes(n)||i.push(n);this.routesPartials.set(o,i)}return{info:r,ast:a,compoundHash:c}};async loadOpenApiDefinitions(t){return(await t.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(t){return(await t.cache.load(".","asyncapi-docs")).data}setSearchEngine(t){this.searchEngine=t}setSearchFacets=t=>{this.searchFacets=t};setGlobalConfig=t=>{const e=Object.keys(t);for(const c of e)for(const o in this.replacedEnvVars)if(o===c||o.startsWith(`${c}:`)){const i=o.split(":"),{error:n,value:l}=S(t,i);(n||l!==this.replacedEnvVars[o].replaced)&&delete this.replacedEnvVars[o]}const{resolvedObj:s,unsetEnvVars:r,replacedValues:a}=J(t);for(const c of r)this.unsetEnvVars.add(c);Object.assign(this.replacedEnvVars,a),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=t=>this.config[t];getSearchFacets=()=>this.searchFacets;addRedirect=(t,e)=>{if(!y.instance().canAccessFeature("redirects")&&t!=="/")return;this.config.redirects||(this.config.redirects={});const a=f(t).toLowerCase();this.config.redirects[a]=e,a.endsWith("*")&&q(this.config.wildcardRedirectsTree,a)};getRedirect=t=>{const e=f(t).toLowerCase();return x(e,this.config.redirects,this.config.wildcardRedirectsTree)};createSharedData=async(t,e,s)=>{if(s&&this.#t[t]===s)return t;const r=JSON.stringify(e),a=s??k(r);return this.#t[t]===a||(this.#t[t]=a,await B(t,r,this.outdir),this.queueEvent("shared-data-updated",t)),t};addRouteSharedData=(t,e,s)=>{const r=M(t),a=this.routesSharedData.get(r)||{};a[e]=s,this.routesSharedData.set(r,a),p.verbose(`Adding shared data to ${t}, ${e}, ${s}`)};getRouteSharedDataByFsPath=t=>{const e=this.routesByFsPath.get(t);return e?this.routesSharedData.get(e)||{}:{}};getPartialsForRoute=t=>{const e=this.getGlobalConfig(g)||{},s=this.routesPartials.get(t);if(!s||s.length===0)return{};const r={};for(const a of s)e[a]&&(r[a]=e[a]);return r};addRoute=t=>{const s={...U(t.fsPath,this.config.metadataGlobs),...t.metadata||{}};this.newRoutes.push({...t,metadata:s}),p.verbose("Created route %s",t.slug)};addRouteSharedDataToAllLocales=(t,e,s)=>{const r=[u,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const c=A(t,u,a.code,r);this.addRouteSharedData(c,e,s)}};addApiRoute=t=>{this.apiRoutes.push(t),p.verbose("Created API route %s",t.slug)};addMiddleware=t=>{this.middleware.push(t),p.verbose("Created middleware %s",t.id)};getRouteByFsPath=t=>{const e=this.routesByFsPath.get(t);return e?this.getRouteBySlug(e):void 0};getRouteBySlug=(t,e={})=>{const{followRedirect:s=!0}=e,r=this.getRedirect(t);return s&&r?this.routesBySlug.get(f(r.to)):this.routesBySlug.get(t)};slugHasRouteOrRedirect=t=>{if(this.routesBySlug.has(t))return!0;const e=this.getRedirect(t);if(!e)return!1;if(!L(e.to))return!0;const s=f(e.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=t=>this.newRoutes.filter(e=>e.templateId===t);getAllRoutesForLocale=(t=u)=>{const e=Array.from(this.routesBySlug.values()),s=t.toLowerCase();return e.filter(r=>t===u?!K(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=t=>this.templates.get(t);getRequestHandler=t=>this.apiRoutesRequestHandlers.get(t);createTemplate=(t,e)=>(this.templates.set(t,e),t);addBrowserPlugin=t=>{this.browserPlugins.add(t)};createRequestHandler=(t,e)=>(this.apiRoutesRequestHandlers.set(t,e),t);registerServerPropsGetter=(t,e)=>(this.serverPropsGetters.set(t,e),t);registerPagePropsGetter=(t,e)=>{this.pagePropsGetters.set(t,e)};async writeRouteStaticData(t,e){const s=await this.resolveRouteStaticData(t,e,!1);s&&V(t.slug,s,this.outdir)}async resolveRouteStaticData(t,e,s){if(this.serverMode)return N(t.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:(l,d)=>this.parseMarkdoc(l,d,{routeSlugs:[t.slug]})},a=await t.getStaticData?.(t,r)||{},c=new Set(this.routesDynamicComponents.get(t.slug)),o=this.routesSharedData.get(t.slug)||{};for(const l of Object.values(o)){const d=this.sharedDataMarkdocComponents.get(l);d&&d.forEach(h=>c.add(h));const m=this.sharedDataDeps.get(l);m&&m.forEach(h=>this.addRouteSharedData(t.slug,h,h))}const i=this.getGlobalConfig("seo"),n=a?.frontmatter||{};return{...a,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await t.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(c),metadata:{...a?.props?.metadata,...t.metadata},seo:{title:C,...i,...a.props?.seo},compilationErrors:this.compilationErrors},lastModified:s||!t.fsPath?null:await this.lifecycleContext?.fs.getLastModified(t.fsPath)}}addSsrComponents(t,e){if(!t?.length)return;const s=typeof t[0]=="string"?t.join(""):I(t);s&&(e==="head"?this.ssr.headTags.push(s):e==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const t=[];for(const[s,r]of Object.entries(R))switch(r){case"map":const a=Array.from(this[s].entries());t.push([s,a]);break;case"object":s==="config"&&t.push([s,await this.getConfigWithEnvPlaceholders()]),t.push([s,this[s]]);break;default:throw new Error("Invalid format")}const e=Object.fromEntries(t);return e[v]=F("PLAN_GATES"),e}static fromJson(t,e){const s=new E(e);for(const[a,c]of Object.entries(R))switch(c){case"map":s[a]=new Map(t[a]);break;case"object":if(a==="config"){s.setGlobalConfig(t[a]);break}s[a]=t[a];break;default:throw new Error("Invalid format")}s.config[g]=z(s.config[g]||{});const r=t[v];return r&&_("PLAN_GATES",r),s}async getConfigWithEnvPlaceholders(){const t=JSON.parse(JSON.stringify(this.config));for(const e in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[e],r=e.split(":"),a=r.pop(),{error:c,value:o}=S(t,r);if(c||!O(o)&&!Array.isArray(o)){await w.panicOnBuild(`Failed to replace env var with env name for ${e}`);continue}o[a]=s}return t}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const t=Array.from(this.unsetEnvVars).filter(s=>!W.includes(s));if(t.length===0)return;const e=`Failed to resolve config. The following environment variables are not set: ${t.join(", ")}`;await w.panicOnBuildContentError(e)}}function z(P){return T(P,t=>b.Ast.fromJSON(JSON.stringify(t)))}export{g as MARKDOC_PARTIALS_DATA_KEY,bt as MARKDOC_PARTIALS_DEPS_KEY,E as Store,At as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{telemetry as a}from"../../telemetry/index.js";import{isProductionMode as c}from"../../utils/envs/is-production-mode.js";import l,{LogLevel as r,shouldLog as h,parseLogLevel as u}from"./formatter.js";import{isVirtualFile as f}from"../../fs/utils/isVirtualFile.js";import{TerminalManager as p}from"./terminal-manager.js";import{isDevelopMode as g}from"../../utils/envs/is-develop-mode.js";class d{#e;#l;#i;#n;#r=new Map;#o=new Map;constructor({context:t,forceNonInteractive:e,minLogLevel:i}={}){this.#e=t,this.#l=c(),this.#i=new p(e),this.#n=i??u(process.env.REDOCLY_LOG_LEVEL)??(g()?r.INFO:r.HTTP)}shouldLog(t){return h(t,this.#n)}info(t,...e){this.#t({level:r.INFO,message:t,args:e})}infoTime(t,e,...i){return this.#s(r.INFO,e,t,...i)}success(t,...e){this.#t({level:r.SUCCESS,message:t,args:e})}logInFooter(t,e,...i){const o=l.interpolate(e,...i)+`
|
|
2
|
-
`;this.isInteractive()||this.#i.isFooterChanged(t,o)&&this.#t({level:r.INFO,message:e,args:i}),this.#i.updateFooter(t,o)}successTime(t,e,...i){return this.#s(r.SUCCESS,e,t,...i)}warn(t,...e){this.#t({level:r.WARN,message:t,args:e})}warnProd(t,...e){this.#l?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#t({level:r.ERROR,message:t,args:e})}contentError(t,...e){this.#t({level:r.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){this.#t({level:r.VERBOSE,message:t,args:e})}verboseTime(t,e,...i){return this.#s(r.VERBOSE,e,t,...i)}httpTime(t){return this.#s(r.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const i=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,i),e}updateContext(t){this.#e={...this.#e,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}isInteractive(){return this.#i.isInteractive()}warnForRealFile(t,e,i,...o){f(e,i)||this.warn(t,e,...o)}#s(t,e,i,...o){const n=this.#r.get(i);if(!n)return;const s=Math.round(performance.now()-n);return this.#r.delete(i),this.#t({level:t,message:e,duration:s,args:o}),{message:e,timeMs:s}}#t({level:t,message:e,duration:i,scope:o,args:n}){if(!h(t,this.#n))return;let s=e&&l.interpolate(e,...n);s&&i!=null&&t!==r.VERBOSE&&a.sendTimingPerformedMessage({timeMs:i,message:s});const m={level:t,message:s,duration:i,scope:o,context:this.#e};process.stderr.write(l.format(m))}}const O=new d;export{d as Logger,O as logger};
|
|
2
|
+
`;this.isInteractive()||this.#i.isFooterChanged(t,o)&&this.#t({level:r.INFO,message:e,args:i}),this.#i.updateFooter(t,o)}successTime(t,e,...i){return this.#s(r.SUCCESS,e,t,...i)}warn(t,...e){this.#t({level:r.WARN,message:t,args:e})}warnProd(t,...e){this.#l?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#t({level:r.ERROR,message:t,args:e})}contentError(t,...e){this.#t({level:r.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){this.#t({level:r.VERBOSE,message:t,args:e})}verboseTime(t,e,...i){return this.#s(r.VERBOSE,e,t,...i)}httpTime(t){return this.#s(r.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const i=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,i),e}updateContext(t){this.#e={...this.#e,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}isInteractive(){return this.#i.isInteractive()}warnForRealFile(t,e,i,...o){f(e,i)||this.warn(t,e,...o)}#s(t,e,i,...o){const n=this.#r.get(i);if(!n)return;const s=Math.round(performance.now()-n);return this.#r.delete(i),this.#t({level:t,message:e,duration:s,args:o}),{message:e,timeMs:s}}#t({level:t,message:e,duration:i,scope:o,args:n}){if(!h(t,this.#n))return;let s=e&&l.interpolate(e,...n);s&&i!=null&&t!==r.VERBOSE&&a.sendTimingPerformedMessage([{object:"timing",timeMs:i,message:s}]);const m={level:t,message:s,duration:i,scope:o,context:this.#e};process.stderr.write(l.format(m))}}const O=new d;export{d as Logger,O as logger};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{isBuildMode as h}from"../../utils/envs/is-build-mode.js";import{logger as e}from"../../tools/notifiers/logger.js";import P from"./formatter.js";import{blue as
|
|
2
|
-
`+r.stack),h()?await this.panic(r,...t):this.pushError(r,"PANIC",...t)}async panicOnBuildContentErrorForRealFile(r,t,o,...
|
|
1
|
+
import{isBuildMode as h}from"../../utils/envs/is-build-mode.js";import{logger as e}from"../../tools/notifiers/logger.js";import P from"./formatter.js";import{blue as b,gray as p,red as c}from"./helpers/colors.js";import{isVirtualFile as g}from"../../fs/utils/isVirtualFile.js";import{telemetry as u}from"../../telemetry/index.js";import{shutdowner as f}from"../shutdowner.js";const a=30;class C{#r=[];#o=[];#e=new Map;#t=[];pushError(r,t,...o){const i=P.interpolate(r,...o);this.#r.push({severity:t,message:i,type:"ERROR"})}reportBrokenLink(r){this.#r.push(r)}reportCompilationError(r){const t=`${r.message}::${r.sourceFileRelativePath}::${r?.sourceFileLocation?.line}`;this.#e.has(t)||this.#e.set(t,r)}reportPageRenderError(r){this.#t.push(r)}async panicOnBuild(r,...t){r instanceof Error&&(r=r.message+`
|
|
2
|
+
`+r.stack),h()?await this.panic(r,...t):this.pushError(r,"PANIC",...t)}async panicOnBuildContentErrorForRealFile(r,t,o,...i){g(t,o)||await this.panicOnBuildContentError(r,...i)}async panicOnBuildContentError(r,...t){r instanceof Error&&(r=r.message+`
|
|
3
3
|
`+r.stack),h()?await this.panicOnContentError(r,...t):this.pushError(r,"PANIC",...t)}async panic(r,...t){let o;r instanceof Error?(o=r,r=r.message+`
|
|
4
|
-
`+r.stack):o=new Error(r),e.error(r,...t),u.sendCliErrorCaughtMessage({message:r}),await f.exitWithCode(1,o)}async panicOnContentError(r,...t){let o;r instanceof Error?(o=r,r=r.message+`
|
|
5
|
-
`+r.stack):o=new Error(r),e.contentError(r,...t),u.sendCliErrorCaughtMessage({message:r,scope:"content"}),await f.exitWithCode(1,o)}reportMarkdocProblem(r){this.#o.push(r)}clearErrors(){this.#r=[]}clearMarkdocProblems(){this.#o=[]}clearEsbuildProblems(){this.#e.clear()}clearPageRenderProblems(){this.#t=[]}getCompilationProblem(r){return this.#e.get(r)}getCompilationProblems(){return[...this.#e.values()]}getPageRenderProblems(){return this.#t}getPageRenderProblem(r){return this.#t.find(t=>t.sourceFileRelativePath===r)}getProblems(){return[...this.#r,...this.getCompilationProblems(),...this.#o,...this.#t]}summary(r,t=0){const o=this.getProblems(),
|
|
6
|
-
`);return}if(t==="e"){r();return}t==="q"&&process.exit(0)})}}const B=new C;function d(
|
|
4
|
+
`+r.stack):o=new Error(r),e.error(r,...t),u.sendCliErrorCaughtMessage([{object:"cli",message:r}]),await f.exitWithCode(1,o)}async panicOnContentError(r,...t){let o;r instanceof Error?(o=r,r=r.message+`
|
|
5
|
+
`+r.stack):o=new Error(r),e.contentError(r,...t),u.sendCliErrorCaughtMessage([{object:"cli",message:r,scope:"content"}]),await f.exitWithCode(1,o)}reportMarkdocProblem(r){this.#o.push(r)}clearErrors(){this.#r=[]}clearMarkdocProblems(){this.#o=[]}clearEsbuildProblems(){this.#e.clear()}clearPageRenderProblems(){this.#t=[]}getCompilationProblem(r){return this.#e.get(r)}getCompilationProblems(){return[...this.#e.values()]}getPageRenderProblems(){return this.#t}getPageRenderProblem(r){return this.#t.find(t=>t.sourceFileRelativePath===r)}getProblems(){return[...this.#r,...this.getCompilationProblems(),...this.#o,...this.#t]}summary(r,t=0){const o=this.getProblems(),i=this.#o.filter(l=>l.type==="BROKEN_LINK").length,s=this.#r.filter(l=>l.type==="BROKEN_LINK").length,m=this.#o.length-i,E=this.#r.length-s+this.getCompilationProblems().length+this.#t.length;return e.logInFooter("validate",o.length?c(" \u274C Status: %s markdoc errors, %s broken links, %s other errors"):" \u2705 Status: No errors found",m,i+s,E),t!==0&&e.logInFooter("pages",` \u{1F4C4} Total pages: ${t}`),e.logInFooter("timing",r),e.logInFooter("validate-sep",""),e.isInteractive()&&(o.length?e.logInFooter("actions","Press (e) to print all errors, (q) to quit"):e.logInFooter("actions",p("Press (q) to quit"))),o}printErrors(r=[]){const t=this.#r.length,o=r.length?r:this.getProblems();let i=0;for(const s of o.slice(0,a))i>=t?e.contentError(c(`[${++i}] `)+d(s)):e.error(c(`[${++i}] `)+d(s));o.length>a&&e.error(`... and ${o.length-a} more errors`)}listenStdin(){if(!e.isInteractive())return;process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const r=this.printErrors.bind(this);process.stdin.on("data",function(t){if(t===""&&process.exit(),t==="\x7F"){process.stdout.write("\b \b");return}if(t==="\r"){process.stdout.write(`
|
|
6
|
+
`);return}if(t==="e"){r();return}t==="q"&&process.exit(0)})}}const B=new C;function d(n){const r=n.sourceFileLocation,t=r?`:${r.line}:${r.character??1}`:"";return n.message+(n.codeframe?`
|
|
7
7
|
|
|
8
|
-
`+
|
|
8
|
+
`+n.codeframe+`
|
|
9
9
|
|
|
10
10
|
`:`
|
|
11
|
-
`)+(
|
|
11
|
+
`)+(n.sourceFileRelativePath?p(`at ${b("./"+n.sourceFileRelativePath)}${t}`)+`
|
|
12
12
|
`:"")}export{C as Reporter,B as reporter};
|
|
@@ -6,7 +6,7 @@ import type { ProductConfig } from '@redocly/theme/config';
|
|
|
6
6
|
import type { SearchFacet } from '@redocly/theme/core/types';
|
|
7
7
|
import type { GlobalData, Feature } from '../../../types/index.js';
|
|
8
8
|
import type { SearchDocument } from '../../types';
|
|
9
|
-
import type { RbacScopeItems, RedirectConfig, RedoclyConfig, ServerPropsContext, ServerPropsRequest, PageProps, PageStaticData, NavItem, ResolvedNavItem, Version, MdOptions } from '@redocly/config';
|
|
9
|
+
import type { RbacScopeItems, RedirectConfig, RedoclyConfig, ServerPropsContext, ServerPropsRequest, PageProps, PageStaticData, NavItem, ResolvedNavItem, Version, MdOptions, KvService } from '@redocly/config';
|
|
10
10
|
import type { LoaderFn } from '../fs';
|
|
11
11
|
import type { MarkdocDeps } from './markdown';
|
|
12
12
|
import type { BundledDefinition } from '../../plugins/openapi-docs/load-definition';
|
|
@@ -148,6 +148,7 @@ export type ProcessContentActions = {
|
|
|
148
148
|
registerServerPropsGetter: (id: string, importPath: string) => string;
|
|
149
149
|
registerPagePropsGetter: (id: string, importPath: string) => void;
|
|
150
150
|
addSsrComponents: (components: JSX.Element[] | string[], position: 'head' | 'preBody' | 'postBody') => void;
|
|
151
|
+
getKv: () => Promise<KvService>;
|
|
151
152
|
serverOutDir: string;
|
|
152
153
|
contentDir: string;
|
|
153
154
|
outdir: string;
|
|
@@ -185,6 +186,7 @@ export type AfterRoutesCreatedActions = {
|
|
|
185
186
|
addApiRoute: (route: ApiRoute) => void;
|
|
186
187
|
loadOpenApiDefinitions(context: LifecycleContext): Promise<BundledDefinition[]>;
|
|
187
188
|
getRouteSharedDataByFsPath: (routeFsPath: string) => Record<string, string> | undefined;
|
|
189
|
+
getKv: () => Promise<KvService>;
|
|
188
190
|
};
|
|
189
191
|
export type LifecycleContext = {
|
|
190
192
|
fs: ContentFs;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ScorecardsConfig } from '@redocly/config';
|
|
2
|
+
import type { Filter } from '../../providers/database/pagination/types.js';
|
|
3
|
+
import type { CatalogEntitiesService } from '../../plugins/catalog-entities/database/catalog-entities-service.js';
|
|
4
|
+
import type { ScorecardsConfigService } from '../../plugins/scorecards/database/scorecards-config-service.js';
|
|
5
|
+
export type ScorecardsWorkerParams = {
|
|
6
|
+
baseDbDir: string;
|
|
7
|
+
scorecardsConfig: ScorecardsConfig;
|
|
8
|
+
pollingIntervalMs?: number;
|
|
9
|
+
};
|
|
10
|
+
export type PollAndProcessEntitiesParams = {
|
|
11
|
+
scorecardsConfig: ScorecardsConfig;
|
|
12
|
+
pollingIntervalMs: number;
|
|
13
|
+
entitiesFilters: Record<string, Filter>;
|
|
14
|
+
entitiesService: CatalogEntitiesService;
|
|
15
|
+
};
|
|
16
|
+
export type SyncConfigAndUpdateEntitiesParams = {
|
|
17
|
+
scorecardsConfig: ScorecardsConfig;
|
|
18
|
+
entitiesFilters: Record<string, Filter>;
|
|
19
|
+
configService: ScorecardsConfigService;
|
|
20
|
+
entitiesService: CatalogEntitiesService;
|
|
21
|
+
};
|
|
22
|
+
export type ScorecardsWorkerResponse = {
|
|
23
|
+
success: true;
|
|
24
|
+
message: string;
|
|
25
|
+
} | {
|
|
26
|
+
success: false;
|
|
27
|
+
message: string;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=scorecards.d.ts.map
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function loadEnvVariables(
|
|
1
|
+
export declare function loadEnvVariables(cwd?: string): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=load-env-variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as a from"dotenv";import*as n from"path";import{simpleGit as s}from"simple-git";import{readEnvVariable as o}from"../../utils/envs/read-env-variable.js";import{sanitizeBranchName as v}from"../../utils/envs/sanitize-branch-name.js";async function p(e){try{return(await s(e??process.cwd()).revparse(["--abbrev-ref","HEAD"])).trim()}catch{return""}}async function h(e){a.config({path:n.resolve(e??"",".env")});const t=o("PUBLIC_REDOCLY_BRANCH_NAME")||await p(e);if(t){const c=v(t);a.config({path:n.resolve(e??"",`.env.branch.${c}`),override:!0})}const i=o("REDOCLY_ENV");let r;switch(i){case"production":r=".env.production";break;case"preview":r=".env.preview";break;case"development":default:r=".env.development";break}a.config({path:n.resolve(e??"",r),override:!0})}export{h as loadEnvVariables};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a branch name for use in env file names and config keys.
|
|
3
|
+
* Replaces `/` with `-` to support branches like `feature/my-branch`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sanitizeBranchName(branchName: string): string;
|
|
6
|
+
//# sourceMappingURL=sanitize-branch-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e){return e.replace(/\//g,"-")}export{n as sanitizeBranchName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as i from"path";import{cliCommandNames as r}from"../../constants/common.js";import{PUBLIC_STATIC_FOLDER as t}from"../constants/common.js";import{logger as n}from"../tools/notifiers/logger.js";import{blue as s,gray as
|
|
1
|
+
import*as i from"path";import{cliCommandNames as r}from"../../constants/common.js";import{PUBLIC_STATIC_FOLDER as t}from"../constants/common.js";import{logger as n}from"../tools/notifiers/logger.js";import{blue as s,gray as a}from"../tools/notifiers/helpers/colors.js";import{loadEnvVariables as c}from"./envs/load-env-variables.js";import{copyFolderRecursiveSync as f}from"./fs.js";import{validateInstalledVersion as l}from"./validate-installed-version.js";import{PACKAGE_NAME as E}from"../../config/product-gates.js";import{PORTAL_VERSION as P}from"../version.js";function u(e){return e?"true":"false"}function v(e){e["log-level"]&&(process.env.REDOCLY_LOG_LEVEL=String(e["log-level"])),process.env.INSPECT_MODE="inspect"in e?u(e.inspect):"false",e.pathPrefix&&(process.env.REDOCLY_PREFIX_PATHS=e.pathPrefix)}function L({contentDir:e,outdir:o}){f(i.join(e,t),i.join(o,t))}async function N(e,o,p){await c(o["project-dir"]),process.env.REDOCLY_RUNNING_COMMAND=e;const m=e===r.DEVELOP?" Previewing with":"Building with";switch(n.logInFooter("product",`${m} ${s(`${E}@${P}`)}`),n.logInFooter("server",` \u{1F310} Preview URL: ${a("server starting...")}`),e){case r.DEVELOP:case r.BUILD:case r.PREPARE:v(o);break;default:break}await l(),L(p)}export{N as beforeCommand};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import '../node-crypto-polyfill.js';
|
|
2
2
|
import { REDOCLY_TEAMS_RBAC, REDOCLY_ROUTE_RBAC } from '@redocly/config';
|
|
3
|
-
import type {
|
|
4
|
-
import type { AuthDetails
|
|
3
|
+
import type { RbacConfig, RbacScopeItems, RedoclyConfig, SsoConfig } from '@redocly/config';
|
|
4
|
+
import type { AuthDetails } from '../types';
|
|
5
5
|
import type { ContentFs } from '../fs/content-fs.js';
|
|
6
6
|
import type { RbacFeatures } from '../../constants/common.js';
|
|
7
7
|
export type ProjectRole = 'NONE' | 'READ' | 'TRIAGE' | 'WRITE' | 'MAINTAIN' | 'ADMIN';
|
|
8
8
|
export declare const PROJECT_ROLES_ORDERED_BY_ACCESS_LEVEL: string[];
|
|
9
9
|
export declare function getHigherRole(a: ProjectRole, b: ProjectRole): ProjectRole;
|
|
10
|
-
export declare function
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export declare function getScopeItemsForResource(rbacConfig: RbacConfig | undefined, resource: {
|
|
11
|
+
fsPath?: string;
|
|
12
|
+
slug?: string;
|
|
13
|
+
}): RbacScopeItems;
|
|
13
14
|
export declare function canAccessFeature(feature: RbacFeatures, auth: AuthDetails, rbacConfig?: RbacConfig, requiresLogin?: boolean): boolean;
|
|
14
15
|
export declare function isResourcePubliclyAccessible(resource: {
|
|
15
16
|
slug: string;
|
|
@@ -84,7 +85,10 @@ export declare const normalizeRbacConfig: (rbacConfig: RbacConfig) => {
|
|
|
84
85
|
} | undefined;
|
|
85
86
|
} | undefined;
|
|
86
87
|
};
|
|
87
|
-
export declare function
|
|
88
|
-
|
|
88
|
+
export declare function getRbacTeamsListForResource(resource: {
|
|
89
|
+
fsPath?: string;
|
|
90
|
+
slug?: string;
|
|
91
|
+
}, rbacConfig: RbacConfig): string[];
|
|
92
|
+
export declare function extractTeamsFromScopeItems(scopeItems: RbacScopeItems | undefined): string[];
|
|
89
93
|
export declare function expandTeamsForRead(rbacConfig: RbacConfig, teamNames: string[]): string[];
|
|
90
94
|
//# sourceMappingURL=rbac.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import h from"path";import O from"picomatch";import"../node-crypto-polyfill.js";import{REDOCLY_TEAMS_RBAC as D,REDOCLY_ROUTE_RBAC as R}from"@redocly/config";import{DEFAULT_ANONYMOUS_VISITOR_TEAM as P,ServerRoutes as j,PUBLIC_RBAC_SCOPE_ITEM as A,RBAC_ALL_OTHER_TEAMS as u,DEFAULT_RBAC_SCOPE as _}from"../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as L,PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_ASSETS_FOLDER as F}from"../constants/common.js";import{removeTrailingSlash as w}from"../../utils/url/remove-trailing-slash.js";import{parsePathVersions as N}from"../../utils/path/parse-path-versions.js";import{reporter as B}from"../tools/notifiers/reporter.js";import{bold as k}from"../tools/notifiers/helpers/colors.js";import{shaDirPathShort as W}from"../utils/crypto/sha-dir-path-short.js";import{isTruthy as U}from"../../utils/guards/is-truthy.js";import{canExpandConfig as b,expandRbacConfig as M,getTeamFolderDefaults as $,parseTeamFoldersTemplate as v,parseTeamNameTemplate as Y}from"./rbac-expand.js";import{getUserParamsFromCookies as z}from"../web-server/auth.js";import{getDeeperGlobPattern as H}from"./globs.js";import{EntitlementsProvider as G}from"../entitlements/entitlements-provider.js";const S=["NONE","READ","TRIAGE","WRITE","MAINTAIN","ADMIN"],K=new Set(["x-parsed-md-description","x-parsed-md-summary"]);function dt(t,e){const n=S.indexOf(t.toUpperCase()),r=S.indexOf(e.toUpperCase());return n>r?t:e}const I={};function y(t,e){if(!t?.content)return A;const n=t.content,{slug:r,fsPath:o}=e;if(!r&&!o)return A;const s=f=>{const m=I[f]||O(f);return I[f]=m,!!(r&&m(r))||!!(o&&m(o))};if(V(r||o||"")&&Object.keys(n).filter(T=>s(T)).length===0)return n[_]||A;const c=Object.keys(n).filter(f=>s(f));if(c.length==0)return A;const l=c.map(f=>O.scan(f,{tokens:!0,parts:!0}));let p=l[0];for(let f=1;f<l.length;f++)p=H(p,l[f]);return n[p.input]}function ht(t,e,n={},r=!1){if(r&&Object.keys(n).length===0)return e.isAuthenticated;const o=n.features?.[t];return o?e.teams.some(s=>o[s]&&o[s].toLowerCase()!=="none"):!0}function Rt(t,e){return E(t,{isAuthenticated:!1,teams:[P]},e.rbac||{},e.requiresLogin||!1)}function E(t,e={},n={},r=!1){if(t.slug&&typeof t.slug=="string"&&Object.values(j).some(c=>{const l=c.split(":")[0].replace(/\/$/,"");return t.slug===l||t.slug?.startsWith(c)})||typeof t.slug=="string"&&t.slug?.endsWith("/mcp")&&G.instance().canAccessFeature("mcp"))return!0;if(r&&Object.keys(n).length===0)return!!e.isAuthenticated;const o=M(n,e.teams||[]),s=t[D]||y(o,t[R]||{});if(Object.keys(s||{}).length===0)return!1;if(Object.keys(s).length===1&&s[u]&&s[u].toLowerCase()!=="none")return!0;const i=(e?.email?[...e?.teams||[],e?.email]:e?.teams)||[],a=[];for(const c of i??[])s[c]?a.push(s[c]):s[u]&&c!==e?.email&&a.push(s[u]);return a.length?a.some(c=>c.toLowerCase()!=="none"):!1}function At(t,e,n,r){if(!t.startsWith(g)&&!t.startsWith(L))return!0;const o=t.replace(new RegExp(`^${g}/`),"").replace(new RegExp(`^${L}/`),""),i=o==="."?"":o,a={[R]:{slug:t,fsPath:i},slug:t};return E(a,r,e,n)}function yt(t,e,n,r,o){if(!t.startsWith(F))return!0;const s=t.match(/.*\..{64}\.([A-Fa-f0-9]{8})\.[^\.]+$/)?.[1];if(!s)return!0;const i=r[s];if(!i)return!0;const{base:a,ext:c}=h.parse(t),l=a.split(".")[0],p=c.split(".").join(""),m=i==="."?"":i,T={[R]:{slug:t,fsPath:h.posix.join(m,`${l}.${p}`)},slug:t};return E(T,o,e,n)}async function Et(t,e){const{isAuthenticated:n=!1,idpAccessToken:r,federatedAccessToken:o,federatedIdToken:s,...i}=await z(t,e),{teams:a=[]}=i;let c;return n?c=a.filter(l=>l!==P):c=[P],{isAuthenticated:n,idpAccessToken:r,teams:c,claims:i}}function C(t,e,n={},r=!1){if(!t)return t;if(Array.isArray(t)){const o=[];for(const s of t){const i=C(s,e,n,r);i!==void 0&&o.push(i)}return o}if(typeof t=="object"){if(!E(t,e,n,r))return;let o=!1;const s={};for(const i in t){if(i===D||i===R)continue;if(K.has(i)){s[i]=t[i];continue}const a=C(t[i],e,n,r);if(i==="items"&&Array.isArray(a)&&a.length===0&&t[i].length!==0){o=!0;continue}a!==void 0&&(s[i]=a)}return o?void 0:s}return t}function Tt(t){return typeof t=="string"?t.split(" ").filter(Boolean):Array.isArray(t)?t.map(e=>e.toString()):[]}function Pt(t,e){if(!e)return;const n=e.content;if(!n)return e;const r=Object.entries(n).flatMap(([s,i])=>s===_?[[s,i]]:[[s,i],...t.localeFolders.map(a=>[s.startsWith("/")?`/${a.toLocaleLowerCase()}${s}`:h.posix.join(t.localizationFolder,a,s),i])]),o=Object.fromEntries(r);return{...e,content:o}}async function xt(t,e){if(!e)return{};const n={},r=new Set((await t.scan()).flatMap(({relativePath:o})=>{const{versionFolderPath:s}=N(o)||{},i=h.dirname(o);return s?[s,i]:i}));for(const o of r)n[W(o)]=o;return n}const d=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function V(t){return t?t.split("/").filter(Boolean).some(n=>n.startsWith(".")):!1}const J=t=>{if(t&&d(t)&&("content"in t&&d(t.content)||"reunite"in t&&d(t.reunite)||"features"in t&&d(t.features)||t.teamFolders&&t.teamNamePatterns)){const e=Object.values(t.content||{});if(e.length===0)return!0;if(e.every(d))return e.every(n=>Object.values(n).every(r=>typeof r=="string"))}return!1},Ot=async t=>{if(t){if(Object.keys(t).length===0)return{};if(J(t))return Q(t);await B.panicOnContentError(`You are using an incorrect format of ${k("rbac:")} configuration. See: https://redocly.com/docs/realm/access`)}},Q=t=>{const e={...t};if(e.content){const n={};for(const r in e.content)if(e.content[r]!==void 0){const o=w(r);n[o]=e.content[r]}e.content=n}return e};function Dt(t,e){const n=t.fsPath,r=t.slug,o=[];if(b(e)&&(n||r)){const s=[n,r].filter(U),i=v(e,s);if(i){const a=e?.teamNamePatterns?.map(l=>l.replace("{teamPathSegment}",i.teamPathSegment).replace("{projectRole}","read"))??[];o.push(...a);const c=y({content:{...$(e),...e.content}},t);o.push(...x(c))}else{const a=y(e,t);o.push(...x(a))}}else{const s=y(e,t);o.push(...x(s))}return X(e,o)}function x(t){if(!t)return[];const e=[],n=u in t?{authenticated:t[u],anonymous:t[u]}:{};for(const[r,o]of Object.entries({...n,...t}))o.toLowerCase()!=="none"&&r!==u&&e.push(r);return e}function X(t,e){return e.map(r=>Y(t,r)??{teamName:r}).map(r=>r.projectRole&&r.projectRole!=="READ"?r.teamName?.toLowerCase().replace(r.projectRole?.toLowerCase?.()??"","read")??"":r.teamName?.toLowerCase()??"")}export{S as PROJECT_ROLES_ORDERED_BY_ACCESS_LEVEL,Pt as applyL10nToRbacConfig,yt as canAccessAsset,ht as canAccessFeature,E as canAccessResource,At as canDownloadApiDefinition,X as expandTeamsForRead,x as extractTeamsFromScopeItems,C as filterDataByAccessDeep,Et as getAuthDetailsFromCookies,dt as getHigherRole,Dt as getRbacTeamsListForResource,y as getScopeItemsForResource,J as isRbacConfigValid,Rt as isResourcePubliclyAccessible,Q as normalizeRbacConfig,Ot as parseRbacConfig,Tt as parseTeamClaimToArray,xt as resolveDirectoryHashes};
|
|
@@ -1,25 +1,57 @@
|
|
|
1
|
+
type TimestampField = 'createdAt' | 'updatedAt' | 'archivedAt';
|
|
2
|
+
type TimestampFieldsOptions = {
|
|
3
|
+
fields?: TimestampField[];
|
|
4
|
+
dates?: {
|
|
5
|
+
createdAt?: Date;
|
|
6
|
+
updatedAt?: Date;
|
|
7
|
+
archivedAt?: Date;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type TimestampFieldsMap = {
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
archivedAt: string;
|
|
14
|
+
};
|
|
15
|
+
type WithTimestampResult<T, F extends TimestampField[]> = T & Pick<TimestampFieldsMap, F[number]>;
|
|
1
16
|
/**
|
|
2
|
-
* Adds timestamp fields (createdAt and
|
|
17
|
+
* Adds timestamp fields (createdAt, updatedAt, and/or archivedAt) to an object.
|
|
3
18
|
*
|
|
4
19
|
* @param data - The object to add timestamps to
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
20
|
+
* @param options - Optional configuration object
|
|
21
|
+
* @param options.fields - Array of timestamp fields to include. Defaults to ['createdAt', 'updatedAt']
|
|
22
|
+
* @param options.dates - Optional custom dates for specific timestamp fields
|
|
23
|
+
* @returns A new object containing all properties from the input data plus the specified timestamp fields in ISO format
|
|
8
24
|
*
|
|
9
25
|
* @example
|
|
10
26
|
* ```ts
|
|
11
|
-
* // Add current timestamps
|
|
27
|
+
* // Add current timestamps (default: createdAt and updatedAt)
|
|
12
28
|
* const result = withTimestamp({ id: 1, name: 'Test' });
|
|
13
29
|
* // Returns { id: 1, name: 'Test', updatedAt: '2025-10-21T10:00:00.000Z', createdAt: '2025-10-21T10:00:00.000Z' }
|
|
14
30
|
*
|
|
31
|
+
* // Only add updatedAt when updating data
|
|
32
|
+
* const result = withTimestamp({ id: 1, name: 'Updated' }, { fields: ['updatedAt'] });
|
|
33
|
+
* // Returns { id: 1, name: 'Updated', updatedAt: '2025-10-21T10:00:00.000Z' }
|
|
34
|
+
*
|
|
35
|
+
* // Only add archivedAt when archiving data
|
|
36
|
+
* const result = withTimestamp({ id: 1 }, { fields: ['archivedAt'] });
|
|
37
|
+
* // Returns { id: 1, archivedAt: '2025-10-21T10:00:00.000Z' }
|
|
38
|
+
*
|
|
15
39
|
* // Use custom dates
|
|
16
40
|
* const customDate = new Date('2025-01-01');
|
|
17
|
-
* const result = withTimestamp({ id: 1 },
|
|
41
|
+
* const result = withTimestamp({ id: 1 }, {
|
|
42
|
+
* fields: ['createdAt', 'updatedAt'],
|
|
43
|
+
* dates: { createdAt: customDate, updatedAt: customDate }
|
|
44
|
+
* });
|
|
18
45
|
* // Returns { id: 1, updatedAt: '2025-01-01T00:00:00.000Z', createdAt: '2025-01-01T00:00:00.000Z' }
|
|
46
|
+
*
|
|
47
|
+
* // Add all three timestamps
|
|
48
|
+
* const result = withTimestamp({ id: 1 }, { fields: ['createdAt', 'updatedAt', 'archivedAt'] });
|
|
49
|
+
* // Returns { id: 1, createdAt: '...', updatedAt: '...', archivedAt: '...' }
|
|
19
50
|
* ```
|
|
20
51
|
*/
|
|
21
|
-
export declare
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
52
|
+
export declare function withTimestamp<T extends Record<string, unknown>>(data: T, options?: TimestampFieldsOptions): WithTimestampResult<T, ['createdAt', 'updatedAt']>;
|
|
53
|
+
export declare function withTimestamp<T extends Record<string, unknown>, F extends TimestampField[]>(data: T, options: {
|
|
54
|
+
fields: F;
|
|
55
|
+
} & TimestampFieldsOptions): WithTimestampResult<T, F>;
|
|
56
|
+
export {};
|
|
25
57
|
//# sourceMappingURL=with-timestamp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function s(i,n){const d=new Date,a=n?.fields??["createdAt","updatedAt"],c=n?.dates??{},e={...i};if(a.includes("createdAt")){const t=c.createdAt??d;e.createdAt=t.toISOString()}if(a.includes("updatedAt")){const t=c.updatedAt??d;e.updatedAt=t.toISOString()}if(a.includes("archivedAt")){const t=c.archivedAt??d;e.archivedAt=t.toISOString()}return e}export{s as withTimestamp};
|