@magicpages/ghost-typesense-core 1.7.0 → 1.8.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.js CHANGED
@@ -114,7 +114,7 @@ var GhostTypesenseManager = class {
114
114
  }
115
115
  this.config.collection.fields.forEach((field) => {
116
116
  const value = post[field.name];
117
- if (!transformed[field.name] && value !== void 0 && value !== null) {
117
+ if (!(field.name in transformed) && value !== void 0 && value !== null) {
118
118
  transformed[field.name] = value;
119
119
  }
120
120
  });
@@ -130,9 +130,22 @@ var GhostTypesenseManager = class {
130
130
  limit: 15
131
131
  // Default limit in Ghost
132
132
  }).include({ tags: true, authors: true });
133
- const response = await posts.fetch();
133
+ let response;
134
+ try {
135
+ response = await posts.fetch();
136
+ } catch (fetchError) {
137
+ if (fetchError.code === "ECONNREFUSED") {
138
+ throw new Error(`Cannot connect to Ghost at ${this.config.ghost.url} - is Ghost running?`);
139
+ }
140
+ throw new Error(`Failed to connect to Ghost: ${fetchError.message || fetchError}`);
141
+ }
134
142
  if (!response.success) {
135
- throw new Error("Failed to fetch posts from Ghost");
143
+ const errors = response.errors || [];
144
+ const errorMessage = errors.map((e) => e.message || e).join(", ");
145
+ if (errors.some((e) => e.code === "UNKNOWN_CONTENT_API_KEY")) {
146
+ throw new Error(`Invalid Ghost API key: ${errorMessage}`);
147
+ }
148
+ throw new Error(`Ghost API error: ${errorMessage || "Unknown error"}`);
136
149
  }
137
150
  allPosts = allPosts.concat(response.data);
138
151
  const total = response.meta.pagination.total;
package/dist/index.mjs CHANGED
@@ -90,7 +90,7 @@ var GhostTypesenseManager = class {
90
90
  }
91
91
  this.config.collection.fields.forEach((field) => {
92
92
  const value = post[field.name];
93
- if (!transformed[field.name] && value !== void 0 && value !== null) {
93
+ if (!(field.name in transformed) && value !== void 0 && value !== null) {
94
94
  transformed[field.name] = value;
95
95
  }
96
96
  });
@@ -106,9 +106,22 @@ var GhostTypesenseManager = class {
106
106
  limit: 15
107
107
  // Default limit in Ghost
108
108
  }).include({ tags: true, authors: true });
109
- const response = await posts.fetch();
109
+ let response;
110
+ try {
111
+ response = await posts.fetch();
112
+ } catch (fetchError) {
113
+ if (fetchError.code === "ECONNREFUSED") {
114
+ throw new Error(`Cannot connect to Ghost at ${this.config.ghost.url} - is Ghost running?`);
115
+ }
116
+ throw new Error(`Failed to connect to Ghost: ${fetchError.message || fetchError}`);
117
+ }
110
118
  if (!response.success) {
111
- throw new Error("Failed to fetch posts from Ghost");
119
+ const errors = response.errors || [];
120
+ const errorMessage = errors.map((e) => e.message || e).join(", ");
121
+ if (errors.some((e) => e.code === "UNKNOWN_CONTENT_API_KEY")) {
122
+ throw new Error(`Invalid Ghost API key: ${errorMessage}`);
123
+ }
124
+ throw new Error(`Ghost API error: ${errorMessage || "Unknown error"}`);
112
125
  }
113
126
  allPosts = allPosts.concat(response.data);
114
127
  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.7.0",
3
+ "version": "1.8.0",
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.7.0",
27
+ "@magicpages/ghost-typesense-config": "^1.8.0",
28
28
  "@ts-ghost/content-api": "^4.0.6",
29
29
  "@ts-ghost/core-api": "^4.0.6",
30
30
  "typesense": "^1.7.2",