@hartl-services/medusa-base 2.6.1 → 2.8.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.
Files changed (151) hide show
  1. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/ImageSettingInput.d.ts +3 -2
  2. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/ImageSettingInput.js +4 -4
  3. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginActionsSection.js +4 -4
  4. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginBreadcrumb.d.ts +16 -0
  5. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginBreadcrumb.js +25 -0
  6. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginDetailPage.js +1 -1
  7. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeatureSections.d.ts +5 -4
  8. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeatureSections.js +8 -5
  9. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeaturesCard.d.ts +4 -4
  10. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeaturesCard.js +24 -27
  11. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.d.ts +2 -2
  12. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.js +9 -9
  13. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginHubCard.d.ts +5 -1
  14. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginHubCard.js +11 -15
  15. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginPageShell.d.ts +10 -4
  16. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginPageShell.js +10 -5
  17. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginSettingsForm.d.ts +0 -1
  18. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginSettingsForm.js +77 -26
  19. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginStatusChips.d.ts +5 -1
  20. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/PluginStatusChips.js +8 -6
  21. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/ShopMasterDataBanner.d.ts +11 -0
  22. package/.medusa/server/src/admin/admin-components/features/plugin-features/components/ShopMasterDataBanner.js +15 -0
  23. package/.medusa/server/src/admin/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.d.ts +40 -5
  24. package/.medusa/server/src/admin/admin-components/features/plugin-features/hooks/usePluginFeatures.d.ts +160 -20
  25. package/.medusa/server/src/admin/admin-components/features/plugin-features/hooks/usePluginSettingsForm.d.ts +40 -5
  26. package/.medusa/server/src/admin/admin-components/features/plugin-features/hooks/usePluginSwitch.d.ts +15 -0
  27. package/.medusa/server/src/admin/admin-components/features/plugin-features/hooks/usePluginSwitch.js +66 -0
  28. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/plugin-features-admin-client.d.ts +160 -20
  29. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/plugin-view.d.ts +49 -0
  30. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/plugin-view.js +72 -0
  31. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/settings-draft.d.ts +1 -12
  32. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/settings-draft.js +4 -20
  33. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/settings-layout.d.ts +47 -0
  34. package/.medusa/server/src/admin/admin-components/features/plugin-features/lib/settings-layout.js +70 -0
  35. package/.medusa/server/src/admin/admin-components/i18n/texts.d.ts +22 -2
  36. package/.medusa/server/src/admin/admin-components/i18n/texts.js +29 -7
  37. package/.medusa/server/src/admin/admin-components/index.d.ts +12 -0
  38. package/.medusa/server/src/admin/admin-components/index.js +11 -0
  39. package/.medusa/server/src/admin/admin-components/shared/ui/AdminPageHeader.d.ts +22 -0
  40. package/.medusa/server/src/admin/admin-components/shared/ui/AdminPageHeader.js +8 -0
  41. package/.medusa/server/src/admin/admin-components/shared/ui/AdminSection.d.ts +26 -0
  42. package/.medusa/server/src/admin/admin-components/shared/ui/AdminSection.js +12 -0
  43. package/.medusa/server/src/admin/admin-components/shared/ui/BreadcrumbTrail.d.ts +23 -0
  44. package/.medusa/server/src/admin/admin-components/shared/ui/BreadcrumbTrail.js +20 -0
  45. package/.medusa/server/src/admin/admin-components/shared/ui/FileDropField.d.ts +21 -0
  46. package/.medusa/server/src/admin/admin-components/shared/ui/FileDropField.js +33 -0
  47. package/.medusa/server/src/admin/admin-components/shared/ui/FocusModalShell.d.ts +27 -0
  48. package/.medusa/server/src/admin/admin-components/shared/ui/FocusModalShell.js +13 -0
  49. package/.medusa/server/src/admin/admin-components/shared/ui/InfoTooltip.d.ts +13 -0
  50. package/.medusa/server/src/admin/admin-components/shared/ui/InfoTooltip.js +8 -0
  51. package/.medusa/server/src/admin/admin-components/shared/ui/MultiSelectDropdown.d.ts +22 -0
  52. package/.medusa/server/src/admin/admin-components/shared/ui/MultiSelectDropdown.js +14 -0
  53. package/.medusa/server/src/admin/admin-components/shared/ui/PluginIcon.d.ts +10 -0
  54. package/.medusa/server/src/admin/admin-components/shared/ui/PluginIcon.js +10 -0
  55. package/.medusa/server/src/admin/admin-components/shared/ui/SwitchRow.d.ts +27 -0
  56. package/.medusa/server/src/admin/admin-components/shared/ui/SwitchRow.js +15 -0
  57. package/.medusa/server/src/admin/admin-components/shared/ui/WidgetHeader.d.ts +15 -0
  58. package/.medusa/server/src/admin/admin-components/shared/ui/WidgetHeader.js +8 -0
  59. package/.medusa/server/src/admin/admin-components/shared/ui/file-drop.d.ts +13 -0
  60. package/.medusa/server/src/admin/admin-components/shared/ui/file-drop.js +16 -0
  61. package/.medusa/server/src/admin/admin-components/shared/ui/multi-select.d.ts +13 -0
  62. package/.medusa/server/src/admin/admin-components/shared/ui/multi-select.js +11 -0
  63. package/.medusa/server/src/admin/admin-components/shared/ui/plugin-icon.d.ts +12 -0
  64. package/.medusa/server/src/admin/admin-components/shared/ui/plugin-icon.js +29 -0
  65. package/.medusa/server/src/admin/index.js +3155 -2039
  66. package/.medusa/server/src/admin/index.mjs +3158 -2042
  67. package/.medusa/server/src/api/admin-first-login-password-policy.js +56 -0
  68. package/.medusa/server/src/api/answer-actor-type-casing-not-found.js +26 -0
  69. package/.medusa/server/src/api/answer-code-provider-route-not-found.js +34 -0
  70. package/.medusa/server/src/api/code-account-password-routes.js +92 -0
  71. package/.medusa/server/src/api/middlewares.js +82 -17
  72. package/.medusa/server/src/api/password-policy.js +55 -10
  73. package/.medusa/server/src/api/require-login-code-customer-email.js +40 -0
  74. package/.medusa/server/src/api/store/customer-auth/login-code/route.js +17 -0
  75. package/.medusa/server/src/api/store/customer-auth/password-policy/route.js +19 -0
  76. package/.medusa/server/src/customer-auth/application/prepare-code-account-password-reset.js +111 -0
  77. package/.medusa/server/src/customer-auth/application/request-login-code.js +145 -0
  78. package/.medusa/server/src/customer-auth/customer-auth-methods-snapshot.js +55 -0
  79. package/.medusa/server/src/customer-auth/customer-password-policy.js +40 -0
  80. package/.medusa/server/src/customer-auth/domain/account-linking.js +53 -0
  81. package/.medusa/server/src/customer-auth/domain/auth-methods.js +32 -0
  82. package/.medusa/server/src/customer-auth/domain/login-code.js +39 -0
  83. package/.medusa/server/src/customer-auth/login-code-accounts.js +146 -0
  84. package/.medusa/server/src/customer-auth/login-code-state.js +139 -0
  85. package/.medusa/server/src/customer-auth/plugin-features.js +80 -0
  86. package/.medusa/server/src/customer-auth/remove-provider-identity.js +18 -0
  87. package/.medusa/server/src/customer-auth/start-customer-auth-methods.js +20 -0
  88. package/.medusa/server/src/documents/plugin-features.js +8 -2
  89. package/.medusa/server/src/email/application/deliver-ephemeral-auth-mail.js +186 -0
  90. package/.medusa/server/src/email/application/deliver-login-code.js +89 -0
  91. package/.medusa/server/src/email/application/handle-customer-verification-event.js +29 -168
  92. package/.medusa/server/src/email/application/handle-password-reset-event.js +27 -166
  93. package/.medusa/server/src/email/customer-verification-snapshot.js +20 -108
  94. package/.medusa/server/src/email/domain/business-keys.js +15 -2
  95. package/.medusa/server/src/email/plugin-features.js +8 -3
  96. package/.medusa/server/src/email/rendering/default-templates.js +2 -1
  97. package/.medusa/server/src/email/templates/blocks/dynamic-blocks.js +19 -1
  98. package/.medusa/server/src/email/templates/defaults/documents.js +7 -1
  99. package/.medusa/server/src/email/templates/defaults/subjects.js +3 -1
  100. package/.medusa/server/src/email/templates/defaults/texts.js +5 -2
  101. package/.medusa/server/src/email/templates/render.js +2 -1
  102. package/.medusa/server/src/email/templates/sample-data.js +2 -1
  103. package/.medusa/server/src/email/templates/validate.js +8 -3
  104. package/.medusa/server/src/email/types/email-kinds.js +4 -2
  105. package/.medusa/server/src/email/types/template-data.js +9 -1
  106. package/.medusa/server/src/modules/customer-auth/index.js +14 -0
  107. package/.medusa/server/src/modules/customer-auth/service.js +35 -0
  108. package/.medusa/server/src/modules/email/migrations/Migration20261010090000.js +20 -0
  109. package/.medusa/server/src/modules/plugin-features/domain/plugin-settings.js +30 -6
  110. package/.medusa/server/src/modules/plugin-features/service.js +29 -3
  111. package/.medusa/server/src/providers/email-otp/index.js +8 -0
  112. package/.medusa/server/src/providers/email-otp/service.js +96 -0
  113. package/.medusa/server/src/public/descriptor.js +138 -5
  114. package/.medusa/server/src/public/effective-features.js +22 -1
  115. package/.medusa/server/src/public/index.js +4 -2
  116. package/.medusa/server/src/public/plugin-icons.js +28 -0
  117. package/.medusa/server/src/public/shop-master-data.js +33 -14
  118. package/.medusa/server/src/shared/lib/dates.js +8 -2
  119. package/.medusa/server/src/shared/lib/index.js +2 -1
  120. package/.medusa/server/src/shared/lib/refreshing-snapshot.js +122 -0
  121. package/.medusa/server/src/shop-config/build-food-shop-config.js +38 -1
  122. package/README.md +436 -87
  123. package/dist/customer-auth/customer-auth-methods-snapshot.d.ts +25 -0
  124. package/dist/customer-auth/customer-auth-methods-snapshot.js +54 -0
  125. package/dist/customer-auth/domain/auth-methods.d.ts +16 -0
  126. package/dist/customer-auth/domain/auth-methods.js +31 -0
  127. package/dist/customer-auth/plugin-features.d.ts +2 -0
  128. package/dist/customer-auth/plugin-features.js +79 -0
  129. package/dist/email/customer-verification-snapshot.d.ts +3 -15
  130. package/dist/email/customer-verification-snapshot.js +19 -107
  131. package/dist/email/types/email-kinds.d.ts +4 -3
  132. package/dist/email/types/email-kinds.js +3 -1
  133. package/dist/email/types/template-data.d.ts +8 -0
  134. package/dist/email/types/template-data.js +8 -0
  135. package/dist/public/descriptor.js +137 -4
  136. package/dist/public/effective-features.d.ts +10 -0
  137. package/dist/public/effective-features.js +21 -0
  138. package/dist/public/index.d.ts +2 -1
  139. package/dist/public/index.js +3 -1
  140. package/dist/public/plugin-icons.d.ts +7 -0
  141. package/dist/public/plugin-icons.js +27 -0
  142. package/dist/public/shop-master-data.js +32 -13
  143. package/dist/public/types.d.ts +74 -2
  144. package/dist/shared/lib/dates.d.ts +2 -0
  145. package/dist/shared/lib/dates.js +7 -1
  146. package/dist/shared/lib/index.d.ts +1 -0
  147. package/dist/shared/lib/index.js +1 -0
  148. package/dist/shared/lib/refreshing-snapshot.d.ts +52 -0
  149. package/dist/shared/lib/refreshing-snapshot.js +121 -0
  150. package/dist/shop-config/build-food-shop-config.js +37 -0
  151. package/package.json +8 -3
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from "react";
2
+ type SwitchRowProps = {
3
+ /** Id of the switch; the label points to it. */
4
+ id: string;
5
+ label: ReactNode;
6
+ /** Info button (`InfoTooltip`) next to the label, for a longer explanation. */
7
+ info?: ReactNode;
8
+ /** Subtle explanation under the label. */
9
+ description?: ReactNode;
10
+ /** Further muted line under the description, e.g. why the switch is locked. */
11
+ hint?: ReactNode;
12
+ checked: boolean;
13
+ onCheckedChange: (checked: boolean) => void;
14
+ /** Locks the switch. Dim the row itself through `className` (e.g. `opacity-50`). */
15
+ disabled?: boolean;
16
+ /** Child row of a parent switch: indented. */
17
+ indent?: boolean;
18
+ /** Element after the switch, e.g. an "Öffnen" button. */
19
+ trailing?: ReactNode;
20
+ className?: string;
21
+ };
22
+ /**
23
+ * One row of switches in an `AdminSection`: label with optional description
24
+ * on the left, `Switch` (and optional `trailing` element) on the right (`px-6 py-3`).
25
+ */
26
+ export declare const SwitchRow: ({ id, label, info, description, hint, checked, onCheckedChange, disabled, indent, trailing, className, }: SwitchRowProps) => import("react/jsx-runtime").JSX.Element;
27
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { clx, Label, Switch, Text } from "@medusajs/ui";
3
+ /**
4
+ * One row of switches in an `AdminSection`: label with optional description
5
+ * on the left, `Switch` (and optional `trailing` element) on the right (`px-6 py-3`).
6
+ */
7
+ export const SwitchRow = ({ id, label, info, description, hint, checked, onCheckedChange, disabled, indent, trailing, className, }) => {
8
+ const describedBy = [
9
+ description ? `${id}-description` : null,
10
+ hint ? `${id}-hint` : null,
11
+ ]
12
+ .filter(Boolean)
13
+ .join(" ");
14
+ return (_jsxs("div", { className: clx("flex items-center gap-4 py-3 pr-6", indent ? "pl-12" : "pl-6", className), children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-y-0.5", children: [_jsxs("div", { className: "flex items-center gap-x-1", children: [_jsx(Label, { htmlFor: id, size: "small", weight: "plus", children: label }), info] }), description ? (_jsx(Text, { id: `${id}-description`, size: "small", leading: "compact", className: "text-ui-fg-subtle", children: description })) : null, hint ? (_jsx(Text, { id: `${id}-hint`, size: "small", leading: "compact", className: "text-ui-fg-muted", children: hint })) : null] }), _jsx(Switch, { id: id, "aria-describedby": describedBy || undefined, className: "shrink-0", checked: checked, disabled: disabled, onCheckedChange: (next) => onCheckedChange(next === true) }), trailing] }));
15
+ };
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from "react";
2
+ type WidgetHeaderProps = {
3
+ title: ReactNode;
4
+ /** Info button (`InfoTooltip`) next to the title, for the explanation that used to be a description. */
5
+ info?: ReactNode;
6
+ /** Button at the end, e.g. "Rechnung ausstellen". */
7
+ actions?: ReactNode;
8
+ };
9
+ /**
10
+ * Header of a compact side widget: `h2` with an optional info button and
11
+ * optional actions on one line (`px-6 py-3`). Sits at the top of a
12
+ * `Container className="divide-y p-0"`.
13
+ */
14
+ export declare const WidgetHeader: ({ title, info, actions }: WidgetHeaderProps) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Heading } from "@medusajs/ui";
3
+ /**
4
+ * Header of a compact side widget: `h2` with an optional info button and
5
+ * optional actions on one line (`px-6 py-3`). Sits at the top of a
6
+ * `Container className="divide-y p-0"`.
7
+ */
8
+ export const WidgetHeader = ({ title, info, actions }) => (_jsxs("div", { className: "flex items-center justify-between gap-3 px-6 py-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-x-1", children: [_jsx(Heading, { level: "h2", children: title }), info] }), actions ? _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions }) : null] }));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The file a drop delivers: the first one, or `null` when the field is
3
+ * disabled or the drop carried no file (text, a link, …).
4
+ */
5
+ export declare const pickDroppedFile: (files: ArrayLike<File> | null | undefined, disabled: boolean) => File | null;
6
+ /**
7
+ * A `dragleave` that only moves onto an element inside the drop area (the
8
+ * icon, the button, the text) does not leave it; only a move outside, or off
9
+ * the page, does.
10
+ */
11
+ export declare const leavesDropArea: (area: {
12
+ contains(node: Node | null): boolean;
13
+ }, relatedTarget: EventTarget | null) => boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The file a drop delivers: the first one, or `null` when the field is
3
+ * disabled or the drop carried no file (text, a link, …).
4
+ */
5
+ export const pickDroppedFile = (files, disabled) => {
6
+ if (disabled || !files || files.length === 0) {
7
+ return null;
8
+ }
9
+ return files[0] ?? null;
10
+ };
11
+ /**
12
+ * A `dragleave` that only moves onto an element inside the drop area (the
13
+ * icon, the button, the text) does not leave it; only a move outside, or off
14
+ * the page, does.
15
+ */
16
+ export const leavesDropArea = (area, relatedTarget) => !area.contains(relatedTarget);
@@ -0,0 +1,13 @@
1
+ export type MultiSelectOption<T extends string = string> = {
2
+ value: T;
3
+ label: string;
4
+ /** Shown but not selectable, e.g. while a change of it is being saved. */
5
+ disabled?: boolean;
6
+ };
7
+ /**
8
+ * Adds or removes `option` and returns the selection in the order of
9
+ * `options`; values that are not options are dropped.
10
+ */
11
+ export declare const toggleMultiSelectValue: <T extends string>(options: readonly MultiSelectOption<T>[], selected: readonly T[], option: T, checked: boolean) => T[];
12
+ /** Labels of the selected options, in the order of `options`. */
13
+ export declare const selectedMultiSelectLabels: <T extends string>(options: readonly MultiSelectOption<T>[], selected: readonly T[]) => string[];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Adds or removes `option` and returns the selection in the order of
3
+ * `options`; values that are not options are dropped.
4
+ */
5
+ export const toggleMultiSelectValue = (options, selected, option, checked) => options
6
+ .map((candidate) => candidate.value)
7
+ .filter((value) => (value === option ? checked : selected.includes(value)));
8
+ /** Labels of the selected options, in the order of `options`. */
9
+ export const selectedMultiSelectLabels = (options, selected) => options
10
+ .filter((candidate) => selected.includes(candidate.value))
11
+ .map((candidate) => candidate.label);
@@ -0,0 +1,12 @@
1
+ import { SquaresPlus } from "@medusajs/icons";
2
+ /** Every icon of `@medusajs/icons` has the type of this one. */
3
+ export type PluginIconComponent = typeof SquaresPlus;
4
+ /**
5
+ * The icons a plugin descriptor may name in `icon` (the server's
6
+ * `PLUGIN_ICON_NAMES`, which the Admin cannot import).
7
+ */
8
+ export declare const PLUGIN_ICONS: Readonly<Record<string, PluginIconComponent>>;
9
+ /** Icon of a plugin without (or with an unknown) `icon`. */
10
+ export declare const DEFAULT_PLUGIN_ICON: PluginIconComponent;
11
+ /** The icon component for a descriptor's icon name; the default icon for `null` or an unknown name. */
12
+ export declare const resolvePluginIcon: (name: string | null | undefined) => PluginIconComponent;
@@ -0,0 +1,29 @@
1
+ import { ArchiveBox, ArrowPath, BuildingStorefront, Buildings, ClockSolid, CogSixTooth, CreditCard, DocumentText, Envelope, ReceiptPercent, ShieldCheck, ShoppingCart, SquaresPlus, Tag, TruckFast, Users, } from "@medusajs/icons";
2
+ /**
3
+ * The icons a plugin descriptor may name in `icon` (the server's
4
+ * `PLUGIN_ICON_NAMES`, which the Admin cannot import).
5
+ */
6
+ export const PLUGIN_ICONS = {
7
+ ArchiveBox,
8
+ ArrowPath,
9
+ BuildingStorefront,
10
+ Buildings,
11
+ ClockSolid,
12
+ CogSixTooth,
13
+ CreditCard,
14
+ DocumentText,
15
+ Envelope,
16
+ ReceiptPercent,
17
+ ShieldCheck,
18
+ ShoppingCart,
19
+ SquaresPlus,
20
+ Tag,
21
+ TruckFast,
22
+ Users,
23
+ };
24
+ /** Icon of a plugin without (or with an unknown) `icon`. */
25
+ export const DEFAULT_PLUGIN_ICON = SquaresPlus;
26
+ /** The icon component for a descriptor's icon name; the default icon for `null` or an unknown name. */
27
+ export const resolvePluginIcon = (name) => (name && Object.prototype.hasOwnProperty.call(PLUGIN_ICONS, name)
28
+ ? PLUGIN_ICONS[name]
29
+ : undefined) ?? DEFAULT_PLUGIN_ICON;