@carlonicora/nextjs-jsonapi 2.2.0 → 2.2.2
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/{BlockNoteEditor-HAUE4EPR.mjs → BlockNoteEditor-ADT6II2V.mjs} +5 -5
- package/dist/{BlockNoteEditor-5TMQ5YCD.js → BlockNoteEditor-QTIDATPF.js} +20 -20
- package/dist/{BlockNoteEditor-5TMQ5YCD.js.map → BlockNoteEditor-QTIDATPF.js.map} +1 -1
- package/dist/{JsonApiRequest-F5LBESSA.mjs → JsonApiRequest-3UWVIIFL.mjs} +2 -2
- package/dist/JsonApiRequest-QRU3IPIU.js +26 -0
- package/dist/{JsonApiRequest-YAPUG4ND.js.map → JsonApiRequest-QRU3IPIU.js.map} +1 -1
- package/dist/billing/index.js +447 -447
- package/dist/billing/index.js.map +1 -1
- package/dist/billing/index.mjs +62 -62
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{chunk-MAWTFEY3.mjs → chunk-7DJOQTNN.mjs} +3 -3
- package/dist/{chunk-P5TMD7GK.mjs → chunk-DLTMYGLR.mjs} +13 -5
- package/dist/chunk-DLTMYGLR.mjs.map +1 -0
- package/dist/{chunk-Z2CB63VG.mjs → chunk-E5YA5Z5X.mjs} +2 -2
- package/dist/chunk-E5YA5Z5X.mjs.map +1 -0
- package/dist/{chunk-HPKCZMQX.js → chunk-F3BPNQDB.js} +743 -739
- package/dist/chunk-F3BPNQDB.js.map +1 -0
- package/dist/{chunk-QWCAOLBD.js → chunk-FPO4DLZN.js} +12 -12
- package/dist/{chunk-QWCAOLBD.js.map → chunk-FPO4DLZN.js.map} +1 -1
- package/dist/{chunk-6YIZX26T.js → chunk-KSU6CCW6.js} +39 -31
- package/dist/chunk-KSU6CCW6.js.map +1 -0
- package/dist/{chunk-JG7MCYCW.js → chunk-LANOKEFZ.js} +9 -9
- package/dist/{chunk-JG7MCYCW.js.map → chunk-LANOKEFZ.js.map} +1 -1
- package/dist/{chunk-PGW2OP3L.mjs → chunk-YEPE2HT6.mjs} +13 -9
- package/dist/chunk-YEPE2HT6.mjs.map +1 -0
- package/dist/client/index.js +5 -5
- package/dist/client/index.mjs +4 -4
- package/dist/components/index.js +5 -5
- package/dist/components/index.mjs +4 -4
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.d.mts +15 -1
- package/dist/core/index.d.ts +15 -1
- package/dist/core/index.js +5 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +4 -2
- package/dist/features/help/index.js +38 -38
- package/dist/features/help/index.mjs +4 -4
- package/dist/features/tokenusage/index.js +72 -72
- package/dist/features/tokenusage/index.mjs +4 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/server/index.js +12 -12
- package/dist/server/index.mjs +2 -2
- package/package.json +1 -1
- package/src/components/containers/RoundPageContainer.tsx +10 -1
- package/src/core/utils/__tests__/translateResponse.test.ts +64 -0
- package/src/core/utils/translateResponse.ts +4 -1
- package/src/features/billing/components/containers/BillingDashboardContainer.tsx +71 -68
- package/src/features/user/components/details/UserStandaloneDetails.tsx +2 -0
- package/src/features/user/components/forms/UserAvatarEditor.tsx +5 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/isRemoteImageSrc.test.ts +29 -0
- package/src/utils/isRemoteImageSrc.ts +16 -0
- package/dist/JsonApiRequest-YAPUG4ND.js +0 -26
- package/dist/chunk-6YIZX26T.js.map +0 -1
- package/dist/chunk-HPKCZMQX.js.map +0 -1
- package/dist/chunk-P5TMD7GK.mjs.map +0 -1
- package/dist/chunk-PGW2OP3L.mjs.map +0 -1
- package/dist/chunk-Z2CB63VG.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-HAUE4EPR.mjs.map → BlockNoteEditor-ADT6II2V.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-F5LBESSA.mjs.map → JsonApiRequest-3UWVIIFL.mjs.map} +0 -0
- /package/dist/{chunk-MAWTFEY3.mjs.map → chunk-7DJOQTNN.mjs.map} +0 -0
|
@@ -7,6 +7,7 @@ import { useEffect, useState } from "react";
|
|
|
7
7
|
import { DropzoneOptions } from "react-dropzone";
|
|
8
8
|
import { FileInput, FileUploader } from "../../../../components";
|
|
9
9
|
import { Button } from "../../../../shadcnui";
|
|
10
|
+
import { isRemoteImageSrc } from "../../../../utils";
|
|
10
11
|
import { UserInterface } from "../../data";
|
|
11
12
|
|
|
12
13
|
type UserAvatarEditorProps = {
|
|
@@ -28,6 +29,8 @@ export function UserAvatarEditor({ user, file, setFile, resetImage, setResetImag
|
|
|
28
29
|
}
|
|
29
30
|
}, [files]);
|
|
30
31
|
|
|
32
|
+
const avatarSrc = file ? URL.createObjectURL(file) : user?.avatar || "";
|
|
33
|
+
|
|
31
34
|
const dropzone = {
|
|
32
35
|
multiple: false,
|
|
33
36
|
maxSize: 100 * 1024 * 1024,
|
|
@@ -48,10 +51,11 @@ export function UserAvatarEditor({ user, file, setFile, resetImage, setResetImag
|
|
|
48
51
|
<FileInput className="bg-muted text-muted-foreground flex h-full w-full flex-col items-center justify-center">
|
|
49
52
|
{!resetImage && (file || user?.avatar) ? (
|
|
50
53
|
<Image
|
|
51
|
-
src={
|
|
54
|
+
src={avatarSrc}
|
|
52
55
|
alt={t(`common.avatar`)}
|
|
53
56
|
width={200}
|
|
54
57
|
height={200}
|
|
58
|
+
unoptimized={isRemoteImageSrc(avatarSrc)}
|
|
55
59
|
/>
|
|
56
60
|
) : (
|
|
57
61
|
<UploadIcon className="my-4 h-8 w-8" />
|
package/src/utils/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { getTableComponents, getTableOptions, TableOptions } from "./table-optio
|
|
|
12
12
|
export { entityObjectSchema, userObjectSchema, type EntityObject, type UserObject } from "./schemas";
|
|
13
13
|
|
|
14
14
|
export { getInitials } from "./getInitials";
|
|
15
|
+
export { isRemoteImageSrc } from "./isRemoteImageSrc";
|
|
15
16
|
export {
|
|
16
17
|
validatePartitaIva,
|
|
17
18
|
validateCodiceFiscale,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { isRemoteImageSrc } from "./isRemoteImageSrc";
|
|
3
|
+
|
|
4
|
+
describe("isRemoteImageSrc", () => {
|
|
5
|
+
it("returns true for an https URL", () => {
|
|
6
|
+
expect(isRemoteImageSrc("https://cdn.discordapp.com/avatars/123/abc.png")).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns true for an http URL", () => {
|
|
10
|
+
expect(isRemoteImageSrc("http://minio.narr8.test:9000/bucket/key.png")).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("returns false for a blob URL", () => {
|
|
14
|
+
expect(isRemoteImageSrc("blob:http://narr8.test:3951/2f8c-4a")).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("returns false for a data URL", () => {
|
|
18
|
+
expect(isRemoteImageSrc("data:image/png;base64,iVBORw0KGgo=")).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("returns false for an app-relative path", () => {
|
|
22
|
+
expect(isRemoteImageSrc("/logo.webp")).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns false for an empty or missing src", () => {
|
|
26
|
+
expect(isRemoteImageSrc("")).toBe(false);
|
|
27
|
+
expect(isRemoteImageSrc(undefined)).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when an image src is an absolute remote URL.
|
|
3
|
+
*
|
|
4
|
+
* `next/image` THROWS when it is given an absolute URL whose hostname is not
|
|
5
|
+
* listed in `images.remotePatterns`, which takes down the whole page through
|
|
6
|
+
* the nearest error boundary. Avatars can come from OAuth providers
|
|
7
|
+
* (Discord, Google, ...), so their hostname is user-controlled and can never
|
|
8
|
+
* be reliably enumerated in config. Pass `unoptimized` for these srcs.
|
|
9
|
+
*
|
|
10
|
+
* `blob:` and `data:` srcs are excluded: `next/image` already marks those
|
|
11
|
+
* unoptimized on its own.
|
|
12
|
+
*/
|
|
13
|
+
export function isRemoteImageSrc(src?: string | null): boolean {
|
|
14
|
+
if (!src) return false;
|
|
15
|
+
return src.startsWith("http://") || src.startsWith("https://");
|
|
16
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkQWCAOLBDjs = require('./chunk-QWCAOLBD.js');
|
|
13
|
-
require('./chunk-7QVYU63E.js');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.JsonApiDelete = _chunkQWCAOLBDjs.JsonApiDelete; exports.JsonApiGet = _chunkQWCAOLBDjs.JsonApiGet; exports.JsonApiPatch = _chunkQWCAOLBDjs.JsonApiPatch; exports.JsonApiPost = _chunkQWCAOLBDjs.JsonApiPost; exports.JsonApiPut = _chunkQWCAOLBDjs.JsonApiPut; exports.buildUrl = _chunkQWCAOLBDjs.buildUrl; exports.configureJsonApi = _chunkQWCAOLBDjs.configureJsonApi; exports.getApiUrl = _chunkQWCAOLBDjs.getApiUrl; exports.getAppUrl = _chunkQWCAOLBDjs.getAppUrl; exports.getTrackablePages = _chunkQWCAOLBDjs.getTrackablePages;
|
|
26
|
-
//# sourceMappingURL=JsonApiRequest-YAPUG4ND.js.map
|