@monza-editor/astro 0.2.0 → 0.2.1

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.
@@ -15,21 +15,13 @@ declare module 'astro:content' {
15
15
  [key: string]: unknown;
16
16
  };
17
17
  }
18
- }
19
18
 
20
- declare module 'astro:content' {
21
19
  type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
22
20
 
23
- export type CollectionKey = keyof AnyEntryMap;
24
- export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
25
-
26
- export type ContentCollectionKey = keyof ContentEntryMap;
27
- export type DataCollectionKey = keyof DataEntryMap;
21
+ export type CollectionKey = keyof DataEntryMap;
22
+ export type CollectionEntry<C extends CollectionKey> = Flatten<DataEntryMap[C]>;
28
23
 
29
24
  type AllValuesOf<T> = T extends any ? T[keyof T] : never;
30
- type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
31
- ContentEntryMap[C]
32
- >['slug'];
33
25
 
34
26
  export type ReferenceDataEntry<
35
27
  C extends CollectionKey,
@@ -38,41 +30,17 @@ declare module 'astro:content' {
38
30
  collection: C;
39
31
  id: E;
40
32
  };
41
- export type ReferenceContentEntry<
42
- C extends keyof ContentEntryMap,
43
- E extends ValidContentEntrySlug<C> | (string & {}) = string,
44
- > = {
45
- collection: C;
46
- slug: E;
47
- };
33
+
48
34
  export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
49
35
  collection: C;
50
36
  id: string;
51
37
  };
52
38
 
53
- /** @deprecated Use `getEntry` instead. */
54
- export function getEntryBySlug<
55
- C extends keyof ContentEntryMap,
56
- E extends ValidContentEntrySlug<C> | (string & {}),
57
- >(
58
- collection: C,
59
- // Note that this has to accept a regular string too, for SSR
60
- entrySlug: E,
61
- ): E extends ValidContentEntrySlug<C>
62
- ? Promise<CollectionEntry<C>>
63
- : Promise<CollectionEntry<C> | undefined>;
64
-
65
- /** @deprecated Use `getEntry` instead. */
66
- export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
67
- collection: C,
68
- entryId: E,
69
- ): Promise<CollectionEntry<C>>;
70
-
71
- export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
39
+ export function getCollection<C extends keyof DataEntryMap, E extends CollectionEntry<C>>(
72
40
  collection: C,
73
41
  filter?: (entry: CollectionEntry<C>) => entry is E,
74
42
  ): Promise<E[]>;
75
- export function getCollection<C extends keyof AnyEntryMap>(
43
+ export function getCollection<C extends keyof DataEntryMap>(
76
44
  collection: C,
77
45
  filter?: (entry: CollectionEntry<C>) => unknown,
78
46
  ): Promise<CollectionEntry<C>[]>;
@@ -84,14 +52,6 @@ declare module 'astro:content' {
84
52
  import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
85
53
  >;
86
54
 
87
- export function getEntry<
88
- C extends keyof ContentEntryMap,
89
- E extends ValidContentEntrySlug<C> | (string & {}),
90
- >(
91
- entry: ReferenceContentEntry<C, E>,
92
- ): E extends ValidContentEntrySlug<C>
93
- ? Promise<CollectionEntry<C>>
94
- : Promise<CollectionEntry<C> | undefined>;
95
55
  export function getEntry<
96
56
  C extends keyof DataEntryMap,
97
57
  E extends keyof DataEntryMap[C] | (string & {}),
@@ -100,15 +60,6 @@ declare module 'astro:content' {
100
60
  ): E extends keyof DataEntryMap[C]
101
61
  ? Promise<DataEntryMap[C][E]>
102
62
  : Promise<CollectionEntry<C> | undefined>;
103
- export function getEntry<
104
- C extends keyof ContentEntryMap,
105
- E extends ValidContentEntrySlug<C> | (string & {}),
106
- >(
107
- collection: C,
108
- slug: E,
109
- ): E extends ValidContentEntrySlug<C>
110
- ? Promise<CollectionEntry<C>>
111
- : Promise<CollectionEntry<C> | undefined>;
112
63
  export function getEntry<
113
64
  C extends keyof DataEntryMap,
114
65
  E extends keyof DataEntryMap[C] | (string & {}),
@@ -126,47 +77,56 @@ declare module 'astro:content' {
126
77
  ): Promise<import('astro').LiveDataEntryResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
127
78
 
128
79
  /** Resolve an array of entry references from the same collection */
129
- export function getEntries<C extends keyof ContentEntryMap>(
130
- entries: ReferenceContentEntry<C, ValidContentEntrySlug<C>>[],
131
- ): Promise<CollectionEntry<C>[]>;
132
80
  export function getEntries<C extends keyof DataEntryMap>(
133
81
  entries: ReferenceDataEntry<C, keyof DataEntryMap[C]>[],
134
82
  ): Promise<CollectionEntry<C>[]>;
135
83
 
136
- export function render<C extends keyof AnyEntryMap>(
137
- entry: AnyEntryMap[C][string],
84
+ export function render<C extends keyof DataEntryMap>(
85
+ entry: DataEntryMap[C][string],
86
+ ): Promise<RenderResult>;
87
+
88
+ export function render<C extends keyof LiveContentConfig['collections']>(
89
+ entry: import('astro').LiveDataEntry<LiveLoaderDataType<C>>,
138
90
  ): Promise<RenderResult>;
139
91
 
140
- export function reference<C extends keyof AnyEntryMap>(
92
+ export function reference<
93
+ C extends
94
+ | keyof DataEntryMap
95
+ // Allow generic `string` to avoid excessive type errors in the config
96
+ // if `dev` is not running to update as you edit.
97
+ // Invalid collection names will be caught at build time.
98
+ | (string & {}),
99
+ >(
141
100
  collection: C,
142
- ): import('astro/zod').ZodEffects<
101
+ ): import('astro/zod').ZodPipe<
143
102
  import('astro/zod').ZodString,
144
- C extends keyof ContentEntryMap
145
- ? ReferenceContentEntry<C, ValidContentEntrySlug<C>>
146
- : ReferenceDataEntry<C, keyof DataEntryMap[C]>
103
+ import('astro/zod').ZodTransform<
104
+ C extends keyof DataEntryMap
105
+ ? {
106
+ collection: C;
107
+ id: string;
108
+ }
109
+ : never,
110
+ string
111
+ >
147
112
  >;
148
- // Allow generic `string` to avoid excessive type errors in the config
149
- // if `dev` is not running to update as you edit.
150
- // Invalid collection names will be caught at build time.
151
- export function reference<C extends string>(
152
- collection: C,
153
- ): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
154
113
 
155
114
  type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
156
- type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
115
+ type InferEntrySchema<C extends keyof DataEntryMap> = import('astro/zod').infer<
157
116
  ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
158
117
  >;
159
-
160
- type ContentEntryMap = {
161
-
162
- };
118
+ type ExtractLoaderConfig<T> = T extends { loader: infer L } ? L : never;
119
+ type InferLoaderSchema<
120
+ C extends keyof DataEntryMap,
121
+ L = ExtractLoaderConfig<ContentConfig['collections'][C]>,
122
+ > = L extends { schema: import('astro/zod').ZodSchema }
123
+ ? import('astro/zod').infer<L['schema']>
124
+ : any;
163
125
 
164
126
  type DataEntryMap = {
165
127
 
166
128
  };
167
129
 
168
- type AnyEntryMap = ContentEntryMap & DataEntryMap;
169
-
170
130
  type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
171
131
  infer TData,
172
132
  infer TEntryFilter,
@@ -175,10 +135,10 @@ declare module 'astro:content' {
175
135
  >
176
136
  ? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
177
137
  : { data: never; entryFilter: never; collectionFilter: never; error: never };
178
- type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
179
138
  type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
180
139
  type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
181
140
  type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
141
+ type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
182
142
 
183
143
  type LiveLoaderDataType<C extends keyof LiveContentConfig['collections']> =
184
144
  LiveContentConfig['collections'][C]['schema'] extends undefined
@@ -194,6 +154,6 @@ declare module 'astro:content' {
194
154
  LiveContentConfig['collections'][C]['loader']
195
155
  >;
196
156
 
197
- export type ContentConfig = typeof import("../src/content.config.mjs");
157
+ export type ContentConfig = never;
198
158
  export type LiveContentConfig = never;
199
159
  }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@monza-editor/astro",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Astro component of Monza editor",
5
- "repository": "https://github.com/raviqqe/monza-editor",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/raviqqe/monza-editor"
8
+ },
6
9
  "license": "MIT",
7
10
  "publishConfig": {
8
11
  "provenance": true
@@ -16,12 +19,12 @@
16
19
  },
17
20
  "dependencies": {
18
21
  "picolight": "^0.2.8",
19
- "monza-editor": "0.5.6"
22
+ "monza-editor": "0.5.10"
20
23
  },
21
24
  "devDependencies": {
22
- "@raviqqe/tsconfig": "^2.0.3",
23
- "astro": "^5.16.4",
24
- "typescript": "^5.9.3"
25
+ "@raviqqe/tsconfig": "^3.0.2",
26
+ "astro": "^7.2.2",
27
+ "typescript": "^6.0.3"
25
28
  },
26
29
  "scripts": {
27
30
  "build": "astro build"
@@ -1 +0,0 @@
1
- export default new Map();
@@ -1 +0,0 @@
1
- export default new Map();