@headroom-cms/api 0.1.3 → 0.1.4
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/astro.js +17 -11
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/astro.js
CHANGED
|
@@ -79,7 +79,7 @@ var HeadroomClient = class {
|
|
|
79
79
|
message = body.error || message;
|
|
80
80
|
} catch {
|
|
81
81
|
}
|
|
82
|
-
throw new HeadroomError(res.status, code, message);
|
|
82
|
+
throw new HeadroomError(res.status, code, `${message} (GET ${url})`);
|
|
83
83
|
}
|
|
84
84
|
return res.json();
|
|
85
85
|
}
|
|
@@ -101,7 +101,7 @@ var HeadroomClient = class {
|
|
|
101
101
|
message = errBody.error || message;
|
|
102
102
|
} catch {
|
|
103
103
|
}
|
|
104
|
-
throw new HeadroomError(res.status, code, message);
|
|
104
|
+
throw new HeadroomError(res.status, code, `${message} (POST ${this.apiUrl(path)})`);
|
|
105
105
|
}
|
|
106
106
|
return res.json();
|
|
107
107
|
}
|
|
@@ -216,7 +216,7 @@ function headroomLoader(opts) {
|
|
|
216
216
|
return {
|
|
217
217
|
name: "headroom",
|
|
218
218
|
schema: opts.schema,
|
|
219
|
-
load: async ({ store, meta, generateDigest, parseData }) => {
|
|
219
|
+
load: async ({ store, meta, generateDigest, parseData, logger }) => {
|
|
220
220
|
const config = opts.config || configFromEnv();
|
|
221
221
|
const client = new HeadroomClient(config);
|
|
222
222
|
try {
|
|
@@ -230,14 +230,20 @@ function headroomLoader(opts) {
|
|
|
230
230
|
}
|
|
231
231
|
const allMetadata = [];
|
|
232
232
|
let cursor;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
try {
|
|
234
|
+
do {
|
|
235
|
+
const result = await client.listContent(opts.collection, {
|
|
236
|
+
limit: 1e3,
|
|
237
|
+
cursor
|
|
238
|
+
});
|
|
239
|
+
allMetadata.push(...result.items);
|
|
240
|
+
cursor = result.hasMore ? result.cursor : void 0;
|
|
241
|
+
} while (cursor);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
const msg = `Failed to load Headroom collection "${opts.collection}" from ${config.url}: ${e instanceof Error ? e.message : e}`;
|
|
244
|
+
logger.error(msg);
|
|
245
|
+
throw new Error(msg, { cause: e });
|
|
246
|
+
}
|
|
241
247
|
const seen = /* @__PURE__ */ new Set();
|
|
242
248
|
const storeId = (item) => item.slug || opts.collection;
|
|
243
249
|
if (opts.bodies) {
|
package/dist/index.cjs
CHANGED
|
@@ -106,7 +106,7 @@ var HeadroomClient = class {
|
|
|
106
106
|
message = body.error || message;
|
|
107
107
|
} catch {
|
|
108
108
|
}
|
|
109
|
-
throw new HeadroomError(res.status, code, message);
|
|
109
|
+
throw new HeadroomError(res.status, code, `${message} (GET ${url})`);
|
|
110
110
|
}
|
|
111
111
|
return res.json();
|
|
112
112
|
}
|
|
@@ -128,7 +128,7 @@ var HeadroomClient = class {
|
|
|
128
128
|
message = errBody.error || message;
|
|
129
129
|
} catch {
|
|
130
130
|
}
|
|
131
|
-
throw new HeadroomError(res.status, code, message);
|
|
131
|
+
throw new HeadroomError(res.status, code, `${message} (POST ${this.apiUrl(path)})`);
|
|
132
132
|
}
|
|
133
133
|
return res.json();
|
|
134
134
|
}
|
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ var HeadroomClient = class {
|
|
|
79
79
|
message = body.error || message;
|
|
80
80
|
} catch {
|
|
81
81
|
}
|
|
82
|
-
throw new HeadroomError(res.status, code, message);
|
|
82
|
+
throw new HeadroomError(res.status, code, `${message} (GET ${url})`);
|
|
83
83
|
}
|
|
84
84
|
return res.json();
|
|
85
85
|
}
|
|
@@ -101,7 +101,7 @@ var HeadroomClient = class {
|
|
|
101
101
|
message = errBody.error || message;
|
|
102
102
|
} catch {
|
|
103
103
|
}
|
|
104
|
-
throw new HeadroomError(res.status, code, message);
|
|
104
|
+
throw new HeadroomError(res.status, code, `${message} (POST ${this.apiUrl(path)})`);
|
|
105
105
|
}
|
|
106
106
|
return res.json();
|
|
107
107
|
}
|