@vite-hub/source 0.0.4 → 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/README.md +219 -82
- package/dist/{auth-Ddw55OUG.js → auth-B-tX_rp0.js} +255 -90
- package/dist/{client-CDfTmtQu.js → client-BwstxtdY.js} +584 -207
- package/dist/client.d.ts +27 -10
- package/dist/client.js +71 -13
- package/dist/collection-B_4w_J8h.d.ts +257 -0
- package/dist/{collection-B8pXGM2d.js → collection-cursor-WzV1Jd6v.js} +37 -54
- package/dist/collection-route-BplWPxHR.js +10 -0
- package/dist/drizzle.d.ts +41 -0
- package/dist/drizzle.js +89 -0
- package/dist/error-diagnostics-X0kuFjBT.js +51 -0
- package/dist/file-BX0FSvgE.js +60 -0
- package/dist/{file-EQ3AjVM6.d.ts → file-DadN9dbN.d.ts} +2 -3
- package/dist/file.d.ts +1 -1
- package/dist/file.js +1 -1
- package/dist/files.d.ts +15 -0
- package/dist/files.js +38 -0
- package/dist/github.d.ts +8 -5
- package/dist/github.js +725 -426
- package/dist/glob-BmFqTvJY.js +993 -0
- package/dist/glob.d.ts +12 -4
- package/dist/glob.js +1 -894
- package/dist/index.d.ts +118 -27
- package/dist/index.js +623 -14
- package/dist/markdown.d.ts +4 -6
- package/dist/markdown.js +2 -2
- package/dist/mcp.d.ts +3 -4
- package/dist/mcp.js +302 -5920
- package/dist/{file-BSWQg9Qv.js → mrmime-40h5OOIp.js} +1 -56
- package/dist/{path-CUhvUREm.js → path-BS8rYm0n.js} +60 -40
- package/dist/{path-BzmU4Eni.js → path-DOBpV8ol.js} +3 -7
- package/dist/server.d.ts +256 -6
- package/dist/server.js +90 -12
- package/dist/{sse-CE9Q2JqM.js → sse-D9gqqNPj.js} +50 -9
- package/dist/{streamableHttp-BszaXLmg.js → streamableHttp-BL-E7pl5.js} +40 -22
- package/dist/types-BigOktIj.d.ts +93 -0
- package/dist/{types-AIBmt_m6.js → types-CoWcW8oz.js} +2502 -1187
- package/dist/vite.d.ts +134 -13
- package/dist/vite.js +1734 -79
- package/package.json +55 -36
- package/dist/collection-CF2ON__k.d.ts +0 -92
- package/dist/collection-route-Dw7QLFyx.js +0 -6
- package/dist/content/client.d.ts +0 -3
- package/dist/content/client.js +0 -2
- package/dist/content.d.ts +0 -44
- package/dist/content.js +0 -157
- package/dist/registry-C8skfCSV.js +0 -120
- package/dist/types-Bu3WvNX9.d.ts +0 -71
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
|
-
import { a as CollectionCursorValue, c as
|
|
2
|
-
import { a as
|
|
1
|
+
import { C as ProviderCollectionPage, D as CollectionCursorError, E as defineCollection, O as CollectionCursorErrorOptions, S as ProviderCollectionOptions, T as SourceCollectionOptions, _ as CollectionReadOptions, a as CollectionCursorValue, b as CursorCollectionSource, c as CollectionItem, d as CollectionOptions, f as CollectionPage, g as CollectionQueryInput, h as CollectionQueryBuilder, i as CollectionClientItem, k as CollectionCursorErrorReason, l as CollectionLoadOptions, m as CollectionQuery, n as AnyCollectionSource, o as CollectionFacetValue, p as CollectionPageOptions, r as Collection, s as CollectionFacets, t as AnyCollection, u as CollectionLoader, v as CollectionRequestQuery, w as ProviderCollectionSource, x as ProviderCollectionLoader, y as CollectionSource } from "./collection-B_4w_J8h.js";
|
|
2
|
+
import { _ as SourceName, a as Source, c as SourceContext, d as SourceFile, f as SourceItem, g as SourceMetadata, h as SourceMap, i as RegisteredSource, l as SourceData, m as SourceListEntry, n as ReadSourceOptions, o as SourceCacheOptions, p as SourceKey, r as ReadSourceResult, s as SourceContent, t as FileSource, u as SourceEntry, v as SourceReader, y as SourceRevision } from "./types-BigOktIj.js";
|
|
3
3
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
4
|
-
|
|
4
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
//#region src/core/array-collection.d.ts
|
|
6
|
+
interface ArrayCollectionSort {
|
|
7
|
+
direction?: "asc" | "desc";
|
|
8
|
+
/** Field path to sort by. Numbers sort numerically; other values sort as strings. */
|
|
9
|
+
field: string;
|
|
10
|
+
}
|
|
11
|
+
interface ArrayCollectionOptions<TFilter extends string = string> {
|
|
12
|
+
/**
|
|
13
|
+
* Field paths clients may filter by. `?category=guide` matches case-insensitively, a repeated key matches any of
|
|
14
|
+
* its values, and `?empty=category` matches items with no value at that path. Dot paths read nested objects and
|
|
15
|
+
* every element of nested arrays.
|
|
16
|
+
*/
|
|
17
|
+
filters?: readonly TFilter[];
|
|
18
|
+
/** Field paths that the `search` query matches as a case-insensitive substring. Omit to reject `search`. */
|
|
19
|
+
search?: readonly string[];
|
|
20
|
+
/** Order of every page. Omit to keep the array order. */
|
|
21
|
+
sort?: ArrayCollectionSort;
|
|
22
|
+
/** Field paths counted into `page.facets` over every matching item. */
|
|
23
|
+
facets?: readonly string[];
|
|
24
|
+
/** Field path that `collection.get(key)` matches. Omit to leave the Collection without `get()`. */
|
|
25
|
+
key?: string;
|
|
26
|
+
/** Page size when the caller omits `limit` (default `50`). */
|
|
27
|
+
defaultLimit?: number;
|
|
28
|
+
/** Largest accepted `limit` and the most values kept per facet (default `100`). */
|
|
29
|
+
maxLimit?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Items plus an optional content digest. Without `digest`, the Collection hashes the items to bind its cursors. */
|
|
32
|
+
interface ArrayCollectionSnapshot<TItem> {
|
|
33
|
+
digest?: string;
|
|
34
|
+
items: readonly TItem[];
|
|
35
|
+
}
|
|
36
|
+
type ArrayCollectionLoader<TItem> = (options: {
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}) => Promise<readonly TItem[] | ArrayCollectionSnapshot<TItem>> | readonly TItem[] | ArrayCollectionSnapshot<TItem>;
|
|
39
|
+
/** Request query accepted by an array Collection route and by `useCollection({ filter })`. */
|
|
40
|
+
type ArrayCollectionQueryInput<TFilter extends string = string> = { [TKey in TFilter]?: string | readonly string[]; } & {
|
|
41
|
+
empty?: TFilter | readonly TFilter[];
|
|
42
|
+
search?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Parsed query that an array Collection evaluates. Values match case-insensitively. */
|
|
45
|
+
type ArrayCollectionQuery<TFilter extends string = string> = { [TKey in TFilter]?: readonly string[]; } & {
|
|
46
|
+
empty?: readonly TFilter[];
|
|
47
|
+
search?: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A Collection source that filters, searches, sorts, counts, and pages an array in memory.
|
|
51
|
+
*
|
|
52
|
+
* `load` runs on every request, so keep the array bounded. Cursors are bound to the data digest and the query:
|
|
53
|
+
* a cursor from changed data or another query is rejected as stale (`409` on the generated route).
|
|
54
|
+
*
|
|
55
|
+
* Pass `schema` to validate every item on load and type the items from its output.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* export const articles = defineCollection({
|
|
59
|
+
* source: array(() => loadArticles(), { filters: ['category'], search: ['title'], facets: ['category'] }),
|
|
60
|
+
* })
|
|
61
|
+
*/
|
|
62
|
+
export declare function array<TSchema extends StandardSchemaV1, const TFilter extends string = never>(load: readonly unknown[] | ArrayCollectionLoader<unknown>, options: ArrayCollectionOptions<TFilter> & {
|
|
63
|
+
schema: TSchema;
|
|
64
|
+
}): ProviderCollectionSource<StandardSchemaV1.InferOutput<TSchema>, ArrayCollectionQuery<TFilter>, ArrayCollectionQueryInput<TFilter>>;
|
|
65
|
+
export declare function array<TItem, const TFilter extends string = never>(load: readonly TItem[] | ArrayCollectionLoader<TItem>, options?: ArrayCollectionOptions<TFilter> & {
|
|
66
|
+
schema?: undefined;
|
|
67
|
+
}): ProviderCollectionSource<TItem, ArrayCollectionQuery<TFilter>, ArrayCollectionQueryInput<TFilter>>;
|
|
68
|
+
//#endregion
|
|
5
69
|
//#region src/core/combine-sources.d.ts
|
|
6
70
|
interface CombinedSourceReader {
|
|
7
71
|
get(key: never): Promise<unknown>;
|
|
@@ -27,7 +91,7 @@ type ValidCombinedGet<TReader> = TReader extends unknown ? TReader extends {
|
|
|
27
91
|
get: infer TGet;
|
|
28
92
|
} ? Equal<TGet, (key: CombinedSourceKey<TReader>) => Promise<CombinedSourceValue<TReader>>> extends true ? TReader : never : never : never;
|
|
29
93
|
type ValidCombinedSource<TReader> = [CombinedSourceItem<TReader>] extends [never] ? ValidCombinedGet<TReader> : Exclude<CombinedSourceItem<TReader>["key"], CombinedSourceKey<TReader>> extends never ? ValidCombinedGet<TReader> : never;
|
|
30
|
-
type ValidCombinedSources<TSources extends CombinedSources> = { [TSource in keyof TSources]: ValidCombinedSource<TSources[TSource]
|
|
94
|
+
type ValidCombinedSources<TSources extends CombinedSources> = { [TSource in keyof TSources]: ValidCombinedSource<TSources[TSource]>; };
|
|
31
95
|
type TaggedCombinedItemVariant<TSource extends string, TItem> = TItem extends {
|
|
32
96
|
key: string;
|
|
33
97
|
} ? Omit<TItem, "identity" | "source"> & {
|
|
@@ -35,41 +99,71 @@ type TaggedCombinedItemVariant<TSource extends string, TItem> = TItem extends {
|
|
|
35
99
|
source: TSource;
|
|
36
100
|
} : never;
|
|
37
101
|
type TaggedCombinedItem<TSource extends string, TReader> = TaggedCombinedItemVariant<TSource, CombinedSourceItem<TReader>>;
|
|
38
|
-
type CombinedItem<TSources extends CombinedSources> = { [TSource in Extract<keyof TSources, string>]: TaggedCombinedItem<TSource, TSources[TSource]
|
|
39
|
-
type CombinedIdentity<TSources extends CombinedSources> = { [TSource in Extract<keyof TSources, string>]: readonly [source: TSource, key: CombinedSourceKey<TSources[TSource]>] }[Extract<keyof TSources, string>];
|
|
102
|
+
type CombinedItem<TSources extends CombinedSources> = { [TSource in Extract<keyof TSources, string>]: TaggedCombinedItem<TSource, TSources[TSource]>; }[Extract<keyof TSources, string>];
|
|
103
|
+
type CombinedIdentity<TSources extends CombinedSources> = { [TSource in Extract<keyof TSources, string>]: readonly [source: TSource, key: CombinedSourceKey<TSources[TSource]>]; }[Extract<keyof TSources, string>];
|
|
40
104
|
type CombinedIdentityValue<TSources extends CombinedSources, TIdentity> = TIdentity extends readonly [infer TSource extends Extract<keyof TSources, string>, string] ? CombinedSourceValue<TSources[TSource]> : never;
|
|
41
105
|
interface CombinedSourcesDefinition<TSources extends CombinedSources> {
|
|
42
106
|
readonly sources: TSources & ValidCombinedSources<TSources> & Record<Exclude<keyof TSources, string>, never>;
|
|
43
107
|
}
|
|
44
|
-
|
|
108
|
+
type CombinedSourcesReader<TSources extends CombinedSources> = {
|
|
45
109
|
get<const TIdentity extends CombinedIdentity<TSources>>(identity: TIdentity): Promise<CombinedIdentityValue<TSources, TIdentity>>;
|
|
110
|
+
} & (TSources[keyof TSources] extends {
|
|
111
|
+
items(): Promise<Array<{
|
|
112
|
+
key: string;
|
|
113
|
+
}>>;
|
|
114
|
+
} ? {
|
|
46
115
|
items(): Promise<Array<CombinedItem<TSources>>>;
|
|
116
|
+
} : {});
|
|
117
|
+
export declare function combineSources<const TSources extends CombinedSources>(definition: CombinedSourcesDefinition<TSources>): CombinedSourcesReader<TSources>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/core/split-source.d.ts
|
|
120
|
+
/** One part of a parent item. Its key is unique inside the parent and has no `#`. */
|
|
121
|
+
type SplitSourcePart = SourceItem<string, unknown, object>;
|
|
122
|
+
interface SplitSourceOptions<TSource extends Source, TPart extends SplitSourcePart> {
|
|
123
|
+
/** The Source whose items are split. */
|
|
124
|
+
source: TSource;
|
|
125
|
+
/** Defaults to the parent Source name. */
|
|
126
|
+
name?: string;
|
|
127
|
+
/** Returns the parts of one parent item, in order. Return an empty array to skip the item. */
|
|
128
|
+
split(item: SourceEntry<TSource>): readonly TPart[] | Promise<readonly TPart[]>;
|
|
47
129
|
}
|
|
48
|
-
|
|
130
|
+
/** A part's key: the parent key, `#`, and the part key. */
|
|
131
|
+
type SplitSourceKey<TSource extends Source> = `${SourceKey<TSource>}#${string}`;
|
|
132
|
+
/** A part as the split Source returns it: its full key, and the parent's path when the part has none. */
|
|
133
|
+
type SplitSourceItem<TSource extends Source, TPart extends SplitSourcePart> = Omit<TPart, "key"> & {
|
|
134
|
+
key: SplitSourceKey<TSource>;
|
|
135
|
+
};
|
|
136
|
+
/** A Source with one item for each part of another Source's items. */
|
|
137
|
+
type SplitSourceMeta<TSource extends Source> = NonNullable<TSource["getMeta"]> extends ((...args: any[]) => infer TResult) ? TResult : Promise<undefined>;
|
|
138
|
+
type SplitSource<TSource extends Source, TPart extends SplitSourcePart> = Omit<Source<SplitSourceKey<TSource>>, "getItem" | "getItems" | "getMeta"> & {
|
|
139
|
+
getItem(key: SplitSourceKey<TSource>, ctx: SourceContext): Promise<SplitSourceItem<TSource, TPart>>;
|
|
140
|
+
getItems(ctx: SourceContext): Promise<SplitSourceItem<TSource, TPart>[]>;
|
|
141
|
+
getMeta(key: SplitSourceKey<TSource>, ctx: SourceContext): SplitSourceMeta<TSource>;
|
|
142
|
+
};
|
|
143
|
+
/** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
|
|
144
|
+
export declare function splitSource<const TSource extends Source, TPart extends SplitSourcePart>(options: SplitSourceOptions<TSource, TPart>): SplitSource<TSource, TPart>;
|
|
49
145
|
//#endregion
|
|
50
146
|
//#region src/core/define.d.ts
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
declare function
|
|
57
|
-
declare function defineSource<const TReader extends KeyedSourceReader>(definition: RuntimeSourceDefinition<TReader>): RuntimeSourceDefinition<TReader>;
|
|
58
|
-
declare function defineSources<const TSources extends Record<string, Source>>(sources: TSources): TSources;
|
|
59
|
-
declare function createSource<const TReader extends KeyedSourceReader>(definition: RuntimeSourceDefinition<TReader>, context: SourceContext): TReader;
|
|
147
|
+
/** Define a loader. Open it with createSource() to bind its runtime context. */
|
|
148
|
+
export declare function defineSource<const TSource extends Source>(source: TSource): TSource;
|
|
149
|
+
export declare function defineSources<const TSources extends Record<string, Source>>(sources: TSources): TSources;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/core/reader.d.ts
|
|
152
|
+
export declare function createSource<const TSource extends Source>(source: TSource, context?: Partial<SourceContext>): SourceReader<TSource>;
|
|
60
153
|
//#endregion
|
|
61
154
|
//#region src/core/registry.d.ts
|
|
62
|
-
declare function registerSource<const TName extends string, const TSource extends Source>(name: TName, source: TSource): TSource;
|
|
63
|
-
declare function registerSources<const TSources extends Record<string, Source>>(sources: TSources): TSources;
|
|
64
|
-
declare function getRegisteredSource<TName extends SourceName>(name: TName):
|
|
65
|
-
declare function clearSources(): void;
|
|
66
|
-
|
|
155
|
+
export declare function registerSource<const TName extends string, const TSource extends Source>(name: TName, source: TSource): TSource;
|
|
156
|
+
export declare function registerSources<const TSources extends Record<string, Source>>(sources: TSources): TSources;
|
|
157
|
+
export declare function getRegisteredSource<TName extends SourceName>(name: TName): RegisteredSource<TName>;
|
|
158
|
+
export declare function clearSources(): void;
|
|
159
|
+
/** Open a registered definition with the same lifecycle as direct Source readers. */
|
|
160
|
+
export declare function useSource<TName extends SourceName>(name: TName, context?: Partial<SourceContext>): SourceReader<RegisteredSource<TName>>;
|
|
67
161
|
//#endregion
|
|
68
162
|
//#region src/core/errors.d.ts
|
|
69
163
|
type SourceErrorCode = "SOURCE_FAILED" | "SOURCE_NOT_FOUND" | "SOURCE_PATH_INVALID";
|
|
70
164
|
//#endregion
|
|
71
165
|
//#region src/ignores.d.ts
|
|
72
|
-
declare const sourceIgnores: Readonly<{
|
|
166
|
+
export declare const sourceIgnores: Readonly<{
|
|
73
167
|
defaults: readonly string[];
|
|
74
168
|
dependencies: readonly string[];
|
|
75
169
|
generated: readonly string[];
|
|
@@ -78,7 +172,4 @@ declare const sourceIgnores: Readonly<{
|
|
|
78
172
|
system: readonly string[];
|
|
79
173
|
}>;
|
|
80
174
|
//#endregion
|
|
81
|
-
|
|
82
|
-
declare function custom<const TSource extends Source>(source: TSource): TSource;
|
|
83
|
-
//#endregion
|
|
84
|
-
export { type AnyCollection, type Collection, type CollectionClientItem, CollectionCursorError, type CollectionCursorValue, type CollectionItem, type CollectionLoadOptions, type CollectionLoader, type CollectionOptions, type CollectionPage, type CollectionPageOptions, type CollectionQuery, type CollectionQueryInput, type CollectionRequestQuery, type ReadSourceOptions, type ReadSourceResult, type Source, type SourceCacheOptions, type SourceContent, type SourceContext, type SourceData, type SourceErrorCode, type SourceItem, type SourceKey, type SourceListEntry, type SourceMap, type SourceMetadata, type SourceName, type SourceReader, type SourceRevision, clearSources, combineSources, createSource, custom, defineCollection, defineSource, defineSources, getRegisteredSource, registerSource, registerSources, sourceIgnores, useSource };
|
|
175
|
+
export { type AnyCollection, type AnyCollectionSource, type ArrayCollectionLoader, type ArrayCollectionOptions, type ArrayCollectionQuery, type ArrayCollectionQueryInput, type ArrayCollectionSnapshot, type ArrayCollectionSort, type Collection, type CollectionClientItem, CollectionCursorError, type CollectionCursorErrorOptions, type CollectionCursorErrorReason, type CollectionCursorValue, type CollectionFacetValue, type CollectionFacets, type CollectionItem, type CollectionLoadOptions, type CollectionLoader, type CollectionOptions, type CollectionPage, type CollectionPageOptions, type CollectionQuery, type CollectionQueryBuilder, type CollectionQueryInput, type CollectionReadOptions, type CollectionRequestQuery, type CollectionSource, type CursorCollectionSource, type FileSource, type ProviderCollectionLoader, type ProviderCollectionOptions, type ProviderCollectionPage, type ProviderCollectionSource, type ReadSourceOptions, type ReadSourceResult, type RegisteredSource, type Source, type SourceCacheOptions, type SourceCollectionOptions, type SourceContent, type SourceContext, type SourceData, type SourceEntry, type SourceErrorCode, type SourceFile, type SourceItem, type SourceKey, type SourceListEntry, type SourceMap, type SourceMetadata, type SourceName, type SourceReader, type SourceRevision, type SplitSource, type SplitSourceItem, type SplitSourceKey, type SplitSourceOptions, type SplitSourcePart, defineCollection };
|