@fewchurs/react 1.0.0 → 1.1.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/LICENSE +1 -1
- package/README.md +2 -0
- package/dist/core.d.mts +10 -5
- package/dist/core.d.ts +10 -5
- package/dist/core.js +9 -6
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +9 -6
- package/dist/core.mjs.map +1 -1
- package/dist/index.d.mts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
|
|
6
6
|
// src/client/version.ts
|
|
7
|
-
var SDK_VERSION = "1.
|
|
7
|
+
var SDK_VERSION = "1.1.0";
|
|
8
8
|
|
|
9
9
|
// src/client/constants.ts
|
|
10
10
|
var SDK_HEADER = `react/${SDK_VERSION}`;
|
|
11
|
-
var DEFAULT_BASE_URL = "https://www.fewchurs.
|
|
11
|
+
var DEFAULT_BASE_URL = "https://www.fewchurs.com/api/v1";
|
|
12
12
|
var DEFAULT_PAGE_SIZE = 20;
|
|
13
13
|
var LIMITS = {
|
|
14
14
|
titleMin: 3,
|
|
@@ -47,6 +47,8 @@ function errorFromResponse(status, body) {
|
|
|
47
47
|
switch (code) {
|
|
48
48
|
case "invalid_key":
|
|
49
49
|
return { code: "invalid_key", status: 401, message };
|
|
50
|
+
case "wrong_app":
|
|
51
|
+
return { code: "invalid_key", status: 403, message };
|
|
50
52
|
// missing_device_id is a client mistake the caller fixes the same way a bad field is fixed,
|
|
51
53
|
// so it collapses into validation_failed rather than widening the public union.
|
|
52
54
|
case "missing_device_id":
|
|
@@ -196,6 +198,7 @@ function createFewchursClient(options = {}) {
|
|
|
196
198
|
const deviceId = getDeviceId();
|
|
197
199
|
if (deviceId) result["X-Device-Id"] = deviceId;
|
|
198
200
|
if (options.language) result["Accept-Language"] = options.language;
|
|
201
|
+
if (options.appId) result["X-Fewchurs-App-Id"] = options.appId;
|
|
199
202
|
return result;
|
|
200
203
|
}
|
|
201
204
|
function url(path, query) {
|
|
@@ -234,7 +237,7 @@ function createFewchursClient(options = {}) {
|
|
|
234
237
|
continue;
|
|
235
238
|
}
|
|
236
239
|
const failure = errorFromResponse(response.status, await readJson(response));
|
|
237
|
-
warnAboutKey(failure
|
|
240
|
+
warnAboutKey(failure);
|
|
238
241
|
return { ok: false, error: failure };
|
|
239
242
|
}
|
|
240
243
|
return { ok: false, error: networkError() };
|
|
@@ -326,12 +329,12 @@ function messageOf(error) {
|
|
|
326
329
|
return error instanceof Error ? error.message : "Network request failed.";
|
|
327
330
|
}
|
|
328
331
|
var warnedAboutKey = false;
|
|
329
|
-
function warnAboutKey(
|
|
330
|
-
if (code !== "invalid_key" || warnedAboutKey) return;
|
|
332
|
+
function warnAboutKey(error) {
|
|
333
|
+
if (error.code !== "invalid_key" || warnedAboutKey) return;
|
|
331
334
|
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
332
335
|
warnedAboutKey = true;
|
|
333
336
|
console.error(
|
|
334
|
-
"[fewchurs] The API key was rejected. Check FEWCHURS_API_KEY (server) or the apiKey passed to FewchursProvider, and that the key is active in your Fewchurs dashboard."
|
|
337
|
+
error.status === 403 ? `[fewchurs] ${error.message}` : "[fewchurs] The API key was rejected. Check FEWCHURS_API_KEY (server) or the apiKey passed to FewchursProvider, and that the key is active in your Fewchurs dashboard."
|
|
335
338
|
);
|
|
336
339
|
}
|
|
337
340
|
|
|
@@ -814,7 +817,7 @@ function Branding() {
|
|
|
814
817
|
"a",
|
|
815
818
|
{
|
|
816
819
|
className: cx("fw-link"),
|
|
817
|
-
href: "https://www.fewchurs.
|
|
820
|
+
href: "https://www.fewchurs.com",
|
|
818
821
|
target: "_blank",
|
|
819
822
|
rel: "noreferrer noopener",
|
|
820
823
|
children: labels.poweredBy
|