@contello/astro 3.0.0 → 3.2.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/dist/index.cjs +304 -414
- package/dist/index.d.cts +89 -86
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +89 -86
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +301 -377
- package/dist/index.js.map +1 -0
- package/package.json +15 -12
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ExcludePattern } from '@astroscope/excludes';
|
|
1
|
+
import { ContelloClient, Schema, SourceDef } from "@contello/client";
|
|
2
|
+
import { MediaResolver, MediaResolverOptions } from "@contello/media";
|
|
3
|
+
import { Assets, AssetsOptions, AssetsSync, AssetsSyncOptions, Collection, CollectionOptions, CollectionSync, CollectionSyncOptions, CreateStoreOptions, ExtractSourceResult, I18nMessages, LazyAssets, LazyAssetsOptions, LazyCollection, LazyCollectionOptions, LazyRoutes, LazyRoutesOptions, Loadable, ReadonlyDeep, ResolveSource, Routes, RoutesOptions, RoutesSync, RoutesSyncOptions, Singleton, SingletonOptions, SingletonSync, SingletonSyncOptions, SourceKeysOf, StoreRoute, SyncCacheOptions } from "@contello/store";
|
|
4
|
+
import { ExcludePattern } from "@astroscope/excludes";
|
|
5
|
+
import { APIContext } from "astro";
|
|
7
6
|
|
|
7
|
+
//#region src/assets-middleware.d.ts
|
|
8
8
|
type ContelloAssetsImagesOptions = {
|
|
9
|
-
|
|
9
|
+
cacheControl?: string | undefined;
|
|
10
10
|
};
|
|
11
11
|
type ContelloAssetsFilesOptions = {
|
|
12
|
-
|
|
12
|
+
cacheControl?: string | undefined;
|
|
13
13
|
};
|
|
14
14
|
type ContelloAssetsVideoOptions = Record<string, never>;
|
|
15
15
|
type ContelloAssetsMiddlewareOptions = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
images?: ContelloAssetsImagesOptions | undefined;
|
|
17
|
+
files?: ContelloAssetsFilesOptions | undefined;
|
|
18
|
+
video?: ContelloAssetsVideoOptions | undefined;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/routing-middleware.d.ts
|
|
21
22
|
type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
22
23
|
/**
|
|
23
24
|
* Derives the path used to look up a Contello route from the request context.
|
|
@@ -30,101 +31,103 @@ type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
|
30
31
|
*/
|
|
31
32
|
type RoutePathResolver = (ctx: APIContext) => string;
|
|
32
33
|
type ContelloRoutingMiddlewareOptions = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Routes instance backing the middleware.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).
|
|
38
|
+
* For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to
|
|
39
|
+
* `contello.init({ load: [routes] })`, and pass that same instance here.
|
|
40
|
+
*/
|
|
41
|
+
routes?: AnyRoutes | undefined;
|
|
42
|
+
exclude?: ExcludePattern[] | undefined;
|
|
43
|
+
resolveRoutePath?: RoutePathResolver | undefined;
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/contello.d.ts
|
|
45
47
|
type ContelloRequestContext = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
url: URL;
|
|
49
|
+
route: ReadonlyDeep<StoreRoute> | undefined;
|
|
50
|
+
rewritten: boolean;
|
|
49
51
|
};
|
|
50
52
|
type ContelloI18nOptions = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
collection: string;
|
|
54
|
+
languages: string[];
|
|
55
|
+
cache?: SyncCacheOptions | undefined;
|
|
54
56
|
};
|
|
55
57
|
type ContelloInitOptions = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
load?: Loadable[] | undefined;
|
|
59
|
+
i18n?: {
|
|
60
|
+
register?: boolean | undefined;
|
|
61
|
+
load?: boolean | undefined;
|
|
62
|
+
} | undefined;
|
|
61
63
|
};
|
|
62
64
|
type ContelloMediaConfig = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
readonly baseUrl: string;
|
|
66
|
+
readonly imagesPath: string;
|
|
67
|
+
readonly videosPath: string;
|
|
68
|
+
readonly filesPath: string;
|
|
67
69
|
};
|
|
68
70
|
type ContelloOptions<TSchema extends Schema | undefined = undefined> = CreateStoreOptions<TSchema> & {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
i18n?: ContelloI18nOptions | undefined;
|
|
72
|
+
media?: Partial<ContelloMediaConfig> | undefined;
|
|
71
73
|
};
|
|
72
74
|
type HasFallback<O> = O extends {
|
|
73
|
-
|
|
75
|
+
fallback: infer F;
|
|
74
76
|
} ? ([F] extends [undefined] ? false : true) : false;
|
|
75
77
|
declare const runRequest: unique symbol;
|
|
76
78
|
type ModelsOf<TSchema> = TSchema extends {
|
|
77
|
-
|
|
79
|
+
models: infer M;
|
|
78
80
|
} ? keyof M & string : string;
|
|
79
81
|
type CollectionArg<TSchema> = SourceKeysOf<TSchema, 'entity'> | SourceDef<ModelsOf<TSchema>, 'entity'>;
|
|
80
82
|
type SingletonArg<TSchema> = SourceKeysOf<TSchema, 'singleton'> | SourceDef<ModelsOf<TSchema>, 'singleton'>;
|
|
81
83
|
type CollectionRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>>;
|
|
82
84
|
type SingletonRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>>;
|
|
83
85
|
declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
86
|
+
private readonly _store;
|
|
87
|
+
private readonly _options;
|
|
88
|
+
private _i18nMessages;
|
|
89
|
+
private _i18nUnsubscribe;
|
|
90
|
+
private _initialized;
|
|
91
|
+
private readonly _als;
|
|
92
|
+
private _autoLazyRoutes?;
|
|
93
|
+
readonly media: ContelloMediaConfig;
|
|
94
|
+
createRoutingMiddleware: (options?: ContelloRoutingMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
95
|
+
createAssetsMiddleware: (options?: ContelloAssetsMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
96
|
+
constructor(options: ContelloOptions<TSchema>);
|
|
97
|
+
init(options?: ContelloInitOptions | undefined): Promise<void>;
|
|
98
|
+
destroy(): Promise<void>;
|
|
99
|
+
ping(): Promise<void>;
|
|
100
|
+
get isReady(): boolean;
|
|
101
|
+
get client(): ContelloClient<TSchema>;
|
|
102
|
+
get i18nMessages(): I18nMessages;
|
|
103
|
+
get request(): ContelloRequestContext;
|
|
104
|
+
defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>>;
|
|
105
|
+
defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Singleton<TMapped>;
|
|
106
|
+
defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): SingletonSync<TMapped>;
|
|
107
|
+
defineCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
108
|
+
id: string;
|
|
109
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
110
|
+
id: string;
|
|
111
|
+
}>(sourceOrKey: TArg, options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Collection<TMapped>;
|
|
112
|
+
defineCollectionSync<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
113
|
+
id: string;
|
|
114
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
115
|
+
id: string;
|
|
116
|
+
}>(sourceOrKey: TArg, options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): CollectionSync<TMapped>;
|
|
117
|
+
defineLazyCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
118
|
+
id: string;
|
|
119
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
120
|
+
id: string;
|
|
121
|
+
}>(sourceOrKey: TArg, options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): LazyCollection<TMapped>;
|
|
122
|
+
defineRoutes(options?: RoutesOptions | undefined): Routes;
|
|
123
|
+
defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync;
|
|
124
|
+
defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes;
|
|
125
|
+
defineAssets(options?: AssetsOptions | undefined): Assets;
|
|
126
|
+
defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync;
|
|
127
|
+
defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
|
|
128
|
+
[runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T;
|
|
127
129
|
}
|
|
128
130
|
declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
129
|
-
|
|
131
|
+
//#endregion
|
|
130
132
|
export { type AnyRoutes, Contello, type ContelloAssetsFilesOptions, type ContelloAssetsImagesOptions, type ContelloAssetsMiddlewareOptions, type ContelloAssetsVideoOptions, type ContelloI18nOptions, type ContelloInitOptions, type ContelloOptions, type ContelloRequestContext, type ContelloRoutingMiddlewareOptions, createContello };
|
|
133
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/assets-middleware.ts","../src/routing-middleware.ts","../src/contello.ts"],"mappings":";;;;;;;KAKY,2BAAA;EACV,YAAY;AAAA;AAAA,KAGF,0BAAA;EACV,YAAY;AAAA;AAAA,KAGF,0BAAA,GAA6B,MAAM;AAAA,KAEnC,+BAAA;EACV,MAAA,GAAS,2BAAA;EACT,KAAA,GAAQ,0BAAA;EACR,KAAA,GAAQ,0BAAA;AAAA;;;KCHE,SAAA,GAAY,MAAA,GAAS,UAAA,GAAa,UAAA;;;ADV9C;;;;AACc;AAGd;;KCiBY,iBAAA,IAAqB,GAAe,EAAV,UAAU;AAAA,KAEpC,gCAAA;EDlBE;AAGd;;;;AAA+C;AAE/C;ECqBE,MAAA,GAAS,SAAA;EACT,OAAA,GAAU,cAAA;EACV,gBAAA,GAAmB,iBAAA;AAAA;;;KCST,sBAAA;EACV,GAAA,EAAK,GAAA;EACL,KAAA,EAAO,YAAA,CAAa,UAA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,IAAA,GAAO,OAAA,EAAS,QAAA,CAAS,OAAA,KAC/E,cAAA,CAAe,OAAA;EAIlB,oBAAA,cACe,aAAA,CAAc,OAAA;IACT,EAAA;EAAA,IAAe,aAAA,CAAc,OAAA,EAAS,IAAA;IAAU,EAAA;EAAA,GAElE,WAAA,EAAa,IAAA,EACb,OAAA,GAAU,qBAAA,CAAsB,aAAA,CAAc,OAAA,EAAS,IAAA,GAAO,OAAA,EAAS,QAAA,CAAS,OAAA,KAC/E,cAAA,CAAe,OAAA;EAIlB,YAAA,CAAa,OAAA,GAAU,aAAA,eAA4B,MAAA;EAInD,gBAAA,CAAiB,OAAA,GAAU,iBAAA,eAAgC,UAAA;EAI3D,gBAAA,CAAiB,OAAA,GAAU,iBAAA,eAAgC,UAAA;EAI3D,YAAA,CAAa,OAAA,GAAU,aAAA,eAA4B,MAAA;EAInD,gBAAA,CAAiB,OAAA,GAAU,iBAAA,eAAgC,UAAA;EAI3D,gBAAA,CAAiB,OAAA,GAAU,iBAAA,eAAgC,UAAA;EAAA,CAM1D,UAAA,KAAe,GAAA,EAAK,sBAAA,EAAwB,EAAA,QAAU,CAAA,GAAI,CAAA;AAAA;AAAA,iBAK7C,cAAA,iBAA+B,MAAA,0BAC7C,OAAA,EAAS,eAAA,CAAgB,OAAA,IACxB,QAAA,CAAS,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ExcludePattern } from '@astroscope/excludes';
|
|
1
|
+
import { MediaResolver, MediaResolverOptions } from "@contello/media";
|
|
2
|
+
import { Assets, AssetsOptions, AssetsSync, AssetsSyncOptions, Collection, CollectionOptions, CollectionSync, CollectionSyncOptions, CreateStoreOptions, ExtractSourceResult, I18nMessages, LazyAssets, LazyAssetsOptions, LazyCollection, LazyCollectionOptions, LazyRoutes, LazyRoutesOptions, Loadable, ReadonlyDeep, ResolveSource, Routes, RoutesOptions, RoutesSync, RoutesSyncOptions, Singleton, SingletonOptions, SingletonSync, SingletonSyncOptions, SourceKeysOf, StoreRoute, SyncCacheOptions } from "@contello/store";
|
|
3
|
+
import { ExcludePattern } from "@astroscope/excludes";
|
|
4
|
+
import { ContelloClient, Schema, SourceDef } from "@contello/client";
|
|
5
|
+
import { APIContext } from "astro";
|
|
7
6
|
|
|
7
|
+
//#region src/assets-middleware.d.ts
|
|
8
8
|
type ContelloAssetsImagesOptions = {
|
|
9
|
-
|
|
9
|
+
cacheControl?: string | undefined;
|
|
10
10
|
};
|
|
11
11
|
type ContelloAssetsFilesOptions = {
|
|
12
|
-
|
|
12
|
+
cacheControl?: string | undefined;
|
|
13
13
|
};
|
|
14
14
|
type ContelloAssetsVideoOptions = Record<string, never>;
|
|
15
15
|
type ContelloAssetsMiddlewareOptions = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
images?: ContelloAssetsImagesOptions | undefined;
|
|
17
|
+
files?: ContelloAssetsFilesOptions | undefined;
|
|
18
|
+
video?: ContelloAssetsVideoOptions | undefined;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/routing-middleware.d.ts
|
|
21
22
|
type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
22
23
|
/**
|
|
23
24
|
* Derives the path used to look up a Contello route from the request context.
|
|
@@ -30,101 +31,103 @@ type AnyRoutes = Routes | RoutesSync | LazyRoutes;
|
|
|
30
31
|
*/
|
|
31
32
|
type RoutePathResolver = (ctx: APIContext) => string;
|
|
32
33
|
type ContelloRoutingMiddlewareOptions = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Routes instance backing the middleware.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to a `LazyRoutes` instance managed by contello (fetched on demand, no init-time load).
|
|
38
|
+
* For eager routing, create a `RoutesSync` via `contello.defineRoutesSync()`, add it to
|
|
39
|
+
* `contello.init({ load: [routes] })`, and pass that same instance here.
|
|
40
|
+
*/
|
|
41
|
+
routes?: AnyRoutes | undefined;
|
|
42
|
+
exclude?: ExcludePattern[] | undefined;
|
|
43
|
+
resolveRoutePath?: RoutePathResolver | undefined;
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/contello.d.ts
|
|
45
47
|
type ContelloRequestContext = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
url: URL;
|
|
49
|
+
route: ReadonlyDeep<StoreRoute> | undefined;
|
|
50
|
+
rewritten: boolean;
|
|
49
51
|
};
|
|
50
52
|
type ContelloI18nOptions = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
collection: string;
|
|
54
|
+
languages: string[];
|
|
55
|
+
cache?: SyncCacheOptions | undefined;
|
|
54
56
|
};
|
|
55
57
|
type ContelloInitOptions = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
load?: Loadable[] | undefined;
|
|
59
|
+
i18n?: {
|
|
60
|
+
register?: boolean | undefined;
|
|
61
|
+
load?: boolean | undefined;
|
|
62
|
+
} | undefined;
|
|
61
63
|
};
|
|
62
64
|
type ContelloMediaConfig = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
readonly baseUrl: string;
|
|
66
|
+
readonly imagesPath: string;
|
|
67
|
+
readonly videosPath: string;
|
|
68
|
+
readonly filesPath: string;
|
|
67
69
|
};
|
|
68
70
|
type ContelloOptions<TSchema extends Schema | undefined = undefined> = CreateStoreOptions<TSchema> & {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
i18n?: ContelloI18nOptions | undefined;
|
|
72
|
+
media?: Partial<ContelloMediaConfig> | undefined;
|
|
71
73
|
};
|
|
72
74
|
type HasFallback<O> = O extends {
|
|
73
|
-
|
|
75
|
+
fallback: infer F;
|
|
74
76
|
} ? ([F] extends [undefined] ? false : true) : false;
|
|
75
77
|
declare const runRequest: unique symbol;
|
|
76
78
|
type ModelsOf<TSchema> = TSchema extends {
|
|
77
|
-
|
|
79
|
+
models: infer M;
|
|
78
80
|
} ? keyof M & string : string;
|
|
79
81
|
type CollectionArg<TSchema> = SourceKeysOf<TSchema, 'entity'> | SourceDef<ModelsOf<TSchema>, 'entity'>;
|
|
80
82
|
type SingletonArg<TSchema> = SourceKeysOf<TSchema, 'singleton'> | SourceDef<ModelsOf<TSchema>, 'singleton'>;
|
|
81
83
|
type CollectionRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'entity'>>>;
|
|
82
84
|
type SingletonRaw<TSchema, TArg> = ExtractSourceResult<Extract<ResolveSource<TSchema, TArg>, SourceDef<string, 'singleton'>>>;
|
|
83
85
|
declare class Contello<TSchema extends Schema | undefined = undefined> {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
86
|
+
private readonly _store;
|
|
87
|
+
private readonly _options;
|
|
88
|
+
private _i18nMessages;
|
|
89
|
+
private _i18nUnsubscribe;
|
|
90
|
+
private _initialized;
|
|
91
|
+
private readonly _als;
|
|
92
|
+
private _autoLazyRoutes?;
|
|
93
|
+
readonly media: ContelloMediaConfig;
|
|
94
|
+
createRoutingMiddleware: (options?: ContelloRoutingMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
95
|
+
createAssetsMiddleware: (options?: ContelloAssetsMiddlewareOptions | undefined) => import("astro").MiddlewareHandler;
|
|
96
|
+
constructor(options: ContelloOptions<TSchema>);
|
|
97
|
+
init(options?: ContelloInitOptions | undefined): Promise<void>;
|
|
98
|
+
destroy(): Promise<void>;
|
|
99
|
+
ping(): Promise<void>;
|
|
100
|
+
get isReady(): boolean;
|
|
101
|
+
get client(): ContelloClient<TSchema>;
|
|
102
|
+
get i18nMessages(): I18nMessages;
|
|
103
|
+
get request(): ContelloRequestContext;
|
|
104
|
+
defineMediaResolver<O extends Partial<MediaResolverOptions>>(options?: O): MediaResolver<HasFallback<O>>;
|
|
105
|
+
defineSingleton<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Singleton<TMapped>;
|
|
106
|
+
defineSingletonSync<TArg extends SingletonArg<TSchema>, TMapped = SingletonRaw<TSchema, TArg>>(sourceOrKey: TArg, options?: SingletonSyncOptions<SingletonRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): SingletonSync<TMapped>;
|
|
107
|
+
defineCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
108
|
+
id: string;
|
|
109
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
110
|
+
id: string;
|
|
111
|
+
}>(sourceOrKey: TArg, options?: CollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): Collection<TMapped>;
|
|
112
|
+
defineCollectionSync<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
113
|
+
id: string;
|
|
114
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
115
|
+
id: string;
|
|
116
|
+
}>(sourceOrKey: TArg, options?: CollectionSyncOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): CollectionSync<TMapped>;
|
|
117
|
+
defineLazyCollection<TArg extends CollectionArg<TSchema>, TMapped extends {
|
|
118
|
+
id: string;
|
|
119
|
+
} = CollectionRaw<TSchema, TArg> & {
|
|
120
|
+
id: string;
|
|
121
|
+
}>(sourceOrKey: TArg, options?: LazyCollectionOptions<CollectionRaw<TSchema, TArg>, TMapped, ModelsOf<TSchema>>): LazyCollection<TMapped>;
|
|
122
|
+
defineRoutes(options?: RoutesOptions | undefined): Routes;
|
|
123
|
+
defineRoutesSync(options?: RoutesSyncOptions | undefined): RoutesSync;
|
|
124
|
+
defineLazyRoutes(options?: LazyRoutesOptions | undefined): LazyRoutes;
|
|
125
|
+
defineAssets(options?: AssetsOptions | undefined): Assets;
|
|
126
|
+
defineAssetsSync(options?: AssetsSyncOptions | undefined): AssetsSync;
|
|
127
|
+
defineLazyAssets(options?: LazyAssetsOptions | undefined): LazyAssets;
|
|
128
|
+
[runRequest]<T>(ctx: ContelloRequestContext, fn: () => T): T;
|
|
127
129
|
}
|
|
128
130
|
declare function createContello<TSchema extends Schema | undefined = undefined>(options: ContelloOptions<TSchema>): Contello<TSchema>;
|
|
129
|
-
|
|
131
|
+
//#endregion
|
|
130
132
|
export { type AnyRoutes, Contello, type ContelloAssetsFilesOptions, type ContelloAssetsImagesOptions, type ContelloAssetsMiddlewareOptions, type ContelloAssetsVideoOptions, type ContelloI18nOptions, type ContelloInitOptions, type ContelloOptions, type ContelloRequestContext, type ContelloRoutingMiddlewareOptions, createContello };
|
|
133
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/assets-middleware.ts","../src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