@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 +35 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,8 @@ type ManyRowsAppKitReady = {
|
|
|
18
18
|
type AppKitAccount = {
|
|
19
19
|
email: string;
|
|
20
20
|
name: string;
|
|
21
|
+
metadata: Record<string, any>;
|
|
22
|
+
appMetadata: Record<string, any>;
|
|
21
23
|
};
|
|
22
24
|
type AppKitProjectAccess = {
|
|
23
25
|
name: string;
|
|
@@ -54,6 +56,8 @@ type ManyRowsAppKitSnapshot = {
|
|
|
54
56
|
workspaceSlug: string;
|
|
55
57
|
workspaceName: string;
|
|
56
58
|
allowRegistration: boolean;
|
|
59
|
+
authMethodPassword?: boolean;
|
|
60
|
+
googleOAuthClientId?: string;
|
|
57
61
|
} | null;
|
|
58
62
|
};
|
|
59
63
|
type ManyRowsAppKitHandle = {
|
|
@@ -327,6 +331,32 @@ declare function useConfigValue<T = any>(key: string, fallback?: T): T | undefin
|
|
|
327
331
|
* ```
|
|
328
332
|
*/
|
|
329
333
|
declare function useToken(): string | null;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the admin-managed metadata for the current user.
|
|
336
|
+
*
|
|
337
|
+
* ```tsx
|
|
338
|
+
* const metadata = useMetadata(); // { tier: "premium", department: "engineering" }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function useMetadata(): Record<string, any>;
|
|
342
|
+
/**
|
|
343
|
+
* Returns the app-managed metadata for the current user.
|
|
344
|
+
*
|
|
345
|
+
* ```tsx
|
|
346
|
+
* const appMetadata = useAppMetadata(); // { theme: "dark", onboarded: true }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function useAppMetadata(): Record<string, any>;
|
|
350
|
+
/**
|
|
351
|
+
* Returns a function to update the current user's app metadata (merge semantics).
|
|
352
|
+
* After updating, call `refresh()` to reload the snapshot with the new values.
|
|
353
|
+
*
|
|
354
|
+
* ```tsx
|
|
355
|
+
* const updateAppMetadata = useUpdateAppMetadata();
|
|
356
|
+
* await updateAppMetadata({ theme: "dark" }); // merges into existing app_metadata
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
declare function useUpdateAppMetadata(): (patch: Record<string, any>) => Promise<void>;
|
|
330
360
|
|
|
331
361
|
type UseImagesOptions = {
|
|
332
362
|
page?: number;
|
|
@@ -529,4 +559,4 @@ interface FileDetailsProps {
|
|
|
529
559
|
}
|
|
530
560
|
declare function FileDetails({ file, onClose, onEdit, onDelete, className, style, }: FileDetailsProps): react_jsx_runtime.JSX.Element;
|
|
531
561
|
|
|
532
|
-
export { AppKit, type AppKitAccount, type AppKitAppData, AppKitAuthed, type AppKitConfigValue, type AppKitFeatureFlag, type AppKitProjectAccess, type AppKitTheme, FileDetails, type FileDetailsProps, type FileListResponse, FilePicker, type FilePickerProps, type FileResource, type FileUpdateOptions, type FileUploadOptions, FileUploader, type FileUploaderProps, ImageDetails, type ImageDetailsProps, type ImageListResponse, ImagePicker, type ImagePickerProps, type ImageResource, type ImageUpdateOptions, type ImageUploadOptions, ImageUploader, type ImageUploaderProps, type ImageVariant, type ManyRowsAppKitError, type ManyRowsAppKitErrorCode, type ManyRowsAppKitHandle, type ManyRowsAppKitReady, type ManyRowsAppKitSnapshot, MrImage, type MrImageProps, type UploadProgress, type UseFileOptions, type UseFileReturn, type UseFileUploadReturn, type UseFilesOptions, type UseFilesReturn, type UseImageOptions, type UseImageReturn, type UseImageUploadReturn, type UseImagesOptions, type UseImagesReturn, UserButton, type UserButtonProps, useAppKit, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUser };
|
|
562
|
+
export { AppKit, type AppKitAccount, type AppKitAppData, AppKitAuthed, type AppKitConfigValue, type AppKitFeatureFlag, type AppKitProjectAccess, type AppKitTheme, FileDetails, type FileDetailsProps, type FileListResponse, FilePicker, type FilePickerProps, type FileResource, type FileUpdateOptions, type FileUploadOptions, FileUploader, type FileUploaderProps, ImageDetails, type ImageDetailsProps, type ImageListResponse, ImagePicker, type ImagePickerProps, type ImageResource, type ImageUpdateOptions, type ImageUploadOptions, ImageUploader, type ImageUploaderProps, type ImageVariant, type ManyRowsAppKitError, type ManyRowsAppKitErrorCode, type ManyRowsAppKitHandle, type ManyRowsAppKitReady, type ManyRowsAppKitSnapshot, MrImage, type MrImageProps, type UploadProgress, type UseFileOptions, type UseFileReturn, type UseFileUploadReturn, type UseFilesOptions, type UseFilesReturn, type UseImageOptions, type UseImageReturn, type UseImageUploadReturn, type UseImagesOptions, type UseImagesReturn, UserButton, type UserButtonProps, useAppKit, useAppMetadata, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, useMetadata, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUpdateAppMetadata, useUser };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ type ManyRowsAppKitReady = {
|
|
|
18
18
|
type AppKitAccount = {
|
|
19
19
|
email: string;
|
|
20
20
|
name: string;
|
|
21
|
+
metadata: Record<string, any>;
|
|
22
|
+
appMetadata: Record<string, any>;
|
|
21
23
|
};
|
|
22
24
|
type AppKitProjectAccess = {
|
|
23
25
|
name: string;
|
|
@@ -54,6 +56,8 @@ type ManyRowsAppKitSnapshot = {
|
|
|
54
56
|
workspaceSlug: string;
|
|
55
57
|
workspaceName: string;
|
|
56
58
|
allowRegistration: boolean;
|
|
59
|
+
authMethodPassword?: boolean;
|
|
60
|
+
googleOAuthClientId?: string;
|
|
57
61
|
} | null;
|
|
58
62
|
};
|
|
59
63
|
type ManyRowsAppKitHandle = {
|
|
@@ -327,6 +331,32 @@ declare function useConfigValue<T = any>(key: string, fallback?: T): T | undefin
|
|
|
327
331
|
* ```
|
|
328
332
|
*/
|
|
329
333
|
declare function useToken(): string | null;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the admin-managed metadata for the current user.
|
|
336
|
+
*
|
|
337
|
+
* ```tsx
|
|
338
|
+
* const metadata = useMetadata(); // { tier: "premium", department: "engineering" }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function useMetadata(): Record<string, any>;
|
|
342
|
+
/**
|
|
343
|
+
* Returns the app-managed metadata for the current user.
|
|
344
|
+
*
|
|
345
|
+
* ```tsx
|
|
346
|
+
* const appMetadata = useAppMetadata(); // { theme: "dark", onboarded: true }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function useAppMetadata(): Record<string, any>;
|
|
350
|
+
/**
|
|
351
|
+
* Returns a function to update the current user's app metadata (merge semantics).
|
|
352
|
+
* After updating, call `refresh()` to reload the snapshot with the new values.
|
|
353
|
+
*
|
|
354
|
+
* ```tsx
|
|
355
|
+
* const updateAppMetadata = useUpdateAppMetadata();
|
|
356
|
+
* await updateAppMetadata({ theme: "dark" }); // merges into existing app_metadata
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
declare function useUpdateAppMetadata(): (patch: Record<string, any>) => Promise<void>;
|
|
330
360
|
|
|
331
361
|
type UseImagesOptions = {
|
|
332
362
|
page?: number;
|
|
@@ -529,4 +559,4 @@ interface FileDetailsProps {
|
|
|
529
559
|
}
|
|
530
560
|
declare function FileDetails({ file, onClose, onEdit, onDelete, className, style, }: FileDetailsProps): react_jsx_runtime.JSX.Element;
|
|
531
561
|
|
|
532
|
-
export { AppKit, type AppKitAccount, type AppKitAppData, AppKitAuthed, type AppKitConfigValue, type AppKitFeatureFlag, type AppKitProjectAccess, type AppKitTheme, FileDetails, type FileDetailsProps, type FileListResponse, FilePicker, type FilePickerProps, type FileResource, type FileUpdateOptions, type FileUploadOptions, FileUploader, type FileUploaderProps, ImageDetails, type ImageDetailsProps, type ImageListResponse, ImagePicker, type ImagePickerProps, type ImageResource, type ImageUpdateOptions, type ImageUploadOptions, ImageUploader, type ImageUploaderProps, type ImageVariant, type ManyRowsAppKitError, type ManyRowsAppKitErrorCode, type ManyRowsAppKitHandle, type ManyRowsAppKitReady, type ManyRowsAppKitSnapshot, MrImage, type MrImageProps, type UploadProgress, type UseFileOptions, type UseFileReturn, type UseFileUploadReturn, type UseFilesOptions, type UseFilesReturn, type UseImageOptions, type UseImageReturn, type UseImageUploadReturn, type UseImagesOptions, type UseImagesReturn, UserButton, type UserButtonProps, useAppKit, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUser };
|
|
562
|
+
export { AppKit, type AppKitAccount, type AppKitAppData, AppKitAuthed, type AppKitConfigValue, type AppKitFeatureFlag, type AppKitProjectAccess, type AppKitTheme, FileDetails, type FileDetailsProps, type FileListResponse, FilePicker, type FilePickerProps, type FileResource, type FileUpdateOptions, type FileUploadOptions, FileUploader, type FileUploaderProps, ImageDetails, type ImageDetailsProps, type ImageListResponse, ImagePicker, type ImagePickerProps, type ImageResource, type ImageUpdateOptions, type ImageUploadOptions, ImageUploader, type ImageUploaderProps, type ImageVariant, type ManyRowsAppKitError, type ManyRowsAppKitErrorCode, type ManyRowsAppKitHandle, type ManyRowsAppKitReady, type ManyRowsAppKitSnapshot, MrImage, type MrImageProps, type UploadProgress, type UseFileOptions, type UseFileReturn, type UseFileUploadReturn, type UseFilesOptions, type UseFilesReturn, type UseImageOptions, type UseImageReturn, type UseImageUploadReturn, type UseImagesOptions, type UseImagesReturn, UserButton, type UserButtonProps, useAppKit, useAppMetadata, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, useMetadata, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUpdateAppMetadata, useUser };
|
package/dist/index.js
CHANGED
|
@@ -407,8 +407,8 @@ function AppKit(props) {
|
|
|
407
407
|
return /* @__PURE__ */ jsx(Ctx.Provider, { value: ctx, children: /* @__PURE__ */ jsxs("div", { className: props.className, style: props.style, children: [
|
|
408
408
|
showLoading && props.loading ? props.loading : null,
|
|
409
409
|
showError && lastError ? props.errorUI ? props.errorUI(lastError) : /* @__PURE__ */ jsx(DefaultError, { err: lastError }) : null,
|
|
410
|
-
|
|
411
|
-
/* @__PURE__ */ jsx("div", {
|
|
410
|
+
/* @__PURE__ */ jsx("div", { id: containerId }),
|
|
411
|
+
/* @__PURE__ */ jsx("div", { style: status === "mounted" && snapshot && !isAuthedSnapshot(snapshot) ? { display: "none" } : void 0, children: props.children })
|
|
412
412
|
] }) });
|
|
413
413
|
}
|
|
414
414
|
function Toast({ toast, onClose }) {
|
|
@@ -891,6 +891,36 @@ function useToken() {
|
|
|
891
891
|
const { snapshot } = useAppKit();
|
|
892
892
|
return snapshot?.jwtToken ?? null;
|
|
893
893
|
}
|
|
894
|
+
function useMetadata() {
|
|
895
|
+
const { snapshot } = useAppKit();
|
|
896
|
+
return snapshot?.appData?.account?.metadata ?? {};
|
|
897
|
+
}
|
|
898
|
+
function useAppMetadata() {
|
|
899
|
+
const { snapshot } = useAppKit();
|
|
900
|
+
return snapshot?.appData?.account?.appMetadata ?? {};
|
|
901
|
+
}
|
|
902
|
+
function useUpdateAppMetadata() {
|
|
903
|
+
const { snapshot } = useAppKit();
|
|
904
|
+
return async (patch) => {
|
|
905
|
+
const token = snapshot?.jwtToken;
|
|
906
|
+
const baseURL = snapshot?.workspaceBaseURL;
|
|
907
|
+
if (!token || !baseURL) {
|
|
908
|
+
throw new Error("Not authenticated");
|
|
909
|
+
}
|
|
910
|
+
const res = await fetch(`${baseURL}/a/me/metadata`, {
|
|
911
|
+
method: "PATCH",
|
|
912
|
+
headers: {
|
|
913
|
+
"Content-Type": "application/json",
|
|
914
|
+
Authorization: `Bearer ${token}`
|
|
915
|
+
},
|
|
916
|
+
body: JSON.stringify(patch)
|
|
917
|
+
});
|
|
918
|
+
if (!res.ok) {
|
|
919
|
+
const body = await res.json().catch(() => ({}));
|
|
920
|
+
throw new Error(body?.issues?.[0]?.message || body?.error || "Failed to update metadata");
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
}
|
|
894
924
|
|
|
895
925
|
// src/appResource.ts
|
|
896
926
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -4642,6 +4672,6 @@ function RowActionBtn({
|
|
|
4642
4672
|
);
|
|
4643
4673
|
}
|
|
4644
4674
|
|
|
4645
|
-
export { AppKit, AppKitAuthed, FileDetails, FilePicker, FileUploader, ImageDetails, ImagePicker, ImageUploader, MrImage, UserButton, useAppKit, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUser };
|
|
4675
|
+
export { AppKit, AppKitAuthed, FileDetails, FilePicker, FileUploader, ImageDetails, ImagePicker, ImageUploader, MrImage, UserButton, useAppKit, useAppMetadata, useConfig, useConfigValue, useFeatureFlag, useFeatureFlags, useFile, useFileUpload, useFiles, useImage, useImageUpload, useImages, useMetadata, usePermission, usePermissions, useProject, useRole, useRoles, useToken, useUpdateAppMetadata, useUser };
|
|
4646
4676
|
//# sourceMappingURL=index.js.map
|
|
4647
4677
|
//# sourceMappingURL=index.js.map
|