@moxn/kb-migrate 0.4.28 → 0.4.29

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.
@@ -171,11 +171,28 @@ export class NotionApiClient {
171
171
  };
172
172
  if (body)
173
173
  headers['Content-Type'] = 'application/json';
174
- const response = await fetch(`${NOTION_API_BASE}${path}`, {
175
- method,
176
- headers,
177
- body: body ? JSON.stringify(body) : undefined,
178
- });
174
+ let response;
175
+ try {
176
+ response = await fetch(`${NOTION_API_BASE}${path}`, {
177
+ method,
178
+ headers,
179
+ body: body ? JSON.stringify(body) : undefined,
180
+ });
181
+ }
182
+ catch (fetchError) {
183
+ // Network-level failure (DNS, TCP reset, timeout, etc.)
184
+ lastError =
185
+ fetchError instanceof Error
186
+ ? fetchError
187
+ : new Error(String(fetchError));
188
+ if (attempt < MAX_RETRIES) {
189
+ const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
190
+ console.warn(`Network error: ${lastError.message}. Retrying in ${delay}ms (attempt ${attempt + 1}/${MAX_RETRIES})`);
191
+ await sleep(delay);
192
+ continue;
193
+ }
194
+ throw lastError;
195
+ }
179
196
  if (response.ok) {
180
197
  return (await response.json());
181
198
  }
@@ -188,7 +188,7 @@ function convertHeading(block, level) {
188
188
  function convertCode(block) {
189
189
  const c = block;
190
190
  const code = richTextToPlain(c.code.rich_text);
191
- const lang = c.code.language === 'plain text' ? '' : c.code.language;
191
+ const lang = c.code.language === 'plain text' ? 'text' : c.code.language;
192
192
  const caption = richTextToPlain(c.code.caption);
193
193
  let text = '```' + lang + '\n' + code + '\n```';
194
194
  if (caption)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxn/kb-migrate",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "description": "Migration tool for importing documents into Moxn Knowledge Base from local files, Notion, Google Docs, and more",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",