@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,473 @@
|
|
|
1
|
+
import { compileQueryParams } from "../../core/query/filter";
|
|
2
|
+
import { decorateLocalePathsWithFallbacks, localizePageResult } from "../../features/localization/results";
|
|
3
|
+
import { normalizeRouteMounts } from "../../features/localization/path";
|
|
4
|
+
import { normalizeReferenceValue } from "../../core/references/resolve";
|
|
5
|
+
import { collectTopLevelReferenceFields } from "../../core/references/schema";
|
|
6
|
+
import { MAX_PUBLIC_QUERY_LIMIT, MAX_PUBLIC_QUERY_SKIP } from "./public-limits.js";
|
|
7
|
+
const NAVIGATION_INTERNAL_FIELDS = [
|
|
8
|
+
"_id",
|
|
9
|
+
"_path",
|
|
10
|
+
"_file",
|
|
11
|
+
"_canonicalKey",
|
|
12
|
+
"_locale",
|
|
13
|
+
"_draft",
|
|
14
|
+
"navigation",
|
|
15
|
+
"title"
|
|
16
|
+
];
|
|
17
|
+
const LOCALIZED_DOC_INTERNAL_FIELDS = [
|
|
18
|
+
"_id",
|
|
19
|
+
"_path",
|
|
20
|
+
"_file",
|
|
21
|
+
"_canonicalKey",
|
|
22
|
+
"_locale",
|
|
23
|
+
"_resolvedLocale",
|
|
24
|
+
"_requestedLocale",
|
|
25
|
+
"_fallback",
|
|
26
|
+
"_availableLocales",
|
|
27
|
+
"_variantPaths",
|
|
28
|
+
"_requestedPath",
|
|
29
|
+
"_requestedRoute",
|
|
30
|
+
"_requestedRef",
|
|
31
|
+
"_extension"
|
|
32
|
+
];
|
|
33
|
+
export const navigationSelectFields = (fields = []) => [
|
|
34
|
+
.../* @__PURE__ */ new Set([...NAVIGATION_INTERNAL_FIELDS, ...fields])
|
|
35
|
+
];
|
|
36
|
+
const isNotFoundError = (error) => {
|
|
37
|
+
const statusCode = error?.statusCode ?? error?.response?.status;
|
|
38
|
+
return statusCode === 404;
|
|
39
|
+
};
|
|
40
|
+
const isQueryEnvelope = (response) => Boolean(response && typeof response === "object" && "result" in response);
|
|
41
|
+
const unwrapResponse = (response) => {
|
|
42
|
+
if (!response) return null;
|
|
43
|
+
if (isQueryEnvelope(response)) {
|
|
44
|
+
const result = response.result;
|
|
45
|
+
return result ?? null;
|
|
46
|
+
}
|
|
47
|
+
return response;
|
|
48
|
+
};
|
|
49
|
+
const unwrapFindResponse = (response) => {
|
|
50
|
+
if (!response) {
|
|
51
|
+
return { result: [], total: 0, skip: 0, limit: 0, hasTotal: false };
|
|
52
|
+
}
|
|
53
|
+
if (isQueryEnvelope(response)) {
|
|
54
|
+
const result2 = Array.isArray(response.result) ? response.result : response.result ? [response.result] : [];
|
|
55
|
+
const hasTotal = typeof response.total === "number";
|
|
56
|
+
return {
|
|
57
|
+
result: result2,
|
|
58
|
+
total: hasTotal ? response.total : result2.length,
|
|
59
|
+
skip: typeof response.skip === "number" ? response.skip : 0,
|
|
60
|
+
limit: typeof response.limit === "number" ? response.limit : result2.length,
|
|
61
|
+
hasTotal
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const result = Array.isArray(response) ? response : [response];
|
|
65
|
+
return { result, total: result.length, skip: 0, limit: result.length, hasTotal: false };
|
|
66
|
+
};
|
|
67
|
+
const unwrapCountResponse = (response) => {
|
|
68
|
+
if (typeof response === "number") {
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
71
|
+
if (isQueryEnvelope(response) && typeof response.result === "number") {
|
|
72
|
+
return response.result;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
const decorate = (doc, collection, runtime, requestedLocale) => {
|
|
77
|
+
if (!doc) return null;
|
|
78
|
+
const collectionI18n = runtime?.collections?.[collection]?.i18n;
|
|
79
|
+
const collectionLocales = collectionI18n && typeof collectionI18n === "object" ? collectionI18n.locales : void 0;
|
|
80
|
+
const collectionDefault = collectionI18n && typeof collectionI18n === "object" ? collectionI18n.defaultLocale : void 0;
|
|
81
|
+
const locales = collectionLocales?.length ? collectionLocales : runtime?.locales?.length ? runtime.locales : [];
|
|
82
|
+
const defaultLocale = collectionDefault || runtime?.defaultLocale;
|
|
83
|
+
const routeMounts = normalizeRouteMounts(runtime?.collections?.[collection]?.route, locales, defaultLocale);
|
|
84
|
+
const hasLocaleConfig = Boolean(locales.length || defaultLocale);
|
|
85
|
+
const page = hasLocaleConfig ? doc : {
|
|
86
|
+
...doc,
|
|
87
|
+
_locale: "",
|
|
88
|
+
_resolvedLocale: void 0,
|
|
89
|
+
_requestedLocale: void 0,
|
|
90
|
+
_variantPaths: void 0,
|
|
91
|
+
_availableLocales: []
|
|
92
|
+
};
|
|
93
|
+
const result = localizePageResult(page, hasLocaleConfig ? requestedLocale : void 0, defaultLocale, locales, routeMounts);
|
|
94
|
+
const fallbackLocale = doc._resolvedLocale || requestedLocale || defaultLocale;
|
|
95
|
+
result.localePaths = decorateLocalePathsWithFallbacks(result.localePaths, locales, fallbackLocale, defaultLocale, routeMounts);
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
98
|
+
const collectionDefaultLocale = (collection, runtime) => {
|
|
99
|
+
const collectionI18n = runtime?.collections?.[collection]?.i18n;
|
|
100
|
+
const collectionDefault = collectionI18n && typeof collectionI18n === "object" ? collectionI18n.defaultLocale : void 0;
|
|
101
|
+
return collectionDefault || runtime?.defaultLocale;
|
|
102
|
+
};
|
|
103
|
+
const resolveFallback = (fallback, collection, runtime) => {
|
|
104
|
+
if (fallback !== "default") return fallback;
|
|
105
|
+
return collectionDefaultLocale(collection, runtime);
|
|
106
|
+
};
|
|
107
|
+
const explainResolution = (collection, requestedBy, normalizedBy, requestedLocale, requestedFallback, doc) => {
|
|
108
|
+
const resolvedLocale = doc?.resolved?.locale || doc?.locale;
|
|
109
|
+
return {
|
|
110
|
+
requested: {
|
|
111
|
+
collection,
|
|
112
|
+
by: requestedBy,
|
|
113
|
+
...requestedLocale ? { locale: requestedLocale } : {},
|
|
114
|
+
...requestedFallback !== void 0 ? { fallback: requestedFallback } : {}
|
|
115
|
+
},
|
|
116
|
+
normalized: {
|
|
117
|
+
by: normalizedBy
|
|
118
|
+
},
|
|
119
|
+
matched: {
|
|
120
|
+
found: Boolean(doc),
|
|
121
|
+
collection,
|
|
122
|
+
...doc?.path ? { path: doc.path } : {},
|
|
123
|
+
...doc?.canonicalPath ? { canonicalPath: doc.canonicalPath } : {},
|
|
124
|
+
...doc?.ref ? { ref: doc.ref } : {},
|
|
125
|
+
...resolvedLocale ? { locale: resolvedLocale } : {}
|
|
126
|
+
},
|
|
127
|
+
fallback: {
|
|
128
|
+
used: Boolean(requestedLocale && resolvedLocale && requestedLocale !== resolvedLocale),
|
|
129
|
+
...requestedLocale && resolvedLocale && requestedLocale !== resolvedLocale ? { locale: resolvedLocale } : {}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const ensureCollectionName = (handle) => {
|
|
134
|
+
if (typeof handle === "string") return handle;
|
|
135
|
+
if (!handle || typeof handle !== "object" || typeof handle.name !== "string") {
|
|
136
|
+
throw new TypeError("query API: expected a collection handle from defineCollection(name, config) or a string collection name");
|
|
137
|
+
}
|
|
138
|
+
return handle.name;
|
|
139
|
+
};
|
|
140
|
+
const isRecord = (value) => {
|
|
141
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
142
|
+
};
|
|
143
|
+
const populateReferenceValue = async (context, target, value, locale, fallback) => {
|
|
144
|
+
if (typeof value !== "string" || !value) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return one(context, target, {
|
|
148
|
+
by: { ref: value },
|
|
149
|
+
...locale ? { locale } : {},
|
|
150
|
+
...fallback !== void 0 ? { fallback } : {}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const populateDocument = async (context, doc, populate, locale, fallback) => {
|
|
154
|
+
if (!populate || !isRecord(populate)) {
|
|
155
|
+
return doc;
|
|
156
|
+
}
|
|
157
|
+
const populated = { ...doc };
|
|
158
|
+
await Promise.all(Object.entries(populate).map(async ([field, target]) => {
|
|
159
|
+
const value = doc[field];
|
|
160
|
+
if (Array.isArray(value)) {
|
|
161
|
+
const resolved = await Promise.all(value.map((item) => populateReferenceValue(context, target, item, locale, fallback)));
|
|
162
|
+
populated[field] = resolved.filter(Boolean);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
populated[field] = await populateReferenceValue(context, target, value, locale, fallback);
|
|
166
|
+
}));
|
|
167
|
+
return populated;
|
|
168
|
+
};
|
|
169
|
+
const selectWithPopulate = (select, populate) => {
|
|
170
|
+
if (!select) {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
return [.../* @__PURE__ */ new Set([
|
|
174
|
+
...select,
|
|
175
|
+
...LOCALIZED_DOC_INTERNAL_FIELDS,
|
|
176
|
+
...populate && isRecord(populate) ? Object.keys(populate) : []
|
|
177
|
+
])];
|
|
178
|
+
};
|
|
179
|
+
export async function resolveOne(context, handle, options) {
|
|
180
|
+
const collection = ensureCollectionName(handle);
|
|
181
|
+
const runtime = context.runtime;
|
|
182
|
+
const by = options.by;
|
|
183
|
+
const fallback = resolveFallback(options.fallback, collection, runtime);
|
|
184
|
+
const params = compileQueryParams({
|
|
185
|
+
collection,
|
|
186
|
+
by,
|
|
187
|
+
locale: options.locale,
|
|
188
|
+
fallback,
|
|
189
|
+
select: selectWithPopulate(options.select, options.populate)
|
|
190
|
+
});
|
|
191
|
+
params.first = true;
|
|
192
|
+
let response;
|
|
193
|
+
try {
|
|
194
|
+
response = await context.transport("query", params);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (isNotFoundError(error)) {
|
|
197
|
+
const explain2 = explainResolution(collection, options.by, by, options.locale, options.fallback, null);
|
|
198
|
+
return { doc: null, explain: explain2 };
|
|
199
|
+
}
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
const unwrapped = unwrapResponse(response);
|
|
203
|
+
const doc = Array.isArray(unwrapped) ? unwrapped[0] ?? null : unwrapped ?? null;
|
|
204
|
+
const decorated = decorate(doc, collection, runtime, options.locale);
|
|
205
|
+
const populated = decorated ? await populateDocument(context, decorated, options.populate, options.locale, options.fallback) : null;
|
|
206
|
+
const explain = explainResolution(collection, options.by, by, options.locale, options.fallback, decorated);
|
|
207
|
+
return {
|
|
208
|
+
doc: populated,
|
|
209
|
+
explain
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export async function one(context, handle, options) {
|
|
213
|
+
const result = await resolveOne(context, handle, options);
|
|
214
|
+
return result.doc;
|
|
215
|
+
}
|
|
216
|
+
export async function many(context, handle, options = {}) {
|
|
217
|
+
const collection = ensureCollectionName(handle);
|
|
218
|
+
const runtime = context.runtime;
|
|
219
|
+
const fallback = resolveFallback(options.fallback, collection, runtime);
|
|
220
|
+
const params = compileQueryParams({
|
|
221
|
+
collection,
|
|
222
|
+
where: options.where,
|
|
223
|
+
sort: options.sort,
|
|
224
|
+
limit: options.limit,
|
|
225
|
+
skip: options.skip,
|
|
226
|
+
locale: options.locale,
|
|
227
|
+
fallback,
|
|
228
|
+
select: selectWithPopulate(options.select, options.populate)
|
|
229
|
+
});
|
|
230
|
+
let response;
|
|
231
|
+
try {
|
|
232
|
+
response = await context.transport("query", params);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (isNotFoundError(error)) return [];
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
const unwrapped = unwrapResponse(response);
|
|
238
|
+
const list = Array.isArray(unwrapped) ? unwrapped : unwrapped ? [unwrapped] : [];
|
|
239
|
+
const decorated = list.map((doc) => decorate(doc, collection, runtime, options.locale)).filter((doc) => Boolean(doc));
|
|
240
|
+
const populated = await Promise.all(decorated.map((doc) => populateDocument(context, doc, options.populate, options.locale, options.fallback)));
|
|
241
|
+
return populated;
|
|
242
|
+
}
|
|
243
|
+
const normalizePositiveInteger = (value, fallback) => {
|
|
244
|
+
const number = typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : fallback;
|
|
245
|
+
return Math.max(1, number);
|
|
246
|
+
};
|
|
247
|
+
export async function paginate(context, handle, options) {
|
|
248
|
+
const collection = ensureCollectionName(handle);
|
|
249
|
+
const runtime = context.runtime;
|
|
250
|
+
const requestedPage = normalizePositiveInteger(options.page, 1);
|
|
251
|
+
const limit = Math.min(normalizePositiveInteger(options.limit, 10), MAX_PUBLIC_QUERY_LIMIT);
|
|
252
|
+
const skip = Math.min((requestedPage - 1) * limit, MAX_PUBLIC_QUERY_SKIP);
|
|
253
|
+
const page = Math.floor(skip / limit) + 1;
|
|
254
|
+
const fallback = resolveFallback(options.fallback, collection, runtime);
|
|
255
|
+
const params = compileQueryParams({
|
|
256
|
+
collection,
|
|
257
|
+
where: options.where,
|
|
258
|
+
sort: options.sort,
|
|
259
|
+
limit,
|
|
260
|
+
skip,
|
|
261
|
+
locale: options.locale,
|
|
262
|
+
fallback,
|
|
263
|
+
select: selectWithPopulate(options.select, options.populate)
|
|
264
|
+
});
|
|
265
|
+
const countParams = compileQueryParams({
|
|
266
|
+
collection,
|
|
267
|
+
where: options.where,
|
|
268
|
+
locale: options.locale,
|
|
269
|
+
fallback
|
|
270
|
+
});
|
|
271
|
+
countParams.count = true;
|
|
272
|
+
let response;
|
|
273
|
+
try {
|
|
274
|
+
response = await context.transport("query", params);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (isNotFoundError(error)) {
|
|
277
|
+
return {
|
|
278
|
+
data: [],
|
|
279
|
+
page,
|
|
280
|
+
limit,
|
|
281
|
+
total: 0,
|
|
282
|
+
pageCount: 0,
|
|
283
|
+
hasNext: false,
|
|
284
|
+
hasPrev: page > 1,
|
|
285
|
+
nextPage: null,
|
|
286
|
+
prevPage: page > 1 ? page - 1 : null
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
const envelope = unwrapFindResponse(response);
|
|
292
|
+
let total = envelope.total;
|
|
293
|
+
if (!envelope.hasTotal) {
|
|
294
|
+
const countResponse = await context.transport("query", countParams);
|
|
295
|
+
total = unwrapCountResponse(countResponse) ?? envelope.total;
|
|
296
|
+
}
|
|
297
|
+
const decorated = envelope.result.map((doc) => decorate(doc, collection, runtime, options.locale)).filter((doc) => Boolean(doc));
|
|
298
|
+
const populated = await Promise.all(decorated.map((doc) => populateDocument(context, doc, options.populate, options.locale, options.fallback)));
|
|
299
|
+
const pageCount = total > 0 ? Math.ceil(total / limit) : 0;
|
|
300
|
+
return {
|
|
301
|
+
data: populated,
|
|
302
|
+
page,
|
|
303
|
+
limit,
|
|
304
|
+
total,
|
|
305
|
+
pageCount,
|
|
306
|
+
hasNext: page < pageCount,
|
|
307
|
+
hasPrev: page > 1,
|
|
308
|
+
nextPage: page < pageCount ? page + 1 : null,
|
|
309
|
+
prevPage: page > 1 ? page - 1 : null
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const backlinkSources = (value) => Array.isArray(value) ? [...value] : [value];
|
|
313
|
+
const isBacklinkFieldMap = (value) => {
|
|
314
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
315
|
+
};
|
|
316
|
+
const resolveExplicitBacklinkFields = (fields, sourceName) => {
|
|
317
|
+
if (Array.isArray(fields)) {
|
|
318
|
+
return fields.filter((field) => typeof field === "string" && field.length > 0);
|
|
319
|
+
}
|
|
320
|
+
if (!isBacklinkFieldMap(fields)) {
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
const sourceFields = fields?.[sourceName];
|
|
324
|
+
return Array.isArray(sourceFields) ? sourceFields.filter((field) => typeof field === "string" && field.length > 0) : [];
|
|
325
|
+
};
|
|
326
|
+
const inferBacklinkFields = (source, targetCollection) => {
|
|
327
|
+
if (typeof source === "string") {
|
|
328
|
+
return [];
|
|
329
|
+
}
|
|
330
|
+
return collectTopLevelReferenceFields(source.schema, targetCollection);
|
|
331
|
+
};
|
|
332
|
+
const targetReferenceCandidates = (doc) => {
|
|
333
|
+
const values = [
|
|
334
|
+
doc.ref,
|
|
335
|
+
doc.id,
|
|
336
|
+
doc._canonicalKey,
|
|
337
|
+
doc._path,
|
|
338
|
+
doc._path ? doc.path : void 0,
|
|
339
|
+
doc._path ? doc.canonicalPath : void 0
|
|
340
|
+
].filter((value) => typeof value === "string" && value.length > 0).flatMap((value) => [value, normalizeReferenceValue(value)]).filter(Boolean);
|
|
341
|
+
return Array.from(new Set(values));
|
|
342
|
+
};
|
|
343
|
+
const backlinkWhere = (fields, candidates) => {
|
|
344
|
+
const clauses = fields.map((field) => ({
|
|
345
|
+
[field]: { $in: candidates }
|
|
346
|
+
}));
|
|
347
|
+
return clauses.length ? { $or: clauses } : void 0;
|
|
348
|
+
};
|
|
349
|
+
export async function backlinks(context, targetHandle, options) {
|
|
350
|
+
const targetCollection = ensureCollectionName(targetHandle);
|
|
351
|
+
const target = await one(context, targetHandle, {
|
|
352
|
+
by: options.by,
|
|
353
|
+
...options.locale ? { locale: options.locale } : {},
|
|
354
|
+
...options.fallback !== void 0 ? { fallback: options.fallback } : {}
|
|
355
|
+
});
|
|
356
|
+
if (!target) {
|
|
357
|
+
return [];
|
|
358
|
+
}
|
|
359
|
+
const candidates = targetReferenceCandidates(target);
|
|
360
|
+
if (!candidates.length) {
|
|
361
|
+
return [];
|
|
362
|
+
}
|
|
363
|
+
const sources = backlinkSources(options.from);
|
|
364
|
+
const results = await Promise.all(sources.map(async (source) => {
|
|
365
|
+
const sourceName = ensureCollectionName(source);
|
|
366
|
+
const fields = [
|
|
367
|
+
.../* @__PURE__ */ new Set([
|
|
368
|
+
...resolveExplicitBacklinkFields(options.fields, sourceName),
|
|
369
|
+
...inferBacklinkFields(source, targetCollection)
|
|
370
|
+
])
|
|
371
|
+
];
|
|
372
|
+
const where = backlinkWhere(fields, candidates);
|
|
373
|
+
if (!where) {
|
|
374
|
+
return [];
|
|
375
|
+
}
|
|
376
|
+
return await many(context, source, {
|
|
377
|
+
where,
|
|
378
|
+
sort: options.sort,
|
|
379
|
+
limit: options.limit,
|
|
380
|
+
skip: options.skip,
|
|
381
|
+
...options.locale ? { locale: options.locale } : {},
|
|
382
|
+
...options.fallback !== void 0 ? { fallback: options.fallback } : {},
|
|
383
|
+
select: options.select,
|
|
384
|
+
populate: options.populate
|
|
385
|
+
});
|
|
386
|
+
}));
|
|
387
|
+
return results.flat();
|
|
388
|
+
}
|
|
389
|
+
export async function variants(context, handle, options) {
|
|
390
|
+
const collection = ensureCollectionName(handle);
|
|
391
|
+
const runtime = context.runtime;
|
|
392
|
+
const collectionI18n = runtime?.collections?.[collection]?.i18n;
|
|
393
|
+
const collectionLocales = collectionI18n && typeof collectionI18n === "object" ? collectionI18n.locales : void 0;
|
|
394
|
+
const collectionDefault = collectionI18n && typeof collectionI18n === "object" ? collectionI18n.defaultLocale : void 0;
|
|
395
|
+
const locales = collectionLocales?.length ? collectionLocales : runtime?.locales || [];
|
|
396
|
+
const defaultLocale = collectionDefault || runtime?.defaultLocale;
|
|
397
|
+
const requestedLocales = options.locales?.length ? options.locales : locales;
|
|
398
|
+
if (!requestedLocales.length) {
|
|
399
|
+
return [];
|
|
400
|
+
}
|
|
401
|
+
const seed = await one(context, handle, {
|
|
402
|
+
by: options.by,
|
|
403
|
+
locale: options.locale || defaultLocale,
|
|
404
|
+
fallback: true
|
|
405
|
+
});
|
|
406
|
+
if (!seed) return [];
|
|
407
|
+
const variantPaths = seed._variantPaths || {};
|
|
408
|
+
const sourceLocale = seed.locale || defaultLocale || "";
|
|
409
|
+
return requestedLocales.map((locale) => {
|
|
410
|
+
const variantPath = variantPaths[locale];
|
|
411
|
+
if (variantPath) {
|
|
412
|
+
return {
|
|
413
|
+
locale,
|
|
414
|
+
path: seed.localePaths?.[locale]?.path || variantPath,
|
|
415
|
+
translated: true
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
locale,
|
|
420
|
+
path: seed.path,
|
|
421
|
+
translated: false,
|
|
422
|
+
fallback: sourceLocale
|
|
423
|
+
};
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
export async function tree(context, handle, options = {}) {
|
|
427
|
+
const collection = ensureCollectionName(handle);
|
|
428
|
+
const runtime = context.runtime;
|
|
429
|
+
const fallback = resolveFallback(options.fallback, collection, runtime);
|
|
430
|
+
const params = compileQueryParams({
|
|
431
|
+
collection,
|
|
432
|
+
where: options.where,
|
|
433
|
+
sort: options.sort,
|
|
434
|
+
locale: options.locale,
|
|
435
|
+
fallback,
|
|
436
|
+
select: navigationSelectFields(options.fields),
|
|
437
|
+
exact: options.fallback === void 0 ? false : void 0
|
|
438
|
+
});
|
|
439
|
+
const response = await context.transport("navigation", params);
|
|
440
|
+
const list = Array.isArray(response) ? response : Array.isArray(response?.result) ? response.result : [];
|
|
441
|
+
return list;
|
|
442
|
+
}
|
|
443
|
+
export async function neighbors(context, handle, options) {
|
|
444
|
+
const seed = await one(context, handle, {
|
|
445
|
+
by: options.by,
|
|
446
|
+
locale: options.locale,
|
|
447
|
+
fallback: options.fallback ?? true
|
|
448
|
+
});
|
|
449
|
+
if (!seed) return { prev: null, next: null };
|
|
450
|
+
const fullTree = await tree(context, handle, {
|
|
451
|
+
locale: options.locale,
|
|
452
|
+
fallback: options.fallback,
|
|
453
|
+
fields: options.fields
|
|
454
|
+
});
|
|
455
|
+
const flat = [];
|
|
456
|
+
const walk = (nodes) => {
|
|
457
|
+
for (const node of nodes) {
|
|
458
|
+
const n = node;
|
|
459
|
+
if (n.path || n._path) {
|
|
460
|
+
flat.push({ path: n.path || n._path || "", item: node });
|
|
461
|
+
}
|
|
462
|
+
if (Array.isArray(n.children)) walk(n.children);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
walk(fullTree);
|
|
466
|
+
const targetPath = seed.path;
|
|
467
|
+
const idx = flat.findIndex((entry) => entry.path === targetPath);
|
|
468
|
+
if (idx === -1) return { prev: null, next: null };
|
|
469
|
+
return {
|
|
470
|
+
prev: flat[idx - 1]?.item ?? null,
|
|
471
|
+
next: flat[idx + 1]?.item ?? null
|
|
472
|
+
};
|
|
473
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cache.js'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NavItem } from '../../../types/content';
|
|
2
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
|
+
contents: unknown[];
|
|
4
|
+
navigation: NavItem[];
|
|
5
|
+
generatedAt: number;
|
|
6
|
+
generateTime: number;
|
|
7
|
+
}>>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { getContentProvider } from "../providers/index.js";
|
|
3
|
+
import { createContentProviderError } from "../../../public/provider-errors";
|
|
4
|
+
import { cacheStorage } from "../storage-access.js";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const now = Date.now();
|
|
7
|
+
const contents = [];
|
|
8
|
+
const provider = await getContentProvider(event);
|
|
9
|
+
if (!provider.navigationQuery) {
|
|
10
|
+
throw createContentProviderError("unsupported_provider_operation", `${provider.name} does not support navigation queries`, {
|
|
11
|
+
provider: provider.name
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const navigation = await provider.navigationQuery(event, {});
|
|
15
|
+
await cacheStorage(event).setItem("_nav.json", navigation);
|
|
16
|
+
const meta = {
|
|
17
|
+
generatedAt: now,
|
|
18
|
+
generateTime: Date.now() - now
|
|
19
|
+
};
|
|
20
|
+
await cacheStorage(event).setItem("_meta.json", meta);
|
|
21
|
+
return {
|
|
22
|
+
...meta,
|
|
23
|
+
contents,
|
|
24
|
+
navigation
|
|
25
|
+
};
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './locales.js'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getQuery } from "h3";
|
|
2
|
+
import { resolveProviderContentVariants } from "../provider-query.js";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const identity = typeof getQuery(event).identity === "string" ? getQuery(event).identity : "";
|
|
5
|
+
const collection = event.context.params?.collection;
|
|
6
|
+
if (!collection || !identity) {
|
|
7
|
+
throw createError({
|
|
8
|
+
statusCode: 400,
|
|
9
|
+
statusMessage: "Missing collection or identity"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const resolved = await resolveProviderContentVariants(event, identity, {
|
|
13
|
+
collection,
|
|
14
|
+
exact: false
|
|
15
|
+
});
|
|
16
|
+
const locales = resolved ? resolved.variants.filter((doc) => doc._canonicalKey === resolved.canonicalKey && typeof doc._locale === "string").sort((left, right) => String(left._locale).localeCompare(String(right._locale))).map((doc) => ({
|
|
17
|
+
canonicalKey: resolved.canonicalKey,
|
|
18
|
+
locale: String(doc._locale),
|
|
19
|
+
...typeof doc._path === "string" ? { path: doc._path } : {}
|
|
20
|
+
})) : [];
|
|
21
|
+
if (!locales.length) {
|
|
22
|
+
throw createError({
|
|
23
|
+
statusCode: 404,
|
|
24
|
+
statusMessage: "Locale variants not found"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return locales;
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigation.js'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "h3";
|
|
2
|
+
import { getContentQuery } from "../../utils/query.js";
|
|
3
|
+
import { getContentProvider } from "../providers/index.js";
|
|
4
|
+
import { createContentProviderError } from "../../../public/provider-errors";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const query = getContentQuery(event);
|
|
7
|
+
const params = getQuery(event);
|
|
8
|
+
if (typeof params.collection === "string" && !query.collection) {
|
|
9
|
+
query.collection = params.collection;
|
|
10
|
+
}
|
|
11
|
+
if (typeof params.locale === "string" && !query.resolveLocale) {
|
|
12
|
+
query.resolveLocale = { locale: params.locale };
|
|
13
|
+
}
|
|
14
|
+
const provider = await getContentProvider(event);
|
|
15
|
+
if (!provider.navigationQuery) {
|
|
16
|
+
throw createContentProviderError("unsupported_provider_operation", `${provider.name} does not support navigation queries`, {
|
|
17
|
+
provider: provider.name
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return await provider.navigationQuery(event, query);
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query.js'
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<import("..").MaybeContentProviderResult<number | import("../../../types").ParsedContent | import("../../../types").ParsedContent[] | import("../../../types/api").ContentQueryResponse<import("../../../types").ParsedContent> | undefined>>>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { getContentQuery } from "../../utils/query.js";
|
|
3
|
+
import { getContentProvider } from "../providers/index.js";
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
return await (await getContentProvider(event)).query(event, getContentQuery(event));
|
|
6
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './revalidate.js'
|