@lupinum/ginko-content 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +18 -4
  2. package/compatibility.json +1 -1
  3. package/dist/cli.mjs +317 -294
  4. package/dist/cms-import/index.js +5 -1
  5. package/dist/config.d.mts +1 -1
  6. package/dist/config.mjs +1 -1
  7. package/dist/core/cache-hints.d.ts +9 -1
  8. package/dist/core/content/collection.js +1 -1
  9. package/dist/core/content/path.js +1 -1
  10. package/dist/core/errors.js +5 -1
  11. package/dist/core/provider-errors +1 -0
  12. package/dist/core/provider-errors.d.ts +10 -0
  13. package/dist/core/provider-errors.js +27 -0
  14. package/dist/core/query/execute.js +12 -3
  15. package/dist/core/query/filter.js +2 -2
  16. package/dist/core/query/lower.js +5 -4
  17. package/dist/features/navigation/build.js +14 -6
  18. package/dist/features/navigation/canonical.js +1 -1
  19. package/dist/features/sitemap/query.js +2 -2
  20. package/dist/integrations/nitro/ingest.d.ts +3 -3
  21. package/dist/integrations/nitro/ingest.js +3 -3
  22. package/dist/integrations/nitro/storage.js +3 -1
  23. package/dist/module.d.mts +151 -526
  24. package/dist/module.json +1 -1
  25. package/dist/module.mjs +1083 -730
  26. package/dist/parsers/csv.js +4 -3
  27. package/dist/parsers/index.d.ts +2 -5
  28. package/dist/parsers/index.js +2 -2
  29. package/dist/parsers/markdown-plugins.d.ts +1 -0
  30. package/dist/parsers/markdown-plugins.js +83 -1
  31. package/dist/parsers/markdown.js +1 -1
  32. package/dist/public/client.d.ts +3 -2
  33. package/dist/public/client.js +2 -2
  34. package/dist/public/provider-errors.d.ts +2 -1
  35. package/dist/public/provider-errors.js +1 -18
  36. package/dist/public/provider.d.ts +3 -10
  37. package/dist/public/server.d.ts +6 -1
  38. package/dist/public/server.js +33 -0
  39. package/dist/runtime/agent-paths +1 -0
  40. package/dist/runtime/agent-paths.d.ts +6 -0
  41. package/dist/runtime/agent-paths.js +41 -0
  42. package/dist/runtime/app/components/internal/MarkdownRenderer.d.ts +1 -1
  43. package/dist/runtime/app/composables/head.d.ts +3 -0
  44. package/dist/runtime/app/composables/head.js +2 -1
  45. package/dist/runtime/app/composables/hot-reload +1 -0
  46. package/dist/runtime/app/composables/hot-reload.d.ts +5 -0
  47. package/dist/runtime/app/composables/hot-reload.js +15 -0
  48. package/dist/runtime/app/composables/locale-context.d.ts +1 -1
  49. package/dist/runtime/app/composables/locale-context.js +2 -1
  50. package/dist/runtime/app/composables/locale.js +2 -2
  51. package/dist/runtime/app/composables/search.js +10 -6
  52. package/dist/runtime/app/composables/use-content-document +1 -0
  53. package/dist/runtime/app/composables/use-content-document.d.ts +29 -0
  54. package/dist/runtime/app/composables/use-content-document.js +44 -0
  55. package/dist/runtime/app/composables/use-content-list +1 -0
  56. package/dist/runtime/app/composables/use-content-list.d.ts +43 -0
  57. package/dist/runtime/app/composables/use-content-list.js +98 -0
  58. package/dist/runtime/app/composables/use-content-navigation +1 -0
  59. package/dist/runtime/app/composables/use-content-navigation.d.ts +40 -0
  60. package/dist/runtime/app/composables/use-content-navigation.js +102 -0
  61. package/dist/runtime/app/composables/use-content-page +1 -0
  62. package/dist/runtime/app/composables/use-content-page.d.ts +47 -0
  63. package/dist/runtime/app/composables/use-content-page.js +142 -0
  64. package/dist/runtime/app/composables/use-content-shared +1 -0
  65. package/dist/runtime/app/composables/use-content-shared.d.ts +13 -0
  66. package/dist/runtime/app/composables/use-content-shared.js +29 -0
  67. package/dist/runtime/app/composables/use-content.d.ts +11 -206
  68. package/dist/runtime/app/composables/use-content.js +4 -377
  69. package/dist/runtime/app/plugins/hot-reload +1 -0
  70. package/dist/runtime/app/plugins/hot-reload.js +6 -0
  71. package/dist/runtime/query/backlinks +1 -0
  72. package/dist/runtime/query/backlinks.d.ts +8 -0
  73. package/dist/runtime/query/backlinks.js +90 -0
  74. package/dist/runtime/query/context +1 -0
  75. package/dist/runtime/query/context.d.ts +20 -0
  76. package/dist/runtime/query/context.js +0 -0
  77. package/dist/runtime/query/documents +1 -0
  78. package/dist/runtime/query/documents.d.ts +6 -0
  79. package/dist/runtime/query/documents.js +98 -0
  80. package/dist/runtime/query/errors +1 -0
  81. package/dist/runtime/query/errors.d.ts +1 -0
  82. package/dist/runtime/query/errors.js +4 -0
  83. package/dist/runtime/query/handles +1 -0
  84. package/dist/runtime/query/handles.d.ts +2 -0
  85. package/dist/runtime/query/handles.js +7 -0
  86. package/dist/runtime/query/locale-options +1 -0
  87. package/dist/runtime/query/locale-options.d.ts +5 -0
  88. package/dist/runtime/query/locale-options.js +14 -0
  89. package/dist/runtime/query/localized-docs +1 -0
  90. package/dist/runtime/query/localized-docs.d.ts +17 -0
  91. package/dist/runtime/query/localized-docs.js +44 -0
  92. package/dist/runtime/query/navigation +1 -0
  93. package/dist/runtime/query/navigation.d.ts +22 -0
  94. package/dist/runtime/query/navigation.js +73 -0
  95. package/dist/runtime/query/pagination +1 -0
  96. package/dist/runtime/query/pagination.d.ts +7 -0
  97. package/dist/runtime/query/pagination.js +78 -0
  98. package/dist/runtime/query/populate +1 -0
  99. package/dist/runtime/query/populate.d.ts +9 -0
  100. package/dist/runtime/query/populate.js +106 -0
  101. package/dist/runtime/query/responses +1 -0
  102. package/dist/runtime/query/responses.d.ts +10 -0
  103. package/dist/runtime/query/responses.js +47 -0
  104. package/dist/runtime/query/unified.d.ts +4 -20
  105. package/dist/runtime/query/unified.js +14 -544
  106. package/dist/runtime/query/variants +1 -0
  107. package/dist/runtime/query/variants.d.ts +11 -0
  108. package/dist/runtime/query/variants.js +36 -0
  109. package/dist/runtime/server/agent-http +1 -0
  110. package/dist/runtime/server/agent-http.d.ts +7 -0
  111. package/dist/runtime/server/agent-http.js +36 -0
  112. package/dist/runtime/server/agent-markdown +1 -0
  113. package/dist/runtime/server/agent-markdown.d.ts +83 -0
  114. package/dist/runtime/server/agent-markdown.js +449 -0
  115. package/dist/runtime/server/agent-site +1 -0
  116. package/dist/runtime/server/agent-site.d.ts +38 -0
  117. package/dist/runtime/server/agent-site.js +272 -0
  118. package/dist/runtime/server/api/agent-llms +1 -0
  119. package/dist/runtime/server/api/agent-llms-full +1 -0
  120. package/dist/runtime/server/api/agent-llms-full.d.ts +2 -0
  121. package/dist/runtime/server/api/agent-llms-full.js +13 -0
  122. package/dist/runtime/server/api/agent-llms.d.ts +2 -0
  123. package/dist/runtime/server/api/agent-llms.js +14 -0
  124. package/dist/runtime/server/api/agent-raw +1 -0
  125. package/dist/runtime/server/api/agent-raw.d.ts +2 -0
  126. package/dist/runtime/server/api/agent-raw.js +17 -0
  127. package/dist/runtime/server/api/locales.d.ts +2 -2
  128. package/dist/runtime/server/api/locales.js +4 -2
  129. package/dist/runtime/server/api/navigation.d.ts +1 -1
  130. package/dist/runtime/server/api/query.d.ts +1 -1
  131. package/dist/runtime/server/api/query.js +4 -1
  132. package/dist/runtime/server/api/revalidate.js +2 -2
  133. package/dist/runtime/server/api/site-data.d.ts +1 -1
  134. package/dist/runtime/server/collection-helpers.js +2 -1
  135. package/dist/runtime/server/middleware/agent-link-headers +1 -0
  136. package/dist/runtime/server/middleware/agent-link-headers.d.ts +2 -0
  137. package/dist/runtime/server/middleware/agent-link-headers.js +41 -0
  138. package/dist/runtime/server/middleware/agent-markdown +1 -0
  139. package/dist/runtime/server/middleware/agent-markdown.d.ts +2 -0
  140. package/dist/runtime/server/middleware/agent-markdown.js +43 -0
  141. package/dist/runtime/server/plugins/sitemap.js +1 -0
  142. package/dist/runtime/server/provider-query.d.ts +8 -5
  143. package/dist/runtime/server/provider-query.js +50 -8
  144. package/dist/runtime/server/provider-result.d.ts +19 -2
  145. package/dist/runtime/server/providers/filesystem.js +4 -1
  146. package/dist/runtime/server/providers/index.d.ts +3 -1
  147. package/dist/runtime/server/providers/index.js +2 -2
  148. package/dist/runtime/server/query-api.js +2 -1
  149. package/dist/runtime/server/query-executor.d.ts +3 -2
  150. package/dist/runtime/server/query-executor.js +13 -5
  151. package/dist/runtime/server/search.js +1 -1
  152. package/dist/runtime/server/sitemap-provider.js +40 -1
  153. package/dist/runtime/server/sitemap.js +3 -2
  154. package/dist/runtime/transformers/component-resolver.js +2 -1
  155. package/dist/runtime/utils/content-components.d.ts +0 -5
  156. package/dist/storage/content.d.ts +2 -9
  157. package/dist/storage/references.d.ts +1 -8
  158. package/dist/storage/references.js +9 -4
  159. package/dist/testing/provider-contract.js +3 -4
  160. package/dist/testing/provider-fixture.d.ts +3 -1
  161. package/dist/testing/provider-fixture.js +27 -14
  162. package/dist/types/config.d.ts +77 -0
  163. package/dist/types/config.js +23 -0
  164. package/dist/types/module.d.ts +15 -5
  165. package/dist/types/query-parts/collections +1 -0
  166. package/dist/types/query-parts/collections.d.ts +15 -0
  167. package/dist/types/query-parts/collections.js +0 -0
  168. package/dist/types/query-parts/public +1 -0
  169. package/dist/types/query-parts/public.d.ts +202 -0
  170. package/dist/types/query-parts/public.js +0 -0
  171. package/dist/types/query-parts/results +1 -0
  172. package/dist/types/query-parts/results.d.ts +95 -0
  173. package/dist/types/query-parts/results.js +0 -0
  174. package/dist/types/query-parts/transport +1 -0
  175. package/dist/types/query-parts/transport.d.ts +103 -0
  176. package/dist/types/query-parts/transport.js +0 -0
  177. package/dist/types/query.d.ts +4 -870
  178. package/dist/types/query.js +4 -0
  179. package/dist/types/runtime.d.ts +2 -2
  180. package/dist/types/virtual.d.ts +54 -0
  181. package/dist/types.d.mts +2 -2
  182. package/dist/web-types.json +1 -1
  183. package/package.json +5 -5
  184. package/dist/runtime/app/composables/web-socket +0 -1
  185. package/dist/runtime/app/composables/web-socket.d.ts +0 -3
  186. package/dist/runtime/app/composables/web-socket.js +0 -65
  187. package/dist/runtime/app/plugins/ws +0 -1
  188. package/dist/runtime/app/plugins/ws.js +0 -7
  189. /package/dist/runtime/app/plugins/{ws.d.ts → hot-reload.d.ts} +0 -0
@@ -63,6 +63,68 @@ export interface ContentCmsCollectionConfig {
63
63
  fields?: Record<string, ContentCmsFieldConfig>;
64
64
  settings?: unknown;
65
65
  }
66
+ export declare const agentMetadataFields: readonly ["title", "description", "url", "route", "locale", "section", "collection", "source", "updated"];
67
+ export type AgentMetadataField = typeof agentMetadataFields[number];
68
+ export type AgentMetadataFieldList = readonly AgentMetadataField[];
69
+ export declare function defineAgentMetadataFields<const TFields extends AgentMetadataFieldList>(fields: TFields): TFields;
70
+ export interface ContentAgentMarkdownOptions {
71
+ includeInIndex?: boolean;
72
+ includeInFull?: boolean;
73
+ metadata?: AgentMetadataFieldList;
74
+ }
75
+ export interface ContentAgentCollectionConfig {
76
+ section?: string;
77
+ markdown?: boolean | ContentAgentMarkdownOptions;
78
+ }
79
+ export type ContentAgentLocalizedValue = string | Record<string, string>;
80
+ export interface ContentAgentSiteConfig {
81
+ title: ContentAgentLocalizedValue;
82
+ description: ContentAgentLocalizedValue;
83
+ url?: string;
84
+ defaultLocale?: string;
85
+ locales?: string[];
86
+ profile?: string;
87
+ contentSignals?: {
88
+ search?: boolean;
89
+ aiInput?: boolean;
90
+ aiTrain?: boolean;
91
+ };
92
+ }
93
+ export interface ContentAgentMarkdownMetadataConfig {
94
+ enabled?: boolean;
95
+ defaultFields?: AgentMetadataFieldList;
96
+ }
97
+ export interface ContentAgentMarkdownPolicyConfig {
98
+ metadata?: boolean | AgentMetadataFieldList | ContentAgentMarkdownMetadataConfig;
99
+ }
100
+ export interface ContentAgentSectionConfig {
101
+ id: string;
102
+ title: ContentAgentLocalizedValue;
103
+ order?: number;
104
+ }
105
+ export interface ContentAgentAppPageContext {
106
+ locale: string;
107
+ defaultLocale?: string;
108
+ siteUrl: string;
109
+ }
110
+ export interface ContentAgentAppPageConfig {
111
+ id: string;
112
+ route: ContentAgentLocalizedValue;
113
+ section: string;
114
+ title: ContentAgentLocalizedValue | ((ctx: ContentAgentAppPageContext) => string | Promise<string>);
115
+ description: ContentAgentLocalizedValue | ((ctx: ContentAgentAppPageContext) => string | Promise<string>);
116
+ updated?: string;
117
+ includeInIndex?: boolean;
118
+ includeInFull?: boolean;
119
+ metadata?: AgentMetadataFieldList;
120
+ render: (ctx: ContentAgentAppPageContext) => string | Promise<string>;
121
+ }
122
+ export interface ContentAgentConfig {
123
+ site?: ContentAgentSiteConfig;
124
+ markdown?: ContentAgentMarkdownPolicyConfig;
125
+ sections?: ContentAgentSectionConfig[];
126
+ pages?: ContentAgentAppPageConfig[];
127
+ }
66
128
  /**
67
129
  * Object source shape accepted for Nuxt Content v3 migration.
68
130
  */
@@ -136,6 +198,12 @@ export interface ContentCollectionConfig<TSchema extends ZodType | undefined = Z
136
198
  * source, i18n, and schema information.
137
199
  */
138
200
  cms?: ContentCmsCollectionConfig;
201
+ /**
202
+ * Agent-facing collection exposure. Collections declare only whether pages
203
+ * produce normalized markdown and which agent section they belong to. Root
204
+ * `agent` config owns site policy; the Ginko module owns route plumbing.
205
+ */
206
+ agent?: ContentAgentCollectionConfig;
139
207
  }
140
208
  export type ContentProviderName = 'filesystem' | (string & {});
141
209
  export type DefineCollectionOptions<TSchema extends ZodType | undefined = ZodType | undefined> = Omit<ContentCollectionConfig<TSchema>, 'source' | 'exclude'>;
@@ -167,6 +235,12 @@ export interface ContentConfig<TCollections extends Record<string, ContentCollec
167
235
  * modules register themselves, so app configs usually do not need this.
168
236
  */
169
237
  providers?: Record<string, string>;
238
+ /**
239
+ * Agent-facing site map and markdown output. Ginko owns the repetitive
240
+ * `/llms.txt`, raw markdown, and static route plumbing; apps provide site
241
+ * facts and app-owned page renderers here.
242
+ */
243
+ agent?: ContentAgentConfig;
170
244
  /**
171
245
  * Named content collections keyed by the identifier used at query time.
172
246
  */
@@ -274,6 +348,9 @@ export declare function defineContentConfig<const TCollections extends Record<st
274
348
  collections: TCollections;
275
349
  }): NamedContentConfig<TCollections>;
276
350
  export declare function defineContentConfig<const TConfig extends ContentConfig<Record<string, ContentCollectionConfig>>>(config: TConfig): TConfig;
351
+ export declare function defineAgentSection<const TConfig extends ContentAgentSectionConfig>(config: TConfig): TConfig;
352
+ export declare function defineAgentAppPage<const TConfig extends ContentAgentAppPageConfig>(config: TConfig): TConfig;
353
+ export declare function defineAgentMarkdownPolicy<const TConfig extends ContentAgentMarkdownPolicyConfig>(config: TConfig): TConfig;
277
354
  /**
278
355
  * Declare a schema field that stores a reference to another content entry.
279
356
  *
@@ -1,5 +1,19 @@
1
1
  import { z } from "zod";
2
2
  import { CONTENT_REFERENCE_PREFIX } from "./reference.js";
3
+ export const agentMetadataFields = [
4
+ "title",
5
+ "description",
6
+ "url",
7
+ "route",
8
+ "locale",
9
+ "section",
10
+ "collection",
11
+ "source",
12
+ "updated"
13
+ ];
14
+ export function defineAgentMetadataFields(fields) {
15
+ return fields;
16
+ }
3
17
  export function defineCollection(config) {
4
18
  if (typeof config === "string" || arguments.length > 1) {
5
19
  throw new TypeError("@lupinum/ginko-content defineCollection(name, config) was removed. Use defineCollection({ ... }) under the desired defineContentConfig({ collections: { docs: ... } }) map key.");
@@ -47,6 +61,15 @@ export function defineContentConfig(config) {
47
61
  }
48
62
  return config;
49
63
  }
64
+ export function defineAgentSection(config) {
65
+ return config;
66
+ }
67
+ export function defineAgentAppPage(config) {
68
+ return config;
69
+ }
70
+ export function defineAgentMarkdownPolicy(config) {
71
+ return config;
72
+ }
50
73
  export function reference(collection) {
51
74
  return z.string().describe(`${CONTENT_REFERENCE_PREFIX}${collection || ""}`);
52
75
  }
@@ -1,5 +1,4 @@
1
- import type { ListenOptions } from 'listhen';
2
- import type { MarkdownPluginDescriptor } from './content';
1
+ import type { MarkdownOptions, MarkdownPluginDescriptor } from './content';
3
2
  import type { ContentCollectionConfig, ContentProviderName } from './config';
4
3
  import type { ContentQueryBuilderWhere } from './query';
5
4
  import type { ContentMiniSearchOptions, ContentSearchEngine } from './search';
@@ -265,6 +264,12 @@ export interface ContentRevalidateOptions {
265
264
  */
266
265
  allowUnsigned?: boolean;
267
266
  }
267
+ export interface ContentAgentRouteOptions {
268
+ routes?: boolean;
269
+ linkHeaders?: boolean;
270
+ markdownNegotiation?: boolean;
271
+ prerender?: boolean;
272
+ }
268
273
  export interface ModuleOptions {
269
274
  api: {
270
275
  /**
@@ -308,6 +313,10 @@ export interface ModuleOptions {
308
313
  * `x-ginko-revalidate-token` or `authorization: Bearer <token>`.
309
314
  */
310
315
  revalidate?: false | ContentRevalidateOptions;
316
+ /**
317
+ * First-class agent markdown and LLM route features.
318
+ */
319
+ agent?: false | ContentAgentRouteOptions;
311
320
  /**
312
321
  * Optional server-side cache adapter module.
313
322
  *
@@ -321,9 +330,7 @@ export interface ModuleOptions {
321
330
  *
322
331
  * @default true
323
332
  */
324
- watch: false | {
325
- ws: Partial<ListenOptions>;
326
- };
333
+ watch: boolean;
327
334
  /**
328
335
  * Contents can be located in multiple places, in multiple directories or even in remote git repositories.
329
336
  * Using sources option you can tell Content module where to look for contents.
@@ -459,3 +466,6 @@ export interface ContentContext extends ModuleOptions {
459
466
  translatedSlugs: boolean;
460
467
  strictTranslatedSlugs: boolean;
461
468
  }
469
+ export type ResolvedContentContext = Omit<ContentContext, 'markdown'> & {
470
+ markdown: MarkdownOptions;
471
+ };
@@ -0,0 +1 @@
1
+ export * from './collections.js'
@@ -0,0 +1,15 @@
1
+ import type { ContentCollectionHandle } from '../config';
2
+ declare global {
3
+ interface GinkoContentCollectionMap {
4
+ }
5
+ interface GinkoContentCollectionI18nMap {
6
+ }
7
+ }
8
+ export interface ContentCollectionMap extends GinkoContentCollectionMap {
9
+ }
10
+ export interface ContentCollectionI18nMap extends GinkoContentCollectionI18nMap {
11
+ }
12
+ export type ContentCollectionName = keyof GinkoContentCollectionMap & string;
13
+ export type ContentCollectionItem<K extends ContentCollectionName> = ContentCollectionMap[K];
14
+ export type ContentCollectionStringName = [ContentCollectionName] extends [never] ? string : ContentCollectionName;
15
+ export type ContentCollectionTarget = ContentCollectionHandle | ContentCollectionStringName;
File without changes
@@ -0,0 +1 @@
1
+ export * from './public.js'
@@ -0,0 +1,202 @@
1
+ import type { ContentNavigationItem, ParsedContent, ParsedContentMeta, StrictParsedContent, StrictParsedContentMeta } from '../content';
2
+ import type { ContentCollectionI18nMap, ContentCollectionMap, ContentCollectionName, ContentCollectionTarget } from './collections';
3
+ import type { ContentRouteMeta, LocalePathEntry } from './results';
4
+ export interface QueryOperators<TValue = unknown> {
5
+ $eq?: TValue;
6
+ $ne?: TValue;
7
+ $gt?: TValue;
8
+ $gte?: TValue;
9
+ $lt?: TValue;
10
+ $lte?: TValue;
11
+ $in?: TValue[];
12
+ $nin?: TValue[];
13
+ $exists?: boolean;
14
+ $contains?: TValue | TValue[];
15
+ $containsAny?: TValue[];
16
+ $icontains?: string;
17
+ $type?: 'string' | 'number' | 'boolean' | 'object' | 'undefined';
18
+ $prefix?: TValue extends string ? string : never;
19
+ $not?: TValue | QueryOperators<TValue>;
20
+ }
21
+ export type ContentSelector = {
22
+ path: string;
23
+ route?: never;
24
+ ref?: never;
25
+ } | {
26
+ route: string;
27
+ path?: never;
28
+ ref?: never;
29
+ } | {
30
+ ref: string;
31
+ path?: never;
32
+ route?: never;
33
+ };
34
+ type WhereValue<T> = T | QueryOperators<T>;
35
+ type PathWhere = string | QueryOperators<string>;
36
+ export type QueryWhere<T = ParsedContentMeta> = {
37
+ path?: PathWhere;
38
+ $and?: QueryWhere<T>[];
39
+ $or?: QueryWhere<T>[];
40
+ $not?: QueryWhere<T>;
41
+ } & {
42
+ [K in Exclude<keyof T, 'path'>]?: WhereValue<NonNullable<T[K]>>;
43
+ };
44
+ export type SortDirection = 'asc' | 'desc' | 1 | -1;
45
+ export type SortSpec<T = ParsedContentMeta> = string extends keyof T ? {
46
+ [key: string]: SortDirection | undefined;
47
+ } : {
48
+ [K in keyof T]?: SortDirection;
49
+ };
50
+ type HandleSchema<H> = H extends {
51
+ __schema: infer S;
52
+ } ? S extends {
53
+ _output: infer O;
54
+ } ? O & StrictParsedContentMeta : StrictParsedContentMeta : H extends ContentCollectionName ? ContentCollectionMap[H] & StrictParsedContentMeta : StrictParsedContentMeta;
55
+ type SelectFields<H> = string extends H ? ReadonlyArray<string> : ReadonlyArray<Extract<keyof HandleSchema<H>, string>>;
56
+ export type DocumentFromHandle<H> = H extends {
57
+ __schema: {
58
+ _output: infer O;
59
+ };
60
+ } ? O & StrictParsedContent : H extends ContentCollectionName ? ContentCollectionMap[H] : ParsedContent;
61
+ export type PopulateSpec = Record<string, ContentCollectionTarget>;
62
+ export type PopulatedDocument<T, P> = P extends undefined ? T : P extends PopulateSpec ? string extends keyof P ? T : Omit<T, keyof P> & {
63
+ [K in keyof P & keyof T]: T[K] extends ReadonlyArray<unknown> ? Array<LocalizedDoc<DocumentFromHandle<P[K]>>> : LocalizedDoc<DocumentFromHandle<P[K]>> | null;
64
+ } : T;
65
+ export type PopulateFromOptions<O> = O extends {
66
+ populate?: infer P;
67
+ } ? P : undefined;
68
+ type PopulateOption<P extends PopulateSpec | undefined = undefined> = {
69
+ populate?: P;
70
+ };
71
+ type HandleIsI18n<H> = H extends {
72
+ __i18n: infer I;
73
+ } ? I extends true ? true : false : H extends keyof ContentCollectionI18nMap ? true : false;
74
+ type LocaleOption<H, OptKey extends string = 'locale'> = HandleIsI18n<H> extends true ? {
75
+ [K in OptKey]: string;
76
+ } : {
77
+ [K in OptKey]?: string;
78
+ };
79
+ type SourceIsI18n<S> = S extends ReadonlyArray<infer I> ? true extends HandleIsI18n<I> ? true : false : HandleIsI18n<S>;
80
+ type BacklinksLocaleOption<Target, Source> = HandleIsI18n<Target> extends true ? {
81
+ locale: string;
82
+ } : SourceIsI18n<Source> extends true ? {
83
+ locale: string;
84
+ } : {
85
+ locale?: string;
86
+ };
87
+ export type LocaleFallback = false | true | 'default' | string | string[];
88
+ export type LocalizedContentDocument<T = ParsedContentMeta> = T & ContentRouteMeta & {
89
+ locale: string;
90
+ path: string;
91
+ canonicalPath: string;
92
+ localePaths: Record<string, LocalePathEntry>;
93
+ stem?: string;
94
+ extension?: string;
95
+ };
96
+ export type LocalizedDoc<T = ParsedContentMeta> = LocalizedContentDocument<T>;
97
+ export interface ResolutionEnvelope {
98
+ requested: {
99
+ collection: string;
100
+ by: ContentSelector;
101
+ locale?: string;
102
+ fallback?: LocaleFallback;
103
+ };
104
+ normalized: {
105
+ by: ContentSelector;
106
+ };
107
+ matched: {
108
+ found: boolean;
109
+ collection: string;
110
+ path?: string;
111
+ canonicalPath?: string;
112
+ ref?: string;
113
+ locale?: string;
114
+ };
115
+ fallback: {
116
+ used: boolean;
117
+ locale?: string;
118
+ };
119
+ }
120
+ export interface ResolveOneResult<T = ParsedContentMeta> {
121
+ doc: LocalizedDoc<T> | null;
122
+ explain: ResolutionEnvelope;
123
+ }
124
+ export type ResolveOneOptions<H = unknown, P extends PopulateSpec | undefined = undefined> = {
125
+ by: ContentSelector;
126
+ fallback?: LocaleFallback;
127
+ select?: SelectFields<H>;
128
+ } & LocaleOption<H> & PopulateOption<P>;
129
+ export type OneOptions<H = unknown, P extends PopulateSpec | undefined = undefined> = ResolveOneOptions<H, P>;
130
+ export type ManyOptions<H = unknown, P extends PopulateSpec | undefined = undefined> = {
131
+ where?: QueryWhere<HandleSchema<H>>;
132
+ sort?: SortSpec<HandleSchema<H>>;
133
+ limit?: number;
134
+ skip?: number;
135
+ fallback?: LocaleFallback;
136
+ select?: SelectFields<H>;
137
+ } & LocaleOption<H> & PopulateOption<P>;
138
+ export type PaginationOptions<H = unknown, P extends PopulateSpec | undefined = undefined> = Omit<ManyOptions<H, P>, 'skip' | 'limit'> & {
139
+ page?: number;
140
+ limit?: number;
141
+ };
142
+ export interface PaginationResult<T = ParsedContentMeta> {
143
+ data: Array<LocalizedDoc<T>>;
144
+ page: number;
145
+ limit: number;
146
+ total: number;
147
+ pageCount: number;
148
+ hasNext: boolean;
149
+ hasPrev: boolean;
150
+ nextPage: number | null;
151
+ prevPage: number | null;
152
+ }
153
+ export type BacklinkSource = ContentCollectionTarget;
154
+ type SourceName<S> = S extends string ? S : S extends {
155
+ name: infer N;
156
+ } ? Extract<N, string> : string;
157
+ export type BacklinkFields<S = BacklinkSource | ReadonlyArray<BacklinkSource>> = ReadonlyArray<string> | Partial<Record<SourceName<S extends ReadonlyArray<infer I> ? I : S>, ReadonlyArray<string>>>;
158
+ type DocumentFromSource<S> = S extends ReadonlyArray<infer I> ? DocumentFromHandle<I> : DocumentFromHandle<S>;
159
+ export type BacklinksOptions<Target = unknown, Source extends BacklinkSource | ReadonlyArray<BacklinkSource> = BacklinkSource | ReadonlyArray<BacklinkSource>, P extends PopulateSpec | undefined = undefined> = {
160
+ by: ContentSelector;
161
+ from: Source;
162
+ fields?: BacklinkFields<Source>;
163
+ sort?: SortSpec<DocumentFromSource<Source>>;
164
+ limit?: number;
165
+ skip?: number;
166
+ fallback?: LocaleFallback;
167
+ select?: string extends Source ? ReadonlyArray<string> : ReadonlyArray<Extract<keyof DocumentFromSource<Source>, string>>;
168
+ } & BacklinksLocaleOption<Target, Source> & PopulateOption<P>;
169
+ export type BacklinksResult<Source extends BacklinkSource | ReadonlyArray<BacklinkSource> = BacklinkSource | ReadonlyArray<BacklinkSource>, P extends PopulateSpec | undefined = undefined> = Array<LocalizedDoc<PopulatedDocument<DocumentFromSource<Source>, P>>>;
170
+ export type VariantsOptions<H = unknown> = {
171
+ by: ContentSelector;
172
+ locales?: string[];
173
+ } & LocaleOption<H>;
174
+ export interface ContentVariant<_T = ParsedContentMeta> {
175
+ locale: string;
176
+ path: string;
177
+ translated: boolean;
178
+ fallback?: string;
179
+ }
180
+ export type TreeOptions<H = unknown, Fields extends ReadonlyArray<keyof HandleSchema<H> | string> | undefined = undefined> = {
181
+ where?: QueryWhere<HandleSchema<H>>;
182
+ sort?: SortSpec<HandleSchema<H>>;
183
+ fields?: Fields;
184
+ fallback?: LocaleFallback;
185
+ locale?: string;
186
+ };
187
+ export type ContentTreeItem<T = ParsedContentMeta, Fields extends ReadonlyArray<keyof T | string> | undefined = undefined> = {
188
+ title: string;
189
+ path: string;
190
+ _path?: string;
191
+ children?: Array<ContentTreeItem<T, Fields>>;
192
+ } & (Fields extends ReadonlyArray<infer K> ? Pick<T, Extract<K, keyof T>> : Record<never, never>);
193
+ export type { ContentNavigationItem };
194
+ export type NeighborsOptions<H = unknown> = {
195
+ by: ContentSelector;
196
+ fallback?: LocaleFallback;
197
+ fields?: SelectFields<H>;
198
+ } & LocaleOption<H>;
199
+ export interface NeighborsResult<T = ParsedContentMeta> {
200
+ prev: ContentTreeItem<T> | null;
201
+ next: ContentTreeItem<T> | null;
202
+ }
File without changes
@@ -0,0 +1 @@
1
+ export * from './results.js'
@@ -0,0 +1,95 @@
1
+ import type { ParsedContentMeta } from '../content';
2
+ import type { ContentQueryBuilderWhere } from './transport';
3
+ export interface ContentCollectionNavigationOptions<TField extends string = string> {
4
+ fields?: TField[];
5
+ locale?: string;
6
+ canonical?: boolean;
7
+ }
8
+ export type ContentCollectionItemSurroundingsOptions<TField extends string = string> = ContentCollectionNavigationOptions<TField>;
9
+ export interface ContentCollectionSearchSectionsOptions {
10
+ ignoredTags?: string[];
11
+ extraFields?: string[];
12
+ filterQuery?: ContentQueryBuilderWhere;
13
+ minHeading?: `h${1 | 2 | 3 | 4 | 5 | 6}`;
14
+ maxHeading?: `h${1 | 2 | 3 | 4 | 5 | 6}`;
15
+ locale?: string;
16
+ canonical?: boolean;
17
+ }
18
+ export interface ContentCollectionPageOptions {
19
+ locale?: string;
20
+ fallback?: string[] | boolean;
21
+ exact?: boolean;
22
+ canonical?: boolean;
23
+ }
24
+ export interface ContentCollectionRouteMetaOptions {
25
+ locale?: string;
26
+ fallback?: string[] | boolean;
27
+ exact?: boolean;
28
+ }
29
+ export interface ResolveContentReferenceOptions {
30
+ locale?: string;
31
+ fallback?: string[] | boolean;
32
+ exact?: boolean;
33
+ collection?: string;
34
+ }
35
+ export interface ContentLocaleEntry {
36
+ canonicalKey: string;
37
+ locale: string;
38
+ path?: string;
39
+ }
40
+ export interface ContentLocaleRoute {
41
+ locale: string;
42
+ path: string;
43
+ canonicalPath: string;
44
+ }
45
+ export interface LocalePathEntry {
46
+ path: string;
47
+ translated: boolean;
48
+ fallback?: string;
49
+ }
50
+ export interface ContentResolvedMeta {
51
+ locale: string;
52
+ requestedLocale?: string;
53
+ fallback: boolean;
54
+ fallbackLocale?: string;
55
+ path: string;
56
+ requestedPath?: string;
57
+ requestedRoute?: string;
58
+ requestedRef?: string;
59
+ availableLocales: string[];
60
+ }
61
+ export interface ContentRouteMeta {
62
+ locale: string;
63
+ defaultLocale: string;
64
+ path: string;
65
+ canonicalPath: string;
66
+ variants: ContentLocaleRoute[];
67
+ localePaths: Record<string, LocalePathEntry>;
68
+ resolved: ContentResolvedMeta;
69
+ }
70
+ export type ContentPageResult<T = ParsedContentMeta> = T & ContentRouteMeta & {
71
+ stem: string;
72
+ extension?: string;
73
+ };
74
+ export interface ContentSitemapAlternative {
75
+ hreflang: string;
76
+ href: string;
77
+ }
78
+ export interface ContentSitemapImage {
79
+ loc: string;
80
+ }
81
+ export interface ContentSitemapEntry {
82
+ loc: string;
83
+ _sitemap?: string;
84
+ lastmod?: string;
85
+ alternatives?: ContentSitemapAlternative[];
86
+ images?: ContentSitemapImage[];
87
+ }
88
+ export interface ContentSearchSection {
89
+ id: string;
90
+ title: string;
91
+ titles: string[];
92
+ level: number;
93
+ content: string;
94
+ [key: string]: unknown;
95
+ }
File without changes
@@ -0,0 +1 @@
1
+ export * from './transport.js'
@@ -0,0 +1,103 @@
1
+ import type { ContentQueryResponse } from '../api';
2
+ import type { ParsedContentInternalMeta, ParsedContentMeta } from '../content';
3
+ export interface ContentQuerySortParams {
4
+ $locale?: string;
5
+ $numeric?: boolean;
6
+ $caseFirst?: 'upper' | 'lower' | 'false';
7
+ $sensitivity?: 'base' | 'accent' | 'case' | 'variant';
8
+ }
9
+ export interface ContentQuerySortFields {
10
+ [field: string]: -1 | 1;
11
+ }
12
+ export type ContentQuerySortOptions = ContentQuerySortParams | ContentQuerySortFields;
13
+ export interface ContentQueryBuilderWhere extends Partial<Record<keyof ParsedContentInternalMeta, string | number | boolean | RegExp | ContentQueryBuilderWhere>> {
14
+ $and?: ContentQueryBuilderWhere[];
15
+ $or?: ContentQueryBuilderWhere[];
16
+ $not?: string | number | boolean | RegExp | ContentQueryBuilderWhere;
17
+ $eq?: string | number | boolean | RegExp;
18
+ $ne?: string | number | boolean | RegExp;
19
+ $gt?: number | string;
20
+ $gte?: number | string;
21
+ $lt?: number | string;
22
+ $lte?: number | string;
23
+ $regex?: RegExp | string;
24
+ $prefix?: string;
25
+ $type?: string;
26
+ $exists?: boolean;
27
+ $contains?: Array<string | number | boolean> | string | number | boolean;
28
+ $containsAny?: Array<string | number | boolean>;
29
+ $icontains?: string;
30
+ $in?: Array<string | number | boolean>;
31
+ [key: string]: string | number | boolean | RegExp | ContentQueryBuilderWhere | Array<string | number | boolean | ContentQueryBuilderWhere> | undefined;
32
+ }
33
+ export interface ContentQueryBuilderParams {
34
+ collection?: string;
35
+ first?: boolean;
36
+ skip?: number;
37
+ limit?: number;
38
+ only?: string[];
39
+ without?: string[];
40
+ sort?: ContentQuerySortOptions[];
41
+ where?: ContentQueryBuilderWhere[] | ContentQueryBuilderWhere;
42
+ canonical?: boolean;
43
+ navigationFields?: string[];
44
+ resolveLocale?: {
45
+ locale?: string;
46
+ fallback?: string[] | boolean;
47
+ exact?: boolean;
48
+ };
49
+ [key: string]: unknown;
50
+ }
51
+ type QueryScalar = string | number | boolean | Date;
52
+ type InternalQueryKeys = Extract<keyof ParsedContentInternalMeta, `_${string}`>;
53
+ export type CollectionQueryKey<T> = Extract<keyof T, string> | InternalQueryKeys;
54
+ export type CollectionQueryField<T> = CollectionQueryKey<T>;
55
+ export type CollectionQueryFieldValue<T, K extends CollectionQueryField<T>> = K extends keyof T ? NonNullable<T[K]> : K extends InternalQueryKeys ? NonNullable<ParsedContentInternalMeta[K]> : never;
56
+ type EqualityValue<T> = T extends QueryScalar ? T | RegExp : T;
57
+ type ComparableValue<T> = T extends string | number | Date ? T : never;
58
+ type MembershipValue<T> = T extends Array<infer U> ? Array<U> : T extends QueryScalar ? Array<T> : never;
59
+ type ContainsValue<T> = T extends string ? string : T extends Array<infer U> ? U | Array<U> : never;
60
+ type ContainsAnyValue<T> = T extends Array<infer U> ? Array<U> : never;
61
+ type RegexValue<T> = T extends string ? RegExp | string : never;
62
+ type IContainsValue<T> = T extends string ? string : never;
63
+ type TypeValue = 'string' | 'number' | 'boolean' | 'object' | 'undefined';
64
+ export type CollectionQueryOperator<T> = '=' | '!=' | 'EXISTS' | 'TYPE' | (ComparableValue<T> extends never ? never : '>' | '>=' | '<' | '<=') | (MembershipValue<T> extends never ? never : 'IN' | 'NOT IN') | (ContainsValue<T> extends never ? never : 'CONTAINS') | (ContainsAnyValue<T> extends never ? never : 'CONTAINS_ANY') | (RegexValue<T> extends never ? never : 'REGEX') | (IContainsValue<T> extends never ? never : 'ICONTAINS');
65
+ export type CollectionQueryValue<T, O extends CollectionQueryOperator<T>> = O extends '=' | '!=' ? EqualityValue<T> : O extends '>' | '>=' | '<' | '<=' ? ComparableValue<T> : O extends 'IN' | 'NOT IN' ? MembershipValue<T> : O extends 'CONTAINS' ? ContainsValue<T> : O extends 'CONTAINS_ANY' ? ContainsAnyValue<T> : O extends 'REGEX' ? RegexValue<T> : O extends 'ICONTAINS' ? IContainsValue<T> : O extends 'EXISTS' ? boolean | undefined : O extends 'TYPE' ? TypeValue : never;
66
+ export type QueryOrderDirection = 'ASC' | 'DESC';
67
+ export interface QueryOrderOptions {
68
+ locale?: string;
69
+ numeric?: boolean;
70
+ caseFirst?: ContentQuerySortParams['$caseFirst'];
71
+ sensitivity?: ContentQuerySortParams['$sensitivity'];
72
+ }
73
+ export interface QueryGroupBuilder<T = ParsedContentMeta> {
74
+ where<K extends CollectionQueryField<T>, O extends CollectionQueryOperator<CollectionQueryFieldValue<T, K>>>(field: K, operator: O, value?: CollectionQueryValue<CollectionQueryFieldValue<T, K>, O>): QueryGroupBuilder<T>;
75
+ andWhere(groupFactory: QueryGroupFunction<T>): QueryGroupBuilder<T>;
76
+ orWhere(groupFactory: QueryGroupFunction<T>): QueryGroupBuilder<T>;
77
+ }
78
+ export type QueryGroupFunction<T = ParsedContentMeta> = (group: QueryGroupBuilder<T>) => QueryGroupBuilder<T>;
79
+ export interface ContentQueryBuilder<T = ParsedContentMeta> {
80
+ where<K extends CollectionQueryField<T>, O extends CollectionQueryOperator<CollectionQueryFieldValue<T, K>>>(field: K, operator: O, value?: CollectionQueryValue<CollectionQueryFieldValue<T, K>, O>): ContentQueryBuilder<T>;
81
+ andWhere(groupFactory: QueryGroupFunction<T>): ContentQueryBuilder<T>;
82
+ orWhere(groupFactory: QueryGroupFunction<T>): ContentQueryBuilder<T>;
83
+ select<const K extends readonly Extract<keyof T, string>[]>(...fields: K): ContentQueryBuilder<Pick<T, K[number]>>;
84
+ order<K extends CollectionQueryField<T>>(field: K, direction: QueryOrderDirection, options?: QueryOrderOptions): ContentQueryBuilder<T>;
85
+ limit(count: number): ContentQueryBuilder<T>;
86
+ skip(count: number): ContentQueryBuilder<T>;
87
+ params: () => ContentQueryBuilderParams;
88
+ locale(locale: string, options?: {
89
+ fallback?: boolean | string[];
90
+ }): ContentQueryBuilder<T>;
91
+ all(): Promise<Array<T>>;
92
+ first(): Promise<T | undefined>;
93
+ count(): Promise<number>;
94
+ }
95
+ export interface CollectionQueryBuilder<T = ParsedContentMeta> extends ContentQueryBuilder<T> {
96
+ select<const K extends readonly Extract<keyof T, string>[]>(...fields: K): CollectionQueryBuilder<Pick<T, K[number]>>;
97
+ }
98
+ export interface ContentQueryRequest {
99
+ params(): ContentQueryBuilderParams;
100
+ }
101
+ export type ContentQueryFetcher<T> = (query: ContentQueryRequest) => Promise<ContentQueryResponse<T>>;
102
+ export type QueryMatchOperator = (item: unknown, condition: unknown) => boolean;
103
+ export {};
File without changes