@manyrows/appkit-react 0.1.7 → 0.1.9

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/index.cjs CHANGED
@@ -413,8 +413,8 @@ function AppKit(props) {
413
413
  return /* @__PURE__ */ jsxRuntime.jsx(Ctx.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: props.className, style: props.style, children: [
414
414
  showLoading && props.loading ? props.loading : null,
415
415
  showError && lastError ? props.errorUI ? props.errorUI(lastError) : /* @__PURE__ */ jsxRuntime.jsx(DefaultError, { err: lastError }) : null,
416
- props.children,
417
- /* @__PURE__ */ jsxRuntime.jsx("div", { id: containerId })
416
+ /* @__PURE__ */ jsxRuntime.jsx("div", { id: containerId }),
417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: status === "mounted" && snapshot && !isAuthedSnapshot(snapshot) ? { display: "none" } : void 0, children: props.children })
418
418
  ] }) });
419
419
  }
420
420
  function Toast({ toast, onClose }) {
@@ -897,6 +897,36 @@ function useToken() {
897
897
  const { snapshot } = useAppKit();
898
898
  return snapshot?.jwtToken ?? null;
899
899
  }
900
+ function useMetadata() {
901
+ const { snapshot } = useAppKit();
902
+ return snapshot?.appData?.account?.metadata ?? {};
903
+ }
904
+ function useAppMetadata() {
905
+ const { snapshot } = useAppKit();
906
+ return snapshot?.appData?.account?.appMetadata ?? {};
907
+ }
908
+ function useUpdateAppMetadata() {
909
+ const { snapshot } = useAppKit();
910
+ return async (patch) => {
911
+ const token = snapshot?.jwtToken;
912
+ const baseURL = snapshot?.workspaceBaseURL;
913
+ if (!token || !baseURL) {
914
+ throw new Error("Not authenticated");
915
+ }
916
+ const res = await fetch(`${baseURL}/a/me/metadata`, {
917
+ method: "PATCH",
918
+ headers: {
919
+ "Content-Type": "application/json",
920
+ Authorization: `Bearer ${token}`
921
+ },
922
+ body: JSON.stringify(patch)
923
+ });
924
+ if (!res.ok) {
925
+ const body = await res.json().catch(() => ({}));
926
+ throw new Error(body?.issues?.[0]?.message || body?.error || "Failed to update metadata");
927
+ }
928
+ };
929
+ }
900
930
 
901
931
  // src/appResource.ts
902
932
  var cache = /* @__PURE__ */ new Map();
@@ -4659,6 +4689,7 @@ exports.ImageUploader = ImageUploader;
4659
4689
  exports.MrImage = MrImage;
4660
4690
  exports.UserButton = UserButton;
4661
4691
  exports.useAppKit = useAppKit;
4692
+ exports.useAppMetadata = useAppMetadata;
4662
4693
  exports.useConfig = useConfig;
4663
4694
  exports.useConfigValue = useConfigValue;
4664
4695
  exports.useFeatureFlag = useFeatureFlag;
@@ -4669,12 +4700,14 @@ exports.useFiles = useFiles;
4669
4700
  exports.useImage = useImage;
4670
4701
  exports.useImageUpload = useImageUpload;
4671
4702
  exports.useImages = useImages;
4703
+ exports.useMetadata = useMetadata;
4672
4704
  exports.usePermission = usePermission;
4673
4705
  exports.usePermissions = usePermissions;
4674
4706
  exports.useProject = useProject;
4675
4707
  exports.useRole = useRole;
4676
4708
  exports.useRoles = useRoles;
4677
4709
  exports.useToken = useToken;
4710
+ exports.useUpdateAppMetadata = useUpdateAppMetadata;
4678
4711
  exports.useUser = useUser;
4679
4712
  //# sourceMappingURL=index.cjs.map
4680
4713
  //# sourceMappingURL=index.cjs.map