@magicpages/ghost-typesense-config 1.1.0 → 1.1.2
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 +33 -90
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @magicpages/ghost-typesense-config
|
|
2
2
|
|
|
3
|
-
Configuration types and utilities for Ghost-Typesense integration.
|
|
3
|
+
Configuration types and utilities for Ghost-Typesense integration.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,8 +11,19 @@ npm install @magicpages/ghost-typesense-config
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
+
import { createDefaultConfig } from '@magicpages/ghost-typesense-config';
|
|
15
|
+
|
|
16
|
+
// Create a config with default schema
|
|
17
|
+
const config = createDefaultConfig(
|
|
18
|
+
'https://your-ghost-blog.com',
|
|
19
|
+
'your-content-api-key',
|
|
20
|
+
'your-typesense-host',
|
|
21
|
+
'your-typesense-api-key',
|
|
22
|
+
'ghost' // collection name
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// Or create a custom config
|
|
14
26
|
import type { Config } from '@magicpages/ghost-typesense-config';
|
|
15
|
-
import { validateConfig } from '@magicpages/ghost-typesense-config';
|
|
16
27
|
|
|
17
28
|
const config: Config = {
|
|
18
29
|
ghost: {
|
|
@@ -26,105 +37,37 @@ const config: Config = {
|
|
|
26
37
|
port: 443,
|
|
27
38
|
protocol: 'https'
|
|
28
39
|
}],
|
|
29
|
-
apiKey: 'your-typesense-api-key'
|
|
30
|
-
connectionTimeoutSeconds: 10,
|
|
31
|
-
retryIntervalSeconds: 0.1
|
|
40
|
+
apiKey: 'your-typesense-api-key'
|
|
32
41
|
},
|
|
33
42
|
collection: {
|
|
34
|
-
name: '
|
|
35
|
-
fields: [
|
|
36
|
-
{ name: 'id', type: 'string' },
|
|
37
|
-
{ name: 'title', type: 'string', index: true, sort: true },
|
|
38
|
-
{ name: 'slug', type: 'string', index: true },
|
|
39
|
-
{ name: 'html', type: 'string', index: true },
|
|
40
|
-
{ name: 'excerpt', type: 'string', index: true },
|
|
41
|
-
{ name: 'feature_image', type: 'string', index: false, optional: true },
|
|
42
|
-
{ name: 'published_at', type: 'int64', sort: true },
|
|
43
|
-
{ name: 'updated_at', type: 'int64', sort: true },
|
|
44
|
-
{ name: 'tags', type: 'string[]', facet: true, optional: true },
|
|
45
|
-
{ name: 'authors', type: 'string[]', facet: true, optional: true }
|
|
46
|
-
]
|
|
43
|
+
name: 'ghost'
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
|
|
50
|
-
// Validate configuration
|
|
51
|
-
const result = validateConfig(config);
|
|
52
|
-
if (!result.success) {
|
|
53
|
-
console.error('Invalid configuration:', result.error);
|
|
54
|
-
}
|
|
55
46
|
```
|
|
56
47
|
|
|
57
|
-
##
|
|
58
|
-
|
|
59
|
-
### `Config`
|
|
60
|
-
|
|
61
|
-
The main configuration type that includes all settings for Ghost and Typesense integration.
|
|
48
|
+
## Types
|
|
62
49
|
|
|
63
50
|
```typescript
|
|
64
51
|
interface Config {
|
|
65
|
-
ghost:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### `TypesenseConfig`
|
|
84
|
-
|
|
85
|
-
Configuration for connecting to Typesense.
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
interface TypesenseConfig {
|
|
89
|
-
nodes: {
|
|
90
|
-
host: string;
|
|
91
|
-
port: number;
|
|
92
|
-
protocol: 'http' | 'https';
|
|
93
|
-
}[];
|
|
94
|
-
apiKey: string;
|
|
95
|
-
connectionTimeoutSeconds?: number;
|
|
96
|
-
retryIntervalSeconds?: number;
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### `CollectionConfig`
|
|
101
|
-
|
|
102
|
-
Configuration for the Typesense collection schema.
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
interface CollectionConfig {
|
|
106
|
-
name: string;
|
|
107
|
-
fields: FieldConfig[];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface FieldConfig {
|
|
111
|
-
name: string;
|
|
112
|
-
type: 'string' | 'int32' | 'int64' | 'float' | 'bool' | 'string[]' | 'int32[]' | 'int64[]' | 'float[]' | 'bool[]';
|
|
113
|
-
index?: boolean;
|
|
114
|
-
sort?: boolean;
|
|
115
|
-
facet?: boolean;
|
|
116
|
-
optional?: boolean;
|
|
52
|
+
ghost: {
|
|
53
|
+
url: string;
|
|
54
|
+
key: string;
|
|
55
|
+
version: string;
|
|
56
|
+
};
|
|
57
|
+
typesense: {
|
|
58
|
+
nodes: {
|
|
59
|
+
host: string;
|
|
60
|
+
port: number;
|
|
61
|
+
protocol: 'http' | 'https';
|
|
62
|
+
}[];
|
|
63
|
+
apiKey: string;
|
|
64
|
+
};
|
|
65
|
+
collection: {
|
|
66
|
+
name: string;
|
|
67
|
+
};
|
|
117
68
|
}
|
|
118
69
|
```
|
|
119
70
|
|
|
120
|
-
## Validation
|
|
121
|
-
|
|
122
|
-
The package uses Zod for runtime type validation of configuration objects. The `validateConfig` function returns a type-safe result that indicates whether the configuration is valid.
|
|
123
|
-
|
|
124
|
-
## TypeScript Support
|
|
125
|
-
|
|
126
|
-
This package is written in TypeScript and includes full type definitions. It uses strict type checking and provides comprehensive type safety for all configuration options.
|
|
127
|
-
|
|
128
71
|
## License
|
|
129
72
|
|
|
130
|
-
MIT
|
|
73
|
+
MIT © [MagicPages](https://www.magicpages.co)
|