@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.js
CHANGED
|
@@ -84,11 +84,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
84
84
|
var import_react = require("react");
|
|
85
85
|
|
|
86
86
|
// src/client/version.ts
|
|
87
|
-
var SDK_VERSION = "1.
|
|
87
|
+
var SDK_VERSION = "1.1.0";
|
|
88
88
|
|
|
89
89
|
// src/client/constants.ts
|
|
90
90
|
var SDK_HEADER = `react/${SDK_VERSION}`;
|
|
91
|
-
var DEFAULT_BASE_URL = "https://www.fewchurs.
|
|
91
|
+
var DEFAULT_BASE_URL = "https://www.fewchurs.com/api/v1";
|
|
92
92
|
var DEFAULT_PAGE_SIZE = 20;
|
|
93
93
|
var LIMITS = {
|
|
94
94
|
titleMin: 3,
|
|
@@ -127,6 +127,8 @@ function errorFromResponse(status, body) {
|
|
|
127
127
|
switch (code) {
|
|
128
128
|
case "invalid_key":
|
|
129
129
|
return { code: "invalid_key", status: 401, message };
|
|
130
|
+
case "wrong_app":
|
|
131
|
+
return { code: "invalid_key", status: 403, message };
|
|
130
132
|
// missing_device_id is a client mistake the caller fixes the same way a bad field is fixed,
|
|
131
133
|
// so it collapses into validation_failed rather than widening the public union.
|
|
132
134
|
case "missing_device_id":
|
|
@@ -276,6 +278,7 @@ function createFewchursClient(options = {}) {
|
|
|
276
278
|
const deviceId = getDeviceId();
|
|
277
279
|
if (deviceId) result["X-Device-Id"] = deviceId;
|
|
278
280
|
if (options.language) result["Accept-Language"] = options.language;
|
|
281
|
+
if (options.appId) result["X-Fewchurs-App-Id"] = options.appId;
|
|
279
282
|
return result;
|
|
280
283
|
}
|
|
281
284
|
function url(path, query) {
|
|
@@ -314,7 +317,7 @@ function createFewchursClient(options = {}) {
|
|
|
314
317
|
continue;
|
|
315
318
|
}
|
|
316
319
|
const failure = errorFromResponse(response.status, await readJson(response));
|
|
317
|
-
warnAboutKey(failure
|
|
320
|
+
warnAboutKey(failure);
|
|
318
321
|
return { ok: false, error: failure };
|
|
319
322
|
}
|
|
320
323
|
return { ok: false, error: networkError() };
|
|
@@ -406,12 +409,12 @@ function messageOf(error) {
|
|
|
406
409
|
return error instanceof Error ? error.message : "Network request failed.";
|
|
407
410
|
}
|
|
408
411
|
var warnedAboutKey = false;
|
|
409
|
-
function warnAboutKey(
|
|
410
|
-
if (code !== "invalid_key" || warnedAboutKey) return;
|
|
412
|
+
function warnAboutKey(error) {
|
|
413
|
+
if (error.code !== "invalid_key" || warnedAboutKey) return;
|
|
411
414
|
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
412
415
|
warnedAboutKey = true;
|
|
413
416
|
console.error(
|
|
414
|
-
"[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."
|
|
417
|
+
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."
|
|
415
418
|
);
|
|
416
419
|
}
|
|
417
420
|
|
|
@@ -894,7 +897,7 @@ function Branding() {
|
|
|
894
897
|
"a",
|
|
895
898
|
{
|
|
896
899
|
className: cx("fw-link"),
|
|
897
|
-
href: "https://www.fewchurs.
|
|
900
|
+
href: "https://www.fewchurs.com",
|
|
898
901
|
target: "_blank",
|
|
899
902
|
rel: "noreferrer noopener",
|
|
900
903
|
children: labels.poweredBy
|