@burdenoff/microfe-eventfullymanaged 2026.1102.4 → 2026.1102.5
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/eventfullymanaged/components/ImageUploadField.d.ts +7 -5
- package/dist/eventfullymanaged/components/ImageUploadField.d.ts.map +1 -1
- package/dist/eventfullymanaged/components/ImageUploadField.js +39 -48
- package/dist/eventfullymanaged/components/ImageUploadField.js.map +1 -1
- package/dist/eventfullymanaged/components/ResolvedImage.d.ts +16 -0
- package/dist/eventfullymanaged/components/ResolvedImage.d.ts.map +1 -0
- package/dist/eventfullymanaged/components/ResolvedImage.js +18 -0
- package/dist/eventfullymanaged/components/ResolvedImage.js.map +1 -0
- package/dist/eventfullymanaged/hooks/useResolvedImageUrl.d.ts +44 -0
- package/dist/eventfullymanaged/hooks/useResolvedImageUrl.d.ts.map +1 -0
- package/dist/eventfullymanaged/hooks/useResolvedImageUrl.js +106 -0
- package/dist/eventfullymanaged/hooks/useResolvedImageUrl.js.map +1 -0
- package/dist/eventfullymanaged/lib/fileRef.d.ts +25 -0
- package/dist/eventfullymanaged/lib/fileRef.d.ts.map +1 -0
- package/dist/eventfullymanaged/lib/fileRef.js +15 -0
- package/dist/eventfullymanaged/lib/fileRef.js.map +1 -0
- package/dist/eventfullymanaged/pages/modules/SponsorDetailsPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/modules/SponsorDetailsPage.js +81 -80
- package/dist/eventfullymanaged/pages/modules/SponsorDetailsPage.js.map +1 -1
- package/dist/eventfullymanaged/pages/modules/VenueResourcesPage.js +1 -1
- package/dist/eventfullymanaged/pages/modules/VenueResourcesPage.js.map +1 -1
- package/dist/eventfullymanaged/pages/speakers/SpeakersPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/speakers/SpeakersPage.js +73 -73
- package/dist/eventfullymanaged/pages/speakers/SpeakersPage.js.map +1 -1
- package/dist/eventfullymanaged/pages/sponsors/SponsorsListPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/sponsors/SponsorsListPage.js +97 -96
- package/dist/eventfullymanaged/pages/sponsors/SponsorsListPage.js.map +1 -1
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js +173 -134
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js.map +1 -1
- package/dist/eventfullymanaged/pages/venues/VenueDetailPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/venues/VenueDetailPage.js +96 -94
- package/dist/eventfullymanaged/pages/venues/VenueDetailPage.js.map +1 -1
- package/dist/node_modules/@apollo/client/react/hooks/useQuery.js.map +1 -1
- package/dist/node_modules/@apollo/client/react/hooks/useSyncExternalStore.js.map +1 -1
- package/dist/utils/pageContext.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
interface ImageUploadFieldProps {
|
|
2
2
|
/** Files-svc folder path the upload is stored under, e.g. "/EventfullyManaged/FloorPlans". */
|
|
3
3
|
folderPath: string;
|
|
4
|
-
/** Current persisted image
|
|
4
|
+
/** Current persisted image value (a `files:<id>` reference or a URL), rendered as a preview. */
|
|
5
5
|
value?: string | null;
|
|
6
|
-
/** Called with the
|
|
7
|
-
onUploaded: (
|
|
6
|
+
/** Called with the stored `files:<id>` reference once the upload completes. */
|
|
7
|
+
onUploaded: (ref: string) => void | Promise<void>;
|
|
8
8
|
/** Accessible label for the control. */
|
|
9
9
|
label: string;
|
|
10
10
|
/** Optional helper text shown under the control. */
|
|
@@ -16,8 +16,10 @@ interface ImageUploadFieldProps {
|
|
|
16
16
|
* Reusable image upload control backed by wspace-files-svc via the shared
|
|
17
17
|
* `uploadBlobToFiles` storage helper (presigned 3-step upload). It never keeps a
|
|
18
18
|
* local blob store — on select it ensures the destination folder, uploads the
|
|
19
|
-
* blob,
|
|
20
|
-
*
|
|
19
|
+
* blob, and hands a stable `files:<fileId>` reference back to the caller to
|
|
20
|
+
* persist through the entity's own mutation. Presigned URLs are never stored:
|
|
21
|
+
* S3 caps them at 7 days, so the UI resolves the reference at render time
|
|
22
|
+
* (see `lib/fileRef` and `ResolvedImage`).
|
|
21
23
|
*/
|
|
22
24
|
export declare function ImageUploadField({ folderPath, value, onUploaded, label, hint, className, disabled, }: ImageUploadFieldProps): import("react").JSX.Element;
|
|
23
25
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploadField.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/components/ImageUploadField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageUploadField.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/components/ImageUploadField.tsx"],"names":[],"mappings":"AAyBA,UAAU,qBAAqB;IAC7B,8FAA8F;IAC9F,UAAU,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+EAA+E;IAC/E,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,KAAK,EACL,UAAU,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EACT,QAAgB,GACjB,EAAE,qBAAqB,+BAoFvB"}
|
|
@@ -1,86 +1,77 @@
|
|
|
1
1
|
import { gql as e } from "../../node_modules/graphql-tag/lib/index.js";
|
|
2
2
|
import { useApolloClient as t } from "../../node_modules/@apollo/client/react/hooks/useApolloClient.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { toFileRef as n } from "../lib/fileRef.js";
|
|
4
|
+
import { notify as r } from "../lib/toast.js";
|
|
5
|
+
import { ResolvedImage as i } from "./ResolvedImage.js";
|
|
6
|
+
import { useId as a, useRef as o, useState as s } from "react";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
import { ImagePlus as u, Loader2 as d, Upload as f } from "lucide-react";
|
|
9
|
+
import { Button as p } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
import { uploadBlobToFiles as m } from "@burdenoff/fe-libs/storage";
|
|
9
11
|
// src/eventfullymanaged/components/ImageUploadField.tsx
|
|
10
|
-
var
|
|
12
|
+
var h = e`
|
|
11
13
|
mutation EventfullymanagedEnsureFolder($path: String!) {
|
|
12
14
|
ensureFolderByPath(path: $path) {
|
|
13
15
|
id
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
query EventfullymanagedGetFileDownloadUrl($id: ID!, $expiresIn: Int) {
|
|
18
|
-
getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
|
|
19
|
-
}
|
|
20
|
-
`, h = 31536e3;
|
|
18
|
+
`;
|
|
21
19
|
function g({ folderPath: e, value: g, onUploaded: _, label: v, hint: y, className: b, disabled: x = !1 }) {
|
|
22
|
-
let S = t(), C =
|
|
23
|
-
let
|
|
24
|
-
if (t.target.value = "",
|
|
25
|
-
if (!
|
|
20
|
+
let S = t(), C = o(null), w = a(), [T, E] = s(!1), D = async (t) => {
|
|
21
|
+
let i = t.target.files?.[0];
|
|
22
|
+
if (t.target.value = "", i) {
|
|
23
|
+
if (!i.type.startsWith("image/")) r.error("Unsupported file", "Please choose an image file.");
|
|
26
24
|
else {
|
|
27
25
|
E(!0);
|
|
28
26
|
try {
|
|
29
27
|
let t = await S.mutate({
|
|
30
|
-
mutation:
|
|
28
|
+
mutation: h,
|
|
31
29
|
variables: { path: e }
|
|
32
|
-
}),
|
|
33
|
-
if (!
|
|
34
|
-
let
|
|
30
|
+
}), a = t.data?.ensureFolderByPath?.id;
|
|
31
|
+
if (!a) throw Error(t.error?.message ?? "Could not resolve the upload folder.");
|
|
32
|
+
let o = await m({
|
|
35
33
|
client: S,
|
|
36
|
-
blob:
|
|
37
|
-
filename:
|
|
38
|
-
mimeType:
|
|
39
|
-
folderId:
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
variables: {
|
|
43
|
-
id: a.id,
|
|
44
|
-
expiresIn: h
|
|
45
|
-
},
|
|
46
|
-
fetchPolicy: "no-cache"
|
|
47
|
-
})).data?.getFileDownloadUrl;
|
|
48
|
-
if (!o) throw Error("The file was uploaded but no download URL was returned.");
|
|
49
|
-
await _(o), n.success("Image uploaded");
|
|
34
|
+
blob: i,
|
|
35
|
+
filename: i.name,
|
|
36
|
+
mimeType: i.type || "application/octet-stream",
|
|
37
|
+
folderId: a
|
|
38
|
+
});
|
|
39
|
+
await _(n(o.id)), r.success("Image uploaded");
|
|
50
40
|
} catch (e) {
|
|
51
|
-
|
|
41
|
+
r.error("Upload failed", e instanceof Error ? e.message : "Please try again.");
|
|
52
42
|
} finally {
|
|
53
43
|
E(!1);
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
46
|
}
|
|
57
47
|
};
|
|
58
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ l("div", {
|
|
59
49
|
className: b,
|
|
60
|
-
children: [/* @__PURE__ */
|
|
50
|
+
children: [/* @__PURE__ */ l("div", {
|
|
61
51
|
className: "flex items-center gap-4",
|
|
62
|
-
children: [
|
|
63
|
-
|
|
52
|
+
children: [/* @__PURE__ */ c(i, {
|
|
53
|
+
value: g,
|
|
64
54
|
alt: v,
|
|
65
|
-
className: "h-16 w-16 shrink-0 rounded-card border border-border-seam object-cover"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
className: "h-16 w-16 shrink-0 rounded-card border border-border-seam object-cover",
|
|
56
|
+
fallback: /* @__PURE__ */ c("div", {
|
|
57
|
+
className: "flex h-16 w-16 shrink-0 items-center justify-center rounded-card border border-dashed border-border-default bg-bg-surface text-text-secondary",
|
|
58
|
+
children: /* @__PURE__ */ c(u, { className: "h-5 w-5" })
|
|
59
|
+
})
|
|
60
|
+
}), /* @__PURE__ */ l("div", {
|
|
70
61
|
className: "space-y-1",
|
|
71
|
-
children: [/* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ l(p, {
|
|
72
63
|
type: "button",
|
|
73
64
|
variant: "secondary",
|
|
74
65
|
size: "sm",
|
|
75
66
|
disabled: x || T,
|
|
76
67
|
onClick: () => C.current?.click(),
|
|
77
|
-
children: [T ? /* @__PURE__ */
|
|
78
|
-
}), y ? /* @__PURE__ */
|
|
68
|
+
children: [T ? /* @__PURE__ */ c(d, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ c(f, { className: "h-4 w-4" }), T ? "Uploading..." : g ? "Replace image" : v]
|
|
69
|
+
}), y ? /* @__PURE__ */ c("p", {
|
|
79
70
|
className: "text-xs text-text-secondary",
|
|
80
71
|
children: y
|
|
81
72
|
}) : null]
|
|
82
73
|
})]
|
|
83
|
-
}), /* @__PURE__ */
|
|
74
|
+
}), /* @__PURE__ */ c("input", {
|
|
84
75
|
ref: C,
|
|
85
76
|
id: w,
|
|
86
77
|
type: "file",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploadField.js","names":["ENSURE_FOLDER","
|
|
1
|
+
{"version":3,"file":"ImageUploadField.js","names":["ENSURE_FOLDER","ImageUploadField","client","useApolloClient","inputRef","useRef","inputId","useId","uploading","setUploading","useState","handleSelect","file","event","folderResult","folderPath","folderId","uploaded","uploadBlobToFiles","onUploaded","toFileRef","notify","error","ResolvedImage","label","ImagePlus","Button","disabled","Loader2","Upload","value","hint"],"sources":["../../../src/eventfullymanaged/components/ImageUploadField.tsx"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { uploadBlobToFiles } from '@burdenoff/fe-libs/storage';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { ImagePlus, Loader2, Upload } from 'lucide-react';\nimport { useId, useRef, useState } from 'react';\n\nimport { toFileRef } from '../lib/fileRef';\nimport { notify } from '../lib/toast';\nimport { ResolvedImage } from './ResolvedImage';\n\n// wspace-files requires a real folder id (File.folderId FK) — resolve/create the\n// destination folder by path before uploading.\nconst ENSURE_FOLDER = gql`\n mutation EventfullymanagedEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) {\n id\n }\n }\n`;\n\ninterface EnsureFolderResponse {\n ensureFolderByPath?: { id: string } | null;\n}\n\ninterface ImageUploadFieldProps {\n /** Files-svc folder path the upload is stored under, e.g. \"/EventfullyManaged/FloorPlans\". */\n folderPath: string;\n /** Current persisted image value (a `files:<id>` reference or a URL), rendered as a preview. */\n value?: string | null;\n /** Called with the stored `files:<id>` reference once the upload completes. */\n onUploaded: (ref: string) => void | Promise<void>;\n /** Accessible label for the control. */\n label: string;\n /** Optional helper text shown under the control. */\n hint?: string;\n className?: string;\n disabled?: boolean;\n}\n\n/**\n * Reusable image upload control backed by wspace-files-svc via the shared\n * `uploadBlobToFiles` storage helper (presigned 3-step upload). It never keeps a\n * local blob store — on select it ensures the destination folder, uploads the\n * blob, and hands a stable `files:<fileId>` reference back to the caller to\n * persist through the entity's own mutation. Presigned URLs are never stored:\n * S3 caps them at 7 days, so the UI resolves the reference at render time\n * (see `lib/fileRef` and `ResolvedImage`).\n */\nexport function ImageUploadField({\n folderPath,\n value,\n onUploaded,\n label,\n hint,\n className,\n disabled = false,\n}: ImageUploadFieldProps) {\n const client = useApolloClient();\n const inputRef = useRef<HTMLInputElement | null>(null);\n const inputId = useId();\n const [uploading, setUploading] = useState(false);\n\n const handleSelect = async (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Reset the input so selecting the same file again re-triggers change.\n event.target.value = '';\n if (!file) {\n return;\n }\n if (!file.type.startsWith('image/')) {\n notify.error('Unsupported file', 'Please choose an image file.');\n return;\n }\n\n setUploading(true);\n try {\n const folderResult = await client.mutate<EnsureFolderResponse>({\n mutation: ENSURE_FOLDER,\n variables: { path: folderPath },\n });\n const folderId = folderResult.data?.ensureFolderByPath?.id;\n if (!folderId) {\n throw new Error(folderResult.error?.message ?? 'Could not resolve the upload folder.');\n }\n\n const uploaded = await uploadBlobToFiles({\n client,\n blob: file,\n filename: file.name,\n mimeType: file.type || 'application/octet-stream',\n folderId,\n });\n\n await onUploaded(toFileRef(uploaded.id));\n notify.success('Image uploaded');\n } catch (error) {\n notify.error('Upload failed', error instanceof Error ? error.message : 'Please try again.');\n } finally {\n setUploading(false);\n }\n };\n\n return (\n <div className={className}>\n <div className=\"flex items-center gap-4\">\n <ResolvedImage\n value={value}\n alt={label}\n className=\"h-16 w-16 shrink-0 rounded-card border border-border-seam object-cover\"\n fallback={\n <div className=\"flex h-16 w-16 shrink-0 items-center justify-center rounded-card border border-dashed border-border-default bg-bg-surface text-text-secondary\">\n <ImagePlus className=\"h-5 w-5\" />\n </div>\n }\n />\n <div className=\"space-y-1\">\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n disabled={disabled || uploading}\n onClick={() => inputRef.current?.click()}\n >\n {uploading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : <Upload className=\"h-4 w-4\" />}\n {uploading ? 'Uploading...' : value ? 'Replace image' : label}\n </Button>\n {hint ? <p className=\"text-xs text-text-secondary\">{hint}</p> : null}\n </div>\n </div>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n accept=\"image/*\"\n className=\"sr-only\"\n aria-label={label}\n onChange={(event) => void handleSelect(event)}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAMA,IAAgB,CAAG;;;;;;;AAoCzB,SAAgBC,EAAiB,EAC/B,eACA,UACA,eACA,UACA,SACA,cACA,cAAW,MACa;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,MAAM;KALzC,UAAA,CAOGI,IAAY,kBAACoB,GAAD,EAAS,WAAU,uBAAwB,CAAA,IAAI,kBAACC,GAAD,EAAQ,WAAU,UAAW,CAAA,GACxFrB,IAAY,iBAAiBsB,IAAQ,kBAAkBN,CAClD;IACP,CAAA,GAAAO,IAAO,kBAAC,KAAD;KAAG,WAAU;KAA+B,UAAAA;IAAQ,CAAA,IAAI,IAC7D;GACF,CAAA,CAAA;EACL,CAAA,GAAA,kBAAC,SAAD;GACE,KAAK3B;GACL,IAAIE;GACJ,MAAK;GACL,QAAO;GACP,WAAU;GACV,cAAYkB;GACZ,WAAW,MAAU,KAAKb,EAAaE,CAAK;EAC7C,CAAA,CACE;;AAET"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ImgHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type ResolvedImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'> & {
|
|
4
|
+
/** Stored image value: a `files:<id>` reference or a plain URL. */
|
|
5
|
+
value: string | null | undefined;
|
|
6
|
+
/** Rendered while resolving, when there is no image, or when it fails to load. */
|
|
7
|
+
fallback?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* `<img>` for an image stored on an EventfullyManaged entity. Resolves
|
|
11
|
+
* `files:<id>` references to a fresh signed URL (see `lib/fileRef`) and falls
|
|
12
|
+
* back gracefully while loading or when the file cannot be resolved.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ResolvedImage({ value, fallback, alt, onError, ...imgProps }: ResolvedImageProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=ResolvedImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedImage.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/components/ResolvedImage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI1D,KAAK,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,GAAG;IAC3E,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,EAAE,kBAAkB,+BAmBtG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useResolvedImageUrl as e } from "../hooks/useResolvedImageUrl.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
4
|
+
// src/eventfullymanaged/components/ResolvedImage.tsx
|
|
5
|
+
function i({ value: i, fallback: a = null, alt: o, onError: s, ...c }) {
|
|
6
|
+
let { url: l } = e(i), [u, d] = t(null);
|
|
7
|
+
return !l || u === l ? /* @__PURE__ */ r(n, { children: a }) : /* @__PURE__ */ r("img", {
|
|
8
|
+
...c,
|
|
9
|
+
src: l,
|
|
10
|
+
alt: o ?? "",
|
|
11
|
+
onError: (e) => {
|
|
12
|
+
d(l), s?.(e);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export { i as ResolvedImage };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=ResolvedImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedImage.js","names":["_Fragment","ResolvedImage","imgProps","useResolvedImageUrl","value","failedUrl","setFailedUrl","useState","url","Fragment","fallback","alt","onError","event"],"sources":["../../../src/eventfullymanaged/components/ResolvedImage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { ImgHTMLAttributes, ReactNode } from 'react';\n\nimport { useResolvedImageUrl } from '../hooks/useResolvedImageUrl';\n\ntype ResolvedImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'> & {\n /** Stored image value: a `files:<id>` reference or a plain URL. */\n value: string | null | undefined;\n /** Rendered while resolving, when there is no image, or when it fails to load. */\n fallback?: ReactNode;\n};\n\n/**\n * `<img>` for an image stored on an EventfullyManaged entity. Resolves\n * `files:<id>` references to a fresh signed URL (see `lib/fileRef`) and falls\n * back gracefully while loading or when the file cannot be resolved.\n */\nexport function ResolvedImage({ value, fallback = null, alt, onError, ...imgProps }: ResolvedImageProps) {\n const { url } = useResolvedImageUrl(value);\n const [failedUrl, setFailedUrl] = useState<string | null>(null);\n\n if (!url || failedUrl === url) {\n return <>{fallback}</>;\n }\n\n return (\n <img\n {...imgProps}\n src={url}\n alt={alt ?? ''}\n onError={(event) => {\n setFailedUrl(url);\n onError?.(event);\n }}\n />\n );\n}\n"],"mappings":";;;;AAiBA,SAAgBC,EAAc,EAAE,UAAO,cAAW,MAAM,QAAK,YAAS,GAAGC,KAAgC;CACvG,IAAM,EAAE,WAAQC,EAAoBC,CAAK,GACnC,CAACC,GAAWC,KAAgBC,EAAwB,IAAI;CAM9D,OAJI,CAACC,KAAOH,MAAcG,IACjB,kBAAAR,GAAA,EAAA,UAAGU,EAAW,CAAA,IAIrB,kBAAC,OAAD;EACE,GAAIR;EACJ,KAAKM;EACL,KAAKG,KAAO;EACZ,UAAU,MAAU;GAElB,AADAL,EAAaE,CAAG,GAChBI,IAAUC,CAAK;EACjB;CACD,CAAA;AAEL"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export declare const GET_FILE_DOWNLOAD_URL: import('graphql').DocumentNode;
|
|
4
|
+
export type CacheEntry = {
|
|
5
|
+
url: string;
|
|
6
|
+
mintedAt: number;
|
|
7
|
+
};
|
|
8
|
+
/** Clears the resolver cache. Exported for tests. */
|
|
9
|
+
export declare function resetResolvedImageUrlCache(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Mints a short-lived signed download URL for a files-svc file id. Concurrent
|
|
12
|
+
* callers for the same file share one request, and a fresh URL is reused for
|
|
13
|
+
* half its lifetime so lists of thumbnails do not hammer files-svc.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveFileDownloadUrl(client: Pick<ApolloClient, 'query'>, fileId: string): Promise<string | null>;
|
|
16
|
+
/**
|
|
17
|
+
* When a mounted consumer should renew its cached URL, and when that URL
|
|
18
|
+
* expires. Renewal happens once the URL leaves its reuse window; after a failed
|
|
19
|
+
* renewal it is retried every minute for as long as the URL is still valid.
|
|
20
|
+
* Exported for tests.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renewalSchedule(entry: CacheEntry, renewFailedAt: number, now: number): {
|
|
23
|
+
renewInMs: number | null;
|
|
24
|
+
expiresInMs: number;
|
|
25
|
+
};
|
|
26
|
+
export interface ResolvedImageUrl {
|
|
27
|
+
/** A URL an `<img>` can load, or null while resolving / when unavailable. */
|
|
28
|
+
url: string | null;
|
|
29
|
+
loading: boolean;
|
|
30
|
+
/** True when files-svc could not mint a URL for the referenced file. */
|
|
31
|
+
failed: boolean;
|
|
32
|
+
/** Asks files-svc again after a failure. A no-op for plain URLs. */
|
|
33
|
+
retry: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Turns a stored image value into something an `<img>` can render: `files:<id>`
|
|
37
|
+
* references are resolved to a signed URL; plain URLs are returned as-is.
|
|
38
|
+
*
|
|
39
|
+
* While a consumer stays mounted its URL is renewed in place once it passes the
|
|
40
|
+
* reuse window, so a page left open for hours (or an image that only starts
|
|
41
|
+
* loading when it scrolls into view) never renders an expired signed URL.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useResolvedImageUrl(value: string | null | undefined): ResolvedImageUrl;
|
|
44
|
+
//# sourceMappingURL=useResolvedImageUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedImageUrl.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/hooks/useResolvedImageUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMnD,eAAO,MAAM,qBAAqB,gCAIjC,CAAC;AAeF,MAAM,MAAM,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB3D,qDAAqD;AACrD,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD;AAUD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EACnC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8BxB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,GACV;IAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAQnD;AAED,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAgFtF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { gql as e } from "../../node_modules/graphql-tag/lib/index.js";
|
|
2
|
+
import { useApolloClient as t } from "../../node_modules/@apollo/client/react/hooks/useApolloClient.js";
|
|
3
|
+
import { FILE_URL_TTL_SECONDS as n, parseFileRef as r } from "../lib/fileRef.js";
|
|
4
|
+
import { useCallback as i, useEffect as a, useState as o, useSyncExternalStore as s } from "react";
|
|
5
|
+
// src/eventfullymanaged/hooks/useResolvedImageUrl.ts
|
|
6
|
+
var c = e`
|
|
7
|
+
query EventfullymanagedGetFileDownloadUrl($id: ID!, $expiresIn: Int) {
|
|
8
|
+
getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
|
|
9
|
+
}
|
|
10
|
+
`, l = n * 1e3 / 2, u = n * 1e3, d = 6e4, f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
|
|
11
|
+
function h() {
|
|
12
|
+
for (let e of m) e();
|
|
13
|
+
}
|
|
14
|
+
function g(e) {
|
|
15
|
+
return m.add(e), () => {
|
|
16
|
+
m.delete(e);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function _(e, t) {
|
|
20
|
+
let n = f.get(e);
|
|
21
|
+
return !n || t - n.mintedAt > l ? null : n.url;
|
|
22
|
+
}
|
|
23
|
+
async function v(e, t) {
|
|
24
|
+
let n = _(t, Date.now());
|
|
25
|
+
if (n) return n;
|
|
26
|
+
let r = p.get(t);
|
|
27
|
+
if (r) return r;
|
|
28
|
+
let i = (async () => {
|
|
29
|
+
try {
|
|
30
|
+
let n = (await e.query({
|
|
31
|
+
query: c,
|
|
32
|
+
variables: {
|
|
33
|
+
id: t,
|
|
34
|
+
expiresIn: 21600
|
|
35
|
+
},
|
|
36
|
+
fetchPolicy: "no-cache"
|
|
37
|
+
})).data?.getFileDownloadUrl ?? null;
|
|
38
|
+
return n && (f.set(t, {
|
|
39
|
+
url: n,
|
|
40
|
+
mintedAt: Date.now()
|
|
41
|
+
}), h()), n;
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
} finally {
|
|
45
|
+
p.delete(t);
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
return p.set(t, i), i;
|
|
49
|
+
}
|
|
50
|
+
function y(e, t, n) {
|
|
51
|
+
let r = e.mintedAt + u, i = t >= e.mintedAt ? t + d : e.mintedAt + l + 1;
|
|
52
|
+
return {
|
|
53
|
+
renewInMs: i < r ? Math.max(0, i - n) : null,
|
|
54
|
+
expiresInMs: Math.max(0, r - n)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function b(e) {
|
|
58
|
+
let n = t(), c = r(e), l = !c && e ? e : null, u = i(() => c ? f.get(c) ?? null : null, [c]), d = s(g, u, u), [p, m] = o(null), [h, _] = o(0), [b, x] = o(null), [S, C] = o(0);
|
|
59
|
+
a(() => {
|
|
60
|
+
if (!c) return;
|
|
61
|
+
let e = !0, t = () => {
|
|
62
|
+
v(n, c).then((t) => {
|
|
63
|
+
e && (m(t ? null : c), t ? C(0) : f.has(c) && C(Date.now()));
|
|
64
|
+
});
|
|
65
|
+
}, r, i, a = f.get(c);
|
|
66
|
+
if (a) {
|
|
67
|
+
let n = y(a, S, Date.now());
|
|
68
|
+
n.renewInMs !== null && (r = setTimeout(t, n.renewInMs)), i = setTimeout(() => {
|
|
69
|
+
e && x(a);
|
|
70
|
+
}, n.expiresInMs);
|
|
71
|
+
} else t();
|
|
72
|
+
return () => {
|
|
73
|
+
e = !1, clearTimeout(r), clearTimeout(i);
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
n,
|
|
77
|
+
c,
|
|
78
|
+
d,
|
|
79
|
+
h,
|
|
80
|
+
S
|
|
81
|
+
]);
|
|
82
|
+
let w = i(() => {
|
|
83
|
+
m(null), C(0), _((e) => e + 1);
|
|
84
|
+
}, []);
|
|
85
|
+
if (!c) return {
|
|
86
|
+
url: l,
|
|
87
|
+
loading: !1,
|
|
88
|
+
failed: !1,
|
|
89
|
+
retry: w
|
|
90
|
+
};
|
|
91
|
+
let T = p === c;
|
|
92
|
+
return d && d !== b ? {
|
|
93
|
+
url: d.url,
|
|
94
|
+
loading: !1,
|
|
95
|
+
failed: !1,
|
|
96
|
+
retry: w
|
|
97
|
+
} : {
|
|
98
|
+
url: null,
|
|
99
|
+
loading: !T,
|
|
100
|
+
failed: T,
|
|
101
|
+
retry: w
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export { c as GET_FILE_DOWNLOAD_URL, y as renewalSchedule, v as resolveFileDownloadUrl, b as useResolvedImageUrl };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=useResolvedImageUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedImageUrl.js","names":["GET_FILE_DOWNLOAD_URL","REUSE_WINDOW_MS","FILE_URL_TTL_SECONDS","URL_LIFETIME_MS","RENEW_RETRY_MS","urlCache","inFlight","listeners","notifyListeners","listener","subscribe","cachedUrl","entry","fileId","now","resolveFileDownloadUrl","cached","pending","request","url","client","renewalSchedule","expiresAt","renewAt","renewFailedAt","useResolvedImageUrl","useApolloClient","parseFileRef","value","passthrough","getSnapshot","useCallback","useSyncExternalStore","failedFileId","setFailedFileId","useState","attempt","setAttempt","expiredEntry","setExpiredEntry","setRenewFailedAt","active","resolve","renewTimer","expiryTimer","current","schedule","retry","failed"],"sources":["../../../src/eventfullymanaged/hooks/useResolvedImageUrl.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport type { ApolloClient } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\n\nimport { FILE_URL_TTL_SECONDS, parseFileRef } from '../lib/fileRef';\n\nexport const GET_FILE_DOWNLOAD_URL = gql`\n query EventfullymanagedGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n`;\n\ninterface DownloadUrlResponse {\n getFileDownloadUrl?: string | null;\n}\n\n/** Re-mint a URL once it is older than this (well inside its 6h lifetime). */\nconst REUSE_WINDOW_MS = (FILE_URL_TTL_SECONDS * 1000) / 2;\n\n/** How long a minted URL stays valid. */\nconst URL_LIFETIME_MS = FILE_URL_TTL_SECONDS * 1000;\n\n/** Delay between renewal attempts after files-svc fails to mint a fresh URL. */\nconst RENEW_RETRY_MS = 60_000;\n\nexport type CacheEntry = { url: string; mintedAt: number };\n\nconst urlCache = new Map<string, CacheEntry>();\nconst inFlight = new Map<string, Promise<string | null>>();\nconst listeners = new Set<() => void>();\n\nfunction notifyListeners(): void {\n for (const listener of listeners) {\n listener();\n }\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/** Clears the resolver cache. Exported for tests. */\nexport function resetResolvedImageUrlCache(): void {\n urlCache.clear();\n inFlight.clear();\n notifyListeners();\n}\n\nfunction cachedUrl(fileId: string, now: number): string | null {\n const entry = urlCache.get(fileId);\n if (!entry || now - entry.mintedAt > REUSE_WINDOW_MS) {\n return null;\n }\n return entry.url;\n}\n\n/**\n * Mints a short-lived signed download URL for a files-svc file id. Concurrent\n * callers for the same file share one request, and a fresh URL is reused for\n * half its lifetime so lists of thumbnails do not hammer files-svc.\n */\nexport async function resolveFileDownloadUrl(\n client: Pick<ApolloClient, 'query'>,\n fileId: string\n): Promise<string | null> {\n const cached = cachedUrl(fileId, Date.now());\n if (cached) {\n return cached;\n }\n const pending = inFlight.get(fileId);\n if (pending) {\n return pending;\n }\n const request = (async () => {\n try {\n const result = await client.query<DownloadUrlResponse>({\n query: GET_FILE_DOWNLOAD_URL,\n variables: { id: fileId, expiresIn: FILE_URL_TTL_SECONDS },\n fetchPolicy: 'no-cache',\n });\n const url = result.data?.getFileDownloadUrl ?? null;\n if (url) {\n urlCache.set(fileId, { url, mintedAt: Date.now() });\n notifyListeners();\n }\n return url;\n } catch {\n return null;\n } finally {\n inFlight.delete(fileId);\n }\n })();\n inFlight.set(fileId, request);\n return request;\n}\n\n/**\n * When a mounted consumer should renew its cached URL, and when that URL\n * expires. Renewal happens once the URL leaves its reuse window; after a failed\n * renewal it is retried every minute for as long as the URL is still valid.\n * Exported for tests.\n */\nexport function renewalSchedule(\n entry: CacheEntry,\n renewFailedAt: number,\n now: number\n): { renewInMs: number | null; expiresInMs: number } {\n const expiresAt = entry.mintedAt + URL_LIFETIME_MS;\n const renewAt =\n renewFailedAt >= entry.mintedAt ? renewFailedAt + RENEW_RETRY_MS : entry.mintedAt + REUSE_WINDOW_MS + 1;\n return {\n renewInMs: renewAt < expiresAt ? Math.max(0, renewAt - now) : null,\n expiresInMs: Math.max(0, expiresAt - now),\n };\n}\n\nexport interface ResolvedImageUrl {\n /** A URL an `<img>` can load, or null while resolving / when unavailable. */\n url: string | null;\n loading: boolean;\n /** True when files-svc could not mint a URL for the referenced file. */\n failed: boolean;\n /** Asks files-svc again after a failure. A no-op for plain URLs. */\n retry: () => void;\n}\n\n/**\n * Turns a stored image value into something an `<img>` can render: `files:<id>`\n * references are resolved to a signed URL; plain URLs are returned as-is.\n *\n * While a consumer stays mounted its URL is renewed in place once it passes the\n * reuse window, so a page left open for hours (or an image that only starts\n * loading when it scrolls into view) never renders an expired signed URL.\n */\nexport function useResolvedImageUrl(value: string | null | undefined): ResolvedImageUrl {\n const client = useApolloClient();\n const fileId = parseFileRef(value);\n const passthrough = !fileId && value ? value : null;\n\n // The shared cache is an external store: every component showing the same\n // file re-renders as soon as any one of them resolves or renews it. The\n // snapshot is the cache entry itself, which is replaced on every mint.\n const getSnapshot = useCallback(() => (fileId ? (urlCache.get(fileId) ?? null) : null), [fileId]);\n const entry = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n const [failedFileId, setFailedFileId] = useState<string | null>(null);\n const [attempt, setAttempt] = useState(0);\n // The cache entry whose URL has passed its lifetime (set by a timer, so the\n // render itself stays pure).\n const [expiredEntry, setExpiredEntry] = useState<CacheEntry | null>(null);\n\n // When the latest renewal attempt failed (epoch ms); drives the retry schedule.\n const [renewFailedAt, setRenewFailedAt] = useState(0);\n\n useEffect(() => {\n if (!fileId) {\n return undefined;\n }\n let active = true;\n const resolve = () => {\n void resolveFileDownloadUrl(client, fileId).then((url) => {\n if (active) {\n setFailedFileId(url ? null : fileId);\n // A successful mint replaces the cache entry, which re-runs this\n // effect with a fresh schedule. A failed renewal (a URL is already\n // cached) schedules a retry; a failed first resolution waits for\n // retry() instead.\n if (url) {\n setRenewFailedAt(0);\n } else if (urlCache.has(fileId)) {\n setRenewFailedAt(Date.now());\n }\n }\n });\n };\n\n let renewTimer: ReturnType<typeof setTimeout> | undefined;\n let expiryTimer: ReturnType<typeof setTimeout> | undefined;\n const current = urlCache.get(fileId);\n if (current) {\n const schedule = renewalSchedule(current, renewFailedAt, Date.now());\n if (schedule.renewInMs !== null) {\n renewTimer = setTimeout(resolve, schedule.renewInMs);\n }\n // Stop serving the URL once it expires, in case every renewal failed.\n expiryTimer = setTimeout(() => {\n if (active) {\n setExpiredEntry(current);\n }\n }, schedule.expiresInMs);\n } else {\n resolve();\n }\n\n return () => {\n active = false;\n clearTimeout(renewTimer);\n clearTimeout(expiryTimer);\n };\n }, [client, fileId, entry, attempt, renewFailedAt]);\n\n const retry = useCallback(() => {\n setFailedFileId(null);\n setRenewFailedAt(0);\n setAttempt((value) => value + 1);\n }, []);\n\n if (!fileId) {\n return { url: passthrough, loading: false, failed: false, retry };\n }\n const failed = failedFileId === fileId;\n if (entry && entry !== expiredEntry) {\n return { url: entry.url, loading: false, failed: false, retry };\n }\n return { url: null, loading: !failed, failed, retry };\n}\n"],"mappings":";;;;;AAOA,IAAaA,IAAwB,CAAG;;;;GAWlCC,IAAmBC,IAAuB,MAAQ,GAGlDC,IAAkBD,IAAuB,KAGzCE,IAAiB,KAIjBC,oBAAW,IAAI,IAAwB,GACvCC,oBAAW,IAAI,IAAoC,GACnDC,oBAAY,IAAI,IAAgB;AAEtC,SAASC,IAAwB;CAC/B,KAAK,IAAMC,KAAYF,GACrB,EAAS;AAEb;AAEA,SAASG,EAAU,GAAkC;CAEnD,OADAH,EAAU,IAAIE,CAAQ,SACT;EACX,EAAU,OAAOA,CAAQ;CAC3B;AACF;AASA,SAASE,EAAU,GAAgB,GAA4B;CAC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EzD;EAAE,KAAK;EAAM,SAAS,CAACoC;EAAQ;EAAQ;CAAM;AACtD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable references to images stored in wspace-files-svc.
|
|
3
|
+
*
|
|
4
|
+
* EventfullyManaged entities keep their images in plain string columns
|
|
5
|
+
* (`FloorPlan.imageUrl`, `Sponsor.logoUrl`, `Speaker.avatarUrl`). Persisting a
|
|
6
|
+
* presigned download URL there does not work: S3 caps presigned GET URLs at
|
|
7
|
+
* 7 days (wspace-files-svc rejects any longer `expiresIn` with
|
|
8
|
+
* INTERNAL_SERVER_ERROR), so a stored link either fails to mint or rots in the
|
|
9
|
+
* database a week later.
|
|
10
|
+
*
|
|
11
|
+
* Uploads therefore persist a `files:<fileId>` reference instead, and the UI
|
|
12
|
+
* resolves it to a short-lived signed URL at render time. Plain `http(s)` URLs
|
|
13
|
+
* (external logos typed into a form, legacy rows) pass through unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare const FILE_REF_PREFIX = "files:";
|
|
16
|
+
/**
|
|
17
|
+
* Presigned URLs are minted for 6 hours. That stays well below the 7-day S3
|
|
18
|
+
* ceiling, and the resolver cache re-mints a URL long before it expires.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FILE_URL_TTL_SECONDS: number;
|
|
21
|
+
/** Builds the stored reference for a files-svc file id. */
|
|
22
|
+
export declare function toFileRef(fileId: string): string;
|
|
23
|
+
/** Returns the file id behind a `files:` reference, or null for anything else. */
|
|
24
|
+
export declare function parseFileRef(value: string | null | undefined): string | null;
|
|
25
|
+
//# sourceMappingURL=fileRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileRef.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/lib/fileRef.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,eAAe,WAAW,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAc,CAAC;AAIhD,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM5E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/eventfullymanaged/lib/fileRef.ts
|
|
2
|
+
var e = "files:", t = 21600, n = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
3
|
+
function r(t) {
|
|
4
|
+
let r = t.trim();
|
|
5
|
+
if (!n.test(r)) throw Error("Invalid file id");
|
|
6
|
+
return `${e}${r}`;
|
|
7
|
+
}
|
|
8
|
+
function i(e) {
|
|
9
|
+
if (!e || !e.startsWith("files:")) return null;
|
|
10
|
+
let t = e.slice(6);
|
|
11
|
+
return n.test(t) ? t : null;
|
|
12
|
+
}
|
|
13
|
+
export { e as FILE_REF_PREFIX, t as FILE_URL_TTL_SECONDS, i as parseFileRef, r as toFileRef };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=fileRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileRef.js","names":["FILE_REF_PREFIX","FILE_URL_TTL_SECONDS","FILE_ID_PATTERN","toFileRef","id","fileId","parseFileRef","value"],"sources":["../../../src/eventfullymanaged/lib/fileRef.ts"],"sourcesContent":["/**\n * Stable references to images stored in wspace-files-svc.\n *\n * EventfullyManaged entities keep their images in plain string columns\n * (`FloorPlan.imageUrl`, `Sponsor.logoUrl`, `Speaker.avatarUrl`). Persisting a\n * presigned download URL there does not work: S3 caps presigned GET URLs at\n * 7 days (wspace-files-svc rejects any longer `expiresIn` with\n * INTERNAL_SERVER_ERROR), so a stored link either fails to mint or rots in the\n * database a week later.\n *\n * Uploads therefore persist a `files:<fileId>` reference instead, and the UI\n * resolves it to a short-lived signed URL at render time. Plain `http(s)` URLs\n * (external logos typed into a form, legacy rows) pass through unchanged.\n */\n\nexport const FILE_REF_PREFIX = 'files:';\n\n/**\n * Presigned URLs are minted for 6 hours. That stays well below the 7-day S3\n * ceiling, and the resolver cache re-mints a URL long before it expires.\n */\nexport const FILE_URL_TTL_SECONDS = 6 * 60 * 60;\n\nconst FILE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;\n\n/** Builds the stored reference for a files-svc file id. */\nexport function toFileRef(fileId: string): string {\n const id = fileId.trim();\n if (!FILE_ID_PATTERN.test(id)) {\n throw new Error('Invalid file id');\n }\n return `${FILE_REF_PREFIX}${id}`;\n}\n\n/** Returns the file id behind a `files:` reference, or null for anything else. */\nexport function parseFileRef(value: string | null | undefined): string | null {\n if (!value || !value.startsWith(FILE_REF_PREFIX)) {\n return null;\n }\n const id = value.slice(FILE_REF_PREFIX.length);\n return FILE_ID_PATTERN.test(id) ? id : null;\n}\n"],"mappings":";AAeA,IAAaA,IAAkB,UAMlBC,IAAuB,OAE9BC,IAAkB;AAGxB,SAAgBC,EAAU,GAAwB;CAChD,IAAMC,IAAKC,EAAO,KAAK;CACvB,IAAI,CAACH,EAAgB,KAAKE,CAAE,GAC1B,MAAU,MAAM,iBAAiB;CAEnC,OAAO,GAAGJ,IAAkBI;AAC9B;AAGA,SAAgBE,EAAa,GAAiD;CAC5E,IAAI,CAACC,KAAS,CAACA,EAAM,WAAA,QAA0B,GAC7C,OAAO;CAET,IAAMH,IAAKG,EAAM,MAAM,CAAsB;CAC7C,OAAOL,EAAgB,KAAKE,CAAE,IAAIA,IAAK;AACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SponsorDetailsPage.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/pages/modules/SponsorDetailsPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SponsorDetailsPage.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/pages/modules/SponsorDetailsPage.tsx"],"names":[],"mappings":"AA2CA,MAAM,CAAC,OAAO,UAAU,kBAAkB,gCA4KzC"}
|