@seed-hypermedia/client 0.0.33 → 0.0.34
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/client.d.ts +1 -1
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type PublishDocumentInput = {
|
|
|
17
17
|
};
|
|
18
18
|
export type SeedClientOptions = {
|
|
19
19
|
fetch?: typeof globalThis.fetch;
|
|
20
|
-
headers?: Record<string, string
|
|
20
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
21
21
|
};
|
|
22
22
|
type PublishBlobsRequest = Extract<HMRequest, {
|
|
23
23
|
key: 'PublishBlobs';
|
package/dist/index.mjs
CHANGED
|
@@ -372,7 +372,7 @@ var QUERY_PARAM_SERIALIZERS = {
|
|
|
372
372
|
function createSeedClient(baseUrl, options) {
|
|
373
373
|
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
|
|
374
374
|
const fetchFn = (options == null ? void 0 : options.fetch) ?? globalThis.fetch;
|
|
375
|
-
const
|
|
375
|
+
const getDefaultHeaders = async () => typeof (options == null ? void 0 : options.headers) === "function" ? await options.headers() : (options == null ? void 0 : options.headers) ?? {};
|
|
376
376
|
async function request(key, input) {
|
|
377
377
|
const requestSchema = HMRequestSchema.options.find((schema) => schema.shape.key.value === key);
|
|
378
378
|
if (!requestSchema) {
|
|
@@ -385,6 +385,7 @@ function createSeedClient(baseUrl, options) {
|
|
|
385
385
|
throw new SeedValidationError(`Invalid input for ${key}: ${err instanceof Error ? err.message : String(err)}`);
|
|
386
386
|
}
|
|
387
387
|
let response;
|
|
388
|
+
const defaultHeaders = await getDefaultHeaders();
|
|
388
389
|
const isAction = HMActionSchema.options.some((s) => s.shape.key.value === key);
|
|
389
390
|
if (isAction) {
|
|
390
391
|
const url = `${normalizedBaseUrl}/api/${key}`;
|