@magicpages/ghost-typesense-core 1.6.3 → 1.7.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.
package/dist/index.d.mts CHANGED
@@ -4,7 +4,6 @@ interface Post {
4
4
  id: string;
5
5
  title: string;
6
6
  slug: string;
7
- url: string;
8
7
  html?: string;
9
8
  plaintext: string;
10
9
  excerpt: string;
@@ -14,7 +13,6 @@ interface Post {
14
13
  'tags.name'?: string[];
15
14
  'tags.slug'?: string[];
16
15
  authors?: string[];
17
- tags?: string[];
18
16
  [key: string]: unknown;
19
17
  }
20
18
  declare class GhostTypesenseManager {
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@ interface Post {
4
4
  id: string;
5
5
  title: string;
6
6
  slug: string;
7
- url: string;
8
7
  html?: string;
9
8
  plaintext: string;
10
9
  excerpt: string;
@@ -14,7 +13,6 @@ interface Post {
14
13
  'tags.name'?: string[];
15
14
  'tags.slug'?: string[];
16
15
  authors?: string[];
17
- tags?: string[];
18
16
  [key: string]: unknown;
19
17
  }
20
18
  declare class GhostTypesenseManager {
package/dist/index.js CHANGED
@@ -92,8 +92,6 @@ var GhostTypesenseManager = class {
92
92
  id: post.id,
93
93
  title: post.title,
94
94
  slug: post.slug,
95
- url: post.url || `${this.config.ghost.url}/${post.slug}/`,
96
- html: post.html || "",
97
95
  plaintext,
98
96
  excerpt: post.excerpt || "",
99
97
  published_at: new Date(post.published_at || Date.now()).getTime(),
@@ -106,7 +104,6 @@ var GhostTypesenseManager = class {
106
104
  if (tags && Array.isArray(tags) && tags.length > 0) {
107
105
  transformed["tags.name"] = tags.map((tag) => tag.name);
108
106
  transformed["tags.slug"] = tags.map((tag) => tag.slug);
109
- transformed.tags = tags.map((tag) => tag.name);
110
107
  }
111
108
  const authors = post.authors;
112
109
  if (authors && Array.isArray(authors) && authors.length > 0) {
@@ -130,9 +127,22 @@ var GhostTypesenseManager = class {
130
127
  limit: 15
131
128
  // Default limit in Ghost
132
129
  }).include({ tags: true, authors: true });
133
- const response = await posts.fetch();
130
+ let response;
131
+ try {
132
+ response = await posts.fetch();
133
+ } catch (fetchError) {
134
+ if (fetchError.code === "ECONNREFUSED") {
135
+ throw new Error(`Cannot connect to Ghost at ${this.config.ghost.url} - is Ghost running?`);
136
+ }
137
+ throw new Error(`Failed to connect to Ghost: ${fetchError.message || fetchError}`);
138
+ }
134
139
  if (!response.success) {
135
- throw new Error("Failed to fetch posts from Ghost");
140
+ const errors = response.errors || [];
141
+ const errorMessage = errors.map((e) => e.message || e).join(", ");
142
+ if (errors.some((e) => e.code === "UNKNOWN_CONTENT_API_KEY")) {
143
+ throw new Error(`Invalid Ghost API key: ${errorMessage}`);
144
+ }
145
+ throw new Error(`Ghost API error: ${errorMessage || "Unknown error"}`);
136
146
  }
137
147
  allPosts = allPosts.concat(response.data);
138
148
  const total = response.meta.pagination.total;
package/dist/index.mjs CHANGED
@@ -68,8 +68,6 @@ var GhostTypesenseManager = class {
68
68
  id: post.id,
69
69
  title: post.title,
70
70
  slug: post.slug,
71
- url: post.url || `${this.config.ghost.url}/${post.slug}/`,
72
- html: post.html || "",
73
71
  plaintext,
74
72
  excerpt: post.excerpt || "",
75
73
  published_at: new Date(post.published_at || Date.now()).getTime(),
@@ -82,7 +80,6 @@ var GhostTypesenseManager = class {
82
80
  if (tags && Array.isArray(tags) && tags.length > 0) {
83
81
  transformed["tags.name"] = tags.map((tag) => tag.name);
84
82
  transformed["tags.slug"] = tags.map((tag) => tag.slug);
85
- transformed.tags = tags.map((tag) => tag.name);
86
83
  }
87
84
  const authors = post.authors;
88
85
  if (authors && Array.isArray(authors) && authors.length > 0) {
@@ -106,9 +103,22 @@ var GhostTypesenseManager = class {
106
103
  limit: 15
107
104
  // Default limit in Ghost
108
105
  }).include({ tags: true, authors: true });
109
- const response = await posts.fetch();
106
+ let response;
107
+ try {
108
+ response = await posts.fetch();
109
+ } catch (fetchError) {
110
+ if (fetchError.code === "ECONNREFUSED") {
111
+ throw new Error(`Cannot connect to Ghost at ${this.config.ghost.url} - is Ghost running?`);
112
+ }
113
+ throw new Error(`Failed to connect to Ghost: ${fetchError.message || fetchError}`);
114
+ }
110
115
  if (!response.success) {
111
- throw new Error("Failed to fetch posts from Ghost");
116
+ const errors = response.errors || [];
117
+ const errorMessage = errors.map((e) => e.message || e).join(", ");
118
+ if (errors.some((e) => e.code === "UNKNOWN_CONTENT_API_KEY")) {
119
+ throw new Error(`Invalid Ghost API key: ${errorMessage}`);
120
+ }
121
+ throw new Error(`Ghost API error: ${errorMessage || "Unknown error"}`);
112
122
  }
113
123
  allPosts = allPosts.concat(response.data);
114
124
  const total = response.meta.pagination.total;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicpages/ghost-typesense-core",
3
- "version": "1.6.3",
3
+ "version": "1.7.1",
4
4
  "description": "Core functionality for Ghost-Typesense integration",
5
5
  "author": "MagicPages",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "typecheck": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "@magicpages/ghost-typesense-config": "^1.6.3",
27
+ "@magicpages/ghost-typesense-config": "^1.7.1",
28
28
  "@ts-ghost/content-api": "^4.0.6",
29
29
  "@ts-ghost/core-api": "^4.0.6",
30
30
  "typesense": "^1.7.2",