@lupinum/ginko-content 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/compatibility.json +27 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +690 -0
- package/dist/cms-contract/build +1 -0
- package/dist/cms-contract/build.d.ts +44 -0
- package/dist/cms-contract/build.js +513 -0
- package/dist/cms-contract/index +1 -0
- package/dist/cms-contract/index.d.ts +25 -0
- package/dist/cms-contract/index.js +37 -0
- package/dist/cms-contract/mdc +1 -0
- package/dist/cms-contract/mdc.d.ts +32 -0
- package/dist/cms-contract/mdc.js +52 -0
- package/dist/cms-contract/path +1 -0
- package/dist/cms-contract/path.d.ts +12 -0
- package/dist/cms-contract/path.js +18 -0
- package/dist/cms-contract/schema +1 -0
- package/dist/cms-contract/schema.d.ts +18 -0
- package/dist/cms-contract/schema.js +13 -0
- package/dist/cms-contract/types +1 -0
- package/dist/cms-contract/types.d.ts +177 -0
- package/dist/cms-contract/types.js +0 -0
- package/dist/cms-import/index +1 -0
- package/dist/cms-import/index.d.ts +21 -0
- package/dist/cms-import/index.js +57 -0
- package/dist/config.d.mts +3 -0
- package/dist/config.mjs +3 -0
- package/dist/core/cache +1 -0
- package/dist/core/cache-hints +1 -0
- package/dist/core/cache-hints.d.ts +3 -0
- package/dist/core/cache-hints.js +55 -0
- package/dist/core/cache.d.ts +29 -0
- package/dist/core/cache.js +0 -0
- package/dist/core/content/collection +1 -0
- package/dist/core/content/collection.d.ts +3 -0
- package/dist/core/content/collection.js +52 -0
- package/dist/core/content/graph +1 -0
- package/dist/core/content/graph.d.ts +147 -0
- package/dist/core/content/graph.js +189 -0
- package/dist/core/content/ignore +1 -0
- package/dist/core/content/ignore.d.ts +5 -0
- package/dist/core/content/ignore.js +10 -0
- package/dist/core/content/locale +1 -0
- package/dist/core/content/locale.d.ts +61 -0
- package/dist/core/content/locale.js +77 -0
- package/dist/core/content/path +1 -0
- package/dist/core/content/path.d.ts +36 -0
- package/dist/core/content/path.js +143 -0
- package/dist/core/content/slug +1 -0
- package/dist/core/content/slug.d.ts +4 -0
- package/dist/core/content/slug.js +41 -0
- package/dist/core/content/sources +1 -0
- package/dist/core/content/sources.d.ts +2 -0
- package/dist/core/content/sources.js +6 -0
- package/dist/core/errors +1 -0
- package/dist/core/errors.d.ts +15 -0
- package/dist/core/errors.js +10 -0
- package/dist/core/markdown/tree +1 -0
- package/dist/core/markdown/tree.d.ts +9 -0
- package/dist/core/markdown/tree.js +47 -0
- package/dist/core/query/builder +1 -0
- package/dist/core/query/builder.d.ts +18 -0
- package/dist/core/query/builder.js +186 -0
- package/dist/core/query/execute +1 -0
- package/dist/core/query/execute.d.ts +52 -0
- package/dist/core/query/execute.js +304 -0
- package/dist/core/query/filter +1 -0
- package/dist/core/query/filter.d.ts +42 -0
- package/dist/core/query/filter.js +118 -0
- package/dist/core/query/json +1 -0
- package/dist/core/query/json.d.ts +2 -0
- package/dist/core/query/json.js +20 -0
- package/dist/core/query/lower +1 -0
- package/dist/core/query/lower.d.ts +14 -0
- package/dist/core/query/lower.js +121 -0
- package/dist/core/query/operators +1 -0
- package/dist/core/query/operators.d.ts +23 -0
- package/dist/core/query/operators.js +126 -0
- package/dist/core/query/params +1 -0
- package/dist/core/query/params.d.ts +15 -0
- package/dist/core/query/params.js +83 -0
- package/dist/core/query/plan +1 -0
- package/dist/core/query/plan.d.ts +110 -0
- package/dist/core/query/plan.js +0 -0
- package/dist/core/references/resolve +1 -0
- package/dist/core/references/resolve.d.ts +31 -0
- package/dist/core/references/resolve.js +121 -0
- package/dist/core/references/schema +1 -0
- package/dist/core/references/schema.d.ts +8 -0
- package/dist/core/references/schema.js +70 -0
- package/dist/core/result +1 -0
- package/dist/core/result.d.ts +27 -0
- package/dist/core/result.js +2 -0
- package/dist/features/collections/resolve +1 -0
- package/dist/features/collections/resolve.d.ts +63 -0
- package/dist/features/collections/resolve.js +76 -0
- package/dist/features/localization/config +1 -0
- package/dist/features/localization/config.d.ts +18 -0
- package/dist/features/localization/config.js +25 -0
- package/dist/features/localization/links +1 -0
- package/dist/features/localization/links.d.ts +1 -0
- package/dist/features/localization/links.js +69 -0
- package/dist/features/localization/path +1 -0
- package/dist/features/localization/path.d.ts +32 -0
- package/dist/features/localization/path.js +80 -0
- package/dist/features/localization/results +1 -0
- package/dist/features/localization/results.d.ts +42 -0
- package/dist/features/localization/results.js +149 -0
- package/dist/features/localization/translated-slugs +1 -0
- package/dist/features/localization/translated-slugs.d.ts +11 -0
- package/dist/features/localization/translated-slugs.js +80 -0
- package/dist/features/navigation/build +1 -0
- package/dist/features/navigation/build.d.ts +28 -0
- package/dist/features/navigation/build.js +104 -0
- package/dist/features/navigation/canonical +1 -0
- package/dist/features/navigation/canonical.d.ts +33 -0
- package/dist/features/navigation/canonical.js +149 -0
- package/dist/features/navigation/query +1 -0
- package/dist/features/navigation/query.d.ts +19 -0
- package/dist/features/navigation/query.js +51 -0
- package/dist/features/navigation/resolve +1 -0
- package/dist/features/navigation/resolve.d.ts +20 -0
- package/dist/features/navigation/resolve.js +79 -0
- package/dist/features/navigation/tree +1 -0
- package/dist/features/navigation/tree.d.ts +6 -0
- package/dist/features/navigation/tree.js +32 -0
- package/dist/features/search/navigation +1 -0
- package/dist/features/search/navigation.d.ts +6 -0
- package/dist/features/search/navigation.js +21 -0
- package/dist/features/search/sections +1 -0
- package/dist/features/search/sections.d.ts +21 -0
- package/dist/features/search/sections.js +98 -0
- package/dist/features/sitemap/query +1 -0
- package/dist/features/sitemap/query.d.ts +68 -0
- package/dist/features/sitemap/query.js +171 -0
- package/dist/integrations/nitro/context +1 -0
- package/dist/integrations/nitro/context.d.ts +63 -0
- package/dist/integrations/nitro/context.js +28 -0
- package/dist/integrations/nitro/ingest +1 -0
- package/dist/integrations/nitro/ingest.d.ts +18 -0
- package/dist/integrations/nitro/ingest.js +120 -0
- package/dist/integrations/nitro/preview +1 -0
- package/dist/integrations/nitro/preview.d.ts +5 -0
- package/dist/integrations/nitro/preview.js +21 -0
- package/dist/integrations/nitro/runtime-config +1 -0
- package/dist/integrations/nitro/runtime-config.d.ts +1 -0
- package/dist/integrations/nitro/runtime-config.js +4 -0
- package/dist/integrations/nitro/storage +1 -0
- package/dist/integrations/nitro/storage.d.ts +9 -0
- package/dist/integrations/nitro/storage.js +113 -0
- package/dist/integrations/vue/content-components +1 -0
- package/dist/integrations/vue/content-components.d.ts +24 -0
- package/dist/integrations/vue/content-components.js +67 -0
- package/dist/integrations/vue/html-tags +1 -0
- package/dist/integrations/vue/html-tags.d.ts +2 -0
- package/dist/integrations/vue/html-tags.js +119 -0
- package/dist/integrations/vue/markdown-refs +1 -0
- package/dist/integrations/vue/markdown-refs.d.ts +1 -0
- package/dist/integrations/vue/markdown-refs.js +1 -0
- package/dist/module.d.mts +2044 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +1381 -0
- package/dist/parsers/csv +1 -0
- package/dist/parsers/csv.d.ts +2 -0
- package/dist/parsers/csv.js +38 -0
- package/dist/parsers/from-csv +1 -0
- package/dist/parsers/from-csv.d.ts +20 -0
- package/dist/parsers/from-csv.js +85 -0
- package/dist/parsers/index +1 -0
- package/dist/parsers/index.d.ts +10 -0
- package/dist/parsers/index.js +50 -0
- package/dist/parsers/json +1 -0
- package/dist/parsers/json.d.ts +2 -0
- package/dist/parsers/json.js +29 -0
- package/dist/parsers/markdown +1 -0
- package/dist/parsers/markdown-plugins +1 -0
- package/dist/parsers/markdown-plugins.d.ts +3 -0
- package/dist/parsers/markdown-plugins.js +58 -0
- package/dist/parsers/markdown.d.ts +2 -0
- package/dist/parsers/markdown.js +64 -0
- package/dist/parsers/path-meta +1 -0
- package/dist/parsers/path-meta.d.ts +4 -0
- package/dist/parsers/path-meta.js +37 -0
- package/dist/parsers/utils +1 -0
- package/dist/parsers/utils.d.ts +2 -0
- package/dist/parsers/utils.js +3 -0
- package/dist/parsers/yaml +1 -0
- package/dist/parsers/yaml.d.ts +2 -0
- package/dist/parsers/yaml.js +19 -0
- package/dist/public/client +1 -0
- package/dist/public/client.d.ts +19 -0
- package/dist/public/client.js +26 -0
- package/dist/public/provider +1 -0
- package/dist/public/provider-errors +1 -0
- package/dist/public/provider-errors.d.ts +4 -0
- package/dist/public/provider-errors.js +28 -0
- package/dist/public/provider.d.ts +74 -0
- package/dist/public/provider.js +6 -0
- package/dist/public/server +1 -0
- package/dist/public/server.d.ts +19 -0
- package/dist/public/server.js +28 -0
- package/dist/runtime/app/components/ContentRenderer.d.vue.ts +62 -0
- package/dist/runtime/app/components/ContentRenderer.vue +84 -0
- package/dist/runtime/app/components/ContentRenderer.vue.d.ts +62 -0
- package/dist/runtime/app/components/ContentRendererInline.d.vue.ts +50 -0
- package/dist/runtime/app/components/ContentRendererInline.vue +97 -0
- package/dist/runtime/app/components/ContentRendererInline.vue.d.ts +50 -0
- package/dist/runtime/app/components/Prose/ProseCode.d.vue.ts +61 -0
- package/dist/runtime/app/components/Prose/ProseCode.vue +32 -0
- package/dist/runtime/app/components/Prose/ProseCode.vue.d.ts +61 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.d.vue.ts +13 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.vue +3 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.vue.d.ts +13 -0
- package/dist/runtime/app/components/Prose/ProseImg.d.vue.ts +59 -0
- package/dist/runtime/app/components/Prose/ProseImg.vue +59 -0
- package/dist/runtime/app/components/Prose/ProseImg.vue.d.ts +59 -0
- package/dist/runtime/app/components/Prose/ProsePre.d.vue.ts +79 -0
- package/dist/runtime/app/components/Prose/ProsePre.vue +42 -0
- package/dist/runtime/app/components/Prose/ProsePre.vue.d.ts +79 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.d.vue.ts +68 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue +99 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue.d.ts +68 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer +1 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer.d.ts +90 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer.js +191 -0
- package/dist/runtime/app/composables/async-data +1 -0
- package/dist/runtime/app/composables/async-data.d.ts +2 -0
- package/dist/runtime/app/composables/async-data.js +4 -0
- package/dist/runtime/app/composables/content-i18n +1 -0
- package/dist/runtime/app/composables/content-i18n.d.ts +5 -0
- package/dist/runtime/app/composables/content-i18n.js +1 -0
- package/dist/runtime/app/composables/head +1 -0
- package/dist/runtime/app/composables/head.d.ts +11 -0
- package/dist/runtime/app/composables/head.js +98 -0
- package/dist/runtime/app/composables/locale +1 -0
- package/dist/runtime/app/composables/locale-context +1 -0
- package/dist/runtime/app/composables/locale-context.d.ts +5 -0
- package/dist/runtime/app/composables/locale-context.js +8 -0
- package/dist/runtime/app/composables/locale.d.ts +8 -0
- package/dist/runtime/app/composables/locale.js +15 -0
- package/dist/runtime/app/composables/navigation +1 -0
- package/dist/runtime/app/composables/navigation.d.ts +3 -0
- package/dist/runtime/app/composables/navigation.js +7 -0
- package/dist/runtime/app/composables/preview +1 -0
- package/dist/runtime/app/composables/preview.d.ts +5 -0
- package/dist/runtime/app/composables/preview.js +52 -0
- package/dist/runtime/app/composables/query-api +1 -0
- package/dist/runtime/app/composables/query-api.d.ts +27 -0
- package/dist/runtime/app/composables/query-api.js +46 -0
- package/dist/runtime/app/composables/route +1 -0
- package/dist/runtime/app/composables/route.d.ts +11 -0
- package/dist/runtime/app/composables/route.js +150 -0
- package/dist/runtime/app/composables/runtime +1 -0
- package/dist/runtime/app/composables/runtime.d.ts +2 -0
- package/dist/runtime/app/composables/runtime.js +7 -0
- package/dist/runtime/app/composables/search +1 -0
- package/dist/runtime/app/composables/search.d.ts +58 -0
- package/dist/runtime/app/composables/search.js +321 -0
- package/dist/runtime/app/composables/site-data +1 -0
- package/dist/runtime/app/composables/site-data.d.ts +12 -0
- package/dist/runtime/app/composables/site-data.js +12 -0
- package/dist/runtime/app/composables/toc +1 -0
- package/dist/runtime/app/composables/toc.d.ts +10 -0
- package/dist/runtime/app/composables/toc.js +31 -0
- package/dist/runtime/app/composables/use-content +1 -0
- package/dist/runtime/app/composables/use-content.d.ts +188 -0
- package/dist/runtime/app/composables/use-content.js +307 -0
- package/dist/runtime/app/composables/useUnwrap +1 -0
- package/dist/runtime/app/composables/useUnwrap.d.ts +8 -0
- package/dist/runtime/app/composables/useUnwrap.js +35 -0
- package/dist/runtime/app/composables/utils +1 -0
- package/dist/runtime/app/composables/utils.d.ts +22 -0
- package/dist/runtime/app/composables/utils.js +76 -0
- package/dist/runtime/app/composables/web-socket +1 -0
- package/dist/runtime/app/composables/web-socket.d.ts +3 -0
- package/dist/runtime/app/composables/web-socket.js +65 -0
- package/dist/runtime/app/pages/content.d.vue.ts +3 -0
- package/dist/runtime/app/pages/content.vue +14 -0
- package/dist/runtime/app/pages/content.vue.d.ts +3 -0
- package/dist/runtime/app/plugins/markdown-components +1 -0
- package/dist/runtime/app/plugins/markdown-components.d.ts +2 -0
- package/dist/runtime/app/plugins/markdown-components.js +19 -0
- package/dist/runtime/app/plugins/ws +1 -0
- package/dist/runtime/app/plugins/ws.d.ts +2 -0
- package/dist/runtime/app/plugins/ws.js +7 -0
- package/dist/runtime/app.d.vue.ts +3 -0
- package/dist/runtime/app.vue +3 -0
- package/dist/runtime/app.vue.d.ts +3 -0
- package/dist/runtime/markdown/plugins +1 -0
- package/dist/runtime/markdown/plugins.d.ts +3 -0
- package/dist/runtime/markdown/plugins.js +39 -0
- package/dist/runtime/query/public-limits +1 -0
- package/dist/runtime/query/public-limits.d.ts +2 -0
- package/dist/runtime/query/public-limits.js +2 -0
- package/dist/runtime/query/resolve +1 -0
- package/dist/runtime/query/resolve.d.ts +5 -0
- package/dist/runtime/query/resolve.js +9 -0
- package/dist/runtime/query/routes +1 -0
- package/dist/runtime/query/routes.d.ts +33 -0
- package/dist/runtime/query/routes.js +21 -0
- package/dist/runtime/query/unified +1 -0
- package/dist/runtime/query/unified.d.ts +94 -0
- package/dist/runtime/query/unified.js +473 -0
- package/dist/runtime/server/api/cache +1 -0
- package/dist/runtime/server/api/cache.d.ts +8 -0
- package/dist/runtime/server/api/cache.js +26 -0
- package/dist/runtime/server/api/locales +1 -0
- package/dist/runtime/server/api/locales.d.ts +6 -0
- package/dist/runtime/server/api/locales.js +28 -0
- package/dist/runtime/server/api/navigation +1 -0
- package/dist/runtime/server/api/navigation.d.ts +2 -0
- package/dist/runtime/server/api/navigation.js +21 -0
- package/dist/runtime/server/api/query +1 -0
- package/dist/runtime/server/api/query.d.ts +2 -0
- package/dist/runtime/server/api/query.js +6 -0
- package/dist/runtime/server/api/revalidate +1 -0
- package/dist/runtime/server/api/revalidate.d.ts +6 -0
- package/dist/runtime/server/api/revalidate.js +156 -0
- package/dist/runtime/server/api/search +1 -0
- package/dist/runtime/server/api/search-index +1 -0
- package/dist/runtime/server/api/search-index.d.ts +2 -0
- package/dist/runtime/server/api/search-index.js +20 -0
- package/dist/runtime/server/api/search.d.ts +2 -0
- package/dist/runtime/server/api/search.js +40 -0
- package/dist/runtime/server/api/site-data +1 -0
- package/dist/runtime/server/api/site-data.d.ts +2 -0
- package/dist/runtime/server/api/site-data.js +22 -0
- package/dist/runtime/server/api/sitemap +1 -0
- package/dist/runtime/server/api/sitemap.d.ts +2 -0
- package/dist/runtime/server/api/sitemap.js +11 -0
- package/dist/runtime/server/cache-adapter +1 -0
- package/dist/runtime/server/cache-adapter.d.ts +2 -0
- package/dist/runtime/server/cache-adapter.js +11 -0
- package/dist/runtime/server/cache-adapters +1 -0
- package/dist/runtime/server/cache-adapters.d.ts +9 -0
- package/dist/runtime/server/cache-adapters.js +50 -0
- package/dist/runtime/server/cache-hints +1 -0
- package/dist/runtime/server/cache-hints.d.ts +5 -0
- package/dist/runtime/server/cache-hints.js +17 -0
- package/dist/runtime/server/collection-helpers +1 -0
- package/dist/runtime/server/collection-helpers.d.ts +13 -0
- package/dist/runtime/server/collection-helpers.js +99 -0
- package/dist/runtime/server/index +1 -0
- package/dist/runtime/server/index.d.ts +9 -0
- package/dist/runtime/server/index.js +15 -0
- package/dist/runtime/server/manifest +1 -0
- package/dist/runtime/server/manifest.d.ts +1 -0
- package/dist/runtime/server/manifest.js +1 -0
- package/dist/runtime/server/navigation +1 -0
- package/dist/runtime/server/navigation-query +1 -0
- package/dist/runtime/server/navigation-query.d.ts +4 -0
- package/dist/runtime/server/navigation-query.js +80 -0
- package/dist/runtime/server/navigation.d.ts +2 -0
- package/dist/runtime/server/navigation.js +9 -0
- package/dist/runtime/server/pagefind +1 -0
- package/dist/runtime/server/pagefind.d.ts +2 -0
- package/dist/runtime/server/pagefind.js +30 -0
- package/dist/runtime/server/plugins/cache +1 -0
- package/dist/runtime/server/plugins/cache.d.ts +2 -0
- package/dist/runtime/server/plugins/cache.js +17 -0
- package/dist/runtime/server/plugins/sitemap +1 -0
- package/dist/runtime/server/plugins/sitemap.d.ts +2 -0
- package/dist/runtime/server/plugins/sitemap.js +25 -0
- package/dist/runtime/server/preview +1 -0
- package/dist/runtime/server/preview.d.ts +1 -0
- package/dist/runtime/server/preview.js +1 -0
- package/dist/runtime/server/provider-query +1 -0
- package/dist/runtime/server/provider-query.d.ts +27 -0
- package/dist/runtime/server/provider-query.js +131 -0
- package/dist/runtime/server/provider-result +1 -0
- package/dist/runtime/server/provider-result.d.ts +10 -0
- package/dist/runtime/server/provider-result.js +30 -0
- package/dist/runtime/server/providers/filesystem +1 -0
- package/dist/runtime/server/providers/filesystem.d.ts +2 -0
- package/dist/runtime/server/providers/filesystem.js +47 -0
- package/dist/runtime/server/providers/index +1 -0
- package/dist/runtime/server/providers/index.d.ts +3 -0
- package/dist/runtime/server/providers/index.js +190 -0
- package/dist/runtime/server/query-api +1 -0
- package/dist/runtime/server/query-api.d.ts +28 -0
- package/dist/runtime/server/query-api.js +54 -0
- package/dist/runtime/server/query-executor +1 -0
- package/dist/runtime/server/query-executor.d.ts +4 -0
- package/dist/runtime/server/query-executor.js +121 -0
- package/dist/runtime/server/runtime-config +1 -0
- package/dist/runtime/server/runtime-config.d.ts +1 -0
- package/dist/runtime/server/runtime-config.js +1 -0
- package/dist/runtime/server/search +1 -0
- package/dist/runtime/server/search.d.ts +18 -0
- package/dist/runtime/server/search.js +134 -0
- package/dist/runtime/server/sitemap +1 -0
- package/dist/runtime/server/sitemap-provider +1 -0
- package/dist/runtime/server/sitemap-provider.d.ts +10 -0
- package/dist/runtime/server/sitemap-provider.js +11 -0
- package/dist/runtime/server/sitemap.d.ts +6 -0
- package/dist/runtime/server/sitemap.js +45 -0
- package/dist/runtime/server/storage +1 -0
- package/dist/runtime/server/storage-access +1 -0
- package/dist/runtime/server/storage-access.d.ts +1 -0
- package/dist/runtime/server/storage-access.js +9 -0
- package/dist/runtime/server/storage.d.ts +2 -0
- package/dist/runtime/server/storage.js +2 -0
- package/dist/runtime/server/validation +1 -0
- package/dist/runtime/server/validation.d.ts +1 -0
- package/dist/runtime/server/validation.js +6 -0
- package/dist/runtime/shared/search +1 -0
- package/dist/runtime/shared/search.d.ts +2 -0
- package/dist/runtime/shared/search.js +89 -0
- package/dist/runtime/transformers/component-resolver +1 -0
- package/dist/runtime/transformers/component-resolver.d.ts +10 -0
- package/dist/runtime/transformers/component-resolver.js +30 -0
- package/dist/runtime/transformers/csv/from-csv +1 -0
- package/dist/runtime/transformers/csv/from-csv.d.ts +1 -0
- package/dist/runtime/transformers/csv/from-csv.js +1 -0
- package/dist/runtime/transformers/csv/index +1 -0
- package/dist/runtime/transformers/csv/index.d.ts +1 -0
- package/dist/runtime/transformers/csv/index.js +1 -0
- package/dist/runtime/transformers/define +1 -0
- package/dist/runtime/transformers/define.d.ts +1 -0
- package/dist/runtime/transformers/define.js +1 -0
- package/dist/runtime/transformers/index +1 -0
- package/dist/runtime/transformers/index.d.ts +1 -0
- package/dist/runtime/transformers/index.js +1 -0
- package/dist/runtime/transformers/json +1 -0
- package/dist/runtime/transformers/json.d.ts +1 -0
- package/dist/runtime/transformers/json.js +1 -0
- package/dist/runtime/transformers/markdown +1 -0
- package/dist/runtime/transformers/markdown.d.ts +1 -0
- package/dist/runtime/transformers/markdown.js +1 -0
- package/dist/runtime/transformers/path-meta +1 -0
- package/dist/runtime/transformers/path-meta.d.ts +2 -0
- package/dist/runtime/transformers/path-meta.js +2 -0
- package/dist/runtime/transformers/utils +1 -0
- package/dist/runtime/transformers/utils.d.ts +1 -0
- package/dist/runtime/transformers/utils.js +1 -0
- package/dist/runtime/transformers/yaml +1 -0
- package/dist/runtime/transformers/yaml.d.ts +1 -0
- package/dist/runtime/transformers/yaml.js +1 -0
- package/dist/runtime/utils/content-components +1 -0
- package/dist/runtime/utils/content-components.d.ts +9 -0
- package/dist/runtime/utils/content-components.js +16 -0
- package/dist/runtime/utils/query +1 -0
- package/dist/runtime/utils/query.d.ts +5 -0
- package/dist/runtime/utils/query.js +18 -0
- package/dist/runtime/virtual/transformers.d.ts +4 -0
- package/dist/runtime/virtual.d.ts +7 -0
- package/dist/storage/cache +1 -0
- package/dist/storage/cache.d.ts +32 -0
- package/dist/storage/cache.js +42 -0
- package/dist/storage/content +1 -0
- package/dist/storage/content.d.ts +41 -0
- package/dist/storage/content.js +86 -0
- package/dist/storage/contents +1 -0
- package/dist/storage/contents.d.ts +5 -0
- package/dist/storage/contents.js +116 -0
- package/dist/storage/driver +1 -0
- package/dist/storage/driver.d.ts +28 -0
- package/dist/storage/driver.js +22 -0
- package/dist/storage/graph +1 -0
- package/dist/storage/graph.d.ts +3 -0
- package/dist/storage/graph.js +14 -0
- package/dist/storage/manifest +1 -0
- package/dist/storage/manifest.d.ts +18 -0
- package/dist/storage/manifest.js +68 -0
- package/dist/storage/references +1 -0
- package/dist/storage/references.d.ts +13 -0
- package/dist/storage/references.js +78 -0
- package/dist/storage/validation +1 -0
- package/dist/storage/validation.d.ts +46 -0
- package/dist/storage/validation.js +341 -0
- package/dist/testing/provider-contract +1 -0
- package/dist/testing/provider-contract.d.ts +31 -0
- package/dist/testing/provider-contract.js +237 -0
- package/dist/testing/provider-fixture +1 -0
- package/dist/testing/provider-fixture.d.ts +65 -0
- package/dist/testing/provider-fixture.js +606 -0
- package/dist/types/api +1 -0
- package/dist/types/api.d.ts +47 -0
- package/dist/types/api.js +1 -0
- package/dist/types/config +1 -0
- package/dist/types/config.d.ts +281 -0
- package/dist/types/config.js +28 -0
- package/dist/types/content +1 -0
- package/dist/types/content.d.ts +311 -0
- package/dist/types/content.js +1 -0
- package/dist/types/fields +1 -0
- package/dist/types/fields.d.ts +81 -0
- package/dist/types/fields.js +146 -0
- package/dist/types/index +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +6 -0
- package/dist/types/module +1 -0
- package/dist/types/module.d.ts +428 -0
- package/dist/types/module.js +0 -0
- package/dist/types/picomatch.d.ts +8 -0
- package/dist/types/query +1 -0
- package/dist/types/query.d.ts +862 -0
- package/dist/types/query.js +1 -0
- package/dist/types/reference +1 -0
- package/dist/types/reference.d.ts +1 -0
- package/dist/types/reference.js +1 -0
- package/dist/types/runtime +1 -0
- package/dist/types/runtime.d.ts +45 -0
- package/dist/types/runtime.js +1 -0
- package/dist/types/search +1 -0
- package/dist/types/search.d.ts +64 -0
- package/dist/types/search.js +0 -0
- package/dist/types/virtual.d.ts +19 -0
- package/dist/types.d.mts +11 -0
- package/dist/web-types.json +466 -0
- package/package.json +135 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { pascalCase } from "scule";
|
|
2
|
+
import { withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
3
|
+
import { slugifyUrlSegment } from "./slug.js";
|
|
4
|
+
const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/;
|
|
5
|
+
const NUMERIC_PREFIX_RE = /^(\d+)\.(.+)$/;
|
|
6
|
+
export const describeId = (id) => {
|
|
7
|
+
const [_source, ...parts] = id.split(":");
|
|
8
|
+
const [, basename, _extension] = parts[parts.length - 1]?.match(/(.*)\.([^.]+)$/) || [];
|
|
9
|
+
if (basename) {
|
|
10
|
+
parts[parts.length - 1] = basename;
|
|
11
|
+
}
|
|
12
|
+
const _path = (parts || []).join("/");
|
|
13
|
+
return {
|
|
14
|
+
_source,
|
|
15
|
+
_path,
|
|
16
|
+
_extension,
|
|
17
|
+
_file: _extension ? `${_path}.${_extension}` : _path,
|
|
18
|
+
_basename: basename || ""
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const isDraftPath = (path) => /\.draft(\/|\.|$)/.test(path);
|
|
22
|
+
export const isPartialPath = (path) => path.split(/[:/]/).some((part) => /^_.*/.test(part));
|
|
23
|
+
export const normalizeContentPath = (path) => {
|
|
24
|
+
if (!path || path === "/") {
|
|
25
|
+
return "/";
|
|
26
|
+
}
|
|
27
|
+
return path.endsWith("/") ? path.slice(0, -1) || "/" : path;
|
|
28
|
+
};
|
|
29
|
+
export function refineUrlPart(name) {
|
|
30
|
+
name = name.split(/[/:]/).pop();
|
|
31
|
+
if (SEMVER_REGEX.test(name)) {
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
34
|
+
return name.replace(/(\d+\.)?(.*)/, "$2").replace(/^index(\.draft)?$/, "").replace(/\.draft$/, "");
|
|
35
|
+
}
|
|
36
|
+
export const generatePath = (path, { forceLeadingSlash = true, respectPathCase = false } = {}) => {
|
|
37
|
+
const generatedPath = path.split("/").map((part) => slugifyUrlSegment(refineUrlPart(part), { lower: !respectPathCase })).join("/");
|
|
38
|
+
return forceLeadingSlash ? withLeadingSlash(withoutTrailingSlash(generatedPath)) : generatedPath;
|
|
39
|
+
};
|
|
40
|
+
const parseSegment = (part) => {
|
|
41
|
+
const base = part.split(/[/:]/).pop() || "";
|
|
42
|
+
const refined = refineUrlPart(base);
|
|
43
|
+
const match = base.match(NUMERIC_PREFIX_RE);
|
|
44
|
+
return {
|
|
45
|
+
refined,
|
|
46
|
+
number: match?.[1]
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export const generateCanonicalKey = (parts, { translatedSlugs = false, respectPathCase = false } = {}) => {
|
|
50
|
+
const segments = parts.map(parseSegment).filter((segment) => segment.refined.length > 0);
|
|
51
|
+
if (!translatedSlugs) {
|
|
52
|
+
return generatePath(segments.map((segment) => segment.refined).join("/"), { respectPathCase }) || "/";
|
|
53
|
+
}
|
|
54
|
+
const translatedSegments = segments.map((segment) => {
|
|
55
|
+
if (segment.number) {
|
|
56
|
+
return segment.number;
|
|
57
|
+
}
|
|
58
|
+
return slugifyUrlSegment(segment.refined, { lower: !respectPathCase }) || segment.refined;
|
|
59
|
+
});
|
|
60
|
+
return translatedSegments.length ? translatedSegments.join("/") : "/";
|
|
61
|
+
};
|
|
62
|
+
export const generateTitle = (path) => path.split(/[\s-]/g).map(pascalCase).join(" ");
|
|
63
|
+
export const normalizeRouteMounts = (route, locales = [], defaultLocale) => {
|
|
64
|
+
if (!route) {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
if (typeof route === "string") {
|
|
68
|
+
const localeList = locales.length ? locales : defaultLocale ? [defaultLocale] : [];
|
|
69
|
+
if (!localeList.length) {
|
|
70
|
+
return defaultLocale ? { [defaultLocale]: normalizeContentPath(route) } : void 0;
|
|
71
|
+
}
|
|
72
|
+
return Object.fromEntries(localeList.map((locale) => [locale, normalizeContentPath(route)]));
|
|
73
|
+
}
|
|
74
|
+
const entries = Object.entries(route).filter(([, mount]) => typeof mount === "string" && mount.length > 0).map(([locale, mount]) => [locale, normalizeContentPath(mount)]);
|
|
75
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
76
|
+
};
|
|
77
|
+
export const longestMountForPath = (path, mounts) => {
|
|
78
|
+
const normalized = normalizeContentPath(path);
|
|
79
|
+
return Object.entries(mounts).filter(([, mount]) => normalized === mount || normalized.startsWith(`${mount}/`)).sort((a, b) => b[1].length - a[1].length)[0];
|
|
80
|
+
};
|
|
81
|
+
export const routeRemainder = (path, mount) => {
|
|
82
|
+
const normalizedPath = normalizeContentPath(path);
|
|
83
|
+
const normalizedMount = normalizeContentPath(mount);
|
|
84
|
+
if (normalizedPath === normalizedMount) {
|
|
85
|
+
return "/";
|
|
86
|
+
}
|
|
87
|
+
return normalizeContentPath(normalizedPath.slice(normalizedMount.length) || "/");
|
|
88
|
+
};
|
|
89
|
+
export const mountContentPath = (remainder, locale, mounts) => {
|
|
90
|
+
const mount = locale && mounts?.[locale];
|
|
91
|
+
if (!mount) {
|
|
92
|
+
return normalizeContentPath(remainder);
|
|
93
|
+
}
|
|
94
|
+
const suffix = normalizeContentPath(remainder);
|
|
95
|
+
return normalizeContentPath(suffix === "/" ? mount : `${mount}${suffix}`);
|
|
96
|
+
};
|
|
97
|
+
const isLocalePrefixedPath = (path, locales) => {
|
|
98
|
+
const segments = path.split("/").filter(Boolean);
|
|
99
|
+
return Boolean(segments[0] && locales.includes(segments[0]));
|
|
100
|
+
};
|
|
101
|
+
export const prefixPathWithLocale = (path, locale, defaultLocale) => {
|
|
102
|
+
const normalizedPath = normalizeContentPath(path || "/");
|
|
103
|
+
if (!locale || locale === defaultLocale) {
|
|
104
|
+
return normalizedPath;
|
|
105
|
+
}
|
|
106
|
+
return normalizedPath === "/" ? `/${locale}` : `/${locale}${normalizedPath}`;
|
|
107
|
+
};
|
|
108
|
+
export const stripLocalePrefix = (path, locales = [], defaultLocale, explicitLocale) => {
|
|
109
|
+
const normalized = normalizeContentPath(path);
|
|
110
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
111
|
+
const routeLocale = segments[0] && locales.includes(segments[0]) && segments[0] !== defaultLocale ? segments[0] : void 0;
|
|
112
|
+
const locale = explicitLocale && locales.includes(explicitLocale) ? explicitLocale : routeLocale || defaultLocale;
|
|
113
|
+
const routePath = routeLocale ? normalizeContentPath("/" + segments.slice(1).join("/")) : normalized;
|
|
114
|
+
return { locale, path: routePath };
|
|
115
|
+
};
|
|
116
|
+
export const routeToContentPathCandidates = (route, requestedLocale, localeChain, defaultLocale, mounts) => {
|
|
117
|
+
const locales = Array.from(new Set([...Object.keys(mounts || {}), ...localeChain, defaultLocale].filter(Boolean)));
|
|
118
|
+
const stripped = stripLocalePrefix(route, locales, defaultLocale, requestedLocale);
|
|
119
|
+
if (!mounts) {
|
|
120
|
+
return localeChain.map((locale) => ({ locale, path: stripped.path }));
|
|
121
|
+
}
|
|
122
|
+
const activeLocale = stripped.locale || requestedLocale || defaultLocale;
|
|
123
|
+
const activeMount = activeLocale ? mounts[activeLocale] : void 0;
|
|
124
|
+
const matchedMount = activeMount && (stripped.path === activeMount || stripped.path.startsWith(`${activeMount}/`)) ? activeMount : longestMountForPath(stripped.path, mounts)?.[1];
|
|
125
|
+
const remainder = matchedMount ? routeRemainder(stripped.path, matchedMount) : stripped.path;
|
|
126
|
+
return localeChain.map((locale) => ({
|
|
127
|
+
locale,
|
|
128
|
+
path: mountContentPath(remainder, locale, mounts)
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
export const projectContentPathToLocale = (path, locale, defaultLocale, mounts) => {
|
|
132
|
+
const normalizedPath = normalizeContentPath(path || "/");
|
|
133
|
+
if (normalizedPath === "/") {
|
|
134
|
+
return prefixPathWithLocale(normalizedPath, locale, defaultLocale);
|
|
135
|
+
}
|
|
136
|
+
if (!locale || !mounts) {
|
|
137
|
+
return prefixPathWithLocale(normalizedPath, locale, defaultLocale);
|
|
138
|
+
}
|
|
139
|
+
const source = longestMountForPath(normalizedPath, mounts);
|
|
140
|
+
const remainder = source ? routeRemainder(normalizedPath, source[1]) : normalizedPath;
|
|
141
|
+
return prefixPathWithLocale(mountContentPath(remainder, locale, mounts), locale, defaultLocale);
|
|
142
|
+
};
|
|
143
|
+
export const pathHasLocalePrefix = isLocalePrefixedPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './slug.js'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const transliterations = {
|
|
2
|
+
"\xC4": "Ae",
|
|
3
|
+
"\xD6": "Oe",
|
|
4
|
+
"\xDC": "Ue",
|
|
5
|
+
"\u1E9E": "SS",
|
|
6
|
+
"\xE4": "ae",
|
|
7
|
+
"\xF6": "oe",
|
|
8
|
+
"\xFC": "ue",
|
|
9
|
+
"\xDF": "ss",
|
|
10
|
+
"\xC6": "AE",
|
|
11
|
+
"\u01FC": "AE",
|
|
12
|
+
"\xE6": "ae",
|
|
13
|
+
"\u01FD": "ae",
|
|
14
|
+
"\u0152": "OE",
|
|
15
|
+
"\u0153": "oe",
|
|
16
|
+
"\xD0": "D",
|
|
17
|
+
"\xF0": "d",
|
|
18
|
+
"\u0110": "D",
|
|
19
|
+
"\u0111": "d",
|
|
20
|
+
"\u0126": "H",
|
|
21
|
+
"\u0127": "h",
|
|
22
|
+
"\u0131": "i",
|
|
23
|
+
"\u0138": "k",
|
|
24
|
+
"\u0141": "L",
|
|
25
|
+
"\u0142": "l",
|
|
26
|
+
"\u0149": "n",
|
|
27
|
+
"\u014A": "N",
|
|
28
|
+
"\u014B": "n",
|
|
29
|
+
"\xD8": "O",
|
|
30
|
+
"\xF8": "o",
|
|
31
|
+
"\xDE": "Th",
|
|
32
|
+
"\xFE": "th",
|
|
33
|
+
"\u0166": "T",
|
|
34
|
+
"\u0167": "t"
|
|
35
|
+
};
|
|
36
|
+
export function slugifyUrlSegment(value, options = {}) {
|
|
37
|
+
const lower = options.lower ?? true;
|
|
38
|
+
const source = lower ? value.toLowerCase() : value;
|
|
39
|
+
const normalized = Array.from(source, (character) => transliterations[character] ?? character).join("");
|
|
40
|
+
return normalized.replace(/&/g, " and ").replace(/\+/g, " plus ").replace(/@/g, " at ").replace(/['\u2019`´]/g, "").normalize("NFD").replace(/[\u0300-\u036F]/g, "").replace(lower ? /[^a-z0-9]+/g : /[^a-z0-9]+/gi, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sources.js'
|
package/dist/core/errors
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './errors.js'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error envelope for the content pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Every expected-failure path in `core/`, `storage/`, and `integrations/` emits
|
|
5
|
+
* a `ContentError` with one of the codes below. Boundary code (HTTP handler,
|
|
6
|
+
* CLI) maps codes to user-facing responses; tests pattern-match on `.code`.
|
|
7
|
+
*/
|
|
8
|
+
export type ContentErrorCode = 'PARSE_FAILED' | 'TRANSFORM_FAILED' | 'VALIDATION_FAILED' | 'INVALID_CONTENT' | 'DUPLICATE_CANONICAL_ID' | 'DUPLICATE_LOCALIZED_PATH' | 'CONFLICTING_REFS' | 'INVALID_REF_VALUE' | 'INVALID_NAVIGATION_YAML' | 'SCHEMA_VALIDATION_FAILED' | 'CONFLICTING_COLLECTION_MATCH' | 'TRANSLATED_SLUG_CONFLICT';
|
|
9
|
+
export declare class ContentError extends Error {
|
|
10
|
+
readonly code: ContentErrorCode;
|
|
11
|
+
readonly context: Record<string, unknown>;
|
|
12
|
+
constructor(code: ContentErrorCode, message: string, context?: Record<string, unknown>, options?: {
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree.js'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MarkdownNode, MarkdownRoot, Toc } from '../../types/content';
|
|
2
|
+
type ComarkTupleNode = string | [string | null, Record<string, unknown>, ...ComarkTupleNode[]];
|
|
3
|
+
export declare function isMarkdownRoot(value: unknown): value is MarkdownRoot;
|
|
4
|
+
export declare function toMarkdownNode(node: ComarkTupleNode): MarkdownNode;
|
|
5
|
+
export declare function toMarkdownRoot(nodes: ComarkTupleNode[], toc?: Toc): MarkdownRoot;
|
|
6
|
+
export declare function mapMarkdownNodes(nodes: MarkdownNode[], mapNode: (node: MarkdownNode) => MarkdownNode): MarkdownNode[];
|
|
7
|
+
export declare function mapMarkdownNode(node: MarkdownNode, mapNode: (node: MarkdownNode) => MarkdownNode): MarkdownNode;
|
|
8
|
+
export declare function extractMarkdownText(node: MarkdownNode, ignoredTags?: string[]): string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function isMarkdownRoot(value) {
|
|
2
|
+
return Boolean(
|
|
3
|
+
value && typeof value === "object" && value.type === "root" && Array.isArray(value.children)
|
|
4
|
+
);
|
|
5
|
+
}
|
|
6
|
+
export function toMarkdownNode(node) {
|
|
7
|
+
if (typeof node === "string") {
|
|
8
|
+
return {
|
|
9
|
+
type: "text",
|
|
10
|
+
value: node
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const [tag, props = {}, ...children] = node;
|
|
14
|
+
return {
|
|
15
|
+
type: "element",
|
|
16
|
+
tag: tag || void 0,
|
|
17
|
+
props: { ...props },
|
|
18
|
+
children: children.map((child) => toMarkdownNode(child))
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function toMarkdownRoot(nodes, toc) {
|
|
22
|
+
return {
|
|
23
|
+
type: "root",
|
|
24
|
+
children: nodes.map((node) => toMarkdownNode(node)),
|
|
25
|
+
...toc ? { toc } : {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function mapMarkdownNodes(nodes, mapNode) {
|
|
29
|
+
return nodes.map((node) => mapMarkdownNode(node, mapNode));
|
|
30
|
+
}
|
|
31
|
+
export function mapMarkdownNode(node, mapNode) {
|
|
32
|
+
const next = {
|
|
33
|
+
...node,
|
|
34
|
+
props: node.props ? { ...node.props } : void 0,
|
|
35
|
+
children: node.children?.map((child) => mapMarkdownNode(child, mapNode))
|
|
36
|
+
};
|
|
37
|
+
return mapNode(next);
|
|
38
|
+
}
|
|
39
|
+
export function extractMarkdownText(node, ignoredTags = []) {
|
|
40
|
+
if (node.type === "text") {
|
|
41
|
+
return node.value || "";
|
|
42
|
+
}
|
|
43
|
+
if (ignoredTags.includes(node.tag || "")) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
return (node.children || []).map((child) => extractMarkdownText(child, ignoredTags)).join("");
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './builder.js'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ParsedContent } from '../../types/content';
|
|
2
|
+
import type { ContentQueryBuilder, ContentQueryBuilderParams, ContentQueryFetcher } from '../../types/query';
|
|
3
|
+
interface QueryOptions {
|
|
4
|
+
initialParams?: ContentQueryBuilderParams;
|
|
5
|
+
}
|
|
6
|
+
export declare function createQuery<T = ParsedContent>(fetcher: ContentQueryFetcher<T>, opts?: QueryOptions): ContentQueryBuilder<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Wrap a query builder so every `.params()` result passes through `transform`
|
|
9
|
+
* and every chainable return value is itself wrapped. The wrapper is a Proxy —
|
|
10
|
+
* it does not mutate or patch the underlying builder, so the immutable
|
|
11
|
+
* guarantee above holds end-to-end.
|
|
12
|
+
*
|
|
13
|
+
* Adapters use this to layer transport-specific normalization (server: inject
|
|
14
|
+
* active locale from request context; app: resolve draft filter from
|
|
15
|
+
* `import.meta.dev`) without coupling the pure core builder to either transport.
|
|
16
|
+
*/
|
|
17
|
+
export declare const wrapQueryBuilder: <T = ParsedContent>(inner: ContentQueryBuilder<T>, transform: (params: ContentQueryBuilderParams) => ContentQueryBuilderParams) => ContentQueryBuilder<T>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { ensureArray } from "./operators.js";
|
|
2
|
+
const resolveQueryResult = (result) => {
|
|
3
|
+
if (!result) {
|
|
4
|
+
return result;
|
|
5
|
+
}
|
|
6
|
+
if (typeof result === "object" && "result" in result) {
|
|
7
|
+
return result.result;
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
const arrayParams = ["sort", "where", "only", "without"];
|
|
12
|
+
const buildCondition = (field, operator, value) => {
|
|
13
|
+
switch (operator) {
|
|
14
|
+
case "=":
|
|
15
|
+
return { [field]: value };
|
|
16
|
+
case "!=":
|
|
17
|
+
return { [field]: { $ne: value } };
|
|
18
|
+
case ">":
|
|
19
|
+
return { [field]: { $gt: value } };
|
|
20
|
+
case ">=":
|
|
21
|
+
return { [field]: { $gte: value } };
|
|
22
|
+
case "<":
|
|
23
|
+
return { [field]: { $lt: value } };
|
|
24
|
+
case "<=":
|
|
25
|
+
return { [field]: { $lte: value } };
|
|
26
|
+
case "IN":
|
|
27
|
+
return { [field]: { $in: value } };
|
|
28
|
+
case "NOT IN":
|
|
29
|
+
return { [field]: { $not: { $in: value } } };
|
|
30
|
+
case "CONTAINS":
|
|
31
|
+
return { [field]: { $contains: value } };
|
|
32
|
+
case "CONTAINS_ANY":
|
|
33
|
+
return { [field]: { $containsAny: value } };
|
|
34
|
+
case "REGEX":
|
|
35
|
+
return { [field]: { $regex: value } };
|
|
36
|
+
case "ICONTAINS":
|
|
37
|
+
return { [field]: { $icontains: value } };
|
|
38
|
+
case "EXISTS":
|
|
39
|
+
return { [field]: { $exists: value ?? true } };
|
|
40
|
+
case "TYPE":
|
|
41
|
+
return { [field]: { $type: value } };
|
|
42
|
+
default:
|
|
43
|
+
throw new TypeError(`Unsupported content query operator: ${operator}`);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const appendWhere = (params, condition) => {
|
|
47
|
+
const existing = Array.isArray(params.where) ? params.where : params.where ? [params.where] : [];
|
|
48
|
+
return [...existing, condition];
|
|
49
|
+
};
|
|
50
|
+
const appendSort = (params, field, direction, options = {}) => {
|
|
51
|
+
const existing = Array.isArray(params.sort) ? params.sort : params.sort ? [params.sort] : [];
|
|
52
|
+
return [
|
|
53
|
+
...existing,
|
|
54
|
+
{
|
|
55
|
+
[field]: direction === "DESC" ? -1 : 1,
|
|
56
|
+
...options.locale ? { $locale: options.locale } : {},
|
|
57
|
+
...typeof options.numeric === "boolean" ? { $numeric: options.numeric } : {},
|
|
58
|
+
...options.caseFirst ? { $caseFirst: options.caseFirst } : {},
|
|
59
|
+
...options.sensitivity ? { $sensitivity: options.sensitivity } : {}
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
};
|
|
63
|
+
const buildGroup = () => {
|
|
64
|
+
const conditions = [];
|
|
65
|
+
const pushCondition = (condition) => {
|
|
66
|
+
conditions.push(condition);
|
|
67
|
+
return group;
|
|
68
|
+
};
|
|
69
|
+
const wrap = (type, groupFactory) => {
|
|
70
|
+
const nested = buildGroup();
|
|
71
|
+
groupFactory(nested);
|
|
72
|
+
const condition = nested.toCondition(type);
|
|
73
|
+
if (condition) {
|
|
74
|
+
conditions.push(condition);
|
|
75
|
+
}
|
|
76
|
+
return group;
|
|
77
|
+
};
|
|
78
|
+
const group = {
|
|
79
|
+
where: (field, operator, value) => pushCondition(buildCondition(String(field), operator, value)),
|
|
80
|
+
andWhere: (groupFactory) => wrap("$and", groupFactory),
|
|
81
|
+
orWhere: (groupFactory) => wrap("$or", groupFactory),
|
|
82
|
+
toCondition: (type = "$and") => {
|
|
83
|
+
if (conditions.length === 0) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (conditions.length === 1) {
|
|
87
|
+
return conditions[0];
|
|
88
|
+
}
|
|
89
|
+
return { [type]: conditions };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return group;
|
|
93
|
+
};
|
|
94
|
+
export function createQuery(fetcher, opts = {}) {
|
|
95
|
+
const queryParams = {};
|
|
96
|
+
for (const key of Object.keys(opts.initialParams || {})) {
|
|
97
|
+
queryParams[key] = arrayParams.includes(key) ? ensureArray(opts.initialParams[key]) : opts.initialParams[key];
|
|
98
|
+
}
|
|
99
|
+
const next = (changes) => createQuery(fetcher, { initialParams: { ...queryParams, ...changes } });
|
|
100
|
+
const query = {
|
|
101
|
+
params: () => ({
|
|
102
|
+
...queryParams,
|
|
103
|
+
...queryParams.where ? { where: [...ensureArray(queryParams.where)] } : {},
|
|
104
|
+
...queryParams.sort ? { sort: [...ensureArray(queryParams.sort)] } : {}
|
|
105
|
+
}),
|
|
106
|
+
where: (field, operator, value) => {
|
|
107
|
+
const condition = typeof field === "object" && field ? field : buildCondition(field, operator, value);
|
|
108
|
+
return next({ where: appendWhere(queryParams, condition) });
|
|
109
|
+
},
|
|
110
|
+
andWhere: (groupFactory) => {
|
|
111
|
+
const group = buildGroup();
|
|
112
|
+
groupFactory(group);
|
|
113
|
+
const resolved = group.toCondition();
|
|
114
|
+
return resolved ? next({ where: appendWhere(queryParams, resolved) }) : query;
|
|
115
|
+
},
|
|
116
|
+
orWhere: (groupFactory) => {
|
|
117
|
+
const group = buildGroup();
|
|
118
|
+
groupFactory(group);
|
|
119
|
+
const resolved = group.toCondition("$or");
|
|
120
|
+
return resolved ? next({ where: appendWhere(queryParams, resolved) }) : query;
|
|
121
|
+
},
|
|
122
|
+
select: (...fields) => {
|
|
123
|
+
const only = Array.isArray(queryParams.only) ? queryParams.only : queryParams.only ? [queryParams.only] : [];
|
|
124
|
+
return next({ only: [...only, ...fields] });
|
|
125
|
+
},
|
|
126
|
+
order: (field, direction, options) => {
|
|
127
|
+
return next({ sort: appendSort(queryParams, field, direction, options) });
|
|
128
|
+
},
|
|
129
|
+
limit: (value) => next({ limit: parseInt(String(value), 10) }),
|
|
130
|
+
skip: (value) => next({ skip: parseInt(String(value), 10) }),
|
|
131
|
+
// Terminal methods: build a transient snapshot with the terminal flag and
|
|
132
|
+
// hand it to the fetcher. We deliberately do NOT mutate `queryParams` — so
|
|
133
|
+
// calling `.first()` on a shared base query does not leak `first: true`
|
|
134
|
+
// back into subsequent `.count()` / `.all()` calls on that same base.
|
|
135
|
+
//
|
|
136
|
+
// These are non-arrow methods so `this` binds to the call site's receiver.
|
|
137
|
+
// When a `wrapQueryBuilder` Proxy wraps this builder, the Proxy is the
|
|
138
|
+
// receiver — so `this.params()` flows through the Proxy's transform.
|
|
139
|
+
// Without this, adapter-level normalization (locale injection, draft
|
|
140
|
+
// filters) would be silently skipped at the terminal methods.
|
|
141
|
+
all() {
|
|
142
|
+
return fetcher(this).then(resolveQueryResult);
|
|
143
|
+
},
|
|
144
|
+
find() {
|
|
145
|
+
return fetcher(this).then(resolveQueryResult);
|
|
146
|
+
},
|
|
147
|
+
first() {
|
|
148
|
+
const snapshot = { params: () => ({ ...this.params(), first: true }) };
|
|
149
|
+
return fetcher(snapshot).then(resolveQueryResult);
|
|
150
|
+
},
|
|
151
|
+
count() {
|
|
152
|
+
const snapshot = { params: () => ({ ...this.params(), count: true }) };
|
|
153
|
+
return fetcher(snapshot).then(resolveQueryResult);
|
|
154
|
+
},
|
|
155
|
+
locale: (_locale, options) => {
|
|
156
|
+
const filteredWhere = queryParams.where ? ensureArray(queryParams.where).filter((item) => typeof item._locale === "undefined") : void 0;
|
|
157
|
+
return next({
|
|
158
|
+
resolveLocale: {
|
|
159
|
+
locale: _locale,
|
|
160
|
+
fallback: Array.isArray(options?.fallback) ? options?.fallback : Boolean(options?.fallback),
|
|
161
|
+
exact: !options?.fallback
|
|
162
|
+
},
|
|
163
|
+
...filteredWhere !== void 0 ? { where: filteredWhere } : {}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return query;
|
|
168
|
+
}
|
|
169
|
+
export const wrapQueryBuilder = (inner, transform) => new Proxy(inner, {
|
|
170
|
+
get(target, key, receiver) {
|
|
171
|
+
if (key === "params") {
|
|
172
|
+
return () => transform(target.params());
|
|
173
|
+
}
|
|
174
|
+
const value = Reflect.get(target, key, receiver);
|
|
175
|
+
if (typeof value !== "function") {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
return (...args) => {
|
|
179
|
+
const returned = Reflect.apply(value, receiver, args);
|
|
180
|
+
if (returned && typeof returned === "object" && "params" in returned && typeof returned.params === "function") {
|
|
181
|
+
return wrapQueryBuilder(returned, transform);
|
|
182
|
+
}
|
|
183
|
+
return returned;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './execute.js'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a `ContentQueryPlan` (see `./plan.ts`) against a content graph.
|
|
3
|
+
*
|
|
4
|
+
* Three execution modes, dispatched from `executeQueryPlan`:
|
|
5
|
+
*
|
|
6
|
+
* 1. `executeVariantPlan` — the plan requested a specific **route path**,
|
|
7
|
+
* so we resolve the variant directly from the graph's route index, then
|
|
8
|
+
* pass it through the same filter/projection/finalization path as every
|
|
9
|
+
* other query.
|
|
10
|
+
* 2. `executeLocalePlan` — the plan has a `resolveLocale` term, so we
|
|
11
|
+
* filter + sort first, then dedupe by canonical key picking the
|
|
12
|
+
* best-ranked locale per document.
|
|
13
|
+
* 3. `executeStandardPlan` — no locale semantics; filter + sort +
|
|
14
|
+
* project + slice.
|
|
15
|
+
*
|
|
16
|
+
* Operator dispatch (`compareOperators` below) maps each `CompareOperator`
|
|
17
|
+
* to a `(item, value) => boolean` comparator. Operand narrowing happens
|
|
18
|
+
* here via type aliases (`Comparable`, `Haystack`) rather than `as any`.
|
|
19
|
+
*/
|
|
20
|
+
import type { ContentQueryResponse } from '../../types/api';
|
|
21
|
+
import type { ContentGraph } from '../content/graph';
|
|
22
|
+
import type { ContentQueryPlan, FilterExpr } from './plan';
|
|
23
|
+
export declare const evaluateQueryPlanFilter: (item: Record<string, unknown>, filter: FilterExpr) => boolean;
|
|
24
|
+
export declare const applyQueryPlanProjection: <T>(items: T[], plan: ContentQueryPlan) => T[];
|
|
25
|
+
export declare const finalizeQueryPlanResponse: <T>(matched: T[], plan: ContentQueryPlan) => ContentQueryResponse<T>;
|
|
26
|
+
export declare const executeQueryPlanOnDocuments: <T>(documents: T[], plan: ContentQueryPlan) => ContentQueryResponse<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Top-level dispatcher. Picks the right execution strategy based on the
|
|
29
|
+
* plan's resolution terms, then returns a uniform `ContentQueryResponse<T>`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const executeQueryPlan: <T>(graph: ContentGraph, plan: ContentQueryPlan, options?: {
|
|
32
|
+
defaultLocale?: string;
|
|
33
|
+
localeFallback?: Record<string, string[]>;
|
|
34
|
+
collections?: Record<string, {
|
|
35
|
+
route?: string | Record<string, string>;
|
|
36
|
+
i18n?: boolean | {
|
|
37
|
+
locales?: string[];
|
|
38
|
+
defaultLocale?: string;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
}) => ContentQueryResponse<T>;
|
|
42
|
+
export declare const resolveQueryPlanVariant: (graph: ContentGraph, plan: ContentQueryPlan, options?: {
|
|
43
|
+
defaultLocale?: string;
|
|
44
|
+
localeFallback?: Record<string, string[]>;
|
|
45
|
+
collections?: Record<string, {
|
|
46
|
+
route?: string | Record<string, string>;
|
|
47
|
+
i18n?: boolean | {
|
|
48
|
+
locales?: string[];
|
|
49
|
+
defaultLocale?: string;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
}) => import("../../types/runtime").ResolvedVariant | null;
|