@magicpages/ghost-typesense-config 0.0.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.d.mts +354 -0
- package/dist/index.d.ts +354 -0
- package/dist/index.js +119 -0
- package/dist/index.mjs +86 -0
- package/package.json +43 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ghost API configuration schema
|
|
5
|
+
*/
|
|
6
|
+
declare const GhostConfigSchema: z.ZodObject<{
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
key: z.ZodString;
|
|
9
|
+
version: z.ZodDefault<z.ZodLiteral<"v5.0">>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
url: string;
|
|
12
|
+
key: string;
|
|
13
|
+
version: "v5.0";
|
|
14
|
+
}, {
|
|
15
|
+
url: string;
|
|
16
|
+
key: string;
|
|
17
|
+
version?: "v5.0" | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Typesense node configuration schema
|
|
21
|
+
*/
|
|
22
|
+
declare const TypesenseNodeSchema: z.ZodObject<{
|
|
23
|
+
host: z.ZodString;
|
|
24
|
+
port: z.ZodNumber;
|
|
25
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
26
|
+
path: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
host: string;
|
|
29
|
+
port: number;
|
|
30
|
+
protocol: "http" | "https";
|
|
31
|
+
path?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
host: string;
|
|
34
|
+
port: number;
|
|
35
|
+
protocol: "http" | "https";
|
|
36
|
+
path?: string | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Typesense configuration schema
|
|
40
|
+
*/
|
|
41
|
+
declare const TypesenseConfigSchema: z.ZodObject<{
|
|
42
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
43
|
+
host: z.ZodString;
|
|
44
|
+
port: z.ZodNumber;
|
|
45
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
46
|
+
path: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
host: string;
|
|
49
|
+
port: number;
|
|
50
|
+
protocol: "http" | "https";
|
|
51
|
+
path?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
host: string;
|
|
54
|
+
port: number;
|
|
55
|
+
protocol: "http" | "https";
|
|
56
|
+
path?: string | undefined;
|
|
57
|
+
}>, "many">;
|
|
58
|
+
apiKey: z.ZodString;
|
|
59
|
+
connectionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
retryIntervalSeconds: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
nodes: {
|
|
63
|
+
host: string;
|
|
64
|
+
port: number;
|
|
65
|
+
protocol: "http" | "https";
|
|
66
|
+
path?: string | undefined;
|
|
67
|
+
}[];
|
|
68
|
+
apiKey: string;
|
|
69
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
70
|
+
retryIntervalSeconds?: number | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
nodes: {
|
|
73
|
+
host: string;
|
|
74
|
+
port: number;
|
|
75
|
+
protocol: "http" | "https";
|
|
76
|
+
path?: string | undefined;
|
|
77
|
+
}[];
|
|
78
|
+
apiKey: string;
|
|
79
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
80
|
+
retryIntervalSeconds?: number | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Collection field configuration schema
|
|
84
|
+
*/
|
|
85
|
+
declare const CollectionFieldSchema: z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
88
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
94
|
+
name: string;
|
|
95
|
+
sort?: boolean | undefined;
|
|
96
|
+
facet?: boolean | undefined;
|
|
97
|
+
index?: boolean | undefined;
|
|
98
|
+
optional?: boolean | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
101
|
+
name: string;
|
|
102
|
+
sort?: boolean | undefined;
|
|
103
|
+
facet?: boolean | undefined;
|
|
104
|
+
index?: boolean | undefined;
|
|
105
|
+
optional?: boolean | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Collection configuration schema
|
|
109
|
+
*/
|
|
110
|
+
declare const CollectionConfigSchema: z.ZodObject<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
115
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
121
|
+
name: string;
|
|
122
|
+
sort?: boolean | undefined;
|
|
123
|
+
facet?: boolean | undefined;
|
|
124
|
+
index?: boolean | undefined;
|
|
125
|
+
optional?: boolean | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
128
|
+
name: string;
|
|
129
|
+
sort?: boolean | undefined;
|
|
130
|
+
facet?: boolean | undefined;
|
|
131
|
+
index?: boolean | undefined;
|
|
132
|
+
optional?: boolean | undefined;
|
|
133
|
+
}>, "many">;
|
|
134
|
+
default_sorting_field: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
name: string;
|
|
137
|
+
fields: {
|
|
138
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
139
|
+
name: string;
|
|
140
|
+
sort?: boolean | undefined;
|
|
141
|
+
facet?: boolean | undefined;
|
|
142
|
+
index?: boolean | undefined;
|
|
143
|
+
optional?: boolean | undefined;
|
|
144
|
+
}[];
|
|
145
|
+
default_sorting_field?: string | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
name: string;
|
|
148
|
+
fields: {
|
|
149
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
150
|
+
name: string;
|
|
151
|
+
sort?: boolean | undefined;
|
|
152
|
+
facet?: boolean | undefined;
|
|
153
|
+
index?: boolean | undefined;
|
|
154
|
+
optional?: boolean | undefined;
|
|
155
|
+
}[];
|
|
156
|
+
default_sorting_field?: string | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Main configuration schema
|
|
160
|
+
*/
|
|
161
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
162
|
+
ghost: z.ZodObject<{
|
|
163
|
+
url: z.ZodString;
|
|
164
|
+
key: z.ZodString;
|
|
165
|
+
version: z.ZodDefault<z.ZodLiteral<"v5.0">>;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
url: string;
|
|
168
|
+
key: string;
|
|
169
|
+
version: "v5.0";
|
|
170
|
+
}, {
|
|
171
|
+
url: string;
|
|
172
|
+
key: string;
|
|
173
|
+
version?: "v5.0" | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
typesense: z.ZodObject<{
|
|
176
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
177
|
+
host: z.ZodString;
|
|
178
|
+
port: z.ZodNumber;
|
|
179
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
180
|
+
path: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
host: string;
|
|
183
|
+
port: number;
|
|
184
|
+
protocol: "http" | "https";
|
|
185
|
+
path?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
host: string;
|
|
188
|
+
port: number;
|
|
189
|
+
protocol: "http" | "https";
|
|
190
|
+
path?: string | undefined;
|
|
191
|
+
}>, "many">;
|
|
192
|
+
apiKey: z.ZodString;
|
|
193
|
+
connectionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
retryIntervalSeconds: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
nodes: {
|
|
197
|
+
host: string;
|
|
198
|
+
port: number;
|
|
199
|
+
protocol: "http" | "https";
|
|
200
|
+
path?: string | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
apiKey: string;
|
|
203
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
204
|
+
retryIntervalSeconds?: number | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
nodes: {
|
|
207
|
+
host: string;
|
|
208
|
+
port: number;
|
|
209
|
+
protocol: "http" | "https";
|
|
210
|
+
path?: string | undefined;
|
|
211
|
+
}[];
|
|
212
|
+
apiKey: string;
|
|
213
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
214
|
+
retryIntervalSeconds?: number | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
collection: z.ZodObject<{
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
219
|
+
name: z.ZodString;
|
|
220
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
221
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
227
|
+
name: string;
|
|
228
|
+
sort?: boolean | undefined;
|
|
229
|
+
facet?: boolean | undefined;
|
|
230
|
+
index?: boolean | undefined;
|
|
231
|
+
optional?: boolean | undefined;
|
|
232
|
+
}, {
|
|
233
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
234
|
+
name: string;
|
|
235
|
+
sort?: boolean | undefined;
|
|
236
|
+
facet?: boolean | undefined;
|
|
237
|
+
index?: boolean | undefined;
|
|
238
|
+
optional?: boolean | undefined;
|
|
239
|
+
}>, "many">;
|
|
240
|
+
default_sorting_field: z.ZodOptional<z.ZodString>;
|
|
241
|
+
}, "strip", z.ZodTypeAny, {
|
|
242
|
+
name: string;
|
|
243
|
+
fields: {
|
|
244
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
245
|
+
name: string;
|
|
246
|
+
sort?: boolean | undefined;
|
|
247
|
+
facet?: boolean | undefined;
|
|
248
|
+
index?: boolean | undefined;
|
|
249
|
+
optional?: boolean | undefined;
|
|
250
|
+
}[];
|
|
251
|
+
default_sorting_field?: string | undefined;
|
|
252
|
+
}, {
|
|
253
|
+
name: string;
|
|
254
|
+
fields: {
|
|
255
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
256
|
+
name: string;
|
|
257
|
+
sort?: boolean | undefined;
|
|
258
|
+
facet?: boolean | undefined;
|
|
259
|
+
index?: boolean | undefined;
|
|
260
|
+
optional?: boolean | undefined;
|
|
261
|
+
}[];
|
|
262
|
+
default_sorting_field?: string | undefined;
|
|
263
|
+
}>;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
ghost: {
|
|
266
|
+
url: string;
|
|
267
|
+
key: string;
|
|
268
|
+
version: "v5.0";
|
|
269
|
+
};
|
|
270
|
+
typesense: {
|
|
271
|
+
nodes: {
|
|
272
|
+
host: string;
|
|
273
|
+
port: number;
|
|
274
|
+
protocol: "http" | "https";
|
|
275
|
+
path?: string | undefined;
|
|
276
|
+
}[];
|
|
277
|
+
apiKey: string;
|
|
278
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
279
|
+
retryIntervalSeconds?: number | undefined;
|
|
280
|
+
};
|
|
281
|
+
collection: {
|
|
282
|
+
name: string;
|
|
283
|
+
fields: {
|
|
284
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
285
|
+
name: string;
|
|
286
|
+
sort?: boolean | undefined;
|
|
287
|
+
facet?: boolean | undefined;
|
|
288
|
+
index?: boolean | undefined;
|
|
289
|
+
optional?: boolean | undefined;
|
|
290
|
+
}[];
|
|
291
|
+
default_sorting_field?: string | undefined;
|
|
292
|
+
};
|
|
293
|
+
}, {
|
|
294
|
+
ghost: {
|
|
295
|
+
url: string;
|
|
296
|
+
key: string;
|
|
297
|
+
version?: "v5.0" | undefined;
|
|
298
|
+
};
|
|
299
|
+
typesense: {
|
|
300
|
+
nodes: {
|
|
301
|
+
host: string;
|
|
302
|
+
port: number;
|
|
303
|
+
protocol: "http" | "https";
|
|
304
|
+
path?: string | undefined;
|
|
305
|
+
}[];
|
|
306
|
+
apiKey: string;
|
|
307
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
308
|
+
retryIntervalSeconds?: number | undefined;
|
|
309
|
+
};
|
|
310
|
+
collection: {
|
|
311
|
+
name: string;
|
|
312
|
+
fields: {
|
|
313
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
314
|
+
name: string;
|
|
315
|
+
sort?: boolean | undefined;
|
|
316
|
+
facet?: boolean | undefined;
|
|
317
|
+
index?: boolean | undefined;
|
|
318
|
+
optional?: boolean | undefined;
|
|
319
|
+
}[];
|
|
320
|
+
default_sorting_field?: string | undefined;
|
|
321
|
+
};
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Type definitions derived from schemas
|
|
325
|
+
*/
|
|
326
|
+
type GhostConfig = z.infer<typeof GhostConfigSchema>;
|
|
327
|
+
type TypesenseNode = z.infer<typeof TypesenseNodeSchema>;
|
|
328
|
+
type TypesenseConfig = z.infer<typeof TypesenseConfigSchema>;
|
|
329
|
+
type CollectionField = z.infer<typeof CollectionFieldSchema>;
|
|
330
|
+
type CollectionConfig = z.infer<typeof CollectionConfigSchema>;
|
|
331
|
+
type Config = z.infer<typeof ConfigSchema>;
|
|
332
|
+
/**
|
|
333
|
+
* Validates the configuration object against the schema
|
|
334
|
+
* @param config The configuration object to validate
|
|
335
|
+
* @returns The validated configuration object with types
|
|
336
|
+
* @throws {ZodError} If validation fails
|
|
337
|
+
*/
|
|
338
|
+
declare function validateConfig(config: unknown): Config;
|
|
339
|
+
/**
|
|
340
|
+
* Default collection fields that should be included
|
|
341
|
+
*/
|
|
342
|
+
declare const DEFAULT_COLLECTION_FIELDS: CollectionField[];
|
|
343
|
+
/**
|
|
344
|
+
* Creates a default configuration object
|
|
345
|
+
* @param ghostUrl The URL of the Ghost instance
|
|
346
|
+
* @param ghostKey The Ghost Content API key
|
|
347
|
+
* @param typesenseHost The Typesense host
|
|
348
|
+
* @param typesenseApiKey The Typesense API key
|
|
349
|
+
* @param collectionName The name of the collection (defaults to 'posts')
|
|
350
|
+
* @returns A default configuration object
|
|
351
|
+
*/
|
|
352
|
+
declare function createDefaultConfig(ghostUrl: string, ghostKey: string, typesenseHost: string, typesenseApiKey: string, collectionName?: string): Config;
|
|
353
|
+
|
|
354
|
+
export { type CollectionConfig, CollectionConfigSchema, type CollectionField, CollectionFieldSchema, type Config, ConfigSchema, DEFAULT_COLLECTION_FIELDS, type GhostConfig, GhostConfigSchema, type TypesenseConfig, TypesenseConfigSchema, type TypesenseNode, TypesenseNodeSchema, createDefaultConfig, validateConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ghost API configuration schema
|
|
5
|
+
*/
|
|
6
|
+
declare const GhostConfigSchema: z.ZodObject<{
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
key: z.ZodString;
|
|
9
|
+
version: z.ZodDefault<z.ZodLiteral<"v5.0">>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
url: string;
|
|
12
|
+
key: string;
|
|
13
|
+
version: "v5.0";
|
|
14
|
+
}, {
|
|
15
|
+
url: string;
|
|
16
|
+
key: string;
|
|
17
|
+
version?: "v5.0" | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Typesense node configuration schema
|
|
21
|
+
*/
|
|
22
|
+
declare const TypesenseNodeSchema: z.ZodObject<{
|
|
23
|
+
host: z.ZodString;
|
|
24
|
+
port: z.ZodNumber;
|
|
25
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
26
|
+
path: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
host: string;
|
|
29
|
+
port: number;
|
|
30
|
+
protocol: "http" | "https";
|
|
31
|
+
path?: string | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
host: string;
|
|
34
|
+
port: number;
|
|
35
|
+
protocol: "http" | "https";
|
|
36
|
+
path?: string | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Typesense configuration schema
|
|
40
|
+
*/
|
|
41
|
+
declare const TypesenseConfigSchema: z.ZodObject<{
|
|
42
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
43
|
+
host: z.ZodString;
|
|
44
|
+
port: z.ZodNumber;
|
|
45
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
46
|
+
path: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
host: string;
|
|
49
|
+
port: number;
|
|
50
|
+
protocol: "http" | "https";
|
|
51
|
+
path?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
host: string;
|
|
54
|
+
port: number;
|
|
55
|
+
protocol: "http" | "https";
|
|
56
|
+
path?: string | undefined;
|
|
57
|
+
}>, "many">;
|
|
58
|
+
apiKey: z.ZodString;
|
|
59
|
+
connectionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
retryIntervalSeconds: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
nodes: {
|
|
63
|
+
host: string;
|
|
64
|
+
port: number;
|
|
65
|
+
protocol: "http" | "https";
|
|
66
|
+
path?: string | undefined;
|
|
67
|
+
}[];
|
|
68
|
+
apiKey: string;
|
|
69
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
70
|
+
retryIntervalSeconds?: number | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
nodes: {
|
|
73
|
+
host: string;
|
|
74
|
+
port: number;
|
|
75
|
+
protocol: "http" | "https";
|
|
76
|
+
path?: string | undefined;
|
|
77
|
+
}[];
|
|
78
|
+
apiKey: string;
|
|
79
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
80
|
+
retryIntervalSeconds?: number | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Collection field configuration schema
|
|
84
|
+
*/
|
|
85
|
+
declare const CollectionFieldSchema: z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
88
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
94
|
+
name: string;
|
|
95
|
+
sort?: boolean | undefined;
|
|
96
|
+
facet?: boolean | undefined;
|
|
97
|
+
index?: boolean | undefined;
|
|
98
|
+
optional?: boolean | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
101
|
+
name: string;
|
|
102
|
+
sort?: boolean | undefined;
|
|
103
|
+
facet?: boolean | undefined;
|
|
104
|
+
index?: boolean | undefined;
|
|
105
|
+
optional?: boolean | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Collection configuration schema
|
|
109
|
+
*/
|
|
110
|
+
declare const CollectionConfigSchema: z.ZodObject<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
115
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
117
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
121
|
+
name: string;
|
|
122
|
+
sort?: boolean | undefined;
|
|
123
|
+
facet?: boolean | undefined;
|
|
124
|
+
index?: boolean | undefined;
|
|
125
|
+
optional?: boolean | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
128
|
+
name: string;
|
|
129
|
+
sort?: boolean | undefined;
|
|
130
|
+
facet?: boolean | undefined;
|
|
131
|
+
index?: boolean | undefined;
|
|
132
|
+
optional?: boolean | undefined;
|
|
133
|
+
}>, "many">;
|
|
134
|
+
default_sorting_field: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
name: string;
|
|
137
|
+
fields: {
|
|
138
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
139
|
+
name: string;
|
|
140
|
+
sort?: boolean | undefined;
|
|
141
|
+
facet?: boolean | undefined;
|
|
142
|
+
index?: boolean | undefined;
|
|
143
|
+
optional?: boolean | undefined;
|
|
144
|
+
}[];
|
|
145
|
+
default_sorting_field?: string | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
name: string;
|
|
148
|
+
fields: {
|
|
149
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
150
|
+
name: string;
|
|
151
|
+
sort?: boolean | undefined;
|
|
152
|
+
facet?: boolean | undefined;
|
|
153
|
+
index?: boolean | undefined;
|
|
154
|
+
optional?: boolean | undefined;
|
|
155
|
+
}[];
|
|
156
|
+
default_sorting_field?: string | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Main configuration schema
|
|
160
|
+
*/
|
|
161
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
162
|
+
ghost: z.ZodObject<{
|
|
163
|
+
url: z.ZodString;
|
|
164
|
+
key: z.ZodString;
|
|
165
|
+
version: z.ZodDefault<z.ZodLiteral<"v5.0">>;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
url: string;
|
|
168
|
+
key: string;
|
|
169
|
+
version: "v5.0";
|
|
170
|
+
}, {
|
|
171
|
+
url: string;
|
|
172
|
+
key: string;
|
|
173
|
+
version?: "v5.0" | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
typesense: z.ZodObject<{
|
|
176
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
177
|
+
host: z.ZodString;
|
|
178
|
+
port: z.ZodNumber;
|
|
179
|
+
protocol: z.ZodEnum<["http", "https"]>;
|
|
180
|
+
path: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
host: string;
|
|
183
|
+
port: number;
|
|
184
|
+
protocol: "http" | "https";
|
|
185
|
+
path?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
host: string;
|
|
188
|
+
port: number;
|
|
189
|
+
protocol: "http" | "https";
|
|
190
|
+
path?: string | undefined;
|
|
191
|
+
}>, "many">;
|
|
192
|
+
apiKey: z.ZodString;
|
|
193
|
+
connectionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
retryIntervalSeconds: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
nodes: {
|
|
197
|
+
host: string;
|
|
198
|
+
port: number;
|
|
199
|
+
protocol: "http" | "https";
|
|
200
|
+
path?: string | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
apiKey: string;
|
|
203
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
204
|
+
retryIntervalSeconds?: number | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
nodes: {
|
|
207
|
+
host: string;
|
|
208
|
+
port: number;
|
|
209
|
+
protocol: "http" | "https";
|
|
210
|
+
path?: string | undefined;
|
|
211
|
+
}[];
|
|
212
|
+
apiKey: string;
|
|
213
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
214
|
+
retryIntervalSeconds?: number | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
collection: z.ZodObject<{
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
219
|
+
name: z.ZodString;
|
|
220
|
+
type: z.ZodEnum<["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]>;
|
|
221
|
+
facet: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
index: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
sort: z.ZodOptional<z.ZodBoolean>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
227
|
+
name: string;
|
|
228
|
+
sort?: boolean | undefined;
|
|
229
|
+
facet?: boolean | undefined;
|
|
230
|
+
index?: boolean | undefined;
|
|
231
|
+
optional?: boolean | undefined;
|
|
232
|
+
}, {
|
|
233
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
234
|
+
name: string;
|
|
235
|
+
sort?: boolean | undefined;
|
|
236
|
+
facet?: boolean | undefined;
|
|
237
|
+
index?: boolean | undefined;
|
|
238
|
+
optional?: boolean | undefined;
|
|
239
|
+
}>, "many">;
|
|
240
|
+
default_sorting_field: z.ZodOptional<z.ZodString>;
|
|
241
|
+
}, "strip", z.ZodTypeAny, {
|
|
242
|
+
name: string;
|
|
243
|
+
fields: {
|
|
244
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
245
|
+
name: string;
|
|
246
|
+
sort?: boolean | undefined;
|
|
247
|
+
facet?: boolean | undefined;
|
|
248
|
+
index?: boolean | undefined;
|
|
249
|
+
optional?: boolean | undefined;
|
|
250
|
+
}[];
|
|
251
|
+
default_sorting_field?: string | undefined;
|
|
252
|
+
}, {
|
|
253
|
+
name: string;
|
|
254
|
+
fields: {
|
|
255
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
256
|
+
name: string;
|
|
257
|
+
sort?: boolean | undefined;
|
|
258
|
+
facet?: boolean | undefined;
|
|
259
|
+
index?: boolean | undefined;
|
|
260
|
+
optional?: boolean | undefined;
|
|
261
|
+
}[];
|
|
262
|
+
default_sorting_field?: string | undefined;
|
|
263
|
+
}>;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
ghost: {
|
|
266
|
+
url: string;
|
|
267
|
+
key: string;
|
|
268
|
+
version: "v5.0";
|
|
269
|
+
};
|
|
270
|
+
typesense: {
|
|
271
|
+
nodes: {
|
|
272
|
+
host: string;
|
|
273
|
+
port: number;
|
|
274
|
+
protocol: "http" | "https";
|
|
275
|
+
path?: string | undefined;
|
|
276
|
+
}[];
|
|
277
|
+
apiKey: string;
|
|
278
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
279
|
+
retryIntervalSeconds?: number | undefined;
|
|
280
|
+
};
|
|
281
|
+
collection: {
|
|
282
|
+
name: string;
|
|
283
|
+
fields: {
|
|
284
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
285
|
+
name: string;
|
|
286
|
+
sort?: boolean | undefined;
|
|
287
|
+
facet?: boolean | undefined;
|
|
288
|
+
index?: boolean | undefined;
|
|
289
|
+
optional?: boolean | undefined;
|
|
290
|
+
}[];
|
|
291
|
+
default_sorting_field?: string | undefined;
|
|
292
|
+
};
|
|
293
|
+
}, {
|
|
294
|
+
ghost: {
|
|
295
|
+
url: string;
|
|
296
|
+
key: string;
|
|
297
|
+
version?: "v5.0" | undefined;
|
|
298
|
+
};
|
|
299
|
+
typesense: {
|
|
300
|
+
nodes: {
|
|
301
|
+
host: string;
|
|
302
|
+
port: number;
|
|
303
|
+
protocol: "http" | "https";
|
|
304
|
+
path?: string | undefined;
|
|
305
|
+
}[];
|
|
306
|
+
apiKey: string;
|
|
307
|
+
connectionTimeoutSeconds?: number | undefined;
|
|
308
|
+
retryIntervalSeconds?: number | undefined;
|
|
309
|
+
};
|
|
310
|
+
collection: {
|
|
311
|
+
name: string;
|
|
312
|
+
fields: {
|
|
313
|
+
type: "string" | "float" | "int32" | "int64" | "bool" | "string[]" | "int32[]" | "int64[]" | "float[]" | "bool[]";
|
|
314
|
+
name: string;
|
|
315
|
+
sort?: boolean | undefined;
|
|
316
|
+
facet?: boolean | undefined;
|
|
317
|
+
index?: boolean | undefined;
|
|
318
|
+
optional?: boolean | undefined;
|
|
319
|
+
}[];
|
|
320
|
+
default_sorting_field?: string | undefined;
|
|
321
|
+
};
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Type definitions derived from schemas
|
|
325
|
+
*/
|
|
326
|
+
type GhostConfig = z.infer<typeof GhostConfigSchema>;
|
|
327
|
+
type TypesenseNode = z.infer<typeof TypesenseNodeSchema>;
|
|
328
|
+
type TypesenseConfig = z.infer<typeof TypesenseConfigSchema>;
|
|
329
|
+
type CollectionField = z.infer<typeof CollectionFieldSchema>;
|
|
330
|
+
type CollectionConfig = z.infer<typeof CollectionConfigSchema>;
|
|
331
|
+
type Config = z.infer<typeof ConfigSchema>;
|
|
332
|
+
/**
|
|
333
|
+
* Validates the configuration object against the schema
|
|
334
|
+
* @param config The configuration object to validate
|
|
335
|
+
* @returns The validated configuration object with types
|
|
336
|
+
* @throws {ZodError} If validation fails
|
|
337
|
+
*/
|
|
338
|
+
declare function validateConfig(config: unknown): Config;
|
|
339
|
+
/**
|
|
340
|
+
* Default collection fields that should be included
|
|
341
|
+
*/
|
|
342
|
+
declare const DEFAULT_COLLECTION_FIELDS: CollectionField[];
|
|
343
|
+
/**
|
|
344
|
+
* Creates a default configuration object
|
|
345
|
+
* @param ghostUrl The URL of the Ghost instance
|
|
346
|
+
* @param ghostKey The Ghost Content API key
|
|
347
|
+
* @param typesenseHost The Typesense host
|
|
348
|
+
* @param typesenseApiKey The Typesense API key
|
|
349
|
+
* @param collectionName The name of the collection (defaults to 'posts')
|
|
350
|
+
* @returns A default configuration object
|
|
351
|
+
*/
|
|
352
|
+
declare function createDefaultConfig(ghostUrl: string, ghostKey: string, typesenseHost: string, typesenseApiKey: string, collectionName?: string): Config;
|
|
353
|
+
|
|
354
|
+
export { type CollectionConfig, CollectionConfigSchema, type CollectionField, CollectionFieldSchema, type Config, ConfigSchema, DEFAULT_COLLECTION_FIELDS, type GhostConfig, GhostConfigSchema, type TypesenseConfig, TypesenseConfigSchema, type TypesenseNode, TypesenseNodeSchema, createDefaultConfig, validateConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
CollectionConfigSchema: () => CollectionConfigSchema,
|
|
24
|
+
CollectionFieldSchema: () => CollectionFieldSchema,
|
|
25
|
+
ConfigSchema: () => ConfigSchema,
|
|
26
|
+
DEFAULT_COLLECTION_FIELDS: () => DEFAULT_COLLECTION_FIELDS,
|
|
27
|
+
GhostConfigSchema: () => GhostConfigSchema,
|
|
28
|
+
TypesenseConfigSchema: () => TypesenseConfigSchema,
|
|
29
|
+
TypesenseNodeSchema: () => TypesenseNodeSchema,
|
|
30
|
+
createDefaultConfig: () => createDefaultConfig,
|
|
31
|
+
validateConfig: () => validateConfig
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
var import_zod = require("zod");
|
|
35
|
+
var GhostConfigSchema = import_zod.z.object({
|
|
36
|
+
url: import_zod.z.string().url(),
|
|
37
|
+
key: import_zod.z.string().min(1),
|
|
38
|
+
version: import_zod.z.literal("v5.0").default("v5.0")
|
|
39
|
+
});
|
|
40
|
+
var TypesenseNodeSchema = import_zod.z.object({
|
|
41
|
+
host: import_zod.z.string(),
|
|
42
|
+
port: import_zod.z.number(),
|
|
43
|
+
protocol: import_zod.z.enum(["http", "https"]),
|
|
44
|
+
path: import_zod.z.string().optional()
|
|
45
|
+
});
|
|
46
|
+
var TypesenseConfigSchema = import_zod.z.object({
|
|
47
|
+
nodes: import_zod.z.array(TypesenseNodeSchema).min(1),
|
|
48
|
+
apiKey: import_zod.z.string().min(1),
|
|
49
|
+
connectionTimeoutSeconds: import_zod.z.number().optional(),
|
|
50
|
+
retryIntervalSeconds: import_zod.z.number().optional()
|
|
51
|
+
});
|
|
52
|
+
var CollectionFieldSchema = import_zod.z.object({
|
|
53
|
+
name: import_zod.z.string(),
|
|
54
|
+
type: import_zod.z.enum(["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]),
|
|
55
|
+
facet: import_zod.z.boolean().optional(),
|
|
56
|
+
index: import_zod.z.boolean().optional(),
|
|
57
|
+
optional: import_zod.z.boolean().optional(),
|
|
58
|
+
sort: import_zod.z.boolean().optional()
|
|
59
|
+
});
|
|
60
|
+
var CollectionConfigSchema = import_zod.z.object({
|
|
61
|
+
name: import_zod.z.string(),
|
|
62
|
+
fields: import_zod.z.array(CollectionFieldSchema).min(1),
|
|
63
|
+
default_sorting_field: import_zod.z.string().optional()
|
|
64
|
+
});
|
|
65
|
+
var ConfigSchema = import_zod.z.object({
|
|
66
|
+
ghost: GhostConfigSchema,
|
|
67
|
+
typesense: TypesenseConfigSchema,
|
|
68
|
+
collection: CollectionConfigSchema
|
|
69
|
+
});
|
|
70
|
+
function validateConfig(config) {
|
|
71
|
+
return ConfigSchema.parse(config);
|
|
72
|
+
}
|
|
73
|
+
var DEFAULT_COLLECTION_FIELDS = [
|
|
74
|
+
{ name: "id", type: "string" },
|
|
75
|
+
{ name: "title", type: "string" },
|
|
76
|
+
{ name: "slug", type: "string" },
|
|
77
|
+
{ name: "html", type: "string" },
|
|
78
|
+
{ name: "excerpt", type: "string" },
|
|
79
|
+
{ name: "feature_image", type: "string", optional: true },
|
|
80
|
+
{ name: "published_at", type: "int64" },
|
|
81
|
+
{ name: "updated_at", type: "int64" },
|
|
82
|
+
{ name: "tags", type: "string[]", facet: true, optional: true },
|
|
83
|
+
{ name: "authors", type: "string[]", facet: true, optional: true }
|
|
84
|
+
];
|
|
85
|
+
function createDefaultConfig(ghostUrl, ghostKey, typesenseHost, typesenseApiKey, collectionName = "posts") {
|
|
86
|
+
return {
|
|
87
|
+
ghost: {
|
|
88
|
+
url: ghostUrl,
|
|
89
|
+
key: ghostKey,
|
|
90
|
+
version: "v5.0"
|
|
91
|
+
},
|
|
92
|
+
typesense: {
|
|
93
|
+
nodes: [
|
|
94
|
+
{
|
|
95
|
+
host: typesenseHost,
|
|
96
|
+
port: 443,
|
|
97
|
+
protocol: "https"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
apiKey: typesenseApiKey
|
|
101
|
+
},
|
|
102
|
+
collection: {
|
|
103
|
+
name: collectionName,
|
|
104
|
+
fields: DEFAULT_COLLECTION_FIELDS
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
CollectionConfigSchema,
|
|
111
|
+
CollectionFieldSchema,
|
|
112
|
+
ConfigSchema,
|
|
113
|
+
DEFAULT_COLLECTION_FIELDS,
|
|
114
|
+
GhostConfigSchema,
|
|
115
|
+
TypesenseConfigSchema,
|
|
116
|
+
TypesenseNodeSchema,
|
|
117
|
+
createDefaultConfig,
|
|
118
|
+
validateConfig
|
|
119
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var GhostConfigSchema = z.object({
|
|
4
|
+
url: z.string().url(),
|
|
5
|
+
key: z.string().min(1),
|
|
6
|
+
version: z.literal("v5.0").default("v5.0")
|
|
7
|
+
});
|
|
8
|
+
var TypesenseNodeSchema = z.object({
|
|
9
|
+
host: z.string(),
|
|
10
|
+
port: z.number(),
|
|
11
|
+
protocol: z.enum(["http", "https"]),
|
|
12
|
+
path: z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
var TypesenseConfigSchema = z.object({
|
|
15
|
+
nodes: z.array(TypesenseNodeSchema).min(1),
|
|
16
|
+
apiKey: z.string().min(1),
|
|
17
|
+
connectionTimeoutSeconds: z.number().optional(),
|
|
18
|
+
retryIntervalSeconds: z.number().optional()
|
|
19
|
+
});
|
|
20
|
+
var CollectionFieldSchema = z.object({
|
|
21
|
+
name: z.string(),
|
|
22
|
+
type: z.enum(["string", "int32", "int64", "float", "bool", "string[]", "int32[]", "int64[]", "float[]", "bool[]"]),
|
|
23
|
+
facet: z.boolean().optional(),
|
|
24
|
+
index: z.boolean().optional(),
|
|
25
|
+
optional: z.boolean().optional(),
|
|
26
|
+
sort: z.boolean().optional()
|
|
27
|
+
});
|
|
28
|
+
var CollectionConfigSchema = z.object({
|
|
29
|
+
name: z.string(),
|
|
30
|
+
fields: z.array(CollectionFieldSchema).min(1),
|
|
31
|
+
default_sorting_field: z.string().optional()
|
|
32
|
+
});
|
|
33
|
+
var ConfigSchema = z.object({
|
|
34
|
+
ghost: GhostConfigSchema,
|
|
35
|
+
typesense: TypesenseConfigSchema,
|
|
36
|
+
collection: CollectionConfigSchema
|
|
37
|
+
});
|
|
38
|
+
function validateConfig(config) {
|
|
39
|
+
return ConfigSchema.parse(config);
|
|
40
|
+
}
|
|
41
|
+
var DEFAULT_COLLECTION_FIELDS = [
|
|
42
|
+
{ name: "id", type: "string" },
|
|
43
|
+
{ name: "title", type: "string" },
|
|
44
|
+
{ name: "slug", type: "string" },
|
|
45
|
+
{ name: "html", type: "string" },
|
|
46
|
+
{ name: "excerpt", type: "string" },
|
|
47
|
+
{ name: "feature_image", type: "string", optional: true },
|
|
48
|
+
{ name: "published_at", type: "int64" },
|
|
49
|
+
{ name: "updated_at", type: "int64" },
|
|
50
|
+
{ name: "tags", type: "string[]", facet: true, optional: true },
|
|
51
|
+
{ name: "authors", type: "string[]", facet: true, optional: true }
|
|
52
|
+
];
|
|
53
|
+
function createDefaultConfig(ghostUrl, ghostKey, typesenseHost, typesenseApiKey, collectionName = "posts") {
|
|
54
|
+
return {
|
|
55
|
+
ghost: {
|
|
56
|
+
url: ghostUrl,
|
|
57
|
+
key: ghostKey,
|
|
58
|
+
version: "v5.0"
|
|
59
|
+
},
|
|
60
|
+
typesense: {
|
|
61
|
+
nodes: [
|
|
62
|
+
{
|
|
63
|
+
host: typesenseHost,
|
|
64
|
+
port: 443,
|
|
65
|
+
protocol: "https"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
apiKey: typesenseApiKey
|
|
69
|
+
},
|
|
70
|
+
collection: {
|
|
71
|
+
name: collectionName,
|
|
72
|
+
fields: DEFAULT_COLLECTION_FIELDS
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
CollectionConfigSchema,
|
|
78
|
+
CollectionFieldSchema,
|
|
79
|
+
ConfigSchema,
|
|
80
|
+
DEFAULT_COLLECTION_FIELDS,
|
|
81
|
+
GhostConfigSchema,
|
|
82
|
+
TypesenseConfigSchema,
|
|
83
|
+
TypesenseNodeSchema,
|
|
84
|
+
createDefaultConfig,
|
|
85
|
+
validateConfig
|
|
86
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magicpages/ghost-typesense-config",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Configuration types and utilities for Ghost-Typesense integration",
|
|
5
|
+
"author": "MagicPages",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/magicpages/ghost-typesense.git",
|
|
10
|
+
"directory": "packages/config"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
20
|
+
"clean": "rimraf dist",
|
|
21
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
|
+
"lint": "eslint src --ext .ts",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"zod": "^3.22.4"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.11.17",
|
|
31
|
+
"tsup": "^8.0.1",
|
|
32
|
+
"rimraf": "^5.0.5",
|
|
33
|
+
"vitest": "^1.2.2",
|
|
34
|
+
"typescript": "^5.3.3"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@tryghost/content-api": "^1.11.20",
|
|
38
|
+
"typesense": "^1.7.2"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|